jsii-rosetta 5.1.2-dev.1 → 5.1.2-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -10,5 +10,6 @@ export * from './rosetta-reader';
10
10
  export * from './rosetta-translator';
11
11
  export * from './snippet';
12
12
  export * from './markdown';
13
+ export * from './commands/transliterate';
13
14
  export * from './strict';
14
15
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -33,5 +33,6 @@ __exportStar(require("./rosetta-reader"), exports);
33
33
  __exportStar(require("./rosetta-translator"), exports);
34
34
  __exportStar(require("./snippet"), exports);
35
35
  __exportStar(require("./markdown"), exports);
36
+ __exportStar(require("./commands/transliterate"), exports);
36
37
  __exportStar(require("./strict"), exports);
37
38
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,+DAA6D;AAApD,iHAAA,cAAc,OAAA;AACvB,6CAAmD;AAA1C,uGAAA,aAAa,OAAA;AACtB,yCAA+C;AAAtC,mGAAA,WAAW,OAAA;AACpB,6CAAmD;AAA1C,uGAAA,aAAa,OAAA;AACtB,qCAA2C;AAAlC,+FAAA,SAAS,OAAA;AAClB,oDAAkC;AAClC,mDAAiC;AACjC,uDAAqC;AACrC,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB","sourcesContent":["export * from './translate';\nexport { renderTree } from './o-tree';\nexport { TargetLanguage } from './languages/target-language';\nexport { CSharpVisitor } from './languages/csharp';\nexport { JavaVisitor } from './languages/java';\nexport { PythonVisitor } from './languages/python';\nexport { GoVisitor } from './languages/go';\nexport * from './tablets/tablets';\nexport * from './rosetta-reader';\nexport * from './rosetta-translator';\nexport * from './snippet';\nexport * from './markdown';\nexport * from './strict';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,+DAA6D;AAApD,iHAAA,cAAc,OAAA;AACvB,6CAAmD;AAA1C,uGAAA,aAAa,OAAA;AACtB,yCAA+C;AAAtC,mGAAA,WAAW,OAAA;AACpB,6CAAmD;AAA1C,uGAAA,aAAa,OAAA;AACtB,qCAA2C;AAAlC,+FAAA,SAAS,OAAA;AAClB,oDAAkC;AAClC,mDAAiC;AACjC,uDAAqC;AACrC,4CAA0B;AAC1B,6CAA2B;AAC3B,2DAAyC;AACzC,2CAAyB","sourcesContent":["export * from './translate';\nexport { renderTree } from './o-tree';\nexport { TargetLanguage } from './languages/target-language';\nexport { CSharpVisitor } from './languages/csharp';\nexport { JavaVisitor } from './languages/java';\nexport { PythonVisitor } from './languages/python';\nexport { GoVisitor } from './languages/go';\nexport * from './tablets/tablets';\nexport * from './rosetta-reader';\nexport * from './rosetta-translator';\nexport * from './snippet';\nexport * from './markdown';\nexport * from './commands/transliterate';\nexport * from './strict';\n"]}
package/lib/main.js CHANGED
@@ -255,7 +255,6 @@ async function main() {
255
255
  describe: 'Assembly to transliterate',
256
256
  })
