diff --git a/dist/bin/compile-typescript-docs.d.ts b/dist/bin/compile-typescript-docs.d.ts new file mode 100644 index 0000000..237deca --- /dev/null +++ b/dist/bin/compile-typescript-docs.d.ts @@ -0,0 +1,2 @@ +#! /usr/bin/env node +export {}; diff --git a/dist/bin/compile-typescript-docs.js b/dist/bin/compile-typescript-docs.js new file mode 100644 index 0000000..6349722 --- /dev/null +++ b/dist/bin/compile-typescript-docs.js @@ -0,0 +1,82 @@ +#! /usr/bin/env node +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const ora = require("ora"); +const chalk = require("chalk"); +const yargs = require("yargs"); +const leftPad = require("left-pad"); +const TypeScriptDocsVerifier = require("../index"); +const ERROR_LINE_EXTRACTION_PATTERN = /\.ts\s*\((\d+),\d+\):/; +const COMPILED_DOCS_FILE_PREFIX_PATTERN = /compiled\-docs\/block\-\d+\.\d+\.ts/g; +yargs.option('input-files', { + description: 'The list of input files to be processed', + array: true, + default: ['README.md'] +}); +const argv = yargs.argv; +const inputFiles = argv['input-files']; +const spinner = ora(); +spinner.info(`Compiling documentation TypeScript code snippets from ${inputFiles.join(', ')}`).start(); +const formatCode = (code, errorLines) => { + const lines = code.split('\n') + .map((line, index) => { + const lineNumber = index + 1; + if (errorLines.indexOf(lineNumber) !== -1) { + return chalk `{bold.red ${leftPad(lineNumber, 2)}| ${line}}`; + } + else { + return `${leftPad(lineNumber, 2)}| ${line}`; + } + }); + return ' ' + lines.join('\n '); +}; +const findErrorLines = (error) => { + const messages = error.diagnosticText.split('\n'); + return messages.map((message) => { + const match = ERROR_LINE_EXTRACTION_PATTERN.exec(message); + if (match && match[1]) { + return match[1]; + } + else { + return NaN; + } + }).filter((lineNumber) => lineNumber) + .map((lineNumber) => parseInt(lineNumber.toString(), 10)); +}; +const formatError = (error) => ' ' + error.message.replace(COMPILED_DOCS_FILE_PREFIX_PATTERN, '') + .split('\n') + .join('\n '); +TypeScriptDocsVerifier.compileSnippets(inputFiles) + .then((results) => { + spinner.info(`Found ${results.length} TypeScript snippets`).start(); + results.forEach((result) => { + if (result.error) { + const errorLines = findErrorLines(result.error); + process.exitCode = 1; + spinner.fail(chalk `{red.bold Error compiling example code block ${result.index} in file ${result.file}:}`); + console.log(formatError(result.error)); + console.log(); + console.log(chalk `{blue.bold Original code:}`); + console.log(formatCode(result.snippet, errorLines)); + } + }); +}) + .then(() => { + if (process.exitCode) { + spinner.fail(chalk `{red.bold Compilation failed, see above errors}`); + } + else { + spinner.succeed(chalk `{green.bold All snippets compiled OK}`); + } +}) + .catch((error) => { + process.exitCode = 1; + console.error(error); + try { + spinner.fail(); + } + catch (error) { + console.error(error); + } +}); +//# sourceMappingURL=compile-typescript-docs.js.map \ No newline at end of file diff --git a/dist/bin/compile-typescript-docs.js.map b/dist/bin/compile-typescript-docs.js.map new file mode 100644 index 0000000..b30b16d --- /dev/null +++ b/dist/bin/compile-typescript-docs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"compile-typescript-docs.js","sourceRoot":"","sources":["../../bin/compile-typescript-docs.ts"],"names":[],"mappings":";;;AAEA,2BAA0B;AAC1B,+BAA8B;AAC9B,+BAA8B;AAE9B,oCAAmC;AACnC,mDAAkD;AAElD,MAAM,6BAA6B,GAAG,uBAAuB,CAAA;AAC7D,MAAM,iCAAiC,GAAG,sCAAsC,CAAA;AAEhF,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE;IAC1B,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,CAAC,WAAW,CAAC;CACvB,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;AACvB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,CAAA;AAEtC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAA;AACrB,OAAO,CAAC,IAAI,CAAC,yDAAyD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;AAEtG,MAAM,UAA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AC,QAAQ,GAAG,CAAC,CAAA;IACpB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,IAAI;QACF,OAAO,CAAC,IAAI,EAAE,CAAA;KACf;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;KACrB;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..7f047aa --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +import { SnippetCompilationResult } from './src/SnippetCompiler'; +export { SnippetCompilationResult } from './src/SnippetCompiler'; +export declare function compileSnippets(markdownFileOrFiles?: string | string[]): Promise; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..c8c6c62 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +const SnippetCompiler_1 = require("./src/SnippetCompiler"); +const DEFAULT_FILES = ['README.md']; +const COMPILED_DOCS_FOLDER = 'compiled-docs'; +const wrapIfString = (arrayOrString) => { + if (Array.isArray(arrayOrString)) { + return arrayOrString; + } + else { + return [arrayOrString]; + } +}; +function compileSnippets(markdownFileOrFiles = DEFAULT_FILES) { + const workingDirectory = path.join(process.cwd(), COMPILED_DOCS_FOLDER); + const compiler = new SnippetCompiler_1.SnippetCompiler(workingDirectory); + return Promise.resolve(markdownFileOrFiles) + .then(wrapIfString) + .then((fileArray) => compiler.compileSnippets(fileArray)); +} +exports.compileSnippets = compileSnippets; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..f2dc0b6 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,2DAAiF;AAIjF,MAAM,aAAa,GAAG,CAAC,WAAW,CAAC,CAAA;AACnC,MAAM,oBAAoB,GAAG,eAAe,CAAA;AAE5C,MAAM,YAAY,GAAG,CAAC,aAAgC,EAAE,EAAE;IACxD,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAChC,OAAO,aAAa,CAAA;KACrB;SAAM;QACL,OAAO,CAAC,aAAa,CAAC,CAAA;KACvB;AACH,CAAC,CAAA;AAED,SAAgB,eAAe,CAAE,sBAAyC,aAAa;IACrF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAA;IACvE,MAAM,QAAQ,GAAG,IAAI,iCAAe,CAAC,gBAAgB,CAAC,CAAA;IACtD,OAAO,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC;SACxC,IAAI,CAAC,YAAY,CAAC;SAClB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,CAAC;AAND,0CAMC"} \ No newline at end of file diff --git a/dist/src/CodeBlockExtractor.d.ts b/dist/src/CodeBlockExtractor.d.ts new file mode 100644 index 0000000..a4522db --- /dev/null +++ b/dist/src/CodeBlockExtractor.d.ts @@ -0,0 +1,7 @@ +export declare class CodeBlockExtractor { + static readonly TYPESCRIPT_CODE_PATTERN: RegExp; + private constructor(); + static extract(markdownFilePath: string): Promise; + private static readFile; + private static extractCodeBlocksFromMarkdown; +} diff --git a/dist/src/CodeBlockExtractor.js b/dist/src/CodeBlockExtractor.js new file mode 100644 index 0000000..5a2f87a --- /dev/null +++ b/dist/src/CodeBlockExtractor.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const fsExtra = require("fs-extra"); +class CodeBlockExtractor { + /* istanbul ignore next */ + constructor() { } + static extract(markdownFilePath) { + return Promise.resolve() + .then(() => CodeBlockExtractor.readFile(markdownFilePath)) + .then((contents) => CodeBlockExtractor.extractCodeBlocksFromMarkdown(contents)) + .catch((error) => { + throw new Error(`Error extracting code blocks from ${markdownFilePath}: ${error.message}`); + }); + } + static readFile(path) { + return fsExtra.readFile(path) + .then((buffer) => buffer.toString()); + } + static extractCodeBlocksFromMarkdown(markdown) { + const codeBlocks = []; + markdown.replace(this.TYPESCRIPT_CODE_PATTERN, (fullMatch, code) => { + codeBlocks.push(code); + return code; + }); + return codeBlocks; + } +} +CodeBlockExtractor.TYPESCRIPT_CODE_PATTERN = /(?:```typescript\n)((?:\n|.)*?)(?:(?=```))/gi; +exports.CodeBlockExtractor = CodeBlockExtractor; +//# sourceMappingURL=CodeBlockExtractor.js.map \ No newline at end of file diff --git a/dist/src/CodeBlockExtractor.js.map b/dist/src/CodeBlockExtractor.js.map new file mode 100644 index 0000000..31444ce --- /dev/null +++ b/dist/src/CodeBlockExtractor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CodeBlockExtractor.js","sourceRoot":"","sources":["../../src/CodeBlockExtractor.ts"],"names":[],"mappings":";;AAAA,oCAAmC;AAEnC,MAAa,kBAAkB;IAG7B,0BAA0B;IAC1B,gBAAwB,CAAC;IAEzB,MAAM,CAAC,OAAO,CAAE,gBAAwB;QACtC,OAAO,OAAO,CAAC,OAAO,EAAE;aACrB,IAAI,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;aACzD,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC;aAC9E,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,gBAAgB,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC5F,CAAC,CAAC,CAAA;IACN,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAE,IAAY;QACnC,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;aAC1B,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IACxC,CAAC;IAEO,MAAM,CAAC,6BAA6B,CAAE,QAAgB;QAC5D,MAAM,UAAU,GAAa,EAAE,CAAA;QAC/B,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE;YACjE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACrB,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QACF,OAAO,UAAU,CAAA;IACnB,CAAC;;AA1Be,0CAAuB,GAAG,8CAA8C,CAAA;AAD1F,gDA4BC"} \ No newline at end of file diff --git a/dist/src/CodeWrapper.d.ts b/dist/src/CodeWrapper.d.ts new file mode 100644 index 0000000..0a31ffe --- /dev/null +++ b/dist/src/CodeWrapper.d.ts @@ -0,0 +1,4 @@ +export declare class CodeWrapper { + private constructor(); + static wrap(code: string): string; +} diff --git a/dist/src/CodeWrapper.js b/dist/src/CodeWrapper.js new file mode 100644 index 0000000..7c3c359 --- /dev/null +++ b/dist/src/CodeWrapper.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class CodeWrapper { + /* istanbul ignore next */ + constructor() { } + static wrap(code) { + const codeLines = code.split('\n'); + const importLines = codeLines.filter((line) => line.trim().startsWith('import ')); + const otherLines = codeLines.filter((line) => !line.trim().startsWith('import')); + const functionName = `fn${Math.random().toString().replace(/\./, '')}`; + const mainCode = importLines.length === 0 ? otherLines.join('\n') : '\n' + otherLines.join('\n'); + const wrappedCode = `${importLines.join('\n')}; const ${functionName} = () => {${mainCode} + }`; + return wrappedCode; + } +} +exports.CodeWrapper = CodeWrapper; +//# sourceMappingURL=CodeWrapper.js.map \ No newline at end of file diff --git a/dist/src/CodeWrapper.js.map b/dist/src/CodeWrapper.js.map new file mode 100644 index 0000000..0845cd0 --- /dev/null +++ b/dist/src/CodeWrapper.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CodeWrapper.js","sourceRoot":"","sources":["../../src/CodeWrapper.ts"],"names":[],"mappings":";;AAAA,MAAa,WAAW;IACtB,0BAA0B;IAC1B,gBAAwB,CAAC;IAEzB,MAAM,CAAC,IAAI,CAAE,IAAY;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;QACjF,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;QAChF,MAAM,YAAY,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAA;QACtE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEhG,MAAM,WAAW,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,YAAY,aAAa,QAAQ;MACvF,CAAA;QACF,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAfD,kCAeC"} \ No newline at end of file diff --git a/dist/src/LocalImportSubstituter.d.ts b/dist/src/LocalImportSubstituter.d.ts new file mode 100644 index 0000000..1e64c54 --- /dev/null +++ b/dist/src/LocalImportSubstituter.d.ts @@ -0,0 +1,7 @@ +import { PackageDefinition } from './PackageInfo'; +export declare class LocalImportSubstituter { + private readonly packageName; + private readonly pathToPackageMain; + constructor(packageDefinition: PackageDefinition); + substituteLocalPackageImports(code: string): string; +} diff --git a/dist/src/LocalImportSubstituter.js b/dist/src/LocalImportSubstituter.js new file mode 100644 index 0000000..c04ad22 --- /dev/null +++ b/dist/src/LocalImportSubstituter.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +class LocalImportSubstituter { + constructor(packageDefinition) { + this.packageName = packageDefinition.name; + const mainImport = packageDefinition.main.replace(/\.(ts|js)$/, ''); + this.pathToPackageMain = path.join(process.cwd(), mainImport); + } + substituteLocalPackageImports(code) { + const projectImportRegex = new RegExp(`('${this.packageName}'|"${this.packageName}")`, 'g'); + const codeLines = code.split('\n'); + const localisedLines = codeLines.map((line) => { + if (line.trim().startsWith('import ')) { + return line.replace(projectImportRegex, `'${this.pathToPackageMain}'`); + } + else { + return line; + } + }); + return localisedLines.join('\n'); + } +} +exports.LocalImportSubstituter = LocalImportSubstituter; +//# sourceMappingURL=LocalImportSubstituter.js.map \ No newline at end of file diff --git a/dist/src/LocalImportSubstituter.js.map b/dist/src/LocalImportSubstituter.js.map new file mode 100644 index 0000000..e9510bb --- /dev/null +++ b/dist/src/LocalImportSubstituter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LocalImportSubstituter.js","sourceRoot":"","sources":["../../src/LocalImportSubstituter.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAG5B,MAAa,sBAAsB;IAIjC,YAAa,iBAAoC;QAC/C,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAA;QACzC,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAA;IAC/D,CAAC;IAED,6BAA6B,CAAE,IAAY;QACzC,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,WAAW,MAAM,IAAI,CAAC,WAAW,IAAI,EAAE,GAAG,CAAC,CAAA;QAC3F,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC5C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBACrC,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAA;aACvE;iBAAM;gBACL,OAAO,IAAI,CAAA;aACZ;QACH,CAAC,CAAC,CAAA;QACF,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;CACF;AAtBD,wDAsBC"} \ No newline at end of file diff --git a/dist/src/PackageInfo.d.ts b/dist/src/PackageInfo.d.ts new file mode 100644 index 0000000..0ab170e --- /dev/null +++ b/dist/src/PackageInfo.d.ts @@ -0,0 +1,8 @@ +export interface PackageDefinition { + readonly name: string; + readonly main: string; +} +export declare class PackageInfo { + private constructor(); + static read(): Promise; +} diff --git a/dist/src/PackageInfo.js b/dist/src/PackageInfo.js new file mode 100644 index 0000000..d84e767 --- /dev/null +++ b/dist/src/PackageInfo.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +const fsExtra = require("fs-extra"); +class PackageInfo { + /* istanbul ignore next */ + constructor() { } + static read() { + const packageJsonPath = path.join(process.cwd(), 'package.json'); + return fsExtra.readFile(packageJsonPath) + .then((contents) => JSON.parse(contents.toString())); + } +} +exports.PackageInfo = PackageInfo; +//# sourceMappingURL=PackageInfo.js.map \ No newline at end of file diff --git a/dist/src/PackageInfo.js.map b/dist/src/PackageInfo.js.map new file mode 100644 index 0000000..96883d2 --- /dev/null +++ b/dist/src/PackageInfo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PackageInfo.js","sourceRoot":"","sources":["../../src/PackageInfo.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,oCAAmC;AAOnC,MAAa,WAAW;IACtB,0BAA0B;IAC1B,gBAAwB,CAAC;IAEzB,MAAM,CAAC,IAAI;QACT,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAA;QAChE,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC;aACrC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACxD,CAAC;CACF;AATD,kCASC"} \ No newline at end of file diff --git a/dist/src/SnippetCompiler.d.ts b/dist/src/SnippetCompiler.d.ts new file mode 100644 index 0000000..927d36c --- /dev/null +++ b/dist/src/SnippetCompiler.d.ts @@ -0,0 +1,19 @@ +import * as Bluebird from 'bluebird'; +import { TSError } from 'ts-node/dist/index'; +export interface SnippetCompilationResult { + readonly file: string; + readonly index: number; + readonly snippet: string; + readonly error?: TSError; +} +export declare class SnippetCompiler { + private readonly workingDirectory; + private readonly runner; + constructor(workingDirectory: string); + compileSnippets(documentationFiles: string[]): Bluebird; + private cleanWorkingDirectory; + private extractAllCodeBlocks; + private extractFileCodeBlocks; + private sanitiseCodeBlock; + private testCodeCompilation; +} diff --git a/dist/src/SnippetCompiler.js b/dist/src/SnippetCompiler.js new file mode 100644 index 0000000..2fe2ab8 --- /dev/null +++ b/dist/src/SnippetCompiler.js @@ -0,0 +1,75 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tsconfig = require("tsconfig"); +const Bluebird = require("bluebird"); +const fsExtra = require("fs-extra"); +const TypeScriptRunner_1 = require("./TypeScriptRunner"); +const PackageInfo_1 = require("./PackageInfo"); +const CodeBlockExtractor_1 = require("./CodeBlockExtractor"); +const LocalImportSubstituter_1 = require("./LocalImportSubstituter"); +const CodeWrapper_1 = require("./CodeWrapper"); +class SnippetCompiler { + constructor(workingDirectory) { + this.workingDirectory = workingDirectory; + const configOptions = tsconfig.loadSync(process.cwd()); + this.runner = new TypeScriptRunner_1.TypeScriptRunner(this.workingDirectory, configOptions.config); + } + compileSnippets(documentationFiles) { + return Bluebird.resolve() + .then(() => this.cleanWorkingDirectory()) + .then(() => fsExtra.ensureDir(this.workingDirectory)) + .then(() => this.extractAllCodeBlocks(documentationFiles)) + .map((example, index) => this.testCodeCompilation(example, index)) + .finally(() => this.cleanWorkingDirectory()); + } + cleanWorkingDirectory() { + return fsExtra.remove(this.workingDirectory); + } + extractAllCodeBlocks(documentationFiles) { + return Bluebird.resolve() + .then(() => PackageInfo_1.PackageInfo.read()) + .then((packageDefn) => new LocalImportSubstituter_1.LocalImportSubstituter(packageDefn)) + .then((importSubstituter) => { + return Bluebird.all(documentationFiles) + .map((file) => this.extractFileCodeBlocks(file, importSubstituter)) + .reduce((previous, current) => { + return previous.concat(current); + }, []); + }); + } + extractFileCodeBlocks(file, importSubstituter) { + return Bluebird.resolve() + .then(() => CodeBlockExtractor_1.CodeBlockExtractor.extract(file)) + .map((block) => { + return { + file, + snippet: block, + sanitisedCode: this.sanitiseCodeBlock(importSubstituter, block) + }; + }); + } + sanitiseCodeBlock(importSubstituter, block) { + const localisedBlock = importSubstituter.substituteLocalPackageImports(block); + return CodeWrapper_1.CodeWrapper.wrap(localisedBlock); + } + testCodeCompilation(example, index) { + return this.runner.run(example.sanitisedCode) + .then(() => { + return { + snippet: example.snippet, + file: example.file, + index: index + 1 + }; + }) + .catch((error) => { + return { + snippet: example.snippet, + error, + file: example.file, + index: index + 1 + }; + }); + } +} +exports.SnippetCompiler = SnippetCompiler; +//# sourceMappingURL=SnippetCompiler.js.map \ No newline at end of file diff --git a/dist/src/SnippetCompiler.js.map b/dist/src/SnippetCompiler.js.map new file mode 100644 index 0000000..3cd7a2b --- /dev/null +++ b/dist/src/SnippetCompiler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SnippetCompiler.js","sourceRoot":"","sources":["../../src/SnippetCompiler.ts"],"names":[],"mappings":";;AAAA,qCAAoC;AACpC,qCAAoC;AACpC,oCAAmC;AAEnC,yDAAqD;AACrD,+CAA2C;AAC3C,6DAAyD;AACzD,qEAAiE;AACjE,+CAA2C;AAe3C,MAAa,eAAe;IAG1B,YAA8B,gBAAwB;QAAxB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACpD,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QACtD,IAAI,CAAC,MAAM,GAAG,IAAI,mCAAgB,CAAC,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACjF,CAAC;IAED,eAAe,CAAE,kBAA4B;QAC3C,OAAO,QAAQ,CAAC,OAAO,EAAE;aACtB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;aACxC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACpD,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;aACzD,GAAG,CAAC,CAAC,OAAkB,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;aAC5E,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAA;IAChD,CAAC;IAEO,qBAAqB;QAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;IAC9C,CAAC;IAEO,oBAAoB,CAAE,kBAA4B;QACxD,OAAO,QAAQ,CAAC,OAAO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AC,GAAG,EAAE;YACT,OAAO;gBACL,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,KAAK,GAAG,CAAC;aACjB,CAAA;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,OAAO;gBACL,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,KAAK;gBACL,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,KAAK,GAAG,CAAC;aACjB,CAAA;QACH,CAAC,CAAC,CAAA;IACN,CAAC;CACF;AArED,0CAqEC"} \ No newline at end of file diff --git a/dist/src/TypeScriptRunner.d.ts b/dist/src/TypeScriptRunner.d.ts new file mode 100644 index 0000000..c5c3de5 --- /dev/null +++ b/dist/src/TypeScriptRunner.d.ts @@ -0,0 +1,6 @@ +export declare class TypeScriptRunner { + private readonly workingDirectory; + constructor(workingDirectory: string, typeScriptOptions: any); + run(code: string): Promise; + private writeCodeFile; +} diff --git a/dist/src/TypeScriptRunner.js b/dist/src/TypeScriptRunner.js new file mode 100644 index 0000000..64eb42f --- /dev/null +++ b/dist/src/TypeScriptRunner.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +const fsExtra = require("fs-extra"); +const TsNode = require("ts-node/dist/index"); +class TypeScriptRunner { + constructor(workingDirectory, typeScriptOptions) { + this.workingDirectory = workingDirectory; + TsNode.register(typeScriptOptions); + } + run(code) { + return Promise.resolve() + .then(() => this.writeCodeFile(code)) + .then((codeFile) => { + require(codeFile); + }); + } + writeCodeFile(code) { + const id = Math.random(); + const codeFile = path.join(this.workingDirectory, `block-${id}.ts`); + return fsExtra.writeFile(codeFile, code) + .then(() => codeFile); + } +} +exports.TypeScriptRunner = TypeScriptRunner; +//# sourceMappingURL=TypeScriptRunner.js.map \ No newline at end of file diff --git a/dist/src/TypeScriptRunner.js.map b/dist/src/TypeScriptRunner.js.map new file mode 100644 index 0000000..818a37e --- /dev/null +++ b/dist/src/TypeScriptRunner.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TypeScriptRunner.js","sourceRoot":"","sources":["../../src/TypeScriptRunner.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,oCAAmC;AACnC,6CAA4C;AAE5C,MAAa,gBAAgB;IAC3B,YAA8B,gBAAwB,EAAE,iBAAsB;QAAhD,qBAAgB,GAAhB,gBAAgB,CAAQ;QACpD,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IACpC,CAAC;IAED,GAAG,CAAE,IAAY;QACf,OAAO,OAAO,CAAC,OAAO,EAAE;aACrB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;aACpC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACjB,OAAO,CAAC,QAAQ,CAAC,CAAA;QACnB,CAAC,CAAC,CAAA;IACN,CAAC;IAEO,aAAa,CAAE,IAAY;QACjC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;QACnE,OAAO,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC;aACrC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAA;IACzB,CAAC;CACF;AAnBD,4CAmBC"} \ No newline at end of file diff --git a/dist/test/TestConfiguration.d.ts b/dist/test/TestConfiguration.d.ts new file mode 100644 index 0000000..b2964c6 --- /dev/null +++ b/dist/test/TestConfiguration.d.ts @@ -0,0 +1,2 @@ +import 'mocha'; +import 'verify-it'; diff --git a/dist/test/TestConfiguration.js b/dist/test/TestConfiguration.js new file mode 100644 index 0000000..e525bb8 --- /dev/null +++ b/dist/test/TestConfiguration.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("mocha"); +require("verify-it"); +const chai = require("chai"); +const chaiAsPromised = require("chai-as-promised"); +chai.use(chaiAsPromised); +chai.should(); +//# sourceMappingURL=TestConfiguration.js.map \ No newline at end of file diff --git a/dist/test/TestConfiguration.js.map b/dist/test/TestConfiguration.js.map new file mode 100644 index 0000000..4ccd421 --- /dev/null +++ b/dist/test/TestConfiguration.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TestConfiguration.js","sourceRoot":"","sources":["../../test/TestConfiguration.ts"],"names":[],"mappings":";;AAAA,iBAAc;AACd,qBAAkB;AAClB,6BAA4B;AAC5B,mDAAkD;AAElD,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AACxB,IAAI,CAAC,MAAM,EAAE,CAAA"} \ No newline at end of file diff --git a/dist/test/TypeScriptDocsVerifierSpec.d.ts b/dist/test/TypeScriptDocsVerifierSpec.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/TypeScriptDocsVerifierSpec.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/TypeScriptDocsVerifierSpec.js b/dist/test/TypeScriptDocsVerifierSpec.js new file mode 100644 index 0000000..6733bfa --- /dev/null +++ b/dist/test/TypeScriptDocsVerifierSpec.js @@ -0,0 +1,251 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const os = require("os"); +const path = require("path"); +const FsExtra = require("fs-extra"); +const verify_it_1 = require("verify-it"); +const TypeScriptDocsVerifier = require("../index"); +const workingDirectory = path.join(os.tmpdir(), 'typescript-docs-verifier-test'); +const fixturePath = path.join(__dirname, '..', '..', 'test', 'fixtures'); +const defaultPackageJson = { + name: verify_it_1.Gen.string(), + main: `${verify_it_1.Gen.string()}.ts` +}; +const defaultMainFile = { + name: 'main-default.ts', + contents: FsExtra.readFileSync(path.join(fixturePath, 'main-default.ts')).toString() +}; +const defaultMarkdownFile = { + name: 'README.md', + contents: FsExtra.readFileSync(path.join(fixturePath, 'no-typescript.md')) +}; +const defaultTsConfig = { + compilerOptions: { + target: 'ES2015', + module: 'commonjs', + sourceMap: true, + allowJs: true, + outDir: './dist', + noEmitOnError: true, + pretty: true, + strict: true, + noImplicitAny: true, + strictNullChecks: true, + noImplicitThis: true, + alwaysStrict: true, + noImplicitReturns: true, + typeRoots: [path.join(__dirname, '..', '..', 'node_modules', '@types')] + }, + exclude: ['node_modules', 'example'] +}; +const defaultProjectFiles = { + packageJson: defaultPackageJson, + markdownFiles: [defaultMarkdownFile], + mainFile: defaultMainFile, + tsConfig: JSON.stringify(defaultTsConfig) +}; +const createProject = (files = defaultProjectFiles) => { + const filesToWrite = [{ + name: 'package.json', + contents: JSON.stringify((files.packageJson || defaultPackageJson)) + }, { + name: (files.mainFile || defaultMainFile).name, + contents: (files.mainFile || defaultMainFile).contents + }, { + name: 'tsconfig.json', + contents: files.tsConfig || JSON.stringify(defaultTsConfig) + }]; + const allFiles = filesToWrite.concat(files.markdownFiles || []); + return Promise.all(allFiles.map((file) => FsExtra.writeFile(path.join(workingDirectory, file.name), file.contents))); +}; +const genSnippet = () => { + const name = 'a' + verify_it_1.Gen.string().replace(/[-]/g, ''); + const value = verify_it_1.Gen.string(); + return `const ${name} = "${value}"`; +}; +const wrapSnippet = (snippet) => { + return `\`\`\`typescript +${snippet}\`\`\``; +}; +describe('TypeScriptDocsVerifier', () => { + describe('compileSnippets', () => { + beforeEach(() => { + return FsExtra.ensureDir(path.join(workingDirectory)) + .then(() => process.chdir(workingDirectory)); + }); + afterEach(() => FsExtra.remove(workingDirectory)); + verify.it('returns an empty array if no code snippets are present', () => { + return createProject() + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.eql([]); + }); + verify.it('returns an empty array if no typescript code snippets are present', verify_it_1.Gen.array(verify_it_1.Gen.string, 4), (strings) => { + const noTypeScriptMarkdown = ` +# A \`README.md\` file + +${strings[0]} + +\`\`\`javascript +${strings[1]} +\`\`\` + +${strings[2]} + +\`\`\`bash +${strings[3]} +\`\`\``; + return createProject({ markdownFiles: [{ name: 'README.md', contents: noTypeScriptMarkdown }] }) + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.eql([]); + }); + verify.it('returns an error if a documentation file does not exist', verify_it_1.Gen.string, (filename) => { + return createProject() + .then(() => TypeScriptDocsVerifier.compileSnippets(['README.md', filename])) + .should.be.rejectedWith(filename); + }); + verify.it('returns a single element result array when a valid typescript block is supplied', genSnippet, verify_it_1.Gen.string, (snippet, fileName) => { + const typeScriptMarkdown = wrapSnippet(snippet); + return createProject({ markdownFiles: [{ name: fileName, contents: typeScriptMarkdown }] }) + .then(() => TypeScriptDocsVerifier.compileSnippets(fileName)) + .should.eventually.eql([{ + file: fileName, + index: 1, + snippet + }]); + }); + verify.it('compiles snippets from multiple files', verify_it_1.Gen.distinct(genSnippet, 3), verify_it_1.Gen.distinct(verify_it_1.Gen.string, 3), (snippets, fileNames) => { + const markdownFiles = snippets.map((snippet, index) => { + return { + name: fileNames[index], + contents: wrapSnippet(snippet) + }; + }); + const expected = snippets.map((snippet, index) => { + return { + file: fileNames[index], + index: index + 1, + snippet + }; + }); + return createProject({ markdownFiles: markdownFiles }) + .then(() => TypeScriptDocsVerifier.compileSnippets(fileNames)) + .should.eventually.eql(expected); + }); + verify.it('reads from README.md if no file paths are supplied', genSnippet, (snippet) => { + const typeScriptMarkdown = wrapSnippet(snippet); + return createProject({ markdownFiles: [{ name: 'README.md', contents: typeScriptMarkdown }] }) + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.eql([{ + file: 'README.md', + index: 1, + snippet + }]); + }); + verify.it('returns an empty array if an empty array is provided', genSnippet, (snippet) => { + const typeScriptMarkdown = wrapSnippet(snippet); + return createProject({ markdownFiles: [{ name: 'README.md', contents: typeScriptMarkdown }] }) + .then(() => TypeScriptDocsVerifier.compileSnippets([])) + .should.eventually.eql([]); + }); + verify.it('returns multiple results when multiple TypeScript snippets are supplied', verify_it_1.Gen.array(genSnippet, verify_it_1.Gen.integerBetween(2, 6)()), (snippets) => { + const markdownBlocks = snippets.map(wrapSnippet); + const markdown = markdownBlocks.join('\n'); + const expected = snippets.map((snippet, index) => { + return { + file: 'README.md', + index: index + 1, + snippet + }; + }); + return createProject({ markdownFiles: [{ name: 'README.md', contents: markdown }] }) + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.eql(expected); + }); + verify.it('compiles snippets with import statements', genSnippet, (snippet) => { + snippet = `import * as path from 'path' + path.join('.', 'some-path') + ${snippet}`; + const typeScriptMarkdown = wrapSnippet(snippet); + return createProject({ markdownFiles: [{ name: 'README.md', contents: typeScriptMarkdown }] }) + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.eql([{ + file: 'README.md', + index: 1, + snippet + }]); + }); + verify.it('reports compilation failures', genSnippet, verify_it_1.Gen.string, (validSnippet, invalidSnippet) => { + const validTypeScriptMarkdown = wrapSnippet(validSnippet); + const invalidTypeScriptMarkdown = wrapSnippet(invalidSnippet); + const markdown = [validTypeScriptMarkdown, invalidTypeScriptMarkdown].join('\n'); + return createProject({ markdownFiles: [{ name: 'README.md', contents: markdown }] }) + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.satisfy((results) => { + results.should.have.length(2); + results[0].should.not.have.property('error'); + const errorResult = results[1]; + errorResult.should.have.property('file', 'README.md'); + errorResult.should.have.property('index', 2); + errorResult.should.have.property('snippet', invalidSnippet); + errorResult.should.have.property('error'); + return true; + }); + }); + verify.it('localises imports of the current package if the package main is a ts file', () => { + const snippet = ` + import { MyClass } from '${defaultPackageJson.name}' + const instance = new MyClass() + instance.doStuff()`; + const mainFile = { + name: `${defaultPackageJson.main}`, + contents: ` + export class MyClass { + doStuff (): void { + return + } + }` + }; + const typeScriptMarkdown = wrapSnippet(snippet); + return createProject({ markdownFiles: [{ name: 'README.md', contents: typeScriptMarkdown }], mainFile }) + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.eql([{ + file: 'README.md', + index: 1, + snippet + }]); + }); + verify.it('localises imports of the current package if the package main is a js file', verify_it_1.Gen.string, verify_it_1.Gen.string, (name, main) => { + const packageJson = { + name, + main: `${main}.js` + }; + const snippet = ` + import { MyClass } from '${packageJson.name}' + const instance: any = MyClass() + instance.doStuff()`; + const mainFile = { + name: `${packageJson.main}`, + contents: ` + module.exports.MyClass = function MyClass () { + this.doStuff = () => { + return + } + }` + }; + const typeScriptMarkdown = wrapSnippet(snippet); + const projectFiles = { + markdownFiles: [{ name: 'README.md', contents: typeScriptMarkdown }], + mainFile, + packageJson + }; + return createProject(projectFiles) + .then(() => TypeScriptDocsVerifier.compileSnippets()) + .should.eventually.eql([{ + file: 'README.md', + index: 1, + snippet + }]); + }); + }); +}); +//# sourceMappingURL=TypeScriptDocsVerifierSpec.js.map \ No newline at end of file diff --git a/dist/test/TypeScriptDocsVerifierSpec.js.map b/dist/test/TypeScriptDocsVerifierSpec.js.map new file mode 100644 index 0000000..724b689 --- /dev/null +++ b/dist/test/TypeScriptDocsVerifierSpec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TypeScriptDocsVerifierSpec.js","sourceRoot":"","sources":["../../test/TypeScriptDocsVerifierSpec.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AACxB,6BAA4B;AAC5B,oCAAmC;AACnC,yCAA+B;AAC/B,mDAAkD;AAGlD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,+BAA+B,CAAC,CAAA;AAChF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;AAExE,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,eAAG,CAAC,MAAM,EAAE;IAClB,IAAI,EAAE,GAAG,eAAG,CAAC,MAAM,EAAE,KAAK;CAC3B,CAAA;AACD,MAAM,eAAe,GAAG;IACtB,IA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AAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;gBACpE,QAAQ;gBACR,WAAW;aACZ,CAAA;YACD,OAAO,aAAa,CAAC,YAAY,CAAC;iBAC/B,IAAI,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,eAAe,EAAE,CAAC;iBACpD,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;oBACtB,IAAI,EAAE,WAAW;oBACjB,KAAK,EAAE,CAAC;oBACR,OAAO;iBACR,CAAC,CAAC,CAAA;QACP,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/fixtures/main-default.d.ts b/dist/test/fixtures/main-default.d.ts new file mode 100644 index 0000000..5b3765f --- /dev/null +++ b/dist/test/fixtures/main-default.d.ts @@ -0,0 +1,3 @@ +export declare class MyTestClass { + doStuff(): void; +} diff --git a/dist/test/fixtures/main-default.js b/dist/test/fixtures/main-default.js new file mode 100644 index 0000000..1de0360 --- /dev/null +++ b/dist/test/fixtures/main-default.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class MyTestClass { + doStuff() { + return; + } +} +exports.MyTestClass = MyTestClass; +//# sourceMappingURL=main-default.js.map \ No newline at end of file diff --git a/dist/test/fixtures/main-default.js.map b/dist/test/fixtures/main-default.js.map new file mode 100644 index 0000000..dc27014 --- /dev/null +++ b/dist/test/fixtures/main-default.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main-default.js","sourceRoot":"","sources":["../../../test/fixtures/main-default.ts"],"names":[],"mappings":";;AAAA,MAAa,WAAW;IACtB,OAAO;QACL,OAAM;IACR,CAAC;CACF;AAJD,kCAIC"} \ No newline at end of file