jsii 5.4.34-dev.1 → 5.4.34-dev.2

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findDependencyDirectory = exports.findPackageJsonUp = exports.findUp = void 0;
4
4
  const fs = require("node:fs");
5
5
  const path = require("node:path");
6
+ const utils_1 = require("../utils");
6
7
  /**
7
8
  * Find a directory up the tree from a starting directory matching a condition
8
9
  *
@@ -52,7 +53,7 @@ function findDependencyDirectory(dependencyName, searchStart) {
52
53
  // the dependency name (so we don't accidentally find stray 'package.jsons').
53
54
  const depPkgJsonPath = findPackageJsonUp(dependencyName, path.dirname(entryPoint));
54
55
  if (!depPkgJsonPath) {
55
- throw new Error(`Could not find dependency '${dependencyName}' from '${searchStart}'`);
56
+ throw new utils_1.JsiiError(`Could not find dependency '${dependencyName}' from '${searchStart}'`);
56
57
  }
57
58
  return depPkgJsonPath;
58
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"find-utils.js","sourceRoot":"","sources":["../../src/common/find-utils.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAElC;;;;;;;GAOG;AACH,SAAgB,MAAM,CAAC,SAAiB,EAAE,IAA8B;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAE/B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC;AAbD,wBAaC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,WAAmB,EAAE,SAAiB;IACtE,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;IACpG,CAAC,CAAC,CAAC;AACL,CAAC;AALD,8CAKC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,cAAsB,EAAE,WAAmB;IACjF,oFAAoF;IACpF,gDAAgD;IAChD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE;QACjD,KAAK,EAAE,CAAC,WAAW,CAAC;KACrB,CAAC,CAAC;IAEH,8EAA8E;IAC9E,6EAA6E;IAC7E,MAAM,cAAc,GAAG,iBAAiB,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,cAAc,WAAW,WAAW,GAAG,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAhBD,0DAgBC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\n/**\n * Find a directory up the tree from a starting directory matching a condition\n *\n * Will return `undefined` if no directory matches\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findUp(directory: string, pred: (dir: string) => boolean): string | undefined {\n const result = pred(directory);\n\n if (result) {\n return directory;\n }\n\n const parent = path.dirname(directory);\n if (parent === directory) {\n return undefined;\n }\n\n return findUp(parent, pred);\n}\n\n/**\n * Find the package.json for a given package upwards from the given directory\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findPackageJsonUp(packageName: string, directory: string) {\n return findUp(directory, (dir) => {\n const pjFile = path.join(dir, 'package.json');\n return fs.existsSync(pjFile) && JSON.parse(fs.readFileSync(pjFile, 'utf-8')).name === packageName;\n });\n}\n\n/**\n * Find the directory that contains a given dependency, identified by its 'package.json', from a starting search directory\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findDependencyDirectory(dependencyName: string, searchStart: string) {\n // Explicitly do not use 'require(\"dep/package.json\")' because that will fail if the\n // package does not export that particular file.\n const entryPoint = require.resolve(dependencyName, {\n paths: [searchStart],\n });\n\n // Search up from the given directory, looking for a package.json that matches\n // the dependency name (so we don't accidentally find stray 'package.jsons').\n const depPkgJsonPath = findPackageJsonUp(dependencyName, path.dirname(entryPoint));\n\n if (!depPkgJsonPath) {\n throw new Error(`Could not find dependency '${dependencyName}' from '${searchStart}'`);\n }\n\n return depPkgJsonPath;\n}\n"]}
1
+ {"version":3,"file":"find-utils.js","sourceRoot":"","sources":["../../src/common/find-utils.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAClC,oCAAqC;AAErC;;;;;;;GAOG;AACH,SAAgB,MAAM,CAAC,SAAiB,EAAE,IAA8B;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAE/B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC;AAbD,wBAaC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,WAAmB,EAAE,SAAiB;IACtE,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;IACpG,CAAC,CAAC,CAAC;AACL,CAAC;AALD,8CAKC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,cAAsB,EAAE,WAAmB;IACjF,oFAAoF;IACpF,gDAAgD;IAChD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE;QACjD,KAAK,EAAE,CAAC,WAAW,CAAC;KACrB,CAAC,CAAC;IAEH,8EAA8E;IAC9E,6EAA6E;IAC7E,MAAM,cAAc,GAAG,iBAAiB,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,iBAAS,CAAC,8BAA8B,cAAc,WAAW,WAAW,GAAG,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAhBD,0DAgBC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { JsiiError } from '../utils';\n\n/**\n * Find a directory up the tree from a starting directory matching a condition\n *\n * Will return `undefined` if no directory matches\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findUp(directory: string, pred: (dir: string) => boolean): string | undefined {\n const result = pred(directory);\n\n if (result) {\n return directory;\n }\n\n const parent = path.dirname(directory);\n if (parent === directory) {\n return undefined;\n }\n\n return findUp(parent, pred);\n}\n\n/**\n * Find the package.json for a given package upwards from the given directory\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findPackageJsonUp(packageName: string, directory: string) {\n return findUp(directory, (dir) => {\n const pjFile = path.join(dir, 'package.json');\n return fs.existsSync(pjFile) && JSON.parse(fs.readFileSync(pjFile, 'utf-8')).name === packageName;\n });\n}\n\n/**\n * Find the directory that contains a given dependency, identified by its 'package.json', from a starting search directory\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findDependencyDirectory(dependencyName: string, searchStart: string) {\n // Explicitly do not use 'require(\"dep/package.json\")' because that will fail if the\n // package does not export that particular file.\n const entryPoint = require.resolve(dependencyName, {\n paths: [searchStart],\n });\n\n // Search up from the given directory, looking for a package.json that matches\n // the dependency name (so we don't accidentally find stray 'package.jsons').\n const depPkgJsonPath = findPackageJsonUp(dependencyName, path.dirname(entryPoint));\n\n if (!depPkgJsonPath) {\n throw new JsiiError(`Could not find dependency '${dependencyName}' from '${searchStart}'`);\n }\n\n return depPkgJsonPath;\n}\n"]}
package/lib/compiler.js CHANGED
@@ -25,7 +25,7 @@ class Compiler {
25
25
  this.options = options;
26
26
  this.rootFiles = [];
27
27
  if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {
28
- throw new Error('Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.');
28
+ throw new utils.JsiiError('Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.');
29
29
  }
30
30
  this.projectRoot = this.options.projectInfo.projectRoot;
31
31
  const configFileName = options.typeScriptConfig ?? options.generateTypeScriptConfig ?? 'tsconfig.json';
@@ -118,7 +118,7 @@ class Compiler {
118
118
  if (error instanceof validator_1.ValidationError) {
119
119
  utils.logDiagnostic(jsii_diagnostic_1.JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION.create(undefined, configName, rules, error.violations), this.projectRoot);
120
120
  }
121
- throw new Error(`Failed validation of tsconfig "compilerOptions" in "${configName}" against rule set "${rules}"!`);
121
+ throw new utils.JsiiError(`Failed validation of tsconfig "compilerOptions" in "${configName}" against rule set "${rules}"!`);
122
122
  }
123
123
  }
124
124
  return config;
@@ -275,7 +275,7 @@ class Compiler {
275
275
  const { config, error } = ts.readConfigFile(this.configPath, ts.sys.readFile);
276
276
  if (error) {
277
277
  utils.logDiagnostic(error, projectRoot);
278
- throw new Error(`Failed to load tsconfig at ${this.configPath}`);
278
+ throw new utils.JsiiError(`Failed to load tsconfig at ${this.configPath}`);
279
279
  }
280
280
  const extended = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot);
281
281
  // the tsconfig parser adds this in, but it is not an expected compilerOption
@@ -298,7 +298,7 @@ class Compiler {
298
298
  if (fs.existsSync(this.configPath)) {
299
299
  const currentConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));
300
300
  if (!(commentKey in currentConfig)) {
301
- throw new Error(`A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`);
301
+ throw new utils.JsiiError(`A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`);
302
302
  }
303
303
  }
304
304
  const outputConfig = {
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAClC,+BAA+B;AAC/B,iCAAiC;AACjC,iCAAiC;AAEjC,2CAAwC;AACxC,oDAA8D;AAC9D,mDAA4E;AAE5E,uCAAgD;AAChD,uDAAmD;AAEnD,4EAA2E;AAC3E,yCAAiF;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U,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK;YACvD,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;YAC/G,CAAC;YACD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjC,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,EAAE;QAC3D,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;KACtD,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as chalk from 'chalk';\nimport * as log4js from 'log4js';\nimport * as ts from 'typescript';\n\nimport { Assembler } from './assembler';\nimport { findDependencyDirectory } from './common/find-utils';\nimport { emitDownleveledDeclarations, TYPES_COMPAT } from './downlevel-dts';\nimport { Emitter } from './emitter';\nimport { normalizeConfigPath } from './helpers';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport { ProjectInfo } from './project-info';\nimport { WARNINGSCODE_FILE_NAME } from './transforms/deprecation-warnings';\nimport { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport { BASE_COMPILER_OPTIONS, convertForJson } from './tsconfig/compiler-options';\nimport { TypeScriptConfigValidator } from './tsconfig/tsconfig-validator';\nimport { ValidationError } from './tsconfig/validator';\nimport * as utils from './utils';\n\nconst LOG = log4js.getLogger('jsii/compiler');\nexport const DIAGNOSTICS = 'diagnostics';\nexport const JSII_DIAGNOSTICS_CODE = 9999;\n\nexport interface CompilerOptions {\n /** The information about the project to be built */\n projectInfo: ProjectInfo;\n /** Whether the compiler should watch for changes or just compile once */\n watch?: boolean;\n /** Whether to detect and generate TypeScript project references */\n projectReferences?: boolean;\n /** Whether to fail when a warning is emitted */\n failOnWarnings?: boolean;\n /** Whether to strip deprecated members from emitted artifacts */\n stripDeprecated?: boolean;\n /** The path to an allowlist of FQNs to strip if stripDeprecated is set */\n stripDeprecatedAllowListFile?: string;\n /** Whether to add warnings for deprecated elements */\n addDeprecationWarnings?: boolean;\n /**\n * The name of the tsconfig file to generate.\n * Cannot be used at the same time as `typeScriptConfig`.\n * @default \"tsconfig.json\"\n */\n generateTypeScriptConfig?: string;\n /**\n * The name of the tsconfig file to use.\n * Cannot be used at the same time as `generateTypeScriptConfig`.\n * @default - generate the tsconfig file\n */\n typeScriptConfig?: string;\n /**\n * The ruleset to validate the provided tsconfig file against.\n * Can only be used when `typeScriptConfig` is provided.\n * @default TypeScriptConfigValidationRuleSet.STRICT - if `typeScriptConfig` is provided\n */\n validateTypeScriptConfig?: TypeScriptConfigValidationRuleSet;\n /**\n * Whether to compress the assembly\n * @default false\n */\n compressAssembly?: boolean;\n}\n\nexport class Compiler implements Emitter {\n private readonly system: ts.System;\n private readonly compilerHost: ts.CompilerHost;\n private readonly userProvidedTypeScriptConfig: boolean;\n private readonly tsconfig: TypeScriptConfig;\n private rootFiles: string[] = [];\n private readonly configPath: string;\n private readonly projectRoot: string;\n\n public constructor(private readonly options: CompilerOptions) {\n if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {\n throw new Error(\n 'Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.',\n );\n }\n\n this.projectRoot = this.options.projectInfo.projectRoot;\n const configFileName = options.typeScriptConfig ?? options.generateTypeScriptConfig ?? 'tsconfig.json';\n this.configPath = path.join(this.projectRoot, configFileName);\n this.userProvidedTypeScriptConfig = Boolean(options.typeScriptConfig);\n\n this.system = {\n ...ts.sys,\n getCurrentDirectory: () => this.projectRoot,\n createDirectory: (pth) => ts.sys.createDirectory(path.resolve(this.projectRoot, pth)),\n deleteFile: ts.sys.deleteFile && ((pth) => ts.sys.deleteFile!(path.join(this.projectRoot, pth))),\n fileExists: (pth) => ts.sys.fileExists(path.resolve(this.projectRoot, pth)),\n getFileSize: ts.sys.getFileSize && ((pth) => ts.sys.getFileSize!(path.resolve(this.projectRoot, pth))),\n readFile: (pth, encoding) => ts.sys.readFile(path.resolve(this.projectRoot, pth), encoding),\n watchFile:\n ts.sys.watchFile &&\n ((pth, callback, pollingInterval, watchOptions) =>\n ts.sys.watchFile!(path.resolve(this.projectRoot, pth), callback, pollingInterval, watchOptions)),\n writeFile: (pth, data, writeByteOrderMark) =>\n ts.sys.writeFile(path.resolve(this.projectRoot, pth), data, writeByteOrderMark),\n };\n\n this.tsconfig = this.configureTypeScript();\n this.compilerHost = ts.createIncrementalCompilerHost(this.tsconfig.compilerOptions, this.system);\n }\n\n /**\n * Compiles the configured program.\n *\n * @param files can be specified to override the standard source code location logic. Useful for example when testing \"negatives\".\n */\n public emit(...files: string[]): ts.EmitResult {\n this.prepareForBuild(...files);\n return this.buildOnce();\n }\n\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In non-blocking mode, this\n * returns the TypeScript watch handle for the application to use.\n *\n * @internal\n */\n public async watch(opts: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram>>;\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results\n * in a never-resolving promise.\n */\n public async watch(): Promise<never>;\n public async watch(opts?: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram> | never> {\n this.prepareForBuild();\n\n const host = ts.createWatchCompilerHost(\n this.configPath,\n {\n ...this.tsconfig.compilerOptions,\n noEmitOnError: false,\n },\n this.system,\n ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n opts?.reportDiagnostics,\n opts?.reportWatchStatus,\n this.tsconfig.watchOptions,\n );\n if (!host.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n const orig = host.afterProgramCreate;\n // This is a callback cascade, so it's \"okay\" to return an unhandled promise there. This may\n // cause an unhandled promise rejection warning, but that's not a big deal.\n //\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n host.afterProgramCreate = (builderProgram) => {\n const emitResult = this.consumeProgram(builderProgram.getProgram(), host.getDefaultLibLocation!());\n\n for (const diag of emitResult.diagnostics.filter((d) => d.code === JSII_DIAGNOSTICS_CODE)) {\n utils.logDiagnostic(diag, this.projectRoot);\n }\n\n if (orig) {\n orig.call(host, builderProgram);\n }\n if (opts?.compilationComplete) {\n opts.compilationComplete(emitResult);\n }\n };\n const watch = ts.createWatchProgram(host);\n\n if (opts?.nonBlocking) {\n // In non-blocking mode, returns the handle to the TypeScript watch interface.\n return watch;\n }\n // In blocking mode, returns a never-resolving promise.\n return new Promise<never>(() => null);\n }\n\n /**\n * Prepares the project for build, by creating the necessary configuration\n * file(s), and assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private configureTypeScript(): TypeScriptConfig {\n if (this.userProvidedTypeScriptConfig) {\n const config = this.readTypeScriptConfig();\n\n // emit a warning if validation is disabled\n const rules = this.options.validateTypeScriptConfig ?? TypeScriptConfigValidationRuleSet.NONE;\n if (rules === TypeScriptConfigValidationRuleSet.NONE) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4009_DISABLED_TSCONFIG_VALIDATION.create(undefined, this.configPath),\n this.projectRoot,\n );\n }\n\n // validate the user provided config\n if (rules !== TypeScriptConfigValidationRuleSet.NONE) {\n const configName = path.relative(this.projectRoot, this.configPath);\n try {\n const validator = new TypeScriptConfigValidator(rules);\n validator.validate({\n ...config,\n // convert the internal format to the user format which is what the validator operates on\n compilerOptions: convertForJson(config.compilerOptions),\n });\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION.create(\n undefined,\n configName,\n rules,\n error.violations,\n ),\n this.projectRoot,\n );\n }\n\n throw new Error(\n `Failed validation of tsconfig \"compilerOptions\" in \"${configName}\" against rule set \"${rules}\"!`,\n );\n }\n }\n\n return config;\n }\n\n // generated config if none is provided by the user\n return this.buildTypeScriptConfig();\n }\n\n /**\n * Final preparations of the project for build.\n *\n * These are preparations that either\n * - must happen immediately before the build, or\n * - can be different for every build like assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private prepareForBuild(...files: string[]) {\n if (!this.userProvidedTypeScriptConfig) {\n this.writeTypeScriptConfig();\n }\n\n this.rootFiles = this.determineSources(files);\n }\n\n /**\n * Do a single build\n */\n private buildOnce(): ts.EmitResult {\n if (!this.compilerHost.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n\n const tsconf = this.tsconfig!;\n\n const prog = ts.createIncrementalProgram({\n rootNames: this.rootFiles.concat(_pathOfLibraries(this.compilerHost)),\n options: tsconf.compilerOptions,\n // Make the references absolute for the compiler\n projectReferences: tsconf.references?.map((ref) => ({\n path: path.resolve(path.dirname(this.configPath), ref.path),\n })),\n host: this.compilerHost,\n });\n\n return this.consumeProgram(prog.getProgram(), this.compilerHost.getDefaultLibLocation());\n }\n\n private consumeProgram(program: ts.Program, stdlib: string): ts.EmitResult {\n const diagnostics = [...ts.getPreEmitDiagnostics(program)];\n let hasErrors = false;\n\n if (!hasErrors && this.diagsHaveAbortableErrors(diagnostics)) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Do the \"Assembler\" part first because we need some of the analysis done in there\n // to post-process the AST\n const assembler = new Assembler(this.options.projectInfo, this.system, program, stdlib, {\n stripDeprecated: this.options.stripDeprecated,\n stripDeprecatedAllowListFile: this.options.stripDeprecatedAllowListFile,\n addDeprecationWarnings: this.options.addDeprecationWarnings,\n compressAssembly: this.options.compressAssembly,\n });\n\n try {\n const assmEmit = assembler.emit();\n if (!hasErrors && (assmEmit.emitSkipped || this.diagsHaveAbortableErrors(assmEmit.diagnostics))) {\n hasErrors = true;\n LOG.error('Type model errors prevented the JSII assembly from being created');\n }\n\n diagnostics.push(...assmEmit.diagnostics);\n } catch (e: any) {\n diagnostics.push(JsiiDiagnostic.JSII_9997_UNKNOWN_ERROR.createDetached(e));\n hasErrors = true;\n }\n\n // Do the emit, but add in transformers which are going to replace real\n // comments with synthetic ones.\n const emit = program.emit(\n undefined, // targetSourceFile\n undefined, // writeFile\n undefined, // cancellationToken\n undefined, // emitOnlyDtsFiles\n assembler.customTransformers,\n );\n diagnostics.push(...emit.diagnostics);\n\n if (!hasErrors && (emit.emitSkipped || this.diagsHaveAbortableErrors(emit.diagnostics))) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n if (!hasErrors) {\n emitDownleveledDeclarations(\n this.projectRoot,\n this.options.projectInfo.packageJson,\n // outDir might be absolute. Need to normalize it.\n normalizeConfigPath(this.projectRoot, this.tsconfig.compilerOptions.outDir),\n );\n }\n\n // Some extra validation on the config.\n // Make sure that { \"./.warnings.jsii.js\": \"./.warnings.jsii.js\" } is in the set of\n // exports, if they are specified.\n if (this.options.addDeprecationWarnings && this.options.projectInfo.exports !== undefined) {\n const expected = `./${WARNINGSCODE_FILE_NAME}`;\n const warningsExport = Object.entries(this.options.projectInfo.exports).filter(\n ([k, v]) => k === expected && v === expected,\n );\n\n if (warningsExport.length === 0) {\n hasErrors = true;\n diagnostics.push(JsiiDiagnostic.JSII_0007_MISSING_WARNINGS_EXPORT.createDetached());\n }\n }\n\n return {\n emitSkipped: hasErrors,\n diagnostics: ts.sortAndDeduplicateDiagnostics(diagnostics),\n emittedFiles: emit.emittedFiles,\n };\n }\n\n /**\n * Build the TypeScript config object from jsii config\n *\n * This is the object that will be written to disk\n * unless an existing tsconfig was provided.\n */\n private buildTypeScriptConfig(): TypeScriptConfig {\n let references: string[] | undefined;\n\n const isComposite =\n this.options.projectReferences !== undefined\n ? this.options.projectReferences\n : this.options.projectInfo.projectReferences !== undefined\n ? this.options.projectInfo.projectReferences\n : false;\n if (isComposite) {\n references = this.findProjectReferences();\n }\n\n const pi = this.options.projectInfo;\n const configDir = path.dirname(this.configPath);\n const absoluteTypesCompat = path.resolve(configDir, pi.tsc?.outDir ?? '.', TYPES_COMPAT);\n const relativeTypesCompat = path.relative(configDir, absoluteTypesCompat);\n\n return {\n compilerOptions: {\n ...pi.tsc,\n ...BASE_COMPILER_OPTIONS,\n // Enable composite mode if project references are enabled\n composite: isComposite,\n // When incremental, configure a tsbuildinfo file\n tsBuildInfoFile: path.join(pi.tsc?.outDir ?? '.', 'tsconfig.tsbuildinfo'),\n },\n include: [pi.tsc?.rootDir != null ? path.join(pi.tsc.rootDir, '**', '*.ts') : path.join('**', '*.ts')],\n exclude: [\n 'node_modules',\n relativeTypesCompat,\n ...(pi.excludeTypescript ?? []),\n ...(pi.tsc?.outDir != null &&\n (pi.tsc?.rootDir == null || path.resolve(pi.tsc.outDir).startsWith(path.resolve(pi.tsc.rootDir) + path.sep))\n ? [path.join(pi.tsc.outDir, '**', '*.ts')]\n : []),\n ],\n // Change the references a little. We write 'originalpath' to the\n // file under the 'path' key, which is the same as what the\n // TypeScript compiler does. Make it relative so that the files are\n // movable. Not strictly required but looks better.\n references: references?.map((p) => ({ path: p })),\n };\n }\n\n /**\n * Load the TypeScript config object from a provided file\n */\n private readTypeScriptConfig(): TypeScriptConfig {\n const projectRoot = this.options.projectInfo.projectRoot;\n const { config, error } = ts.readConfigFile(this.configPath, ts.sys.readFile);\n if (error) {\n utils.logDiagnostic(error, projectRoot);\n throw new Error(`Failed to load tsconfig at ${this.configPath}`);\n }\n const extended = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot);\n // the tsconfig parser adds this in, but it is not an expected compilerOption\n delete extended.options.configFilePath;\n\n return {\n compilerOptions: extended.options,\n watchOptions: extended.watchOptions,\n include: extended.fileNames,\n };\n }\n\n /**\n * Creates a `tsconfig.json` file to improve the IDE experience.\n *\n * @return the fully qualified path to the `tsconfig.json` file\n */\n private writeTypeScriptConfig(): void {\n const commentKey = '_generated_by_jsii_';\n const commentValue = 'Generated by jsii - safe to delete, and ideally should be in .gitignore';\n\n (this.tsconfig as any)[commentKey] = commentValue;\n\n if (fs.existsSync(this.configPath)) {\n const currentConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));\n if (!(commentKey in currentConfig)) {\n throw new Error(\n `A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`,\n );\n }\n }\n\n const outputConfig = {\n ...this.tsconfig,\n compilerOptions: convertForJson(this.tsconfig?.compilerOptions),\n };\n\n LOG.debug(`Creating or updating ${chalk.blue(this.configPath)}`);\n fs.writeFileSync(this.configPath, JSON.stringify(outputConfig, null, 2), 'utf8');\n }\n\n /**\n * Find all dependencies that look like TypeScript projects.\n *\n * Enumerate all dependencies, if they have a tsconfig.json file with\n * \"composite: true\" we consider them project references.\n *\n * (Note: TypeScript seems to only correctly find transitive project references\n * if there's an \"index\" tsconfig.json of all projects somewhere up the directory\n * tree)\n */\n private findProjectReferences(): string[] {\n const pkg = this.options.projectInfo.packageJson;\n\n const ret = new Array<string>();\n\n const dependencyNames = new Set<string>();\n for (const dependencyMap of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]) {\n if (dependencyMap === undefined) {\n continue;\n }\n for (const name of Object.keys(dependencyMap)) {\n dependencyNames.add(name);\n }\n }\n\n for (const tsconfigFile of Array.from(dependencyNames).map((depName) => this.findMonorepoPeerTsconfig(depName))) {\n if (!tsconfigFile) {\n continue;\n }\n\n const { config: tsconfig } = ts.readConfigFile(tsconfigFile, this.system.readFile);\n\n // Add references to any TypeScript package we find that is 'composite' enabled.\n // Make it relative.\n if (tsconfig.compilerOptions?.composite) {\n ret.push(path.relative(this.options.projectInfo.projectRoot, path.dirname(tsconfigFile)));\n } else {\n // Not a composite package--if this package is in a node_modules directory, that is most\n // likely correct, otherwise it is most likely an error (heuristic here, I don't know how to\n // properly check this).\n if (tsconfigFile.includes('node_modules')) {\n LOG.warn('%s: not a composite TypeScript package, but it probably should be', path.dirname(tsconfigFile));\n }\n }\n }\n\n return ret;\n }\n\n /**\n * Find source files using the same mechanism that the TypeScript compiler itself uses.\n *\n * Respects includes/excludes/etc.\n *\n * This makes it so that running 'typescript' and running 'jsii' has the same behavior.\n */\n private determineSources(files: string[]): string[] {\n // explicitly requested files\n if (files.length > 0) {\n return [...files];\n }\n\n // for user provided config we already have parsed the full list of files\n if (this.userProvidedTypeScriptConfig) {\n return [...(this.tsconfig.include ?? [])];\n }\n\n // finally get the file list for the generated config\n const parseConfigHost = parseConfigHostFromCompilerHost(this.compilerHost);\n const parsed = ts.parseJsonConfigFileContent(this.tsconfig, parseConfigHost, this.options.projectInfo.projectRoot);\n return [...parsed.fileNames];\n }\n\n /**\n * Resolve the given dependency name from the current package, and find the associated tsconfig.json location\n *\n * Because we have the following potential directory layout:\n *\n * package/node_modules/some_dependency\n * package/tsconfig.json\n *\n * We resolve symlinks and only find a \"TypeScript\" dependency if doesn't have 'node_modules' in\n * the path after resolving symlinks (i.e., if it's a peer package in the same monorepo).\n *\n * Returns undefined if no such tsconfig could be found.\n */\n private findMonorepoPeerTsconfig(depName: string): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n const { builtinModules } = require('node:module');\n if ((builtinModules ?? []).includes(depName)) {\n // Can happen for modules like 'punycode' which are declared as dependency for polyfill purposes\n return undefined;\n }\n\n try {\n const depDir = findDependencyDirectory(depName, this.options.projectInfo.projectRoot);\n\n const dep = path.join(depDir, 'tsconfig.json');\n if (!fs.existsSync(dep)) {\n return undefined;\n }\n\n // Resolve symlinks, to check if this is a monorepo peer\n const dependencyRealPath = fs.realpathSync(dep);\n if (dependencyRealPath.split(path.sep).includes('node_modules')) {\n return undefined;\n }\n\n return dependencyRealPath;\n } catch (e: any) {\n // @types modules cannot be required, for example\n if (['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(e.code)) {\n return undefined;\n }\n throw e;\n }\n }\n\n private diagsHaveAbortableErrors(diags: readonly ts.Diagnostic[]) {\n return diags.some(\n (d) =>\n d.category === ts.DiagnosticCategory.Error ||\n (this.options.failOnWarnings && d.category === ts.DiagnosticCategory.Warning),\n );\n }\n}\n\n/**\n * Options for Watch in non-blocking mode.\n *\n * @internal\n */\nexport interface NonBlockingWatchOptions {\n /**\n * Signals non-blocking execution\n */\n readonly nonBlocking: true;\n\n /**\n * Configures the diagnostics reporter\n */\n readonly reportDiagnostics: ts.DiagnosticReporter;\n\n /**\n * Configures the watch status reporter\n */\n readonly reportWatchStatus: ts.WatchStatusReporter;\n\n /**\n * This hook gets invoked when a compilation cycle (complete with Assembler execution) completes.\n */\n readonly compilationComplete: (emitResult: ts.EmitResult) => void;\n}\n\nfunction _pathOfLibraries(host: ts.CompilerHost | ts.WatchCompilerHost<any>): string[] {\n if (!BASE_COMPILER_OPTIONS.lib || BASE_COMPILER_OPTIONS.lib.length === 0) {\n return [];\n }\n const lib = host.getDefaultLibLocation?.();\n if (!lib) {\n throw new Error(\n `Compiler host doesn't have a default library directory available for ${BASE_COMPILER_OPTIONS.lib.join(', ')}`,\n );\n }\n return BASE_COMPILER_OPTIONS.lib.map((name) => path.join(lib, name));\n}\n\nfunction parseConfigHostFromCompilerHost(host: ts.CompilerHost): ts.ParseConfigHost {\n // Copied from upstream\n // https://github.com/Microsoft/TypeScript/blob/9e05abcfd3f8bb3d6775144ede807daceab2e321/src/compiler/program.ts#L3105\n return {\n fileExists: (f) => host.fileExists(f),\n readDirectory(root, extensions, excludes, includes, depth) {\n if (host.readDirectory === undefined) {\n throw new Error(\"'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'\");\n }\n return host.readDirectory(root, extensions, excludes, includes, depth);\n },\n readFile: (f) => host.readFile(f),\n useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),\n trace: host.trace ? (s) => host.trace!(s) : undefined,\n };\n}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AAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,+BAA+B,CAAC,IAAqB;IAC5D,uBAAuB;IACvB,sHAAsH;IACtH,OAAO;QACL,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QACrC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK;YACvD,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;YAC/G,CAAC;YACD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjC,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,EAAE;QAC3D,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;KACtD,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as chalk from 'chalk';\nimport * as log4js from 'log4js';\nimport * as ts from 'typescript';\n\nimport { Assembler } from './assembler';\nimport { findDependencyDirectory } from './common/find-utils';\nimport { emitDownleveledDeclarations, TYPES_COMPAT } from './downlevel-dts';\nimport { Emitter } from './emitter';\nimport { normalizeConfigPath } from './helpers';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport { ProjectInfo } from './project-info';\nimport { WARNINGSCODE_FILE_NAME } from './transforms/deprecation-warnings';\nimport { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport { BASE_COMPILER_OPTIONS, convertForJson } from './tsconfig/compiler-options';\nimport { TypeScriptConfigValidator } from './tsconfig/tsconfig-validator';\nimport { ValidationError } from './tsconfig/validator';\nimport * as utils from './utils';\n\nconst LOG = log4js.getLogger('jsii/compiler');\nexport const DIAGNOSTICS = 'diagnostics';\nexport const JSII_DIAGNOSTICS_CODE = 9999;\n\nexport interface CompilerOptions {\n /** The information about the project to be built */\n projectInfo: ProjectInfo;\n /** Whether the compiler should watch for changes or just compile once */\n watch?: boolean;\n /** Whether to detect and generate TypeScript project references */\n projectReferences?: boolean;\n /** Whether to fail when a warning is emitted */\n failOnWarnings?: boolean;\n /** Whether to strip deprecated members from emitted artifacts */\n stripDeprecated?: boolean;\n /** The path to an allowlist of FQNs to strip if stripDeprecated is set */\n stripDeprecatedAllowListFile?: string;\n /** Whether to add warnings for deprecated elements */\n addDeprecationWarnings?: boolean;\n /**\n * The name of the tsconfig file to generate.\n * Cannot be used at the same time as `typeScriptConfig`.\n * @default \"tsconfig.json\"\n */\n generateTypeScriptConfig?: string;\n /**\n * The name of the tsconfig file to use.\n * Cannot be used at the same time as `generateTypeScriptConfig`.\n * @default - generate the tsconfig file\n */\n typeScriptConfig?: string;\n /**\n * The ruleset to validate the provided tsconfig file against.\n * Can only be used when `typeScriptConfig` is provided.\n * @default TypeScriptConfigValidationRuleSet.STRICT - if `typeScriptConfig` is provided\n */\n validateTypeScriptConfig?: TypeScriptConfigValidationRuleSet;\n /**\n * Whether to compress the assembly\n * @default false\n */\n compressAssembly?: boolean;\n}\n\nexport class Compiler implements Emitter {\n private readonly system: ts.System;\n private readonly compilerHost: ts.CompilerHost;\n private readonly userProvidedTypeScriptConfig: boolean;\n private readonly tsconfig: TypeScriptConfig;\n private rootFiles: string[] = [];\n private readonly configPath: string;\n private readonly projectRoot: string;\n\n public constructor(private readonly options: CompilerOptions) {\n if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {\n throw new utils.JsiiError(\n 'Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.',\n );\n }\n\n this.projectRoot = this.options.projectInfo.projectRoot;\n const configFileName = options.typeScriptConfig ?? options.generateTypeScriptConfig ?? 'tsconfig.json';\n this.configPath = path.join(this.projectRoot, configFileName);\n this.userProvidedTypeScriptConfig = Boolean(options.typeScriptConfig);\n\n this.system = {\n ...ts.sys,\n getCurrentDirectory: () => this.projectRoot,\n createDirectory: (pth) => ts.sys.createDirectory(path.resolve(this.projectRoot, pth)),\n deleteFile: ts.sys.deleteFile && ((pth) => ts.sys.deleteFile!(path.join(this.projectRoot, pth))),\n fileExists: (pth) => ts.sys.fileExists(path.resolve(this.projectRoot, pth)),\n getFileSize: ts.sys.getFileSize && ((pth) => ts.sys.getFileSize!(path.resolve(this.projectRoot, pth))),\n readFile: (pth, encoding) => ts.sys.readFile(path.resolve(this.projectRoot, pth), encoding),\n watchFile:\n ts.sys.watchFile &&\n ((pth, callback, pollingInterval, watchOptions) =>\n ts.sys.watchFile!(path.resolve(this.projectRoot, pth), callback, pollingInterval, watchOptions)),\n writeFile: (pth, data, writeByteOrderMark) =>\n ts.sys.writeFile(path.resolve(this.projectRoot, pth), data, writeByteOrderMark),\n };\n\n this.tsconfig = this.configureTypeScript();\n this.compilerHost = ts.createIncrementalCompilerHost(this.tsconfig.compilerOptions, this.system);\n }\n\n /**\n * Compiles the configured program.\n *\n * @param files can be specified to override the standard source code location logic. Useful for example when testing \"negatives\".\n */\n public emit(...files: string[]): ts.EmitResult {\n this.prepareForBuild(...files);\n return this.buildOnce();\n }\n\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In non-blocking mode, this\n * returns the TypeScript watch handle for the application to use.\n *\n * @internal\n */\n public async watch(opts: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram>>;\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results\n * in a never-resolving promise.\n */\n public async watch(): Promise<never>;\n public async watch(opts?: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram> | never> {\n this.prepareForBuild();\n\n const host = ts.createWatchCompilerHost(\n this.configPath,\n {\n ...this.tsconfig.compilerOptions,\n noEmitOnError: false,\n },\n this.system,\n ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n opts?.reportDiagnostics,\n opts?.reportWatchStatus,\n this.tsconfig.watchOptions,\n );\n if (!host.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n const orig = host.afterProgramCreate;\n // This is a callback cascade, so it's \"okay\" to return an unhandled promise there. This may\n // cause an unhandled promise rejection warning, but that's not a big deal.\n //\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n host.afterProgramCreate = (builderProgram) => {\n const emitResult = this.consumeProgram(builderProgram.getProgram(), host.getDefaultLibLocation!());\n\n for (const diag of emitResult.diagnostics.filter((d) => d.code === JSII_DIAGNOSTICS_CODE)) {\n utils.logDiagnostic(diag, this.projectRoot);\n }\n\n if (orig) {\n orig.call(host, builderProgram);\n }\n if (opts?.compilationComplete) {\n opts.compilationComplete(emitResult);\n }\n };\n const watch = ts.createWatchProgram(host);\n\n if (opts?.nonBlocking) {\n // In non-blocking mode, returns the handle to the TypeScript watch interface.\n return watch;\n }\n // In blocking mode, returns a never-resolving promise.\n return new Promise<never>(() => null);\n }\n\n /**\n * Prepares the project for build, by creating the necessary configuration\n * file(s), and assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private configureTypeScript(): TypeScriptConfig {\n if (this.userProvidedTypeScriptConfig) {\n const config = this.readTypeScriptConfig();\n\n // emit a warning if validation is disabled\n const rules = this.options.validateTypeScriptConfig ?? TypeScriptConfigValidationRuleSet.NONE;\n if (rules === TypeScriptConfigValidationRuleSet.NONE) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4009_DISABLED_TSCONFIG_VALIDATION.create(undefined, this.configPath),\n this.projectRoot,\n );\n }\n\n // validate the user provided config\n if (rules !== TypeScriptConfigValidationRuleSet.NONE) {\n const configName = path.relative(this.projectRoot, this.configPath);\n try {\n const validator = new TypeScriptConfigValidator(rules);\n validator.validate({\n ...config,\n // convert the internal format to the user format which is what the validator operates on\n compilerOptions: convertForJson(config.compilerOptions),\n });\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION.create(\n undefined,\n configName,\n rules,\n error.violations,\n ),\n this.projectRoot,\n );\n }\n\n throw new utils.JsiiError(\n `Failed validation of tsconfig \"compilerOptions\" in \"${configName}\" against rule set \"${rules}\"!`,\n );\n }\n }\n\n return config;\n }\n\n // generated config if none is provided by the user\n return this.buildTypeScriptConfig();\n }\n\n /**\n * Final preparations of the project for build.\n *\n * These are preparations that either\n * - must happen immediately before the build, or\n * - can be different for every build like assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private prepareForBuild(...files: string[]) {\n if (!this.userProvidedTypeScriptConfig) {\n this.writeTypeScriptConfig();\n }\n\n this.rootFiles = this.determineSources(files);\n }\n\n /**\n * Do a single build\n */\n private buildOnce(): ts.EmitResult {\n if (!this.compilerHost.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n\n const tsconf = this.tsconfig!;\n\n const prog = ts.createIncrementalProgram({\n rootNames: this.rootFiles.concat(_pathOfLibraries(this.compilerHost)),\n options: tsconf.compilerOptions,\n // Make the references absolute for the compiler\n projectReferences: tsconf.references?.map((ref) => ({\n path: path.resolve(path.dirname(this.configPath), ref.path),\n })),\n host: this.compilerHost,\n });\n\n return this.consumeProgram(prog.getProgram(), this.compilerHost.getDefaultLibLocation());\n }\n\n private consumeProgram(program: ts.Program, stdlib: string): ts.EmitResult {\n const diagnostics = [...ts.getPreEmitDiagnostics(program)];\n let hasErrors = false;\n\n if (!hasErrors && this.diagsHaveAbortableErrors(diagnostics)) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Do the \"Assembler\" part first because we need some of the analysis done in there\n // to post-process the AST\n const assembler = new Assembler(this.options.projectInfo, this.system, program, stdlib, {\n stripDeprecated: this.options.stripDeprecated,\n stripDeprecatedAllowListFile: this.options.stripDeprecatedAllowListFile,\n addDeprecationWarnings: this.options.addDeprecationWarnings,\n compressAssembly: this.options.compressAssembly,\n });\n\n try {\n const assmEmit = assembler.emit();\n if (!hasErrors && (assmEmit.emitSkipped || this.diagsHaveAbortableErrors(assmEmit.diagnostics))) {\n hasErrors = true;\n LOG.error('Type model errors prevented the JSII assembly from being created');\n }\n\n diagnostics.push(...assmEmit.diagnostics);\n } catch (e: any) {\n diagnostics.push(JsiiDiagnostic.JSII_9997_UNKNOWN_ERROR.createDetached(e));\n hasErrors = true;\n }\n\n // Do the emit, but add in transformers which are going to replace real\n // comments with synthetic ones.\n const emit = program.emit(\n undefined, // targetSourceFile\n undefined, // writeFile\n undefined, // cancellationToken\n undefined, // emitOnlyDtsFiles\n assembler.customTransformers,\n );\n diagnostics.push(...emit.diagnostics);\n\n if (!hasErrors && (emit.emitSkipped || this.diagsHaveAbortableErrors(emit.diagnostics))) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n if (!hasErrors) {\n emitDownleveledDeclarations(\n this.projectRoot,\n this.options.projectInfo.packageJson,\n // outDir might be absolute. Need to normalize it.\n normalizeConfigPath(this.projectRoot, this.tsconfig.compilerOptions.outDir),\n );\n }\n\n // Some extra validation on the config.\n // Make sure that { \"./.warnings.jsii.js\": \"./.warnings.jsii.js\" } is in the set of\n // exports, if they are specified.\n if (this.options.addDeprecationWarnings && this.options.projectInfo.exports !== undefined) {\n const expected = `./${WARNINGSCODE_FILE_NAME}`;\n const warningsExport = Object.entries(this.options.projectInfo.exports).filter(\n ([k, v]) => k === expected && v === expected,\n );\n\n if (warningsExport.length === 0) {\n hasErrors = true;\n diagnostics.push(JsiiDiagnostic.JSII_0007_MISSING_WARNINGS_EXPORT.createDetached());\n }\n }\n\n return {\n emitSkipped: hasErrors,\n diagnostics: ts.sortAndDeduplicateDiagnostics(diagnostics),\n emittedFiles: emit.emittedFiles,\n };\n }\n\n /**\n * Build the TypeScript config object from jsii config\n *\n * This is the object that will be written to disk\n * unless an existing tsconfig was provided.\n */\n private buildTypeScriptConfig(): TypeScriptConfig {\n let references: string[] | undefined;\n\n const isComposite =\n this.options.projectReferences !== undefined\n ? this.options.projectReferences\n : this.options.projectInfo.projectReferences !== undefined\n ? this.options.projectInfo.projectReferences\n : false;\n if (isComposite) {\n references = this.findProjectReferences();\n }\n\n const pi = this.options.projectInfo;\n const configDir = path.dirname(this.configPath);\n const absoluteTypesCompat = path.resolve(configDir, pi.tsc?.outDir ?? '.', TYPES_COMPAT);\n const relativeTypesCompat = path.relative(configDir, absoluteTypesCompat);\n\n return {\n compilerOptions: {\n ...pi.tsc,\n ...BASE_COMPILER_OPTIONS,\n // Enable composite mode if project references are enabled\n composite: isComposite,\n // When incremental, configure a tsbuildinfo file\n tsBuildInfoFile: path.join(pi.tsc?.outDir ?? '.', 'tsconfig.tsbuildinfo'),\n },\n include: [pi.tsc?.rootDir != null ? path.join(pi.tsc.rootDir, '**', '*.ts') : path.join('**', '*.ts')],\n exclude: [\n 'node_modules',\n relativeTypesCompat,\n ...(pi.excludeTypescript ?? []),\n ...(pi.tsc?.outDir != null &&\n (pi.tsc?.rootDir == null || path.resolve(pi.tsc.outDir).startsWith(path.resolve(pi.tsc.rootDir) + path.sep))\n ? [path.join(pi.tsc.outDir, '**', '*.ts')]\n : []),\n ],\n // Change the references a little. We write 'originalpath' to the\n // file under the 'path' key, which is the same as what the\n // TypeScript compiler does. Make it relative so that the files are\n // movable. Not strictly required but looks better.\n references: references?.map((p) => ({ path: p })),\n };\n }\n\n /**\n * Load the TypeScript config object from a provided file\n */\n private readTypeScriptConfig(): TypeScriptConfig {\n const projectRoot = this.options.projectInfo.projectRoot;\n const { config, error } = ts.readConfigFile(this.configPath, ts.sys.readFile);\n if (error) {\n utils.logDiagnostic(error, projectRoot);\n throw new utils.JsiiError(`Failed to load tsconfig at ${this.configPath}`);\n }\n const extended = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot);\n // the tsconfig parser adds this in, but it is not an expected compilerOption\n delete extended.options.configFilePath;\n\n return {\n compilerOptions: extended.options,\n watchOptions: extended.watchOptions,\n include: extended.fileNames,\n };\n }\n\n /**\n * Creates a `tsconfig.json` file to improve the IDE experience.\n *\n * @return the fully qualified path to the `tsconfig.json` file\n */\n private writeTypeScriptConfig(): void {\n const commentKey = '_generated_by_jsii_';\n const commentValue = 'Generated by jsii - safe to delete, and ideally should be in .gitignore';\n\n (this.tsconfig as any)[commentKey] = commentValue;\n\n if (fs.existsSync(this.configPath)) {\n const currentConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));\n if (!(commentKey in currentConfig)) {\n throw new utils.JsiiError(\n `A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`,\n );\n }\n }\n\n const outputConfig = {\n ...this.tsconfig,\n compilerOptions: convertForJson(this.tsconfig?.compilerOptions),\n };\n\n LOG.debug(`Creating or updating ${chalk.blue(this.configPath)}`);\n fs.writeFileSync(this.configPath, JSON.stringify(outputConfig, null, 2), 'utf8');\n }\n\n /**\n * Find all dependencies that look like TypeScript projects.\n *\n * Enumerate all dependencies, if they have a tsconfig.json file with\n * \"composite: true\" we consider them project references.\n *\n * (Note: TypeScript seems to only correctly find transitive project references\n * if there's an \"index\" tsconfig.json of all projects somewhere up the directory\n * tree)\n */\n private findProjectReferences(): string[] {\n const pkg = this.options.projectInfo.packageJson;\n\n const ret = new Array<string>();\n\n const dependencyNames = new Set<string>();\n for (const dependencyMap of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]) {\n if (dependencyMap === undefined) {\n continue;\n }\n for (const name of Object.keys(dependencyMap)) {\n dependencyNames.add(name);\n }\n }\n\n for (const tsconfigFile of Array.from(dependencyNames).map((depName) => this.findMonorepoPeerTsconfig(depName))) {\n if (!tsconfigFile) {\n continue;\n }\n\n const { config: tsconfig } = ts.readConfigFile(tsconfigFile, this.system.readFile);\n\n // Add references to any TypeScript package we find that is 'composite' enabled.\n // Make it relative.\n if (tsconfig.compilerOptions?.composite) {\n ret.push(path.relative(this.options.projectInfo.projectRoot, path.dirname(tsconfigFile)));\n } else {\n // Not a composite package--if this package is in a node_modules directory, that is most\n // likely correct, otherwise it is most likely an error (heuristic here, I don't know how to\n // properly check this).\n if (tsconfigFile.includes('node_modules')) {\n LOG.warn('%s: not a composite TypeScript package, but it probably should be', path.dirname(tsconfigFile));\n }\n }\n }\n\n return ret;\n }\n\n /**\n * Find source files using the same mechanism that the TypeScript compiler itself uses.\n *\n * Respects includes/excludes/etc.\n *\n * This makes it so that running 'typescript' and running 'jsii' has the same behavior.\n */\n private determineSources(files: string[]): string[] {\n // explicitly requested files\n if (files.length > 0) {\n return [...files];\n }\n\n // for user provided config we already have parsed the full list of files\n if (this.userProvidedTypeScriptConfig) {\n return [...(this.tsconfig.include ?? [])];\n }\n\n // finally get the file list for the generated config\n const parseConfigHost = parseConfigHostFromCompilerHost(this.compilerHost);\n const parsed = ts.parseJsonConfigFileContent(this.tsconfig, parseConfigHost, this.options.projectInfo.projectRoot);\n return [...parsed.fileNames];\n }\n\n /**\n * Resolve the given dependency name from the current package, and find the associated tsconfig.json location\n *\n * Because we have the following potential directory layout:\n *\n * package/node_modules/some_dependency\n * package/tsconfig.json\n *\n * We resolve symlinks and only find a \"TypeScript\" dependency if doesn't have 'node_modules' in\n * the path after resolving symlinks (i.e., if it's a peer package in the same monorepo).\n *\n * Returns undefined if no such tsconfig could be found.\n */\n private findMonorepoPeerTsconfig(depName: string): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n const { builtinModules } = require('node:module');\n if ((builtinModules ?? []).includes(depName)) {\n // Can happen for modules like 'punycode' which are declared as dependency for polyfill purposes\n return undefined;\n }\n\n try {\n const depDir = findDependencyDirectory(depName, this.options.projectInfo.projectRoot);\n\n const dep = path.join(depDir, 'tsconfig.json');\n if (!fs.existsSync(dep)) {\n return undefined;\n }\n\n // Resolve symlinks, to check if this is a monorepo peer\n const dependencyRealPath = fs.realpathSync(dep);\n if (dependencyRealPath.split(path.sep).includes('node_modules')) {\n return undefined;\n }\n\n return dependencyRealPath;\n } catch (e: any) {\n // @types modules cannot be required, for example\n if (['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(e.code)) {\n return undefined;\n }\n throw e;\n }\n }\n\n private diagsHaveAbortableErrors(diags: readonly ts.Diagnostic[]) {\n return diags.some(\n (d) =>\n d.category === ts.DiagnosticCategory.Error ||\n (this.options.failOnWarnings && d.category === ts.DiagnosticCategory.Warning),\n );\n }\n}\n\n/**\n * Options for Watch in non-blocking mode.\n *\n * @internal\n */\nexport interface NonBlockingWatchOptions {\n /**\n * Signals non-blocking execution\n */\n readonly nonBlocking: true;\n\n /**\n * Configures the diagnostics reporter\n */\n readonly reportDiagnostics: ts.DiagnosticReporter;\n\n /**\n * Configures the watch status reporter\n */\n readonly reportWatchStatus: ts.WatchStatusReporter;\n\n /**\n * This hook gets invoked when a compilation cycle (complete with Assembler execution) completes.\n */\n readonly compilationComplete: (emitResult: ts.EmitResult) => void;\n}\n\nfunction _pathOfLibraries(host: ts.CompilerHost | ts.WatchCompilerHost<any>): string[] {\n if (!BASE_COMPILER_OPTIONS.lib || BASE_COMPILER_OPTIONS.lib.length === 0) {\n return [];\n }\n const lib = host.getDefaultLibLocation?.();\n if (!lib) {\n throw new Error(\n `Compiler host doesn't have a default library directory available for ${BASE_COMPILER_OPTIONS.lib.join(', ')}`,\n );\n }\n return BASE_COMPILER_OPTIONS.lib.map((name) => path.join(lib, name));\n}\n\nfunction parseConfigHostFromCompilerHost(host: ts.CompilerHost): ts.ParseConfigHost {\n // Copied from upstream\n // https://github.com/Microsoft/TypeScript/blob/9e05abcfd3f8bb3d6775144ede807daceab2e321/src/compiler/program.ts#L3105\n return {\n fileExists: (f) => host.fileExists(f),\n readDirectory(root, extensions, excludes, includes, depth) {\n if (host.readDirectory === undefined) {\n throw new Error(\"'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'\");\n }\n return host.readDirectory(root, extensions, excludes, includes, depth);\n },\n readFile: (f) => host.readFile(f),\n useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),\n trace: host.trace ? (s) => host.trace!(s) : undefined,\n };\n}\n"]}
package/lib/helpers.js CHANGED
@@ -68,7 +68,7 @@ function compileJsiiForTest(source, options, compilerOptions) {
68
68
  // logDiagnostic() doesn't work out of the box, so console.error() it is.
69
69
  }
70
70
  if (errors.length > 0 || emitResult.emitSkipped) {
71
- throw new Error('There were compiler errors');
71
+ throw new utils_1.JsiiError('There were compiler errors');
72
72
  }
73
73
  const assembly = (0, spec_1.loadAssemblyFromPath)(process.cwd(), false);
74
74
  const files = {};
@@ -187,7 +187,7 @@ class TestWorkspace {
187
187
  */
188
188
  addDependency(dependencyAssembly) {
189
189
  if (this.installed.has(dependencyAssembly.assembly.name)) {
190
- throw new Error(`A dependency with name '${dependencyAssembly.assembly.name}' was already installed. Give one a different name.`);
190
+ throw new utils_1.JsiiError(`A dependency with name '${dependencyAssembly.assembly.name}' was already installed. Give one a different name.`);
191
191
  }
192
192
  this.installed.add(dependencyAssembly.assembly.name);
193
193
  // The following is silly, however: the helper has compiled the given source to
@@ -211,7 +211,7 @@ class TestWorkspace {
211
211
  }
212
212
  dependencyDir(name) {
213
213
  if (!this.installed.has(name)) {
214
- throw new Error(`No dependency with name '${name}' has been installed`);
214
+ throw new utils_1.JsiiError(`No dependency with name '${name}' has been installed`);
215
215
  }
216
216
  return path.join(this.rootDirectory, 'node_modules', name);
217
217
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;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AAsB,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;IAEM,OAAO;QACZ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AA3ED,sCA2EC;AAKD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,IAAY,EAAE,eAAwB;IACxE,IAAI,eAAe,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjE,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC9C,CAAC;AALD,kDAKC","sourcesContent":["/**\n * Helper routines for use with the jsii compiler\n *\n * These are mostly used for testing, but all projects that need to exercise\n * the JSII compiler to test something need to share this code, so might as\n * well put it in one reusable place.\n */\n\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { PackageJson, loadAssemblyFromPath, writeAssembly } from '@jsii/spec';\nimport * as spec from '@jsii/spec';\nimport { DiagnosticCategory } from 'typescript';\n\nimport { Compiler, CompilerOptions } from './compiler';\nimport { loadProjectInfo, ProjectInfo } from './project-info';\nimport { formatDiagnostic } from './utils';\n\n/**\n * A set of source files for `sourceToAssemblyHelper`, at least containing 'index.ts'\n */\nexport type MultipleSourceFiles = {\n 'index.ts': string;\n [name: string]: string;\n};\n\n/**\n * Compile a piece of source and return the JSII assembly for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function sourceToAssemblyHelper(\n source: string | MultipleSourceFiles,\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n): spec.Assembly {\n return compileJsiiForTest(source, options).assembly;\n}\n\nexport interface HelperCompilationResult {\n /**\n * The generated assembly\n */\n readonly assembly: spec.Assembly;\n\n /**\n * Generated .js/.d.ts file(s)\n */\n readonly files: Record<string, string>;\n\n /**\n * The packageInfo used\n */\n readonly packageJson: PackageJson;\n\n /**\n * Whether to compress the assembly file\n */\n readonly compressAssembly: boolean;\n}\n\n/**\n * Compile a piece of source and return the assembly and compiled sources for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function compileJsiiForTest(\n source: string | { 'index.ts': string; [name: string]: string },\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n compilerOptions?: Omit<CompilerOptions, 'projectInfo' | 'watch'>,\n): HelperCompilationResult {\n if (typeof source === 'string') {\n source = { 'index.ts': source };\n }\n\n const inSomeLocation =\n isOptionsObject(options) && options.compilationDirectory ? inOtherDir(options.compilationDirectory) : inTempDir;\n\n // Easiest way to get the source into the compiler is to write it to disk somewhere.\n // I guess we could make an in-memory compiler host but that seems like work...\n return inSomeLocation(() => {\n for (const [fileName, content] of Object.entries(source)) {\n fs.mkdirSync(path.dirname(fileName), { recursive: true });\n fs.writeFileSync(fileName, content, { encoding: 'utf-8' });\n }\n const { projectInfo, packageJson } = makeProjectInfo(\n 'index.ts',\n typeof options === 'function'\n ? options\n : (pi) => {\n Object.assign(pi, options?.packageJson ?? options?.projectInfo ?? {});\n },\n );\n const compiler = new Compiler({\n projectInfo,\n ...compilerOptions,\n });\n const emitResult = compiler.emit();\n\n const errors = emitResult.diagnostics.filter((d) => d.category === DiagnosticCategory.Error);\n for (const error of errors) {\n console.error(formatDiagnostic(error, projectInfo.projectRoot));\n // logDiagnostic() doesn't work out of the box, so console.error() it is.\n }\n if (errors.length > 0 || emitResult.emitSkipped) {\n throw new Error('There were compiler errors');\n }\n const assembly = loadAssemblyFromPath(process.cwd(), false);\n const files: Record<string, string> = {};\n\n for (const filename of Object.keys(source)) {\n let jsFile = filename.replace(/\\.ts$/, '.js');\n let dtsFile = filename.replace(/\\.ts$/, '.d.ts');\n if (projectInfo.tsc?.outDir && filename !== 'README.md') {\n jsFile = path.join(projectInfo.tsc.outDir, jsFile);\n dtsFile = path.join(projectInfo.tsc.outDir, dtsFile);\n }\n\n // eslint-disable-next-line no-await-in-loop\n files[jsFile] = fs.readFileSync(jsFile, { encoding: 'utf-8' });\n // eslint-disable-next-line no-await-in-loop\n files[dtsFile] = fs.readFileSync(dtsFile, { encoding: 'utf-8' });\n\n const warningsFileName = '.warnings.jsii.js';\n if (fs.existsSync(warningsFileName)) {\n // eslint-disable-next-line no-await-in-loop\n files[warningsFileName] = fs.readFileSync(warningsFileName, {\n encoding: 'utf-8',\n });\n }\n }\n\n return {\n assembly,\n files,\n packageJson,\n compressAssembly: isOptionsObject(options) && options.compressAssembly ? true : false,\n } as HelperCompilationResult;\n });\n}\n\nfunction inTempDir<T>(block: () => T): T {\n const origDir = process.cwd();\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii'));\n process.chdir(tmpDir);\n const ret = block();\n process.chdir(origDir);\n fs.rmSync(tmpDir, { force: true, recursive: true });\n return ret;\n}\n\nfunction inOtherDir(dir: string) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\n return <T extends unknown>(block: () => T): T => {\n const origDir = process.cwd();\n process.chdir(dir);\n try {\n return block();\n } finally {\n process.chdir(origDir);\n }\n };\n}\n\n/**\n * Obtain project info so we can call the compiler\n *\n * Creating this directly in-memory leads to slightly different behavior from calling\n * jsii from the command-line, and I don't want to figure out right now.\n *\n * Most consistent behavior seems to be to write a package.json to disk and\n * then calling the same functions as the CLI would.\n */\nfunction makeProjectInfo(\n types: string,\n cb?: (obj: PackageJson) => void,\n): { projectInfo: ProjectInfo; packageJson: PackageJson } {\n const packageJson: PackageJson = {\n types,\n main: types.replace(/(?:\\.d)?\\.ts(x?)/, '.js$1'),\n name: 'testpkg', // That's what package.json would tell if we look up...\n version: '0.0.1',\n license: 'Apache-2.0',\n author: { name: 'John Doe' },\n repository: { type: 'git', url: 'https://github.com/aws/jsii.git' },\n jsii: {},\n };\n\n if (cb) {\n cb(packageJson);\n }\n\n fs.writeFileSync(\n 'package.json',\n JSON.stringify(packageJson, (_: string, v: any) => v, 2),\n 'utf-8',\n );\n\n const { projectInfo } = loadProjectInfo(path.resolve(process.cwd(), '.'));\n return { projectInfo, packageJson };\n}\n\nexport interface TestCompilationOptions {\n /**\n * The directory in which we write and compile the files\n */\n readonly compilationDirectory?: string;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @deprecated Prefer using `packageJson` instead.\n */\n readonly projectInfo?: Partial<PackageJson>;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @default - Use some default values\n */\n readonly packageJson?: Partial<PackageJson>;\n\n /**\n * Whether to compress the assembly file.\n *\n * @default false\n */\n readonly compressAssembly?: boolean;\n}\n\nfunction isOptionsObject(\n x: TestCompilationOptions | ((obj: PackageJson) => void) | undefined,\n): x is TestCompilationOptions {\n return x ? typeof x === 'object' : false;\n}\n\n/**\n * An NPM-ready workspace where we can install test-compile dependencies and compile new assemblies\n */\nexport class TestWorkspace {\n /**\n * Create a new workspace.\n *\n * Creates a temporary directory, don't forget to call cleanUp\n */\n public static create(): TestWorkspace {\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii-testworkspace'));\n fs.mkdirSync(tmpDir, { recursive: true });\n return new TestWorkspace(tmpDir);\n }\n\n /**\n * Execute a block with a temporary workspace\n */\n public static withWorkspace<A>(block: (ws: TestWorkspace) => A): A {\n const ws = TestWorkspace.create();\n try {\n return block(ws);\n } finally {\n ws.cleanup();\n }\n }\n\n private readonly installed = new Set<string>();\n\n private constructor(public readonly rootDirectory: string) {}\n\n /**\n * Add a test-compiled jsii assembly as a dependency\n */\n public addDependency(dependencyAssembly: HelperCompilationResult) {\n if (this.installed.has(dependencyAssembly.assembly.name)) {\n throw new Error(\n `A dependency with name '${dependencyAssembly.assembly.name}' was already installed. Give one a different name.`,\n );\n }\n this.installed.add(dependencyAssembly.assembly.name);\n\n // The following is silly, however: the helper has compiled the given source to\n // an assembly, and output files, and then removed their traces from disk.\n // We need those files back on disk, so write them back out again.\n //\n // We will drop them in 'node_modules/<name>' so they can be imported\n // as if they were installed.\n const modDir = path.join(this.rootDirectory, 'node_modules', dependencyAssembly.assembly.name);\n fs.mkdirSync(modDir, { recursive: true });\n\n writeAssembly(modDir, dependencyAssembly.assembly, {\n compress: dependencyAssembly.compressAssembly,\n });\n fs.writeFileSync(\n path.join(modDir, 'package.json'),\n JSON.stringify(dependencyAssembly.packageJson, null, 2),\n 'utf-8',\n );\n\n for (const [fileName, fileContents] of Object.entries(dependencyAssembly.files)) {\n fs.mkdirSync(path.dirname(path.join(modDir, fileName)), {\n recursive: true,\n });\n fs.writeFileSync(path.join(modDir, fileName), fileContents);\n }\n }\n\n public dependencyDir(name: string) {\n if (!this.installed.has(name)) {\n throw new Error(`No dependency with name '${name}' has been installed`);\n }\n return path.join(this.rootDirectory, 'node_modules', name);\n }\n\n public cleanup() {\n fs.rmSync(this.rootDirectory, { force: true, recursive: true });\n }\n}\n\n// Alias for backwards compatibility\nexport type PackageInfo = PackageJson;\n\n/**\n * TSConfig paths can either be relative to the project or absolute.\n * This function normalizes paths to be relative to the provided root.\n * After normalization, code using these paths can be much simpler.\n *\n * @param root the project root\n * @param pathToNormalize the path to normalize, might be empty\n */\nexport function normalizeConfigPath(root: string, pathToNormalize?: string): string | undefined {\n if (pathToNormalize == null || !path.isAbsolute(pathToNormalize)) {\n return pathToNormalize;\n }\n return path.relative(root, pathToNormalize);\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;A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CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;IAEM,OAAO;QACZ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AA3ED,sCA2EC;AAKD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,IAAY,EAAE,eAAwB;IACxE,IAAI,eAAe,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjE,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC9C,CAAC;AALD,kDAKC","sourcesContent":["/**\n * Helper routines for use with the jsii compiler\n *\n * These are mostly used for testing, but all projects that need to exercise\n * the JSII compiler to test something need to share this code, so might as\n * well put it in one reusable place.\n */\n\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { PackageJson, loadAssemblyFromPath, writeAssembly } from '@jsii/spec';\nimport * as spec from '@jsii/spec';\nimport { DiagnosticCategory } from 'typescript';\n\nimport { Compiler, CompilerOptions } from './compiler';\nimport { loadProjectInfo, ProjectInfo } from './project-info';\nimport { formatDiagnostic, JsiiError } from './utils';\n\n/**\n * A set of source files for `sourceToAssemblyHelper`, at least containing 'index.ts'\n */\nexport type MultipleSourceFiles = {\n 'index.ts': string;\n [name: string]: string;\n};\n\n/**\n * Compile a piece of source and return the JSII assembly for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function sourceToAssemblyHelper(\n source: string | MultipleSourceFiles,\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n): spec.Assembly {\n return compileJsiiForTest(source, options).assembly;\n}\n\nexport interface HelperCompilationResult {\n /**\n * The generated assembly\n */\n readonly assembly: spec.Assembly;\n\n /**\n * Generated .js/.d.ts file(s)\n */\n readonly files: Record<string, string>;\n\n /**\n * The packageInfo used\n */\n readonly packageJson: PackageJson;\n\n /**\n * Whether to compress the assembly file\n */\n readonly compressAssembly: boolean;\n}\n\n/**\n * Compile a piece of source and return the assembly and compiled sources for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function compileJsiiForTest(\n source: string | { 'index.ts': string; [name: string]: string },\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n compilerOptions?: Omit<CompilerOptions, 'projectInfo' | 'watch'>,\n): HelperCompilationResult {\n if (typeof source === 'string') {\n source = { 'index.ts': source };\n }\n\n const inSomeLocation =\n isOptionsObject(options) && options.compilationDirectory ? inOtherDir(options.compilationDirectory) : inTempDir;\n\n // Easiest way to get the source into the compiler is to write it to disk somewhere.\n // I guess we could make an in-memory compiler host but that seems like work...\n return inSomeLocation(() => {\n for (const [fileName, content] of Object.entries(source)) {\n fs.mkdirSync(path.dirname(fileName), { recursive: true });\n fs.writeFileSync(fileName, content, { encoding: 'utf-8' });\n }\n const { projectInfo, packageJson } = makeProjectInfo(\n 'index.ts',\n typeof options === 'function'\n ? options\n : (pi) => {\n Object.assign(pi, options?.packageJson ?? options?.projectInfo ?? {});\n },\n );\n const compiler = new Compiler({\n projectInfo,\n ...compilerOptions,\n });\n const emitResult = compiler.emit();\n\n const errors = emitResult.diagnostics.filter((d) => d.category === DiagnosticCategory.Error);\n for (const error of errors) {\n console.error(formatDiagnostic(error, projectInfo.projectRoot));\n // logDiagnostic() doesn't work out of the box, so console.error() it is.\n }\n if (errors.length > 0 || emitResult.emitSkipped) {\n throw new JsiiError('There were compiler errors');\n }\n const assembly = loadAssemblyFromPath(process.cwd(), false);\n const files: Record<string, string> = {};\n\n for (const filename of Object.keys(source)) {\n let jsFile = filename.replace(/\\.ts$/, '.js');\n let dtsFile = filename.replace(/\\.ts$/, '.d.ts');\n if (projectInfo.tsc?.outDir && filename !== 'README.md') {\n jsFile = path.join(projectInfo.tsc.outDir, jsFile);\n dtsFile = path.join(projectInfo.tsc.outDir, dtsFile);\n }\n\n // eslint-disable-next-line no-await-in-loop\n files[jsFile] = fs.readFileSync(jsFile, { encoding: 'utf-8' });\n // eslint-disable-next-line no-await-in-loop\n files[dtsFile] = fs.readFileSync(dtsFile, { encoding: 'utf-8' });\n\n const warningsFileName = '.warnings.jsii.js';\n if (fs.existsSync(warningsFileName)) {\n // eslint-disable-next-line no-await-in-loop\n files[warningsFileName] = fs.readFileSync(warningsFileName, {\n encoding: 'utf-8',\n });\n }\n }\n\n return {\n assembly,\n files,\n packageJson,\n compressAssembly: isOptionsObject(options) && options.compressAssembly ? true : false,\n } as HelperCompilationResult;\n });\n}\n\nfunction inTempDir<T>(block: () => T): T {\n const origDir = process.cwd();\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii'));\n process.chdir(tmpDir);\n const ret = block();\n process.chdir(origDir);\n fs.rmSync(tmpDir, { force: true, recursive: true });\n return ret;\n}\n\nfunction inOtherDir(dir: string) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\n return <T extends unknown>(block: () => T): T => {\n const origDir = process.cwd();\n process.chdir(dir);\n try {\n return block();\n } finally {\n process.chdir(origDir);\n }\n };\n}\n\n/**\n * Obtain project info so we can call the compiler\n *\n * Creating this directly in-memory leads to slightly different behavior from calling\n * jsii from the command-line, and I don't want to figure out right now.\n *\n * Most consistent behavior seems to be to write a package.json to disk and\n * then calling the same functions as the CLI would.\n */\nfunction makeProjectInfo(\n types: string,\n cb?: (obj: PackageJson) => void,\n): { projectInfo: ProjectInfo; packageJson: PackageJson } {\n const packageJson: PackageJson = {\n types,\n main: types.replace(/(?:\\.d)?\\.ts(x?)/, '.js$1'),\n name: 'testpkg', // That's what package.json would tell if we look up...\n version: '0.0.1',\n license: 'Apache-2.0',\n author: { name: 'John Doe' },\n repository: { type: 'git', url: 'https://github.com/aws/jsii.git' },\n jsii: {},\n };\n\n if (cb) {\n cb(packageJson);\n }\n\n fs.writeFileSync(\n 'package.json',\n JSON.stringify(packageJson, (_: string, v: any) => v, 2),\n 'utf-8',\n );\n\n const { projectInfo } = loadProjectInfo(path.resolve(process.cwd(), '.'));\n return { projectInfo, packageJson };\n}\n\nexport interface TestCompilationOptions {\n /**\n * The directory in which we write and compile the files\n */\n readonly compilationDirectory?: string;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @deprecated Prefer using `packageJson` instead.\n */\n readonly projectInfo?: Partial<PackageJson>;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @default - Use some default values\n */\n readonly packageJson?: Partial<PackageJson>;\n\n /**\n * Whether to compress the assembly file.\n *\n * @default false\n */\n readonly compressAssembly?: boolean;\n}\n\nfunction isOptionsObject(\n x: TestCompilationOptions | ((obj: PackageJson) => void) | undefined,\n): x is TestCompilationOptions {\n return x ? typeof x === 'object' : false;\n}\n\n/**\n * An NPM-ready workspace where we can install test-compile dependencies and compile new assemblies\n */\nexport class TestWorkspace {\n /**\n * Create a new workspace.\n *\n * Creates a temporary directory, don't forget to call cleanUp\n */\n public static create(): TestWorkspace {\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii-testworkspace'));\n fs.mkdirSync(tmpDir, { recursive: true });\n return new TestWorkspace(tmpDir);\n }\n\n /**\n * Execute a block with a temporary workspace\n */\n public static withWorkspace<A>(block: (ws: TestWorkspace) => A): A {\n const ws = TestWorkspace.create();\n try {\n return block(ws);\n } finally {\n ws.cleanup();\n }\n }\n\n private readonly installed = new Set<string>();\n\n private constructor(public readonly rootDirectory: string) {}\n\n /**\n * Add a test-compiled jsii assembly as a dependency\n */\n public addDependency(dependencyAssembly: HelperCompilationResult) {\n if (this.installed.has(dependencyAssembly.assembly.name)) {\n throw new JsiiError(\n `A dependency with name '${dependencyAssembly.assembly.name}' was already installed. Give one a different name.`,\n );\n }\n this.installed.add(dependencyAssembly.assembly.name);\n\n // The following is silly, however: the helper has compiled the given source to\n // an assembly, and output files, and then removed their traces from disk.\n // We need those files back on disk, so write them back out again.\n //\n // We will drop them in 'node_modules/<name>' so they can be imported\n // as if they were installed.\n const modDir = path.join(this.rootDirectory, 'node_modules', dependencyAssembly.assembly.name);\n fs.mkdirSync(modDir, { recursive: true });\n\n writeAssembly(modDir, dependencyAssembly.assembly, {\n compress: dependencyAssembly.compressAssembly,\n });\n fs.writeFileSync(\n path.join(modDir, 'package.json'),\n JSON.stringify(dependencyAssembly.packageJson, null, 2),\n 'utf-8',\n );\n\n for (const [fileName, fileContents] of Object.entries(dependencyAssembly.files)) {\n fs.mkdirSync(path.dirname(path.join(modDir, fileName)), {\n recursive: true,\n });\n fs.writeFileSync(path.join(modDir, fileName), fileContents);\n }\n }\n\n public dependencyDir(name: string) {\n if (!this.installed.has(name)) {\n throw new JsiiError(`No dependency with name '${name}' has been installed`);\n }\n return path.join(this.rootDirectory, 'node_modules', name);\n }\n\n public cleanup() {\n fs.rmSync(this.rootDirectory, { force: true, recursive: true });\n }\n}\n\n// Alias for backwards compatibility\nexport type PackageInfo = PackageJson;\n\n/**\n * TSConfig paths can either be relative to the project or absolute.\n * This function normalizes paths to be relative to the provided root.\n * After normalization, code using these paths can be much simpler.\n *\n * @param root the project root\n * @param pathToNormalize the path to normalize, might be empty\n */\nexport function normalizeConfigPath(root: string, pathToNormalize?: string): string | undefined {\n if (pathToNormalize == null || !path.isAbsolute(pathToNormalize)) {\n return pathToNormalize;\n }\n return path.relative(root, pathToNormalize);\n}\n"]}
package/lib/main.js CHANGED
@@ -113,43 +113,60 @@ const ruleSets = {
113
113
  desc: 'Increase the verbosity of output',
114
114
  global: true,
115
115
  }), async (argv) => {
116
- _configureLog4js(argv.verbose);
117
- if (argv['generate-tsconfig'] != null && argv.tsconfig != null) {
118
- throw new Error('Options --generate-tsconfig and --tsconfig are mutually exclusive');
119
- }
120
- const projectRoot = path.normalize(path.resolve(process.cwd(), argv.PROJECT_ROOT));
121
- const { projectInfo, diagnostics: projectInfoDiagnostics } = (0, project_info_1.loadProjectInfo)(projectRoot);
122
- // disable all silenced warnings
123
- for (const key of argv['silence-warnings']) {
124
- if (!(key in warnings_1.enabledWarnings)) {
125
- throw new Error(`Unknown warning type ${key}. Must be one of: ${warningTypes.join(', ')}`);
116
+ try {
117
+ _configureLog4js(argv.verbose);
118
+ if (argv['generate-tsconfig'] != null && argv.tsconfig != null) {
119
+ throw new utils.JsiiError('Options --generate-tsconfig and --tsconfig are mutually exclusive', true);
120
+ }
121
+ const projectRoot = path.normalize(path.resolve(process.cwd(), argv.PROJECT_ROOT));
122
+ const { projectInfo, diagnostics: projectInfoDiagnostics } = (0, project_info_1.loadProjectInfo)(projectRoot);
123
+ // disable all silenced warnings
124
+ for (const key of argv['silence-warnings']) {
125
+ if (!(key in warnings_1.enabledWarnings)) {
126
+ throw new utils.JsiiError(`Unknown warning type ${key}. Must be one of: ${warningTypes.join(', ')}`);
127
+ }
128
+ warnings_1.enabledWarnings[key] = false;
129
+ }
130
+ (0, jsii_diagnostic_1.configureCategories)(projectInfo.diagnostics ?? {});
131
+ const typeScriptConfig = argv.tsconfig ?? projectInfo.packageJson.jsii?.tsconfig;
132
+ const validateTypeScriptConfig = argv['validate-tsconfig'] ??
133
+ projectInfo.packageJson.jsii?.validateTsconfig ??
134
+ tsconfig_1.TypeScriptConfigValidationRuleSet.STRICT;
135
+ const compiler = new compiler_1.Compiler({
136
+ projectInfo,
137
+ projectReferences: argv['project-references'],
138
+ failOnWarnings: argv['fail-on-warnings'],
139
+ stripDeprecated: argv['strip-deprecated'] != null,
140
+ stripDeprecatedAllowListFile: argv['strip-deprecated'],
141
+ addDeprecationWarnings: argv['add-deprecation-warnings'],
142
+ generateTypeScriptConfig: argv['generate-tsconfig'],
143
+ typeScriptConfig,
144
+ validateTypeScriptConfig,
145
+ compressAssembly: argv['compress-assembly'],
146
+ });
147
+ const emitResult = argv.watch ? await compiler.watch() : compiler.emit();
148
+ const allDiagnostics = [...projectInfoDiagnostics, ...emitResult.diagnostics];
149
+ for (const diagnostic of allDiagnostics) {
150
+ utils.logDiagnostic(diagnostic, projectRoot);
151
+ }
152
+ if (emitResult.emitSkipped) {
153
+ process.exitCode = 1;
126
154
  }
127
- warnings_1.enabledWarnings[key] = false;
128
- }
129
- (0, jsii_diagnostic_1.configureCategories)(projectInfo.diagnostics ?? {});
130
- const typeScriptConfig = argv.tsconfig ?? projectInfo.packageJson.jsii?.tsconfig;
131
- const validateTypeScriptConfig = argv['validate-tsconfig'] ??
132
- projectInfo.packageJson.jsii?.validateTsconfig ??
133
- tsconfig_1.TypeScriptConfigValidationRuleSet.STRICT;
134
- const compiler = new compiler_1.Compiler({
135
- projectInfo,
136
- projectReferences: argv['project-references'],
137
- failOnWarnings: argv['fail-on-warnings'],
138
- stripDeprecated: argv['strip-deprecated'] != null,
139
- stripDeprecatedAllowListFile: argv['strip-deprecated'],
140
- addDeprecationWarnings: argv['add-deprecation-warnings'],
141
- generateTypeScriptConfig: argv['generate-tsconfig'],
142
- typeScriptConfig,
143
- validateTypeScriptConfig,
144
- compressAssembly: argv['compress-assembly'],
145
- });
146
- const emitResult = argv.watch ? await compiler.watch() : compiler.emit();
147
- const allDiagnostics = [...projectInfoDiagnostics, ...emitResult.diagnostics];
148
- for (const diagnostic of allDiagnostics) {
149
- utils.logDiagnostic(diagnostic, projectRoot);
150
155
  }
151
- if (emitResult.emitSkipped) {
152
- process.exitCode = 1;
156
+ catch (e) {
157
+ if (e instanceof utils.JsiiError) {
158
+ if (e.showHelp) {
159
+ console.log();
160
+ yargs.showHelp();
161
+ console.log();
162
+ }
163
+ const LOG = log4js.getLogger(utils.CLI_LOGGER);
164
+ LOG.error(e.message);
165
+ process.exitCode = -1;
166
+ }
167
+ else {
168
+ throw e;
169
+ }
153
170
  }
154
171
  })
155
172
  .help()
@@ -177,12 +194,23 @@ function _configureLog4js(verbosity) {
177
194
  type: stdoutColor ? 'messagePassThrough' : 'passThroughNoColor',
178
195
  },
179
196
  },
197
+ [utils.CLI_LOGGER]: {
198
+ type: 'stderr',
199
+ layout: {
200
+ type: 'pattern',
201
+ pattern: stdoutColor ? '%[[%p]%] %m' : '[%p] %m',
202
+ },
203
+ },
180
204
  },
181
205
  categories: {
182
206
  default: { appenders: ['console'], level: _logLevel() },
207
+ [utils.CLI_LOGGER]: {
208
+ appenders: [utils.CLI_LOGGER],
209
+ level: _logLevel(),
210
+ },
183
211
  // The diagnostics logger must be set to INFO or more verbose, or watch won't show important messages
184
212
  [utils.DIAGNOSTICS]: {
185
- appenders: ['diagnostics'],
213
+ appenders: [utils.DIAGNOSTICS],
186
214
  level: _logLevel(Math.max(verbosity, 1)),
187
215
  },
188
216
  },
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAE9B,kCAAkC;AAClC,kCAAkC;AAClC,iCAAiC;AACjC,0DAA+D;AAC/D,+BAA+B;AAE/B,yCAAsC;AACtC,uDAAwD;AACxD,iDAAiD;AACjD,uCAAyD;AACzD,yCAA+D;AAC/D,iCAAiC;AACjC,uCAAoC;AACpC,yCAA6C;AAE7C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAElD,SAAS,cAAc,CACrB,OAAqC,EACrC,IAAY;IAKZ,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,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F,CAAC,CAAC;IAEH,SAAS,SAAS,CAAC,cAAc,GAAG,SAAS;QAC3C,QAAQ,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC;gBACJ,OAAO,MAAM,CAAC;YAChB,KAAK,CAAC;gBACJ,OAAO,MAAM,CAAC;YAChB,KAAK,CAAC;gBACJ,OAAO,OAAO,CAAC;YACjB,KAAK,CAAC;gBACJ,OAAO,OAAO,CAAC;YACjB;gBACE,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import '@jsii/check-node/run';\n\nimport * as path from 'node:path';\nimport * as util from 'node:util';\nimport * as log4js from 'log4js';\nimport { version as tsVersion } from 'typescript/package.json';\nimport * as yargs from 'yargs';\n\nimport { Compiler } from './compiler';\nimport { configureCategories } from './jsii-diagnostic';\nimport { loadProjectInfo } from './project-info';\nimport { emitSupportPolicyInformation } from './support';\nimport { TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport * as utils from './utils';\nimport { VERSION } from './version';\nimport { enabledWarnings } from './warnings';\n\nconst warningTypes = Object.keys(enabledWarnings);\n\nfunction choiceWithDesc(\n choices: { [choice: string]: string },\n desc: string,\n): {\n choices: string[];\n desc: string;\n} {\n return {\n choices: Object.keys(choices),\n desc: [desc, ...Object.entries(choices).map(([choice, docs]) => `${choice}: ${docs}`)].join('\\n'),\n };\n}\n\nenum OPTION_GROUP {\n JSII = 'jsii compiler options:',\n TS = 'TypeScript config options:',\n}\n\nconst ruleSets: {\n [choice in TypeScriptConfigValidationRuleSet]: string;\n} = {\n [TypeScriptConfigValidationRuleSet.STRICT]:\n 'Validates the provided config against a strict rule set designed for maximum backwards-compatibility.',\n [TypeScriptConfigValidationRuleSet.GENERATED]:\n 'Enforces a config as created by --generate-tsconfig. Use this to stay compatible with the generated config, but have full ownership over the file.',\n [TypeScriptConfigValidationRuleSet.MINIMAL]:\n 'Only enforce options that are known to be incompatible with jsii. This rule set is likely to be incomplete and new rules will be added without notice as incompatibilities emerge.',\n [TypeScriptConfigValidationRuleSet.NONE]:\n 'Disables all config validation, including options that are known to be incompatible with jsii. Intended for experimentation only. Use at your own risk.',\n};\n\n(async () => {\n await emitSupportPolicyInformation();\n\n await yargs\n .env('JSII')\n .command(\n ['$0 [PROJECT_ROOT]', 'compile [PROJECT_ROOT]'],\n 'Compiles a jsii/TypeScript project',\n (argv) =>\n argv\n .positional('PROJECT_ROOT', {\n type: 'string',\n desc: 'The root of the project to be compiled',\n default: '.',\n normalize: true,\n })\n .option('watch', {\n alias: 'w',\n type: 'boolean',\n desc: 'Watch for file changes and recompile automatically',\n })\n .option('project-references', {\n group: OPTION_GROUP.JSII,\n alias: 'r',\n type: 'boolean',\n desc: 'Generate TypeScript project references (also [package.json].jsii.projectReferences)\\nHas no effect if --tsconfig is provided',\n })\n .option('fix-peer-dependencies', {\n type: 'boolean',\n default: true,\n desc: 'This option no longer has any effect.',\n hidden: true,\n })\n .options('fail-on-warnings', {\n group: OPTION_GROUP.JSII,\n alias: 'Werr',\n type: 'boolean',\n desc: 'Treat warnings as errors',\n })\n .option('silence-warnings', {\n group: OPTION_GROUP.JSII,\n type: 'array',\n default: [],\n desc: `List of warnings to silence (warnings: ${warningTypes.join(',')})`,\n })\n .option('strip-deprecated', {\n group: OPTION_GROUP.JSII,\n type: 'string',\n desc: '[EXPERIMENTAL] Hides all @deprecated members from the API (implementations remain). If an optional file name is given, only FQNs present in the file will be stripped.',\n })\n .option('add-deprecation-warnings', {\n group: OPTION_GROUP.JSII,\n type: 'boolean',\n default: false,\n desc: '[EXPERIMENTAL] Injects warning statements for all deprecated elements, to be printed at runtime',\n })\n .option('generate-tsconfig', {\n group: OPTION_GROUP.TS,\n type: 'string',\n defaultDescription: 'tsconfig.json',\n desc: 'Name of the typescript configuration file to generate with compiler settings',\n })\n .option('tsconfig', {\n group: OPTION_GROUP.TS,\n alias: 'c',\n type: 'string',\n desc: '[EXPERIMENTAL] Use this typescript configuration file to compile the jsii project.',\n })\n .conflicts('tsconfig', ['generate-tsconfig', 'project-references'])\n .option('validate-tsconfig', {\n group: OPTION_GROUP.TS,\n ...choiceWithDesc(\n ruleSets,\n '[EXPERIMENTAL] Validate the provided typescript configuration file against a set of rules.',\n ),\n defaultDescription: TypeScriptConfigValidationRuleSet.STRICT,\n })\n .option('compress-assembly', {\n group: OPTION_GROUP.JSII,\n type: 'boolean',\n default: false,\n desc: 'Emit a compressed version of the assembly',\n })\n .option('verbose', {\n alias: 'v',\n type: 'count',\n desc: 'Increase the verbosity of output',\n global: true,\n }),\n async (argv) => {\n _configureLog4js(argv.verbose);\n\n if (argv['generate-tsconfig'] != null && argv.tsconfig != null) {\n throw new Error('Options --generate-tsconfig and --tsconfig are mutually exclusive');\n }\n\n const projectRoot = path.normalize(path.resolve(process.cwd(), argv.PROJECT_ROOT));\n\n const { projectInfo, diagnostics: projectInfoDiagnostics } = loadProjectInfo(projectRoot);\n\n // disable all silenced warnings\n for (const key of argv['silence-warnings']) {\n if (!(key in enabledWarnings)) {\n throw new Error(`Unknown warning type ${key as any}. Must be one of: ${warningTypes.join(', ')}`);\n }\n\n enabledWarnings[key] = false;\n }\n\n configureCategories(projectInfo.diagnostics ?? {});\n\n const typeScriptConfig = argv.tsconfig ?? projectInfo.packageJson.jsii?.tsconfig;\n const validateTypeScriptConfig =\n (argv['validate-tsconfig'] as TypeScriptConfigValidationRuleSet) ??\n projectInfo.packageJson.jsii?.validateTsconfig ??\n TypeScriptConfigValidationRuleSet.STRICT;\n\n const compiler = new Compiler({\n projectInfo,\n projectReferences: argv['project-references'],\n failOnWarnings: argv['fail-on-warnings'],\n stripDeprecated: argv['strip-deprecated'] != null,\n stripDeprecatedAllowListFile: argv['strip-deprecated'],\n addDeprecationWarnings: argv['add-deprecation-warnings'],\n generateTypeScriptConfig: argv['generate-tsconfig'],\n typeScriptConfig,\n validateTypeScriptConfig,\n compressAssembly: argv['compress-assembly'],\n });\n\n const emitResult = argv.watch ? await compiler.watch() : compiler.emit();\n\n const allDiagnostics = [...projectInfoDiagnostics, ...emitResult.diagnostics];\n\n for (const diagnostic of allDiagnostics) {\n utils.logDiagnostic(diagnostic, projectRoot);\n }\n if (emitResult.emitSkipped) {\n process.exitCode = 1;\n }\n },\n )\n .help()\n .version(`${VERSION}, typescript ${tsVersion}`)\n .parse();\n})().catch((e) => {\n console.error(`Error: ${e.stack}`);\n process.exitCode = -1;\n});\n\nfunction _configureLog4js(verbosity: number) {\n const stderrColor = !!process.stderr.isTTY;\n const stdoutColor = !!process.stdout.isTTY;\n\n log4js.addLayout('passThroughNoColor', () => {\n return (loggingEvent) => utils.stripAnsi(util.format(...loggingEvent.data));\n });\n\n log4js.configure({\n appenders: {\n console: {\n type: 'stderr',\n layout: { type: stderrColor ? 'colored' : 'basic' },\n },\n [utils.DIAGNOSTICS]: {\n type: 'stdout',\n layout: {\n type: stdoutColor ? 'messagePassThrough' : ('passThroughNoColor' as any),\n },\n },\n },\n categories: {\n default: { appenders: ['console'], level: _logLevel() },\n // The diagnostics logger must be set to INFO or more verbose, or watch won't show important messages\n [utils.DIAGNOSTICS]: {\n appenders: ['diagnostics'],\n level: _logLevel(Math.max(verbosity, 1)),\n },\n },\n });\n\n function _logLevel(verbosityLevel = verbosity): keyof log4js.Levels {\n switch (verbosityLevel) {\n case 0:\n return 'WARN';\n case 1:\n return 'INFO';\n case 2:\n return 'DEBUG';\n case 3:\n return 'TRACE';\n default:\n return 'ALL';\n }\n }\n}\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAE9B,kCAAkC;AAClC,kCAAkC;AAClC,iCAAiC;AACjC,0DAA+D;AAC/D,+BAA+B;AAE/B,yCAAsC;AACtC,uDAAwD;AACxD,iDAAiD;AACjD,uCAAyD;AACzD,yCAA+D;AAC/D,iCAAiC;AACjC,uCAAoC;AACpC,yCAA6C;AAE7C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAElD,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AAE,CAAC;YACvB,KAAK,CAAC;gBACJ,OAAO,MAAM,CAAC;YAChB,KAAK,CAAC;gBACJ,OAAO,MAAM,CAAC;YAChB,KAAK,CAAC;gBACJ,OAAO,OAAO,CAAC;YACjB,KAAK,CAAC;gBACJ,OAAO,OAAO,CAAC;YACjB;gBACE,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import '@jsii/check-node/run';\n\nimport * as path from 'node:path';\nimport * as util from 'node:util';\nimport * as log4js from 'log4js';\nimport { version as tsVersion } from 'typescript/package.json';\nimport * as yargs from 'yargs';\n\nimport { Compiler } from './compiler';\nimport { configureCategories } from './jsii-diagnostic';\nimport { loadProjectInfo } from './project-info';\nimport { emitSupportPolicyInformation } from './support';\nimport { TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport * as utils from './utils';\nimport { VERSION } from './version';\nimport { enabledWarnings } from './warnings';\n\nconst warningTypes = Object.keys(enabledWarnings);\n\nfunction choiceWithDesc(\n choices: { [choice: string]: string },\n desc: string,\n): {\n choices: string[];\n desc: string;\n} {\n return {\n choices: Object.keys(choices),\n desc: [desc, ...Object.entries(choices).map(([choice, docs]) => `${choice}: ${docs}`)].join('\\n'),\n };\n}\n\nenum OPTION_GROUP {\n JSII = 'jsii compiler options:',\n TS = 'TypeScript config options:',\n}\n\nconst ruleSets: {\n [choice in TypeScriptConfigValidationRuleSet]: string;\n} = {\n [TypeScriptConfigValidationRuleSet.STRICT]:\n 'Validates the provided config against a strict rule set designed for maximum backwards-compatibility.',\n [TypeScriptConfigValidationRuleSet.GENERATED]:\n 'Enforces a config as created by --generate-tsconfig. Use this to stay compatible with the generated config, but have full ownership over the file.',\n [TypeScriptConfigValidationRuleSet.MINIMAL]:\n 'Only enforce options that are known to be incompatible with jsii. This rule set is likely to be incomplete and new rules will be added without notice as incompatibilities emerge.',\n [TypeScriptConfigValidationRuleSet.NONE]:\n 'Disables all config validation, including options that are known to be incompatible with jsii. Intended for experimentation only. Use at your own risk.',\n};\n\n(async () => {\n await emitSupportPolicyInformation();\n\n await yargs\n .env('JSII')\n .command(\n ['$0 [PROJECT_ROOT]', 'compile [PROJECT_ROOT]'],\n 'Compiles a jsii/TypeScript project',\n (argv) =>\n argv\n .positional('PROJECT_ROOT', {\n type: 'string',\n desc: 'The root of the project to be compiled',\n default: '.',\n normalize: true,\n })\n .option('watch', {\n alias: 'w',\n type: 'boolean',\n desc: 'Watch for file changes and recompile automatically',\n })\n .option('project-references', {\n group: OPTION_GROUP.JSII,\n alias: 'r',\n type: 'boolean',\n desc: 'Generate TypeScript project references (also [package.json].jsii.projectReferences)\\nHas no effect if --tsconfig is provided',\n })\n .option('fix-peer-dependencies', {\n type: 'boolean',\n default: true,\n desc: 'This option no longer has any effect.',\n hidden: true,\n })\n .options('fail-on-warnings', {\n group: OPTION_GROUP.JSII,\n alias: 'Werr',\n type: 'boolean',\n desc: 'Treat warnings as errors',\n })\n .option('silence-warnings', {\n group: OPTION_GROUP.JSII,\n type: 'array',\n default: [],\n desc: `List of warnings to silence (warnings: ${warningTypes.join(',')})`,\n })\n .option('strip-deprecated', {\n group: OPTION_GROUP.JSII,\n type: 'string',\n desc: '[EXPERIMENTAL] Hides all @deprecated members from the API (implementations remain). If an optional file name is given, only FQNs present in the file will be stripped.',\n })\n .option('add-deprecation-warnings', {\n group: OPTION_GROUP.JSII,\n type: 'boolean',\n default: false,\n desc: '[EXPERIMENTAL] Injects warning statements for all deprecated elements, to be printed at runtime',\n })\n .option('generate-tsconfig', {\n group: OPTION_GROUP.TS,\n type: 'string',\n defaultDescription: 'tsconfig.json',\n desc: 'Name of the typescript configuration file to generate with compiler settings',\n })\n .option('tsconfig', {\n group: OPTION_GROUP.TS,\n alias: 'c',\n type: 'string',\n desc: '[EXPERIMENTAL] Use this typescript configuration file to compile the jsii project.',\n })\n .conflicts('tsconfig', ['generate-tsconfig', 'project-references'])\n .option('validate-tsconfig', {\n group: OPTION_GROUP.TS,\n ...choiceWithDesc(\n ruleSets,\n '[EXPERIMENTAL] Validate the provided typescript configuration file against a set of rules.',\n ),\n defaultDescription: TypeScriptConfigValidationRuleSet.STRICT,\n })\n .option('compress-assembly', {\n group: OPTION_GROUP.JSII,\n type: 'boolean',\n default: false,\n desc: 'Emit a compressed version of the assembly',\n })\n .option('verbose', {\n alias: 'v',\n type: 'count',\n desc: 'Increase the verbosity of output',\n global: true,\n }),\n async (argv) => {\n try {\n _configureLog4js(argv.verbose);\n\n if (argv['generate-tsconfig'] != null && argv.tsconfig != null) {\n throw new utils.JsiiError('Options --generate-tsconfig and --tsconfig are mutually exclusive', true);\n }\n\n const projectRoot = path.normalize(path.resolve(process.cwd(), argv.PROJECT_ROOT));\n\n const { projectInfo, diagnostics: projectInfoDiagnostics } = loadProjectInfo(projectRoot);\n\n // disable all silenced warnings\n for (const key of argv['silence-warnings']) {\n if (!(key in enabledWarnings)) {\n throw new utils.JsiiError(\n `Unknown warning type ${key as any}. Must be one of: ${warningTypes.join(', ')}`,\n );\n }\n\n enabledWarnings[key] = false;\n }\n\n configureCategories(projectInfo.diagnostics ?? {});\n\n const typeScriptConfig = argv.tsconfig ?? projectInfo.packageJson.jsii?.tsconfig;\n const validateTypeScriptConfig =\n (argv['validate-tsconfig'] as TypeScriptConfigValidationRuleSet) ??\n projectInfo.packageJson.jsii?.validateTsconfig ??\n TypeScriptConfigValidationRuleSet.STRICT;\n\n const compiler = new Compiler({\n projectInfo,\n projectReferences: argv['project-references'],\n failOnWarnings: argv['fail-on-warnings'],\n stripDeprecated: argv['strip-deprecated'] != null,\n stripDeprecatedAllowListFile: argv['strip-deprecated'],\n addDeprecationWarnings: argv['add-deprecation-warnings'],\n generateTypeScriptConfig: argv['generate-tsconfig'],\n typeScriptConfig,\n validateTypeScriptConfig,\n compressAssembly: argv['compress-assembly'],\n });\n\n const emitResult = argv.watch ? await compiler.watch() : compiler.emit();\n\n const allDiagnostics = [...projectInfoDiagnostics, ...emitResult.diagnostics];\n\n for (const diagnostic of allDiagnostics) {\n utils.logDiagnostic(diagnostic, projectRoot);\n }\n if (emitResult.emitSkipped) {\n process.exitCode = 1;\n }\n } catch (e: unknown) {\n if (e instanceof utils.JsiiError) {\n if (e.showHelp) {\n console.log();\n yargs.showHelp();\n console.log();\n }\n\n const LOG = log4js.getLogger(utils.CLI_LOGGER);\n LOG.error(e.message);\n\n process.exitCode = -1;\n } else {\n throw e;\n }\n }\n },\n )\n .help()\n .version(`${VERSION}, typescript ${tsVersion}`)\n .parse();\n})().catch((e) => {\n console.error(`Error: ${e.stack}`);\n process.exitCode = -1;\n});\n\nfunction _configureLog4js(verbosity: number) {\n const stderrColor = !!process.stderr.isTTY;\n const stdoutColor = !!process.stdout.isTTY;\n\n log4js.addLayout('passThroughNoColor', () => {\n return (loggingEvent) => utils.stripAnsi(util.format(...loggingEvent.data));\n });\n\n log4js.configure({\n appenders: {\n console: {\n type: 'stderr',\n layout: { type: stderrColor ? 'colored' : 'basic' },\n },\n\n [utils.DIAGNOSTICS]: {\n type: 'stdout',\n layout: {\n type: stdoutColor ? 'messagePassThrough' : ('passThroughNoColor' as any),\n },\n },\n [utils.CLI_LOGGER]: {\n type: 'stderr',\n layout: {\n type: 'pattern',\n pattern: stdoutColor ? '%[[%p]%] %m' : '[%p] %m',\n },\n },\n },\n categories: {\n default: { appenders: ['console'], level: _logLevel() },\n [utils.CLI_LOGGER]: {\n appenders: [utils.CLI_LOGGER],\n level: _logLevel(),\n },\n // The diagnostics logger must be set to INFO or more verbose, or watch won't show important messages\n [utils.DIAGNOSTICS]: {\n appenders: [utils.DIAGNOSTICS],\n level: _logLevel(Math.max(verbosity, 1)),\n },\n },\n });\n\n function _logLevel(verbosityLevel = verbosity): keyof log4js.Levels {\n switch (verbosityLevel) {\n case 0:\n return 'WARN';\n case 1:\n return 'INFO';\n case 2:\n return 'DEBUG';\n case 3:\n return 'TRACE';\n default:\n return 'ALL';\n }\n }\n}\n"]}