257
257
  .option('language', {
258
- alias: 'l',
259
258
  type: 'string',
260
259
  array: true,
261
260
  default: [],
@@ -280,7 +279,9 @@ async function main() {
280
279
  }), wrapHandler((args) => {
281
280
  const assemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((dir) => path.resolve(process.cwd(), dir));
282
281
  const languages = args.language.length > 0
283
- ? args.language.map((lang) => {
282
+ ? args.language
283
+ .map((lang) => lang.toUpperCase())
284
+ .map((lang) => {
284
285
  const target = Object.entries(languages_1.TargetLanguage).find(([k]) => k === lang)?.[1];
285
286
  if (target == null) {
286
287
  throw new Error(`Unknown target language: ${lang}. Expected one of ${Object.keys(languages_1.TargetLanguage).join(', ')}`);
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAE9B,qCAAyC;AACzC,kCAAkC;AAClC,+BAA+B;AAE/B,gDAAuD;AACvD,kDAAoD;AACpD,gDAAuF;AACvF,8CAA0E;AAC1E,0CAA6C;AAC7C,4DAAiE;AACjE,sDAAkD;AAClD,mCAAkF;AAClF,2CAA6C;AAC7C,+CAAmD;AACnD,qDAA4D;AAC5D,qCAAqC;AACrC,uCAAyD;AACzD,iCAAsD;AAEtD,KAAK,UAAU,IAAI;IACjB,MAAM,IAAA,sCAA4B,GAAE,CAAC;IAErC,MAAM,IAAI,GAAG,KAAK;SACf,KAAK,CAAC,iBAAiB,CAAC;SACxB,MAAM,CAAC,SAAS,EAAE;QACjB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,4BAA4B;QAClC,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC;KACX,CAAC;SACD,OAAO,CACN,cAAc,EACd,4BAA4B,EAC5B,CAAC,OAAO,EAAE,EAAE,CACV,OAAO;SACJ,UAAU,CAAC,MAAM,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,6CAA6C;KACxD,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE;QAChB,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,8BAA8B;KAC5C,CAAC,EACN,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,IAAA,2BAAmB,EAAC,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAE,UAAU,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1G,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CACH;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,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpE,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,+BAA+B,YAAY,WAAW,CAAC,CAAC;KAC3F;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACvC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC","sourcesContent":["import '@jsii/check-node/run';\n\nimport { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport * as yargs from 'yargs';\n\nimport { translateMarkdown } from './commands/convert';\nimport { checkCoverage } from './commands/coverage';\nimport { extractAndInfuse, extractSnippets, ExtractOptions } from './commands/extract';\nimport { infuse, DEFAULT_INFUSION_RESULTS_NAME } from './commands/infuse';\nimport { readTablet } from './commands/read';\nimport { transliterateAssembly } from './commands/transliterate';\nimport { trimCache } from './commands/trim-cache';\nimport { TranslateResult, translateTypeScript, RosettaDiagnostic } from './index';\nimport { TargetLanguage } from './languages';\nimport { PythonVisitor } from './languages/python';\nimport { VisualizeAstVisitor } from './languages/visualize';\nimport * as logging from './logging';\nimport { emitSupportPolicyInformation } from './support';\nimport { File, fmap, printDiagnostics } from './util';\n\nasync function main() {\n await emitSupportPolicyInformation();\n\n const argv = yargs\n .usage('$0 <cmd> [args]')\n .option('verbose', {\n alias: 'v',\n type: 'boolean',\n desc: 'Increase logging verbosity',\n count: true,\n default: 0,\n })\n .command(\n 'snippet FILE',\n 'Translate a single snippet',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n description: 'Translate snippets to Python',\n }),\n wrapHandler(async (args) => {\n const result = translateTypeScript(await makeFileSource(args.FILE ?? '-', 'stdin.ts'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'markdown FILE',\n 'Translate a MarkDown file',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n description: 'Translate snippets to Python',\n }),\n wrapHandler(async (args) => {\n const result = translateMarkdown(await makeFileSource(args.FILE ?? '-', 'stdin.md'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'infuse [ASSEMBLY..]',\n '(EXPERIMENTAL) mutates one or more assemblies by adding documentation examples to top-level types',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to mutate',\n })\n .option('log-file', {\n alias: 'l',\n type: 'string',\n describe: 'Output file to store logging results. Ignored if -log is not true',\n default: DEFAULT_INFUSION_RESULTS_NAME,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to'),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'], path.resolve);\n const result = await infuse(absAssemblies, {\n logFile: args['log-file'],\n cacheToFile: absCacheTo,\n cacheFromFile: absCacheFrom,\n });\n\n let totalTypes = 0;\n let insertedExamples = 0;\n for (const [directory, map] of Object.entries(result.coverageResults)) {\n const commonName = directory.split('/').pop()!;\n const newCoverage = roundPercentage(map.typesWithInsertedExamples / map.types);\n process.stdout.write(\n `${commonName}: Added ${map.typesWithInsertedExamples} examples to ${map.types} types.\\n`,\n );\n process.stdout.write(`${commonName}: New coverage: ${newCoverage}%.\\n`);\n\n insertedExamples += map.typesWithInsertedExamples;\n totalTypes += map.types;\n }\n const newCoverage = roundPercentage(insertedExamples / totalTypes);\n process.stdout.write(`\\n\\nFinal Stats:\\nNew coverage: ${newCoverage}%.\\n`);\n }),\n )\n .command(\n ['extract [ASSEMBLY..]', '$0 [ASSEMBLY..]'],\n 'Extract code snippets from one or more assemblies into language tablets',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to extract from',\n })\n .option('output', {\n type: 'string',\n describe: 'Additional output file where to store translated samples (deprecated, alias for --cache-to)',\n requiresArg: true,\n default: undefined,\n })\n .option('compile', {\n alias: 'c',\n type: 'boolean',\n describe: 'Try compiling (on by default, use --no-compile to switch off)',\n default: true,\n })\n .option('directory', {\n alias: 'd',\n type: 'string',\n describe: 'Working directory (for require() etc)',\n })\n .option('include', {\n alias: 'i',\n type: 'string',\n array: true,\n describe: 'Extract only snippets with given ids',\n default: [],\n })\n .option('infuse', {\n type: 'boolean',\n describe: 'bundle this command with the infuse command',\n default: false,\n })\n .option('fail', {\n alias: 'f',\n type: 'boolean',\n describe: 'Fail if there are compilation errors',\n default: false,\n })\n .option('validate-assemblies', {\n type: 'boolean',\n describe: 'Whether to validate loaded assemblies or not (this can be slow)',\n default: false,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache-to', 'output')\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to')\n .option('trim-cache', {\n alias: 'T',\n type: 'boolean',\n describe: 'Remove translations that are not referenced by any of the assemblies anymore from the cache',\n })\n .option('strict', {\n alias: 'S',\n type: 'boolean',\n describe:\n 'Require all code samples compile, and fail if one does not. Strict mode always enables --compile and --fail',\n default: false,\n })\n .options('loose', {\n alias: 'l',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .options('compress-tablet', {\n alias: 'z',\n type: 'boolean',\n describe: 'Compress the implicit tablet file',\n default: false,\n })\n .options('compress-cache', {\n type: 'boolean',\n describe: 'Compress the cache-to file',\n default: false,\n })\n .options('cleanup', {\n type: 'boolean',\n describe: 'Clean up temporary directories',\n default: true,\n })\n .conflicts('loose', 'strict')\n .conflicts('loose', 'fail'),\n wrapHandler(async (args) => {\n // `--strict` is short for `--compile --fail`, and we'll override those even if they're set to `false`, such as\n // using `--no-(compile|fail)`, because yargs does not quite give us a better option that does not hurt CX.\n if (args.strict) {\n args.compile = args.c = true;\n args.fail = args.f = true;\n }\n\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'] ?? args.output, path.resolve);\n\n const extractOptions: ExtractOptions = {\n compilationDirectory: args.directory,\n includeCompilerDiagnostics: !!args.compile,\n validateAssemblies: args['validate-assemblies'],\n only: args.include,\n cacheFromFile: absCacheFrom,\n cacheToFile: absCacheTo,\n trimCache: args['trim-cache'],\n loose: args.loose,\n compressTablet: args['compress-tablet'],\n compressCacheToFile: args['compress-cache'],\n cleanup: args.cleanup,\n };\n\n const result = args.infuse\n ? await extractAndInfuse(absAssemblies, extractOptions)\n : await extractSnippets(absAssemblies, extractOptions);\n\n handleDiagnostics(result.diagnostics, args.fail, result.tablet.count);\n }),\n )\n .command(\n 'transliterate [ASSEMBLY..]',\n '(EXPERIMENTAL) Transliterates the designated assemblies',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n required: true,\n describe: 'Assembly to transliterate',\n })\n .option('language', {\n alias: 'l',\n type: 'string',\n array: true,\n default: [],\n describe: 'Language ID to transliterate to',\n })\n .options('strict', {\n alias: 's',\n conflicts: 'loose',\n describe:\n 'Fail if an example that needs live transliteration fails to compile (which could cause incorrect transpilation results)',\n type: 'boolean',\n })\n .options('loose', {\n alias: 'l',\n conflicts: 'strict',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .option('tablet', {\n alias: 't',\n type: 'string',\n describe:\n 'Language tablet containing pre-translated code examples to use (these are generated by the `extract` command)',\n }),\n wrapHandler((args) => {\n const assemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((dir) =>\n path.resolve(process.cwd(), dir),\n );\n const languages =\n args.language.length > 0\n ? args.language.map((lang) => {\n const target = Object.entries(TargetLanguage).find(([k]) => k === lang)?.[1];\n if (target == null) {\n throw new Error(\n `Unknown target language: ${lang}. Expected one of ${Object.keys(TargetLanguage).join(', ')}`,\n );\n }\n return target;\n })\n : Object.values(TargetLanguage);\n return transliterateAssembly(assemblies, languages, args);\n }),\n )\n .command(\n 'trim-cache <TABLET> [ASSEMBLY..]',\n 'Retain only those snippets in the cache which occur in one of the given assemblies',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to trim',\n })\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to search',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await trimCache({\n cacheFile: args.TABLET,\n assemblyLocations: args.ASSEMBLY,\n });\n }),\n )\n .command(\n 'coverage [ASSEMBLY..]',\n 'Check the translation coverage of implicit tablets for the given assemblies',\n (command) =>\n command.positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: ['.'],\n describe: 'Assembly or directory to search',\n }),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n await checkCoverage(absAssemblies);\n }),\n )\n .command(\n 'read <TABLET> [KEY] [LANGUAGE]',\n 'Display snippets in a language tablet file',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to read',\n })\n .positional('KEY', {\n type: 'string',\n describe: 'Snippet key to read',\n })\n .positional('LANGUAGE', {\n type: 'string',\n describe: 'Language ID to read',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await readTablet(args.TABLET, args.KEY, args.LANGUAGE);\n }),\n )\n .command(\n 'configure-strict [PACKAGE]',\n \"Enables strict mode for a package's assembly\",\n (command) =>\n command.positional('PACKAGE', {\n type: 'string',\n describe: 'The path to the package to configure',\n required: false,\n default: '.',\n normalize: true,\n }),\n wrapHandler(async (args) => {\n const packageJsonPath = (await fs.stat(args.PACKAGE)).isDirectory()\n ? path.join(args.PACKAGE, 'package.json')\n : args.PACKAGE;\n const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n if (packageJson.jsii == null) {\n console.error(\n `The package in ${args.PACKAGE} does not have a jsii configuration! You can set it up using jsii-config.`,\n );\n process.exitCode = 1;\n return Promise.resolve();\n }\n if (packageJson.jsii.metadata?.jsii?.rosetta?.strict) {\n // Nothing to do - it's already configured, so we assert idempotent success!\n return Promise.resolve();\n }\n const md = (packageJson.jsii.metadata = packageJson.jsii.metadata ?? {});\n const mdJsii = (md.jsii = md.jsii ?? {});\n const mdRosetta = (mdJsii.rosetta = mdJsii.rosetta ?? {});\n mdRosetta.strict = true;\n\n return fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }),\n )\n .demandCommand()\n .help()\n .strict() // Error on wrong command\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n .version(require('../package.json').version)\n .showHelpOnFail(false).argv;\n\n // Evaluating .argv triggers the parsing but the command gets implicitly executed,\n // so we don't need the output.\n Array.isArray(argv);\n}\n\n/**\n * Wrap a command's handler with standard pre- and post-work\n */\nfunction wrapHandler<A extends { verbose?: number }, R>(handler: (x: A) => Promise<R>) {\n return (argv: A) => {\n logging.configure({ level: argv.verbose !== undefined ? argv.verbose : 0 });\n handler(argv).catch((e) => {\n logging.error(e.message);\n logging.error(e.stack);\n process.exitCode = 1;\n });\n };\n}\n\nfunction makeVisitor(args: { python?: boolean }) {\n if (args.python) {\n return new PythonVisitor();\n }\n // Default to visualizing AST, including nodes we don't recognize yet\n return new VisualizeAstVisitor();\n}\n\nasync function makeFileSource(fileName: string, stdinName: string): Promise<File> {\n if (fileName === '-') {\n return {\n contents: await readStdin(),\n fileName: stdinName,\n };\n }\n return {\n contents: await fs.readFile(fileName, { encoding: 'utf-8' }),\n fileName: fileName,\n };\n}\n\nasync function readStdin(): Promise<string> {\n process.stdin.setEncoding('utf8');\n\n const parts: Buffer[] = [];\n\n return new Promise((resolve, reject) => {\n process.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n parts.push(Buffer.from(chunk));\n }\n });\n\n process.stdin.on('error', reject);\n process.stdin.on('end', () => resolve(Buffer.concat(parts).toString('utf-8')));\n });\n}\n\nfunction handleSingleResult(result: TranslateResult) {\n process.stdout.write(`${result.translation}\\n`);\n\n // For a single result, we always request implicit failure.\n handleDiagnostics(result.diagnostics, 'implicit');\n}\n\n/**\n * Print diagnostics and set exit code\n *\n * 'fail' is whether or not the user passed '--fail' for commands that accept\n * it, or 'implicit' for commands that should always fail. 'implicit' will be\n * treated as 'fail=true, but will not print to the user that the '--fail' is\n * set (because for this particular command that switch does not exist and so it\n * would be confusing).\n */\nfunction handleDiagnostics(diagnostics: readonly RosettaDiagnostic[], fail: boolean | 'implicit', snippetCount = 1) {\n if (fail !== false) {\n // Fail on any diagnostic\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.error(\n [\n `${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`,\n ...(fail === true ? [\"(running with '--fail')\"] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n }\n\n return;\n }\n\n // Otherwise fail only on strict diagnostics. If we have strict diagnostics, print only those\n // (so it's very clear what is failing the build), otherwise print everything.\n const strictDiagnostics = diagnostics.filter((diag) => diag.isFromStrictAssembly);\n if (strictDiagnostics.length > 0) {\n printDiagnostics(strictDiagnostics, process.stderr, process.stderr.isTTY);\n const remaining = diagnostics.length - strictDiagnostics.length;\n logging.warn(\n [\n `${strictDiagnostics.length} diagnostics from assemblies with 'strict' mode on`,\n ...(remaining > 0 ? [`(and ${remaining} more non-strict diagnostics)`] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n return;\n }\n\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.warn(`${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`);\n }\n}\n\n/**\n * Rounds a decimal number to two decimal points.\n * The function is useful for fractions that need to be outputted as percentages.\n */\nfunction roundPercentage(num: number): number {\n return Math.round(10000 * num) / 100;\n}\n\nmain().catch((cause) => {\n console.error(cause);\n process.exitCode = -1;\n});\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAE9B,qCAAyC;AACzC,kCAAkC;AAClC,+BAA+B;AAE/B,gDAAuD;AACvD,kDAAoD;AACpD,gDAAuF;AACvF,8CAA0E;AAC1E,0CAA6C;AAC7C,4DAAiE;AACjE,sDAAkD;AAClD,mCAAkF;AAClF,2CAA6C;AAC7C,+CAAmD;AACnD,qDAA4D;AAC5D,qCAAqC;AACrC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AC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC","sourcesContent":["import '@jsii/check-node/run';\n\nimport { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport * as yargs from 'yargs';\n\nimport { translateMarkdown } from './commands/convert';\nimport { checkCoverage } from './commands/coverage';\nimport { extractAndInfuse, extractSnippets, ExtractOptions } from './commands/extract';\nimport { infuse, DEFAULT_INFUSION_RESULTS_NAME } from './commands/infuse';\nimport { readTablet } from './commands/read';\nimport { transliterateAssembly } from './commands/transliterate';\nimport { trimCache } from './commands/trim-cache';\nimport { TranslateResult, translateTypeScript, RosettaDiagnostic } from './index';\nimport { TargetLanguage } from './languages';\nimport { PythonVisitor } from './languages/python';\nimport { VisualizeAstVisitor } from './languages/visualize';\nimport * as logging from './logging';\nimport { emitSupportPolicyInformation } from './support';\nimport { File, fmap, printDiagnostics } from './util';\n\nasync function main() {\n await emitSupportPolicyInformation();\n\n const argv = yargs\n .usage('$0 <cmd> [args]')\n .option('verbose', {\n alias: 'v',\n type: 'boolean',\n desc: 'Increase logging verbosity',\n count: true,\n default: 0,\n })\n .command(\n 'snippet FILE',\n 'Translate a single snippet',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n description: 'Translate snippets to Python',\n }),\n wrapHandler(async (args) => {\n const result = translateTypeScript(await makeFileSource(args.FILE ?? '-', 'stdin.ts'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'markdown FILE',\n 'Translate a MarkDown file',\n (command) =>\n command\n .positional('FILE', {\n type: 'string',\n describe: 'The file to translate (leave out for stdin)',\n })\n .option('python', {\n alias: 'p',\n boolean: true,\n description: 'Translate snippets to Python',\n }),\n wrapHandler(async (args) => {\n const result = translateMarkdown(await makeFileSource(args.FILE ?? '-', 'stdin.md'), makeVisitor(args));\n handleSingleResult(result);\n }),\n )\n .command(\n 'infuse [ASSEMBLY..]',\n '(EXPERIMENTAL) mutates one or more assemblies by adding documentation examples to top-level types',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to mutate',\n })\n .option('log-file', {\n alias: 'l',\n type: 'string',\n describe: 'Output file to store logging results. Ignored if -log is not true',\n default: DEFAULT_INFUSION_RESULTS_NAME,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to'),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'], path.resolve);\n const result = await infuse(absAssemblies, {\n logFile: args['log-file'],\n cacheToFile: absCacheTo,\n cacheFromFile: absCacheFrom,\n });\n\n let totalTypes = 0;\n let insertedExamples = 0;\n for (const [directory, map] of Object.entries(result.coverageResults)) {\n const commonName = directory.split('/').pop()!;\n const newCoverage = roundPercentage(map.typesWithInsertedExamples / map.types);\n process.stdout.write(\n `${commonName}: Added ${map.typesWithInsertedExamples} examples to ${map.types} types.\\n`,\n );\n process.stdout.write(`${commonName}: New coverage: ${newCoverage}%.\\n`);\n\n insertedExamples += map.typesWithInsertedExamples;\n totalTypes += map.types;\n }\n const newCoverage = roundPercentage(insertedExamples / totalTypes);\n process.stdout.write(`\\n\\nFinal Stats:\\nNew coverage: ${newCoverage}%.\\n`);\n }),\n )\n .command(\n ['extract [ASSEMBLY..]', '$0 [ASSEMBLY..]'],\n 'Extract code snippets from one or more assemblies into language tablets',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to extract from',\n })\n .option('output', {\n type: 'string',\n describe: 'Additional output file where to store translated samples (deprecated, alias for --cache-to)',\n requiresArg: true,\n default: undefined,\n })\n .option('compile', {\n alias: 'c',\n type: 'boolean',\n describe: 'Try compiling (on by default, use --no-compile to switch off)',\n default: true,\n })\n .option('directory', {\n alias: 'd',\n type: 'string',\n describe: 'Working directory (for require() etc)',\n })\n .option('include', {\n alias: 'i',\n type: 'string',\n array: true,\n describe: 'Extract only snippets with given ids',\n default: [],\n })\n .option('infuse', {\n type: 'boolean',\n describe: 'bundle this command with the infuse command',\n default: false,\n })\n .option('fail', {\n alias: 'f',\n type: 'boolean',\n describe: 'Fail if there are compilation errors',\n default: false,\n })\n .option('validate-assemblies', {\n type: 'boolean',\n describe: 'Whether to validate loaded assemblies or not (this can be slow)',\n default: false,\n })\n .option('cache-from', {\n alias: 'C',\n type: 'string',\n // eslint-disable-next-line prettier/prettier\n describe:\n 'Reuse translations from the given tablet file if the snippet and type definitions did not change',\n requiresArg: true,\n default: undefined,\n })\n .option('cache-to', {\n alias: 'o',\n type: 'string',\n describe: 'Append all translated snippets to the given tablet file',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache-to', 'output')\n .option('cache', {\n alias: 'k',\n type: 'string',\n describe: 'Alias for --cache-from and --cache-to together',\n requiresArg: true,\n default: undefined,\n })\n .conflicts('cache', 'cache-from')\n .conflicts('cache', 'cache-to')\n .option('trim-cache', {\n alias: 'T',\n type: 'boolean',\n describe: 'Remove translations that are not referenced by any of the assemblies anymore from the cache',\n })\n .option('strict', {\n alias: 'S',\n type: 'boolean',\n describe:\n 'Require all code samples compile, and fail if one does not. Strict mode always enables --compile and --fail',\n default: false,\n })\n .options('loose', {\n alias: 'l',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .options('compress-tablet', {\n alias: 'z',\n type: 'boolean',\n describe: 'Compress the implicit tablet file',\n default: false,\n })\n .options('compress-cache', {\n type: 'boolean',\n describe: 'Compress the cache-to file',\n default: false,\n })\n .options('cleanup', {\n type: 'boolean',\n describe: 'Clean up temporary directories',\n default: true,\n })\n .conflicts('loose', 'strict')\n .conflicts('loose', 'fail'),\n wrapHandler(async (args) => {\n // `--strict` is short for `--compile --fail`, and we'll override those even if they're set to `false`, such as\n // using `--no-(compile|fail)`, because yargs does not quite give us a better option that does not hurt CX.\n if (args.strict) {\n args.compile = args.c = true;\n args.fail = args.f = true;\n }\n\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n\n const absCacheFrom = fmap(args.cache ?? args['cache-from'], path.resolve);\n const absCacheTo = fmap(args.cache ?? args['cache-to'] ?? args.output, path.resolve);\n\n const extractOptions: ExtractOptions = {\n compilationDirectory: args.directory,\n includeCompilerDiagnostics: !!args.compile,\n validateAssemblies: args['validate-assemblies'],\n only: args.include,\n cacheFromFile: absCacheFrom,\n cacheToFile: absCacheTo,\n trimCache: args['trim-cache'],\n loose: args.loose,\n compressTablet: args['compress-tablet'],\n compressCacheToFile: args['compress-cache'],\n cleanup: args.cleanup,\n };\n\n const result = args.infuse\n ? await extractAndInfuse(absAssemblies, extractOptions)\n : await extractSnippets(absAssemblies, extractOptions);\n\n handleDiagnostics(result.diagnostics, args.fail, result.tablet.count);\n }),\n )\n .command(\n 'transliterate [ASSEMBLY..]',\n '(EXPERIMENTAL) Transliterates the designated assemblies',\n (command) =>\n command\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n required: true,\n describe: 'Assembly to transliterate',\n })\n .option('language', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Language ID to transliterate to',\n })\n .options('strict', {\n alias: 's',\n conflicts: 'loose',\n describe:\n 'Fail if an example that needs live transliteration fails to compile (which could cause incorrect transpilation results)',\n type: 'boolean',\n })\n .options('loose', {\n alias: 'l',\n conflicts: 'strict',\n describe: 'Ignore missing fixtures and literate markdown files instead of failing',\n type: 'boolean',\n })\n .option('tablet', {\n alias: 't',\n type: 'string',\n describe:\n 'Language tablet containing pre-translated code examples to use (these are generated by the `extract` command)',\n }),\n wrapHandler((args) => {\n const assemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((dir) =>\n path.resolve(process.cwd(), dir),\n );\n const languages =\n args.language.length > 0\n ? args.language\n .map((lang) => lang.toUpperCase())\n .map((lang) => {\n const target = Object.entries(TargetLanguage).find(([k]) => k === lang)?.[1];\n if (target == null) {\n throw new Error(\n `Unknown target language: ${lang}. Expected one of ${Object.keys(TargetLanguage).join(', ')}`,\n );\n }\n return target;\n })\n : Object.values(TargetLanguage);\n return transliterateAssembly(assemblies, languages, args);\n }),\n )\n .command(\n 'trim-cache <TABLET> [ASSEMBLY..]',\n 'Retain only those snippets in the cache which occur in one of the given assemblies',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to trim',\n })\n .positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: [],\n describe: 'Assembly or directory to search',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await trimCache({\n cacheFile: args.TABLET,\n assemblyLocations: args.ASSEMBLY,\n });\n }),\n )\n .command(\n 'coverage [ASSEMBLY..]',\n 'Check the translation coverage of implicit tablets for the given assemblies',\n (command) =>\n command.positional('ASSEMBLY', {\n type: 'string',\n array: true,\n default: ['.'],\n describe: 'Assembly or directory to search',\n }),\n wrapHandler(async (args) => {\n const absAssemblies = (args.ASSEMBLY.length > 0 ? args.ASSEMBLY : ['.']).map((x) => path.resolve(x));\n await checkCoverage(absAssemblies);\n }),\n )\n .command(\n 'read <TABLET> [KEY] [LANGUAGE]',\n 'Display snippets in a language tablet file',\n (command) =>\n command\n .positional('TABLET', {\n type: 'string',\n required: true,\n describe: 'Language tablet to read',\n })\n .positional('KEY', {\n type: 'string',\n describe: 'Snippet key to read',\n })\n .positional('LANGUAGE', {\n type: 'string',\n describe: 'Language ID to read',\n })\n .demandOption('TABLET'),\n wrapHandler(async (args) => {\n await readTablet(args.TABLET, args.KEY, args.LANGUAGE);\n }),\n )\n .command(\n 'configure-strict [PACKAGE]',\n \"Enables strict mode for a package's assembly\",\n (command) =>\n command.positional('PACKAGE', {\n type: 'string',\n describe: 'The path to the package to configure',\n required: false,\n default: '.',\n normalize: true,\n }),\n wrapHandler(async (args) => {\n const packageJsonPath = (await fs.stat(args.PACKAGE)).isDirectory()\n ? path.join(args.PACKAGE, 'package.json')\n : args.PACKAGE;\n const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n if (packageJson.jsii == null) {\n console.error(\n `The package in ${args.PACKAGE} does not have a jsii configuration! You can set it up using jsii-config.`,\n );\n process.exitCode = 1;\n return Promise.resolve();\n }\n if (packageJson.jsii.metadata?.jsii?.rosetta?.strict) {\n // Nothing to do - it's already configured, so we assert idempotent success!\n return Promise.resolve();\n }\n const md = (packageJson.jsii.metadata = packageJson.jsii.metadata ?? {});\n const mdJsii = (md.jsii = md.jsii ?? {});\n const mdRosetta = (mdJsii.rosetta = mdJsii.rosetta ?? {});\n mdRosetta.strict = true;\n\n return fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }),\n )\n .demandCommand()\n .help()\n .strict() // Error on wrong command\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n .version(require('../package.json').version)\n .showHelpOnFail(false).argv;\n\n // Evaluating .argv triggers the parsing but the command gets implicitly executed,\n // so we don't need the output.\n Array.isArray(argv);\n}\n\n/**\n * Wrap a command's handler with standard pre- and post-work\n */\nfunction wrapHandler<A extends { verbose?: number }, R>(handler: (x: A) => Promise<R>) {\n return (argv: A) => {\n logging.configure({ level: argv.verbose !== undefined ? argv.verbose : 0 });\n handler(argv).catch((e) => {\n logging.error(e.message);\n logging.error(e.stack);\n process.exitCode = 1;\n });\n };\n}\n\nfunction makeVisitor(args: { python?: boolean }) {\n if (args.python) {\n return new PythonVisitor();\n }\n // Default to visualizing AST, including nodes we don't recognize yet\n return new VisualizeAstVisitor();\n}\n\nasync function makeFileSource(fileName: string, stdinName: string): Promise<File> {\n if (fileName === '-') {\n return {\n contents: await readStdin(),\n fileName: stdinName,\n };\n }\n return {\n contents: await fs.readFile(fileName, { encoding: 'utf-8' }),\n fileName: fileName,\n };\n}\n\nasync function readStdin(): Promise<string> {\n process.stdin.setEncoding('utf8');\n\n const parts: Buffer[] = [];\n\n return new Promise((resolve, reject) => {\n process.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n parts.push(Buffer.from(chunk));\n }\n });\n\n process.stdin.on('error', reject);\n process.stdin.on('end', () => resolve(Buffer.concat(parts).toString('utf-8')));\n });\n}\n\nfunction handleSingleResult(result: TranslateResult) {\n process.stdout.write(`${result.translation}\\n`);\n\n // For a single result, we always request implicit failure.\n handleDiagnostics(result.diagnostics, 'implicit');\n}\n\n/**\n * Print diagnostics and set exit code\n *\n * 'fail' is whether or not the user passed '--fail' for commands that accept\n * it, or 'implicit' for commands that should always fail. 'implicit' will be\n * treated as 'fail=true, but will not print to the user that the '--fail' is\n * set (because for this particular command that switch does not exist and so it\n * would be confusing).\n */\nfunction handleDiagnostics(diagnostics: readonly RosettaDiagnostic[], fail: boolean | 'implicit', snippetCount = 1) {\n if (fail !== false) {\n // Fail on any diagnostic\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.error(\n [\n `${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`,\n ...(fail === true ? [\"(running with '--fail')\"] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n }\n\n return;\n }\n\n // Otherwise fail only on strict diagnostics. If we have strict diagnostics, print only those\n // (so it's very clear what is failing the build), otherwise print everything.\n const strictDiagnostics = diagnostics.filter((diag) => diag.isFromStrictAssembly);\n if (strictDiagnostics.length > 0) {\n printDiagnostics(strictDiagnostics, process.stderr, process.stderr.isTTY);\n const remaining = diagnostics.length - strictDiagnostics.length;\n logging.warn(\n [\n `${strictDiagnostics.length} diagnostics from assemblies with 'strict' mode on`,\n ...(remaining > 0 ? [`(and ${remaining} more non-strict diagnostics)`] : []),\n ].join(' '),\n );\n process.exitCode = 1;\n return;\n }\n\n if (diagnostics.length > 0) {\n printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);\n logging.warn(`${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`);\n }\n}\n\n/**\n * Rounds a decimal number to two decimal points.\n * The function is useful for fractions that need to be outputted as percentages.\n */\nfunction roundPercentage(num: number): number {\n return Math.round(10000 * num) / 100;\n}\n\nmain().catch((cause) => {\n console.error(cause);\n process.exitCode = -1;\n});\n"]}
package/package.json CHANGED
@@ -54,14 +54,14 @@
54
54
  "mock-fs": "^5.2.0",
55
55
  "npm-check-updates": "^16",
56
56
  "prettier": "^2.8.8",
57
- "projen": "^0.71.91",
57
+ "projen": "^0.71.96",
58
58
  "tar": "^6.1.15",
59
59
  "ts-jest": "^29.1.0",
60
60
  "ts-node": "^10.9.1"
61
61
  },
62
62
  "dependencies": {
63
- "@jsii/check-node": "1.83.0",
64
- "@jsii/spec": "^1.83.0",
63
+ "@jsii/check-node": "1.84.0",
64
+ "@jsii/spec": "^1.84.0",
65
65
  "@xmldom/xmldom": "^0.8.8",
66
66
  "chalk": "^4",
67
67
  "commonmark": "^0.30.0",
@@ -80,7 +80,7 @@
80
80
  "main": "lib/index.js",
81
81
  "license": "Apache-2.0",
82
82
  "homepage": "https://aws.github.io/jsii",
83
- "version": "5.1.2-dev.1",
83
+ "version": "5.1.2-dev.3",
84
84
  "types": "lib/index.d.ts",
85
85
  "exports": {
86
86
  ".": "./lib/index.js",