jsii-rosetta 4.9.0-dev.2 → 4.9.0-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/README.md CHANGED
@@ -278,6 +278,17 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
278
278
  This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
279
279
  Contributions of any kind welcome!
280
280
 
281
+ ## :gear: Maintenance & Support
282
+
283
+ The applicable _Maintenance & Support policy_ can be reviewed in [SUPPORT.md](./SUPPORT.md).
284
+
285
+ The current status of `jsii-rosetta` releases is:
286
+
287
+ Release | Status | Comment
288
+ --------|---------|-----------------------------
289
+ `1.x` | Current | https://github.com/aws/jsii
290
+ `4.9.x` | Preview | ![](https://img.shields.io/npm/v/jsii-rosetta/v4.9-next?label=jsii-rosetta%40v4.9-next&logo=npm)
291
+
281
292
  ## :balance_scale: License
282
293
 
283
294
  **jsii** is distributed under the [Apache License, Version 2.0][apache-2.0].
package/SUPPORT.md ADDED
@@ -0,0 +1,129 @@
1
+ ## Maintenance & Support Policy
2
+
3
+ This document describes the Maintenance & Support Policy applicable to releases
4
+ of the `jsii-rosetta` tool ([`npm:jsii-rosetta`](https://npmjs.com/packages/jsii-rosetta))
5
+ with versions `4.9.x` and newer.
6
+
7
+ ### Versioning Scheme
8
+
9
+ In-scope `jsii-rosetta` release lines use the same `major.minor` version as the
10
+ TypeScript compiler ([`npm:typescript`](https://npmjs.com/packages/typescript))
11
+ they are built with. This means that `jsii-rosetta@4.9.x` is built on top of
12
+ `typescript@4.9.x`.
13
+
14
+ Since the `typescript` package does not follow [Semantic Versioning][semver],
15
+ the `jsii-rosetta` package does not eiher. The `typescript` compiler guarantees
16
+ no breaking change is introduced within a given `major.minor` release line, and
17
+ `jsii` upholds the same guarantee. As a consequence, users are advised to use
18
+ `~` ranges (also referred to as minor-pinned ranges) when declaring dependencies
19
+ on `jsii-rosetta`.
20
+
21
+ New `jsii-rosetta` release lines will be started matching new `typescript`
22
+ compiler releases shortly after they become `latest` (i.e: the first regular
23
+ release of is issued).
24
+
25
+ [semver]: https://semver.org
26
+
27
+ ### Release Lines Lifecycle Stages
28
+
29
+ This Maintenance & Support Policy assigns one of the following lifecycle stages
30
+ to each in-scope `jsii-rosetta` release line in existence:
31
+
32
+ 1. **Current**: The latest release line is always the **Current** one. This is
33
+ the release under active development, receiving new features, bug fixes and
34
+ security updates.
35
+
36
+ 1. **Maintenace**: Release lines in **Maintenance** stage are no longer
37
+ considered in active development, and no new features will be added to these.
38
+ They however continue to receive bug fixes and security updates. Users can
39
+ continue to use release lines in **Maintenance** stage indefinitely, but we
40
+ recommend they regularly upgrade to the **Current** release lines in order to
41
+ keep the necessary effort low.
42
+
43
+ 1. **End-of-Support**: Release lines in **End-of-Support** are considered
44
+ defunct and are no longer maintained. They no longer receive new features,
45
+ bug fixes, or security updates. **End-of-Support** releases may continue to
46
+ be usable for a period of time, but they could be indirectly broken by
47
+ changes in newer releases at any time. Users are advised to migrate away from
48
+ **End-of-Support** release lines at the earliest convenience.
49
+
50
+ ### Stage Transitions
51
+
52
+ ```mermaid
53
+ ---
54
+ title: Release Line Lifecycle
55
+ ---
56
+ stateDiagram-v2
57
+ direction LR
58
+
59
+ EoL: End-of-Support
60
+
61
+ [*] --> Current
62
+ Current --> Maintenance : new release line started
63
+ Maintenance --> EoL : after 6 months
64
+ EoL --> [*]
65
+ ```
66
+
67
+ Whenever a new release line is started (typically with a new `x.y.0` release,
68
+ excluding pre-releases), it becomes **Current** and the release line it replaced
69
+ immediately enters the **Maintenace** stage.
70
+
71
+ Releases stay in the **Maintenance** stage for a minimum of 6 months before they
72
+ reach **End-of-Support**.
73
+
74
+ Once a release line has reached **End-of-Support**, it remains in this stage
75
+ indefinitely.
76
+
77
+ ### Timelines & Communication
78
+
79
+ The `typescript` compiler maintainers start a new release line on a quarterly
80
+ basis, and users should expect the `jsii-rosetta` maintainers to do the same.
81
+ Users should expect some small code changes may be necessary when upgrading from
82
+ one release line to another, as a result of breaking changes introduced by the
83
+ `typescript` compiler or `jsii-rosetta` itself. In either case, the release
84
+ notes for the first release in a line includes the relevant information about
85
+ the breaking changes and instructions for users to fix their codebase.
86
+
87
+ The `jsii-rosetta` tool has a built-in mechanism to inform users that they are
88
+ using an unsupported or soon-to-become unsupported release line. A message is
89
+ emitted to `STDERR` when invoking the `jsii-rosetta` command if the current
90
+ release is:
91
+
92
+ - **End-of-Support** already
93
+ - Planned to move to **End-of-Support** within the next 30 calendar days
94
+
95
+ The built-in messaging can only be expected to deliver the message if the
96
+ tool is on the latest available release within the line, or if the environment
97
+ in which the tool is run is able to download the lifecycle manifest document.
98
+
99
+ The current status of `jsii-rosetta` tool release lines is also documented on
100
+ the [repository's `README.md` document][readme].
101
+
102
+ ### Modification
103
+
104
+ The maintainers of the jsii project reserve the right to modify this Maintenance
105
+ and Support Policy as necessary. Updates will be proposed by way of a pull
106
+ request updating this document. Updates that materially affect the support
107
+ timeline of release lines will be broadly announced to the community via
108
+ established communication channels (such as the `cdk.dev` Slack), and will
109
+ remain open for the community to comment on for a minimum of 15 days.
110
+
111
+ Community members are welcome to propose changes to the support and maintenace
112
+ policy through the same process.
113
+
114
+ ### Derogation
115
+
116
+ Under _exceptional_ circumstances, the project maintainers may elect to derogate
117
+ from this Support & Maintenance Policy. In cases where the decisision to
118
+ derogate extends supplemental maintenance & support coverage for a release line,
119
+ the increased coverage will be documented in the
120
+ [repository's `README.md` document][readme].
121
+
122
+ However, in situations where the derogation results in reduced support for one
123
+ or more release lines, the decision to derogate is considered a "break glass"
124
+ event and maintainers will document the motivation for the derogation, as well
125
+ as provide the post-mortem analysis to determine and address the reason
126
+ why this decision has to be taken, including an action plan put in place to
127
+ ensure the same situation does not occur again in the future.
128
+
129
+ [readme]: ./README.md
package/lib/main.js CHANGED
@@ -16,8 +16,10 @@ const languages_1 = require("./languages");
16
16
  const python_1 = require("./languages/python");
17
17
  const visualize_1 = require("./languages/visualize");
18
18
  const logging = require("./logging");
19
+ const support_1 = require("./support");
19
20
  const util_1 = require("./util");
20
- function main() {
21
+ async function main() {
22
+ await (0, support_1.emitSupportPolicyInformation)();
21
23
  const argv = yargs
22
24
  .usage('$0 <cmd> [args]')
23
25
  .option('verbose', {
@@ -460,5 +462,8 @@ function handleDiagnostics(diagnostics, fail, snippetCount = 1) {
460
462
  function roundPercentage(num) {
461
463
  return Math.round(10000 * num) / 100;
462
464
  }
463
- main();
465
+ main().catch((cause) => {
466
+ console.error(cause);
467
+ process.exitCode = -1;
468
+ });
464
469
  //# sourceMappingURL=main.js.map
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,iCAAsD;AAEtD,SAAS,IAAI;IACX,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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AA,uBAAgB,EAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,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","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 { File, fmap, printDiagnostics } from './util';\n\nfunction main() {\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 .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 };\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);\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);\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);\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();\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,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,E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C,CAAC,CAAC,CAAC,QAAQ,SAAS,+BAA+B,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7E,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;KACR;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1B,IAAA,uBAAgB,EAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,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 .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 };\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);\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);\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);\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"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Checks whether the current release line is close to End-of-Support (within
3
+ * 30 days), or already in End-of-Support, and if that is the case, emits a
4
+ * warning to call the user to action.
5
+ *
6
+ * It is possible for users to opt out of these notifications by setting the
7
+ * `JSII_SILENCE_SUPPORT_WARNING` environment variable to any truthy value (that
8
+ * is, any non-empty value).
9
+ */
10
+ export declare function emitSupportPolicyInformation(): Promise<void>;
11
+ //# sourceMappingURL=support.d.ts.map
package/lib/support.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emitSupportPolicyInformation = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_https_1 = require("node:https");
6
+ const node_path_1 = require("node:path");
7
+ const chalk = require("chalk");
8
+ const typescript_1 = require("typescript");
9
+ const SILENCE_ENV_VAR = 'JSII_SILENCE_SUPPORT_WARNING';
10
+ const THIRTY_DAYS_IN_MILLIS = 2592000000;
11
+ /**
12
+ * Checks whether the current release line is close to End-of-Support (within
13
+ * 30 days), or already in End-of-Support, and if that is the case, emits a
14
+ * warning to call the user to action.
15
+ *
16
+ * It is possible for users to opt out of these notifications by setting the
17
+ * `JSII_SILENCE_SUPPORT_WARNING` environment variable to any truthy value (that
18
+ * is, any non-empty value).
19
+ */
20
+ async function emitSupportPolicyInformation() {
21
+ if (process.env[SILENCE_ENV_VAR]) {
22
+ return;
23
+ }
24
+ const data = await getReleasesDocument();
25
+ if (data.current == typescript_1.versionMajorMinor) {
26
+ // Current release is not close to deprecation
27
+ return;
28
+ }
29
+ const endOfSupportDate = data.endOfSupport?.includes(typescript_1.versionMajorMinor)
30
+ ? new Date(0)
31
+ : data.maintenance[typescript_1.versionMajorMinor];
32
+ if (endOfSupportDate == null) {
33
+ // Don't know the status, so don't say anything...
34
+ return;
35
+ }
36
+ const now = new Date();
37
+ const inThirtyDays = new Date(now.getTime() + THIRTY_DAYS_IN_MILLIS);
38
+ const alternatives = Object.entries(data.maintenance)
39
+ .flatMap(([release, dateStr]) => {
40
+ const date = new Date(dateStr);
41
+ if (date <= inThirtyDays) {
42
+ return [];
43
+ }
44
+ return [{ release, date }];
45
+ })
46
+ .reduce((acc, { release, date }) => {
47
+ if (acc.length === 0) {
48
+ acc.push('', 'Other actively supported release lines include:');
49
+ }
50
+ acc.push(`- ${release} (planned End-of-Support date: ${date.toISOString()})`);
51
+ return acc;
52
+ }, new Array());
53
+ if (endOfSupportDate <= now) {
54
+ // End-of-Support already!
55
+ veryVisibleMessage(chalk.bgRed.white.bold, `The ${typescript_1.versionMajorMinor} release line of jsii has reached End-of-Support.`, `We strongly recommend you upgrade to the current release line (${data.current}) at your earliest convenience.`, ...alternatives);
56
+ }
57
+ else if (endOfSupportDate <= inThirtyDays) {
58
+ // End-of-Support within 30 days!
59
+ veryVisibleMessage(chalk.bgYellow.black, `The ${typescript_1.versionMajorMinor} release line of jsii will reach End-of-Support soon, on ${endOfSupportDate.toISOString()}.`, `We strongly recommend you upgrade to the current release line (${data.current}) at your earliest convenience.`, ...alternatives);
60
+ }
61
+ }
62
+ exports.emitSupportPolicyInformation = emitSupportPolicyInformation;
63
+ /**
64
+ * Downloads the latest `releases.json` document from 'https://raw.githubusercontent.com/aws/jsii-rosetta/main/releases.json'
65
+ * if possible, or falls back to the built-in version of that file if that fails in any way.
66
+ */
67
+ async function getReleasesDocument() {
68
+ const downloaded = await new Promise((ok, ko) => {
69
+ const request = (0, node_https_1.get)(new URL('https://raw.githubusercontent.com/aws/jsii-rosetta/main/releases.json'), (response) => {
70
+ if (response.statusCode === 404) {
71
+ return ok(undefined);
72
+ }
73
+ if (response.statusCode !== 200) {
74
+ return ko(`received error response: HTTP ${response.statusCode} - ${response.statusMessage}`);
75
+ }
76
+ response.once('error', ko);
77
+ const chunks = new Array();
78
+ response.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
79
+ response.once('end', () => ok(Buffer.concat(chunks).toString('utf-8')));
80
+ });
81
+ request.once('abort', () => ko('request aborted'));
82
+ request.once('timeout', () => ko('request timed out'));
83
+ request.once('error', ko);
84
+ request.end();
85
+ }).catch((cause) => {
86
+ if (process.env.JSII_DEBUG) {
87
+ console.error(`Could not download releases.json from GitHub: ${cause}`);
88
+ }
89
+ undefined;
90
+ });
91
+ return JSON.parse(downloaded ?? (0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'releases.json'), 'utf-8'), (key, value) => {
92
+ if (key !== 'maintenance') {
93
+ return value;
94
+ }
95
+ return Object.fromEntries(Object.entries(value).map(([release, date]) => [release, new Date(date)]));
96
+ });
97
+ }
98
+ function veryVisibleMessage(formatter, ...lines) {
99
+ if (lines.length === 0) {
100
+ throw new Error(`At least one line of message must be provided!`);
101
+ }
102
+ const len = Math.max(...lines.map((line) => line.length));
103
+ const border = formatter('!'.repeat(len + 8));
104
+ const spacer = formatter(`!! ${' '.repeat(len)} !!`);
105
+ console.error(border);
106
+ console.error(spacer);
107
+ for (const line of lines) {
108
+ console.error(formatter(`!! ${line.padEnd(len, ' ')} !!`));
109
+ }
110
+ console.error(spacer);
111
+ console.error(border);
112
+ }
113
+ //# sourceMappingURL=support.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support.js","sourceRoot":"","sources":["../src/support.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,2CAAiC;AACjC,yCAAiC;AACjC,+BAA+B;AAC/B,2CAA+C;AAE/C,MAAM,eAAe,GAAG,8BAA8B,CAAC;AACvD,MAAM,qBAAqB,GAAG,UAAa,CAAC;AAuB5C;;;;;;;;GAQG;AACI,KAAK,UAAU,4BAA4B;IAChD,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;QAChC,OAAO;KACR;IAED,MAAM,IAAI,GAAG,MAAM,mBAAmB,EAAE,CAAC;IAEzC,IAAI,IAAI,CAAC,OAAO,IAAI,8BAAiB,EAAE;QACrC,8CAA8C;QAC9C,OAAO;KACR;IAED,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,8BAAiB,CAAC;QACrE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,8BAAiB,CAAC,CAAC;IACxC,IAAI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AAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEvD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;KAC9D;IACD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import { readFileSync } from 'node:fs';\nimport { get } from 'node:https';\nimport { join } from 'node:path';\nimport * as chalk from 'chalk';\nimport { versionMajorMinor } from 'typescript';\n\nconst SILENCE_ENV_VAR = 'JSII_SILENCE_SUPPORT_WARNING';\nconst THIRTY_DAYS_IN_MILLIS = 2_592_000_000;\n\n/** @internal */\nexport interface ReleasesDocument {\n /**\n * The release line that occupies the 'Current' stage.\n */\n readonly current: ReleaseLine;\n /**\n * Release lines currently in 'Maintenance' with the date at which they are\n * planned to go into the 'End-of-Support' stage. This date should always be\n * set a minimum of 6 months in the future when a release line is added to the\n * list.\n */\n readonly maintenance: { readonly [release: ReleaseLine]: Date };\n /**\n * Release lines that are currently out-of-support. This is semantically\n * equivalent to being in the `maintenance` list with a past date, but offers\n * slightly faster look-up.\n */\n readonly endOfSupport?: readonly ReleaseLine[];\n}\n\n/**\n * Checks whether the current release line is close to End-of-Support (within\n * 30 days), or already in End-of-Support, and if that is the case, emits a\n * warning to call the user to action.\n *\n * It is possible for users to opt out of these notifications by setting the\n * `JSII_SILENCE_SUPPORT_WARNING` environment variable to any truthy value (that\n * is, any non-empty value).\n */\nexport async function emitSupportPolicyInformation() {\n if (process.env[SILENCE_ENV_VAR]) {\n return;\n }\n\n const data = await getReleasesDocument();\n\n if (data.current == versionMajorMinor) {\n // Current release is not close to deprecation\n return;\n }\n\n const endOfSupportDate = data.endOfSupport?.includes(versionMajorMinor)\n ? new Date(0)\n : data.maintenance[versionMajorMinor];\n if (endOfSupportDate == null) {\n // Don't know the status, so don't say anything...\n return;\n }\n\n const now = new Date();\n const inThirtyDays = new Date(now.getTime() + THIRTY_DAYS_IN_MILLIS);\n const alternatives = Object.entries(data.maintenance)\n .flatMap(([release, dateStr]) => {\n const date = new Date(dateStr);\n if (date <= inThirtyDays) {\n return [];\n }\n return [{ release, date }];\n })\n .reduce((acc, { release, date }) => {\n if (acc.length === 0) {\n acc.push('', 'Other actively supported release lines include:');\n }\n acc.push(`- ${release} (planned End-of-Support date: ${date.toISOString()})`);\n return acc;\n }, new Array<string>());\n if (endOfSupportDate <= now) {\n // End-of-Support already!\n veryVisibleMessage(\n chalk.bgRed.white.bold,\n `The ${versionMajorMinor} release line of jsii has reached End-of-Support.`,\n `We strongly recommend you upgrade to the current release line (${data.current}) at your earliest convenience.`,\n ...alternatives,\n );\n } else if (endOfSupportDate <= inThirtyDays) {\n // End-of-Support within 30 days!\n veryVisibleMessage(\n chalk.bgYellow.black,\n `The ${versionMajorMinor} release line of jsii will reach End-of-Support soon, on ${endOfSupportDate.toISOString()}.`,\n `We strongly recommend you upgrade to the current release line (${data.current}) at your earliest convenience.`,\n ...alternatives,\n );\n }\n}\n\n/**\n * Downloads the latest `releases.json` document from 'https://raw.githubusercontent.com/aws/jsii-rosetta/main/releases.json'\n * if possible, or falls back to the built-in version of that file if that fails in any way.\n */\nasync function getReleasesDocument(): Promise<ReleasesDocument> {\n const downloaded = await new Promise<string | undefined>((ok, ko) => {\n const request = get(\n new URL('https://raw.githubusercontent.com/aws/jsii-rosetta/main/releases.json'),\n (response) => {\n if (response.statusCode === 404) {\n return ok(undefined);\n }\n if (response.statusCode !== 200) {\n return ko(`received error response: HTTP ${response.statusCode} - ${response.statusMessage}`);\n }\n response.once('error', ko);\n const chunks = new Array<Buffer>();\n response.on('data', (chunk) => chunks.push(Buffer.from(chunk)));\n response.once('end', () => ok(Buffer.concat(chunks).toString('utf-8')));\n },\n );\n request.once('abort', () => ko('request aborted'));\n request.once('timeout', () => ko('request timed out'));\n request.once('error', ko);\n request.end();\n }).catch((cause) => {\n if (process.env.JSII_DEBUG) {\n console.error(`Could not download releases.json from GitHub: ${cause}`);\n }\n undefined;\n });\n\n return JSON.parse(downloaded ?? readFileSync(join(__dirname, '..', 'releases.json'), 'utf-8'), (key, value) => {\n if (key !== 'maintenance') {\n return value;\n }\n return Object.fromEntries(Object.entries(value).map(([release, date]) => [release, new Date(date as string)]));\n }) as ReleasesDocument;\n}\n\nfunction veryVisibleMessage(formatter: chalk.Chalk, ...lines: readonly string[]): void {\n if (lines.length === 0) {\n throw new Error(`At least one line of message must be provided!`);\n }\n\n const len = Math.max(...lines.map((line) => line.length));\n const border = formatter('!'.repeat(len + 8));\n const spacer = formatter(`!! ${' '.repeat(len)} !!`);\n\n console.error(border);\n console.error(spacer);\n for (const line of lines) {\n console.error(formatter(`!! ${line.padEnd(len, ' ')} !!`));\n }\n console.error(spacer);\n console.error(border);\n}\n\ntype ReleaseLine = `${number}.${number}`;\n"]}
package/package.json CHANGED
@@ -35,33 +35,34 @@
35
35
  "@actions/core": "^1.10.0",
36
36
  "@actions/github": "^5.1.1",
37
37
  "@types/commonmark": "^0.27.5",
38
- "@types/jest": "^29.4.0",
38
+ "@types/jest": "^29.4.1",
39
39
  "@types/mock-fs": "^4.13.1",
40
40
  "@types/node": "^14",
41
41
  "@types/tar": "^6.1.4",
42
- "@types/workerpool": "^6.1.1",
42
+ "@types/workerpool": "^6.4.0",
43
43
  "@typescript-eslint/eslint-plugin": "^5",
44
44
  "@typescript-eslint/parser": "^5",
45
45
  "eslint": "^8",
46
- "eslint-config-prettier": "^8.6.0",
46
+ "eslint-config-prettier": "^8.7.0",
47
47
  "eslint-import-resolver-node": "^0.3.7",
48
48
  "eslint-import-resolver-typescript": "^3.5.3",
49
49
  "eslint-plugin-import": "^2.27.5",
50
50
  "eslint-plugin-prettier": "^4.2.1",
51
51
  "eslint-plugin-unicorn": "^45.0.2",
52
- "jest": "^29.4.3",
52
+ "jest": "^29.5.0",
53
53
  "mock-fs": "^5.2.0",
54
54
  "npm-check-updates": "^16",
55
55
  "prettier": "^2.8.4",
56
- "projen": "^0.67.68",
56
+ "projen": "^0.68.1",
57
57
  "tar": "^6.1.13",
58
58
  "ts-jest": "^29.0.5",
59
59
  "ts-node": "^10.9.1"
60
60
  },
61
61
  "dependencies": {
62
- "@jsii/check-node": "1.76.0",
63
- "@jsii/spec": "^1.76.0",
62
+ "@jsii/check-node": "1.77.0",
63
+ "@jsii/spec": "^1.77.0",
64
64
  "@xmldom/xmldom": "^0.8.6",
65
+ "chalk": "^4",
65
66
  "commonmark": "^0.30.0",
66
67
  "fast-glob": "^3.2.12",
67
68
  "jsii": "v4.9-next",
@@ -77,7 +78,7 @@
77
78
  "main": "lib/index.js",
78
79
  "license": "Apache-2.0",
79
80
  "homepage": "https://aws.github.io/jsii",
80
- "version": "4.9.0-dev.2",
81
+ "version": "4.9.0-dev.3",
81
82
  "types": "lib/index.d.ts",
82
83
  "exports": {
83
84
  ".": "./lib/index.js",
package/releases.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "current": "4.9",
3
+ "maintenance": {},
4
+ "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"."
5
+ }
package/temp.tabl.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "version": "2",
3
- "toolVersion": "4.9.0-dev.2",
4
- "snippets": {
5
- "d54054dded92a8c59670816ed22b893ca888d5e2cab871b833af1723039662c9": {
6
- "translations": {
7
- "python": {
8
- "source": "print(\"hello world\")",
9
- "version": "2"
10
- },
11
- "csharp": {
12
- "source": "Console.WriteLine(\"hello world\");",
13
- "version": "1"
14
- },
15
- "java": {
16
- "source": "System.out.println(\"hello world\");",
17
- "version": "1"
18
- },
19
- "go": {
20
- "source": "fmt.Println(\"hello world\")",
21
- "version": "1"
22
- },
23
- "$": {
24
- "source": "console.log(\"hello world\");",
25
- "version": "0"
26
- }
27
- },
28
- "location": {
29
- "api": {
30
- "api": "file",
31
- "fileName": "test.ts"
32
- }
33
- },
34
- "didCompile": false,
35
- "fqnsReferenced": [],
36
- "fullSource": "console.log(\"hello world\");",
37
- "syntaxKindCounter": {
38
- "10": 1,
39
- "79": 2,
40
- "208": 1,
41
- "210": 1,
42
- "241": 1,
43
- "308": 1
44
- },
45
- "fqnsFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
46
- }
47
- }
48
- }