jsii 5.4.16-dev.2 → 5.4.16-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/case.d.ts +1 -0
- package/lib/case.js +2 -1
- package/lib/case.js.map +1 -1
- package/lib/compiler.d.ts +38 -14
- package/lib/compiler.js +114 -108
- package/lib/compiler.js.map +1 -1
- package/lib/jsii-diagnostic.d.ts +3 -0
- package/lib/jsii-diagnostic.js +15 -1
- package/lib/jsii-diagnostic.js.map +1 -1
- package/lib/main.js +45 -2
- package/lib/main.js.map +1 -1
- package/lib/project-info.d.ts +5 -0
- package/lib/project-info.js +13 -0
- package/lib/project-info.js.map +1 -1
- package/lib/tsconfig/compiler-options.d.ts +54 -0
- package/lib/tsconfig/compiler-options.js +136 -0
- package/lib/tsconfig/compiler-options.js.map +1 -0
- package/lib/tsconfig/index.d.ts +18 -0
- package/lib/tsconfig/index.js +11 -0
- package/lib/tsconfig/index.js.map +1 -0
- package/lib/tsconfig/rulesets/configurable.d.ts +4 -0
- package/lib/tsconfig/rulesets/configurable.js +22 -0
- package/lib/tsconfig/rulesets/configurable.js.map +1 -0
- package/lib/tsconfig/rulesets/generated.public.d.ts +4 -0
- package/lib/tsconfig/rulesets/generated.public.js +28 -0
- package/lib/tsconfig/rulesets/generated.public.js.map +1 -0
- package/lib/tsconfig/rulesets/incompatible-options.d.ts +4 -0
- package/lib/tsconfig/rulesets/incompatible-options.js +11 -0
- package/lib/tsconfig/rulesets/incompatible-options.js.map +1 -0
- package/lib/tsconfig/rulesets/minimal.public.d.ts +4 -0
- package/lib/tsconfig/rulesets/minimal.public.js +11 -0
- package/lib/tsconfig/rulesets/minimal.public.js.map +1 -0
- package/lib/tsconfig/rulesets/strict.public.d.ts +4 -0
- package/lib/tsconfig/rulesets/strict.public.js +29 -0
- package/lib/tsconfig/rulesets/strict.public.js.map +1 -0
- package/lib/tsconfig/tsconfig-validator.d.ts +16 -0
- package/lib/tsconfig/tsconfig-validator.js +46 -0
- package/lib/tsconfig/tsconfig-validator.js.map +1 -0
- package/lib/tsconfig/validator.d.ts +155 -0
- package/lib/tsconfig/validator.js +301 -0
- package/lib/tsconfig/validator.js.map +1 -0
- package/lib/version.d.ts +2 -2
- package/lib/version.js +2 -2
- package/lib/version.js.map +1 -1
- package/package.json +2 -1
package/lib/main.js
CHANGED
|
@@ -10,10 +10,28 @@ const compiler_1 = require("./compiler");
|
|
|
10
10
|
const jsii_diagnostic_1 = require("./jsii-diagnostic");
|
|
11
11
|
const project_info_1 = require("./project-info");
|
|
12
12
|
const support_1 = require("./support");
|
|
13
|
+
const tsconfig_1 = require("./tsconfig");
|
|
13
14
|
const utils = require("./utils");
|
|
14
15
|
const version_1 = require("./version");
|
|
15
16
|
const warnings_1 = require("./warnings");
|
|
16
17
|
const warningTypes = Object.keys(warnings_1.enabledWarnings);
|
|
18
|
+
function choiceWithDesc(choices, desc) {
|
|
19
|
+
return {
|
|
20
|
+
choices: Object.keys(choices),
|
|
21
|
+
desc: [desc, ...Object.entries(choices).map(([choice, docs]) => `${choice}: ${docs}`)].join('\n'),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var OPTION_GROUP;
|
|
25
|
+
(function (OPTION_GROUP) {
|
|
26
|
+
OPTION_GROUP["JSII"] = "jsii compiler options:";
|
|
27
|
+
OPTION_GROUP["TS"] = "TypeScript config options:";
|
|
28
|
+
})(OPTION_GROUP || (OPTION_GROUP = {}));
|
|
29
|
+
const ruleSets = {
|
|
30
|
+
[tsconfig_1.TypeScriptConfigValidationRuleSet.STRICT]: 'Validates the provided config against a strict rule set designed for maximum backwards-compatibility.',
|
|
31
|
+
[tsconfig_1.TypeScriptConfigValidationRuleSet.GENERATED]: 'Enforces a config as created by --generate-tsconfig. Use this to stay compatible with the generated config, but have full ownership over the file.',
|
|
32
|
+
[tsconfig_1.TypeScriptConfigValidationRuleSet.MINIMAL]: '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.',
|
|
33
|
+
[tsconfig_1.TypeScriptConfigValidationRuleSet.NONE]: 'Disables all config validation, including options that are known to be incompatible with jsii. Intended for experimentation only. Use at your own risk.',
|
|
34
|
+
};
|
|
17
35
|
(async () => {
|
|
18
36
|
await (0, support_1.emitSupportPolicyInformation)();
|
|
19
37
|
await yargs
|
|
@@ -31,9 +49,10 @@ const warningTypes = Object.keys(warnings_1.enabledWarnings);
|
|
|
31
49
|
desc: 'Watch for file changes and recompile automatically',
|
|
32
50
|
})
|
|
33
51
|
.option('project-references', {
|
|
52
|
+
group: OPTION_GROUP.JSII,
|
|
34
53
|
alias: 'r',
|
|
35
54
|
type: 'boolean',
|
|
36
|
-
desc: 'Generate TypeScript project references (also [package.json].jsii.projectReferences)',
|
|
55
|
+
desc: 'Generate TypeScript project references (also [package.json].jsii.projectReferences)\nHas no effect if --tsconfig is provided',
|
|
37
56
|
})
|
|
38
57
|
.option('fix-peer-dependencies', {
|
|
39
58
|
type: 'boolean',
|
|
@@ -42,30 +61,48 @@ const warningTypes = Object.keys(warnings_1.enabledWarnings);
|
|
|
42
61
|
hidden: true,
|
|
43
62
|
})
|
|
44
63
|
.options('fail-on-warnings', {
|
|
64
|
+
group: OPTION_GROUP.JSII,
|
|
45
65
|
alias: 'Werr',
|
|
46
66
|
type: 'boolean',
|
|
47
67
|
desc: 'Treat warnings as errors',
|
|
48
68
|
})
|
|
49
69
|
.option('silence-warnings', {
|
|
70
|
+
group: OPTION_GROUP.JSII,
|
|
50
71
|
type: 'array',
|
|
51
72
|
default: [],
|
|
52
73
|
desc: `List of warnings to silence (warnings: ${warningTypes.join(',')})`,
|
|
53
74
|
})
|
|
54
75
|
.option('strip-deprecated', {
|
|
76
|
+
group: OPTION_GROUP.JSII,
|
|
55
77
|
type: 'string',
|
|
56
78
|
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.',
|
|
57
79
|
})
|
|
58
80
|
.option('add-deprecation-warnings', {
|
|
81
|
+
group: OPTION_GROUP.JSII,
|
|
59
82
|
type: 'boolean',
|
|
60
83
|
default: false,
|
|
61
84
|
desc: '[EXPERIMENTAL] Injects warning statements for all deprecated elements, to be printed at runtime',
|
|
62
85
|
})
|
|
63
86
|
.option('generate-tsconfig', {
|
|
87
|
+
group: OPTION_GROUP.TS,
|
|
64
88
|
type: 'string',
|
|
65
|
-
|
|
89
|
+
defaultDescription: 'tsconfig.json',
|
|
66
90
|
desc: 'Name of the typescript configuration file to generate with compiler settings',
|
|
91
|
+
})
|
|
92
|
+
.option('tsconfig', {
|
|
93
|
+
group: OPTION_GROUP.TS,
|
|
94
|
+
alias: 'c',
|
|
95
|
+
type: 'string',
|
|
96
|
+
desc: '[EXPERIMENTAL] Use this typescript configuration file to compile the jsii project.',
|
|
97
|
+
})
|
|
98
|
+
.conflicts('tsconfig', ['generate-tsconfig', 'project-references'])
|
|
99
|
+
.option('validate-tsconfig', {
|
|
100
|
+
group: OPTION_GROUP.TS,
|
|
101
|
+
...choiceWithDesc(ruleSets, '[EXPERIMENTAL] Validate the provided typescript configuration file against a set of rules.'),
|
|
102
|
+
default: tsconfig_1.TypeScriptConfigValidationRuleSet.STRICT,
|
|
67
103
|
})
|
|
68
104
|
.option('compress-assembly', {
|
|
105
|
+
group: OPTION_GROUP.JSII,
|
|
69
106
|
type: 'boolean',
|
|
70
107
|
default: false,
|
|
71
108
|
desc: 'Emit a compressed version of the assembly',
|
|
@@ -77,6 +114,9 @@ const warningTypes = Object.keys(warnings_1.enabledWarnings);
|
|
|
77
114
|
global: true,
|
|
78
115
|
}), async (argv) => {
|
|
79
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
|
+
}
|
|
80
120
|
const projectRoot = path.normalize(path.resolve(process.cwd(), argv.PROJECT_ROOT));
|
|
81
121
|
const { projectInfo, diagnostics: projectInfoDiagnostics } = (0, project_info_1.loadProjectInfo)(projectRoot);
|
|
82
122
|
// disable all silenced warnings
|
|
@@ -95,6 +135,9 @@ const warningTypes = Object.keys(warnings_1.enabledWarnings);
|
|
|
95
135
|
stripDeprecatedAllowListFile: argv['strip-deprecated'],
|
|
96
136
|
addDeprecationWarnings: argv['add-deprecation-warnings'],
|
|
97
137
|
generateTypeScriptConfig: argv['generate-tsconfig'],
|
|
138
|
+
typeScriptConfig: argv.tsconfig ?? projectInfo.packageJson.jsii?.tsconfig,
|
|
139
|
+
validateTypeScriptConfig: argv['validate-tsconfig'] ??
|
|
140
|
+
projectInfo.packageJson.jsii?.validateTsConfig,
|
|
98
141
|
compressAssembly: argv['compress-assembly'],
|
|
99
142
|
});
|
|
100
143
|
const emitResult = argv.watch ? await compiler.watch() : compiler.emit();
|
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,iCAAiC;AACjC,uCAAoC;AACpC,yCAA6C;AAE7C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAElD,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,IAAA,sCAA4B,GAAE,CAAC;IAErC,MAAM,KAAK;SACR,GAAG,CAAC,MAAM,CAAC;SACX,OAAO,CACN,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,EAC/C,oCAAoC,EACpC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI;SACD,UAAU,CAAC,cAAc,EAAE;QAC1B,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,wCAAwC;QAC9C,OAAO,EAAE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AAI,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE;aACpD;YACD,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;gBACnB,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACN,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAE,oBAA4B;iBACzE;aACF;SACF;QACD,UAAU,EAAE;YACV,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YACvD,qGAAqG;YACrG,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;gBACnB,SAAS,EAAE,CAAC,aAAa,CAAC;gBAC1B,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;aACzC;SACF;KACF,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 * as utils from './utils';\nimport { VERSION } from './version';\nimport { enabledWarnings } from './warnings';\n\nconst warningTypes = Object.keys(enabledWarnings);\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 alias: 'r',\n type: 'boolean',\n desc: 'Generate TypeScript project references (also [package.json].jsii.projectReferences)',\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 alias: 'Werr',\n type: 'boolean',\n desc: 'Treat warnings as errors',\n })\n .option('silence-warnings', {\n type: 'array',\n default: [],\n desc: `List of warnings to silence (warnings: ${warningTypes.join(',')})`,\n })\n .option('strip-deprecated', {\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 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 type: 'string',\n default: 'tsconfig.json',\n desc: 'Name of the typescript configuration file to generate with compiler settings',\n })\n .option('compress-assembly', {\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 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 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 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
|
+
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AAC,KAAK,CAAC,WAAW,CAAC,EAAE;gBACnB,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACN,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAE,oBAA4B;iBACzE;aACF;SACF;QACD,UAAU,EAAE;YACV,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YACvD,qGAAqG;YACrG,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;gBACnB,SAAS,EAAE,CAAC,aAAa,CAAC;gBAC1B,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;aACzC;SACF;KACF,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 default: 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 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: argv.tsconfig ?? projectInfo.packageJson.jsii?.tsconfig,\n validateTypeScriptConfig:\n (argv['validate-tsconfig'] as TypeScriptConfigValidationRuleSet) ??\n projectInfo.packageJson.jsii?.validateTsConfig,\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"]}
|
package/lib/project-info.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as spec from '@jsii/spec';
|
|
2
2
|
import * as ts from 'typescript';
|
|
3
|
+
import { TypeScriptConfigValidationRuleSet } from './tsconfig';
|
|
3
4
|
export type TSCompilerOptions = Partial<Pick<ts.CompilerOptions, 'outDir' | 'rootDir' | 'baseUrl' | 'paths' | 'forceConsistentCasingInFileNames' | 'noImplicitOverride' | 'noPropertyAccessFromIndexSignature' | 'noUncheckedIndexedAccess' | 'declarationMap' | 'inlineSourceMap' | 'inlineSources' | 'sourceMap' | 'types'>>;
|
|
4
5
|
export interface ProjectInfo {
|
|
5
6
|
readonly projectRoot: string;
|
|
@@ -50,6 +51,8 @@ export interface ProjectInfo {
|
|
|
50
51
|
readonly [name: string]: string;
|
|
51
52
|
};
|
|
52
53
|
};
|
|
54
|
+
readonly tsconfig?: string;
|
|
55
|
+
readonly validateTsConfig?: TypeScriptConfigValidationRuleSet;
|
|
53
56
|
}
|
|
54
57
|
export interface PackageJson {
|
|
55
58
|
readonly description?: string;
|
|
@@ -102,6 +105,8 @@ export interface PackageJson {
|
|
|
102
105
|
readonly [name: string]: unknown;
|
|
103
106
|
};
|
|
104
107
|
readonly versionFormat?: 'short' | 'full';
|
|
108
|
+
readonly tsconfig?: string;
|
|
109
|
+
readonly validateTsConfig?: string;
|
|
105
110
|
readonly excludeTypescript?: readonly string[];
|
|
106
111
|
readonly projectReferences?: boolean;
|
|
107
112
|
readonly tsc?: TSCompilerOptions;
|
package/lib/project-info.js
CHANGED
|
@@ -10,6 +10,7 @@ const semver = require("semver");
|
|
|
10
10
|
const ts = require("typescript");
|
|
11
11
|
const find_utils_1 = require("./common/find-utils");
|
|
12
12
|
const jsii_diagnostic_1 = require("./jsii-diagnostic");
|
|
13
|
+
const tsconfig_1 = require("./tsconfig");
|
|
13
14
|
const utils_1 = require("./utils");
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
15
16
|
const spdx = require('spdx-license-list/simple');
|
|
@@ -103,6 +104,9 @@ function loadProjectInfo(projectRoot) {
|
|
|
103
104
|
bin: pkg.bin,
|
|
104
105
|
exports: pkg.exports,
|
|
105
106
|
diagnostics: _loadDiagnostics(pkg.jsii?.diagnostics),
|
|
107
|
+
// user-provided tsconfig
|
|
108
|
+
tsconfig: pkg.jsii?.tsconfig,
|
|
109
|
+
validateTsConfig: _validateTsConfigRuleSet(pkg.jsii?.validateTsConfig ?? 'strict'),
|
|
106
110
|
};
|
|
107
111
|
return { projectInfo, diagnostics };
|
|
108
112
|
}
|
|
@@ -293,6 +297,15 @@ function _validateStability(stability, deprecated) {
|
|
|
293
297
|
}
|
|
294
298
|
return stability;
|
|
295
299
|
}
|
|
300
|
+
function _validateTsConfigRuleSet(ruleSet) {
|
|
301
|
+
if (ruleSet == null) {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
if (!Object.values(tsconfig_1.TypeScriptConfigValidationRuleSet).includes(ruleSet)) {
|
|
305
|
+
throw new Error(`Invalid validateTsConfig "${ruleSet}", it must be one of ${Object.values(tsconfig_1.TypeScriptConfigValidationRuleSet).join(', ')}`);
|
|
306
|
+
}
|
|
307
|
+
return ruleSet;
|
|
308
|
+
}
|
|
296
309
|
/**
|
|
297
310
|
* Resolves an NPM package specifier to a version range
|
|
298
311
|
*
|
package/lib/project-info.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-info.js","sourceRoot":"","sources":["../src/project-info.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAClC,mCAAmC;AACnC,qCAAoE;AACpE,iCAAiC;AACjC,iCAAiC;AACjC,iCAAiC;AAEjC,oDAA8D;AAC9D,uDAAmD;AACnD,mCAAuD;AAEvD,qGAAqG;AACrG,MAAM,IAAI,GAAgB,OAAO,CA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import * as path from 'node:path';\nimport * as spec from '@jsii/spec';\nimport { findAssemblyFile, loadAssemblyFromFile } from '@jsii/spec';\nimport * as log4js from 'log4js';\nimport * as semver from 'semver';\nimport * as ts from 'typescript';\n\nimport { findDependencyDirectory } from './common/find-utils';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport { parsePerson, parseRepository } from './utils';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\nconst spdx: Set<string> = require('spdx-license-list/simple');\n\nconst LOG = log4js.getLogger('jsii/package-info');\n\nexport type TSCompilerOptions = Partial<\n Pick<\n ts.CompilerOptions,\n // Directory preferences\n | 'outDir'\n | 'rootDir'\n // TypeScript path mapping\n | 'baseUrl'\n | 'paths'\n // Style preferences\n | 'forceConsistentCasingInFileNames'\n | 'noImplicitOverride'\n | 'noPropertyAccessFromIndexSignature'\n | 'noUncheckedIndexedAccess'\n // Source map preferences\n | 'declarationMap'\n | 'inlineSourceMap'\n | 'inlineSources'\n | 'sourceMap'\n // Types limitations\n | 'types'\n >\n>;\n\nexport interface ProjectInfo {\n readonly projectRoot: string;\n readonly packageJson: PackageJson;\n\n readonly name: string;\n readonly version: string;\n readonly author: spec.Person;\n readonly deprecated?: string;\n readonly stability?: spec.Stability;\n readonly license: string;\n readonly repository: {\n readonly type: string;\n readonly url: string;\n readonly directory?: string;\n };\n readonly keywords?: readonly string[];\n\n readonly main: string;\n readonly types: string;\n\n readonly dependencies: { readonly [name: string]: string };\n readonly peerDependencies: { readonly [name: string]: string };\n readonly dependencyClosure: readonly spec.Assembly[];\n readonly bundleDependencies?: { readonly [name: string]: string };\n readonly targets: spec.AssemblyTargets;\n readonly metadata?: { readonly [key: string]: any };\n readonly jsiiVersionFormat: 'short' | 'full';\n readonly diagnostics?: { readonly [code: string]: ts.DiagnosticCategory };\n readonly description?: string;\n readonly homepage?: string;\n readonly contributors?: readonly spec.Person[];\n readonly excludeTypescript: readonly string[];\n readonly projectReferences?: boolean;\n readonly tsc?: TSCompilerOptions;\n readonly bin?: { readonly [name: string]: string };\n readonly exports?: {\n readonly [name: string]: string | { readonly [name: string]: string };\n };\n}\n\nexport interface PackageJson {\n readonly description?: string;\n readonly homepage?: string;\n readonly name?: string;\n readonly version?: string;\n readonly keywords?: readonly string[];\n readonly license?: string;\n readonly private?: boolean;\n\n readonly exports?: { readonly [path: string]: string | { readonly [name: string]: string } };\n readonly main?: string;\n readonly types?: string;\n /**\n * @example { \"<4.0\": { \"*\": [\"ts3.9/*\"] } }\n * @example { \"<4.0\": { \"index.d.ts\": [\"index.ts3-9.d.ts\"] } }\n */\n readonly typesVersions?: {\n readonly [versionRange: string]: { readonly [pattern: string]: readonly string[] };\n };\n\n readonly bin?: { readonly [name: string]: string };\n\n readonly stability?: string;\n readonly deprecated?: string;\n\n readonly dependencies?: { readonly [name: string]: string };\n readonly devDependencies?: { readonly [name: string]: string };\n readonly peerDependencies?: { readonly [name: string]: string };\n\n readonly bundleDependencies?: readonly string[];\n readonly bundledDependencies?: readonly string[];\n\n readonly jsii?: {\n readonly diagnostics?: { readonly [id: string]: 'error' | 'warning' | 'suggestion' | 'message' };\n readonly metadata?: { readonly [key: string]: unknown };\n readonly targets?: { readonly [name: string]: unknown };\n readonly versionFormat?: 'short' | 'full';\n\n readonly excludeTypescript?: readonly string[];\n readonly projectReferences?: boolean;\n readonly tsc?: TSCompilerOptions;\n\n readonly [key: string]: unknown;\n };\n\n readonly [key: string]: unknown;\n}\n\nexport interface ProjectInfoResult {\n readonly projectInfo: ProjectInfo;\n readonly diagnostics: readonly ts.Diagnostic[];\n}\n\nexport function loadProjectInfo(projectRoot: string): ProjectInfoResult {\n const packageJsonPath = path.join(projectRoot, 'package.json');\n const pkg: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n\n const diagnostics: ts.Diagnostic[] = [];\n\n let bundleDependencies: { [name: string]: string } | undefined;\n for (const name of pkg.bundleDependencies ?? pkg.bundledDependencies ?? []) {\n const version = pkg.dependencies?.[name];\n if (!version) {\n throw new Error(\n `The \"package.json\" file has \"${name}\" in \"bundleDependencies\", but it is not declared in \"dependencies\"`,\n );\n }\n\n if (pkg.peerDependencies && name in pkg.peerDependencies) {\n throw new Error(`The \"package.json\" file has \"${name}\" in \"bundleDependencies\", and also in \"peerDependencies\"`);\n }\n\n bundleDependencies = bundleDependencies ?? {};\n bundleDependencies[name] = _resolveVersion(version, projectRoot).version;\n }\n\n // Check peerDependencies are also in devDependencies\n // You need this to write tests properly. There are probably cases where\n // it makes sense to have this different, so most of what this checking\n // produces is warnings, not errors.\n const devDependencies = pkg.devDependencies ?? {};\n for (const [name, rng] of Object.entries(pkg.peerDependencies ?? {})) {\n const range = new semver.Range(_resolveVersion(rng as string, projectRoot).version);\n const minVersion = semver.minVersion(range)?.raw;\n\n if (!(name in devDependencies) || devDependencies[name] !== `${minVersion}`) {\n diagnostics.push(\n JsiiDiagnostic.JSII_0006_MISSING_DEV_DEPENDENCY.createDetached(\n name,\n `${rng as any}`,\n `${minVersion}`,\n `${devDependencies[name]}`,\n ),\n );\n continue;\n }\n }\n\n const bundled = new Set(Object.keys(bundleDependencies ?? {}));\n const dependencies: Record<string, string> = filterDictByKey(\n pkg.dependencies ?? {},\n (depName) => !bundled.has(depName),\n );\n const peerDependencies: Record<string, string> = pkg.peerDependencies ?? {};\n\n const resolver = new DependencyResolver();\n const resolved = resolver.discoverDependencyTree(projectRoot, {\n ...dependencies,\n ...peerDependencies,\n });\n const transitiveDependencies = resolver.assemblyClosure(resolved);\n\n const metadata = mergeMetadata(\n {\n jsii: {\n pacmak: {\n // When `true`, `jsii-pacmak` will use the `Jsii$Default` implementation in code generation even for dependencies.\n hasDefaultInterfaces: true,\n },\n },\n },\n pkg.jsii?.metadata,\n );\n\n const projectInfo: ProjectInfo = {\n projectRoot,\n packageJson: pkg,\n\n name: _required(pkg.name, 'The \"package.json\" file must specify the \"name\" attribute'),\n version: _required(pkg.version, 'The \"package.json\" file must specify the \"version\" attribute'),\n deprecated: pkg.deprecated,\n stability: _validateStability(pkg.stability, pkg.deprecated),\n author: _toPerson(_required(pkg.author, 'The \"package.json\" file must specify the \"author\" attribute'), 'author'),\n repository: _toRepository(\n _required(pkg.repository, 'The \"package.json\" file must specify the \"repository\" attribute'),\n ),\n license: _validateLicense(pkg.license),\n keywords: pkg.keywords,\n\n main: _required(pkg.main, 'The \"package.json\" file must specify the \"main\" attribute'),\n types: _required(pkg.types, 'The \"package.json\" file must specify the \"types\" attribute'),\n\n dependencies,\n peerDependencies,\n dependencyClosure: transitiveDependencies,\n bundleDependencies,\n targets: {\n ..._required(pkg.jsii, 'The \"package.json\" file must specify the \"jsii\" attribute').targets,\n js: { npm: pkg.name },\n },\n metadata,\n jsiiVersionFormat: _validateVersionFormat(pkg.jsii?.versionFormat ?? 'full'),\n\n description: pkg.description,\n homepage: pkg.homepage,\n contributors: (pkg.contributors as any[])?.map((contrib, index) =>\n _toPerson(contrib, `contributors[${index}]`, 'contributor'),\n ),\n\n excludeTypescript: pkg.jsii?.excludeTypescript ?? [],\n projectReferences: pkg.jsii?.projectReferences,\n tsc: {\n outDir: pkg.jsii?.tsc?.outDir,\n rootDir: pkg.jsii?.tsc?.rootDir,\n baseUrl: pkg.jsii?.tsc?.baseUrl,\n paths: pkg.jsii?.tsc?.paths,\n forceConsistentCasingInFileNames: pkg.jsii?.tsc?.forceConsistentCasingInFileNames,\n noImplicitOverride: pkg.jsii?.tsc?.noImplicitOverride,\n noPropertyAccessFromIndexSignature: pkg.jsii?.tsc?.noPropertyAccessFromIndexSignature,\n noUncheckedIndexedAccess: pkg.jsii?.tsc?.noUncheckedIndexedAccess,\n ..._sourceMapPreferences(pkg.jsii?.tsc),\n types: pkg.jsii?.tsc?.types,\n },\n bin: pkg.bin,\n exports: pkg.exports,\n diagnostics: _loadDiagnostics(pkg.jsii?.diagnostics),\n };\n return { projectInfo, diagnostics };\n}\n\nfunction _guessRepositoryType(url: string): string {\n if (url.endsWith('.git')) {\n return 'git';\n }\n const parts = /^([^:]+):\\/\\//.exec(url);\n if (parts?.[1] !== 'http' && parts?.[1] !== 'https') {\n return parts![1];\n }\n throw new Error(`The \"package.json\" file must specify the \"repository.type\" attribute (could not guess from ${url})`);\n}\n\nfunction _sourceMapPreferences({ declarationMap, inlineSourceMap, inlineSources, sourceMap }: TSCompilerOptions = {}) {\n // If none of the options are specified, use the default configuration from jsii <= 1.58.0, which\n // means inline source maps with embedded source information.\n if (declarationMap == null && inlineSourceMap == null && inlineSources == null && sourceMap == null) {\n declarationMap = false;\n inlineSourceMap = true;\n inlineSources = true;\n sourceMap = undefined;\n }\n\n return {\n declarationMap,\n inlineSourceMap,\n inlineSources,\n sourceMap,\n };\n}\n\ninterface DependencyInfo {\n readonly assembly: spec.Assembly;\n readonly resolvedDependencies: Record<string, string>;\n}\n\nclass DependencyResolver {\n private readonly cache = new Map<string, DependencyInfo>();\n\n /**\n * Discover the dependency tree starting at 'root', validating versions as we go along\n *\n * This primes the data structures in this class and should be called first.\n *\n * Return the resolved jsii dependency paths\n */\n public discoverDependencyTree(root: string, dependencies: Record<string, string>): Record<string, string> {\n const ret: Record<string, string> = {};\n for (const [name, declaration] of Object.entries(dependencies)) {\n // eslint-disable-next-line no-await-in-loop\n let resolved;\n try {\n resolved = this.resolveDependency(root, name, declaration);\n } catch (e) {\n LOG.error(\n `Unable to find a JSII dependency named \"${name}\" as \"${declaration}\". If you meant to include a non-JSII dependency, try adding it to bundledDependencies instead.`,\n );\n throw e;\n }\n\n const actualVersion = resolved.dependencyInfo.assembly.version;\n if (!semver.satisfies(actualVersion, declaration)) {\n throw new Error(\n `Declared dependency on version ${declaration} of ${name}, but version ${actualVersion} was found`,\n );\n }\n\n ret[name] = resolved.resolvedFile;\n }\n return ret;\n }\n\n /**\n * From a set of resolved paths, recursively return all assemblies\n */\n public assemblyClosure(resolved: Record<string, string>): spec.Assembly[] {\n const closure = new Map<string, spec.Assembly>();\n const queue = Array.from(Object.values(resolved));\n while (queue.length > 0) {\n const next = queue.shift()!;\n const depInfo = this.cache.get(next);\n if (!depInfo) {\n throw new Error(`Path ${next} not seen before`);\n }\n if (closure.has(next)) {\n continue;\n }\n\n closure.set(next, depInfo.assembly);\n queue.push(...Object.values(depInfo.resolvedDependencies));\n }\n return Array.from(closure.values());\n }\n\n private resolveDependency(root: string, name: string, declaration: string) {\n const { version: versionString, localPackage } = _resolveVersion(declaration, root);\n const version = new semver.Range(versionString);\n if (!version) {\n throw new Error(`Invalid semver expression for ${name}: ${versionString}`);\n }\n const jsiiFile = _tryResolveAssembly(name, localPackage, root);\n LOG.debug(`Resolved dependency ${name} to ${jsiiFile}`);\n return {\n resolvedVersion: versionString,\n resolvedFile: jsiiFile,\n dependencyInfo: this.loadAssemblyAndRecurse(jsiiFile),\n };\n }\n\n private loadAssemblyAndRecurse(jsiiFile: string) {\n // Only recurse if we haven't seen this assembly yet\n if (this.cache.has(jsiiFile)) {\n return this.cache.get(jsiiFile)!;\n }\n\n const assembly = loadAssemblyFromFile(jsiiFile);\n\n // Continue loading any dependencies declared in the asm\n const resolvedDependencies = assembly.dependencies\n ? this.discoverDependencyTree(path.dirname(jsiiFile), assembly.dependencies)\n : {};\n\n const depInfo: DependencyInfo = {\n assembly,\n resolvedDependencies,\n };\n this.cache.set(jsiiFile, depInfo);\n return depInfo;\n }\n}\n\nfunction _required<T>(value: T | undefined, message: string): T {\n if (value == null) {\n throw new Error(message);\n }\n return value;\n}\n\nfunction _toPerson(value: any, field: string, defaultRole: string = field): spec.Person {\n if (typeof value === 'string') {\n value = parsePerson(value);\n }\n return {\n name: _required(value.name, `The \"package.json\" file must specify the \"${field}.name\" attribute`),\n roles: value.roles ? [...new Set(value.roles as string[])] : [defaultRole],\n email: value.email,\n url: value.url,\n organization: value.organization ? value.organization : undefined,\n };\n}\n\nfunction _toRepository(value: any): {\n type: string;\n url: string;\n directory?: string;\n} {\n if (typeof value === 'string') {\n value = parseRepository(value);\n }\n return {\n url: _required(value.url, 'The \"package.json\" file must specify the \"repository.url\" attribute'),\n type: value.type || _guessRepositoryType(value.url),\n directory: value.directory,\n };\n}\n\nfunction _tryResolveAssembly(mod: string, localPackage: string | undefined, searchPath: string): string {\n if (localPackage) {\n const result = findAssemblyFile(localPackage);\n if (!fs.existsSync(result)) {\n throw new Error(`Assembly does not exist: ${result}`);\n }\n return result;\n }\n try {\n const dependencyDir = findDependencyDirectory(mod, searchPath);\n return findAssemblyFile(dependencyDir);\n } catch (e: any) {\n throw new Error(\n `Unable to locate jsii assembly for \"${mod}\". If this module is not jsii-enabled, it must also be declared under bundledDependencies: ${e}`,\n );\n }\n}\n\nfunction _validateLicense(id: string | undefined): string {\n if (id == null) {\n throw new Error(\n 'No \"license\" was specified in \"package.json\", see valid license identifiers at https://spdx.org/licenses/',\n );\n }\n if (id === 'UNLICENSED') {\n return id;\n }\n if (!spdx.has(id)) {\n throw new Error(`Invalid license identifier \"${id}\", see valid license identifiers at https://spdx.org/licenses/`);\n }\n return id;\n}\n\nfunction _validateVersionFormat(format: string): 'short' | 'full' {\n if (format !== 'short' && format !== 'full') {\n throw new Error(`Invalid jsii.versionFormat \"${format}\", it must be either \"short\" or \"full\" (the default)`);\n }\n return format;\n}\n\nfunction _validateStability(stability: string | undefined, deprecated: string | undefined): spec.Stability | undefined {\n if (!stability && deprecated) {\n stability = spec.Stability.Deprecated;\n } else if (deprecated && stability !== spec.Stability.Deprecated) {\n console.warn(\n `Package is deprecated (${deprecated}), but it's stability is ${stability} and not ${spec.Stability.Deprecated}`,\n );\n }\n if (!stability) {\n return undefined;\n }\n if (!Object.values(spec.Stability).includes(stability as any)) {\n throw new Error(`Invalid stability \"${stability}\", it must be one of ${Object.values(spec.Stability).join(', ')}`);\n }\n return stability as spec.Stability;\n}\n\n/**\n * Resolves an NPM package specifier to a version range\n *\n * If it was already a version range, return it. If it the\n * package references a local file, return the version that\n * package is at.\n */\nfunction _resolveVersion(dep: string, searchPath: string): { version: string; localPackage?: string } {\n const matches = /^file:(.+)$/.exec(dep);\n if (!matches) {\n return { version: dep };\n }\n const localPackage = path.resolve(searchPath, matches[1]);\n return {\n // Rendering as a caret version to maintain uniformity against the \"standard\".\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n version: `^${JSON.parse(fs.readFileSync(path.join(localPackage, 'package.json'), 'utf-8')).version}`,\n localPackage,\n };\n}\n\n/**\n * Merges two metadata blocks together.\n *\n * @param base the base values\n * @param user the user-supplied values, which can override the `base` values\n *\n * @returns the merged metadata block\n */\nfunction mergeMetadata(\n base: NonNullable<ProjectInfo['metadata']>,\n user: ProjectInfo['metadata'],\n): ProjectInfo['metadata'] {\n if (user == null) {\n return base;\n }\n return mergeObjects(base, user);\n\n function mergeObjects(baseObj: Record<string, any>, override: Record<string, any>): Record<string, any> {\n const result: Record<string, any> = {};\n const allKeys = Array.from(new Set([...Object.keys(baseObj), ...Object.keys(override)])).sort();\n for (const key of allKeys) {\n const baseValue = baseObj[key];\n const overrideValue = override[key];\n\n if (typeof baseValue === 'object' && typeof overrideValue === 'object') {\n if (overrideValue != null) {\n result[key] = mergeObjects(baseValue, overrideValue);\n }\n } else {\n result[key] = overrideValue ?? baseValue;\n }\n }\n return result;\n }\n}\n\nfunction _loadDiagnostics(entries?: { [key: string]: string }):\n | {\n readonly [key: string]: ts.DiagnosticCategory;\n }\n | undefined {\n if (entries === undefined || Object.keys(entries).length === 0) {\n return undefined;\n }\n const result: { [key: string]: ts.DiagnosticCategory } = {};\n for (const code of Object.keys(entries)) {\n let category: ts.DiagnosticCategory;\n switch (entries[code].trim().toLowerCase()) {\n case 'error':\n category = ts.DiagnosticCategory.Error;\n break;\n case 'warning':\n category = ts.DiagnosticCategory.Warning;\n break;\n case 'suggestion':\n category = ts.DiagnosticCategory.Suggestion;\n break;\n case 'message':\n category = ts.DiagnosticCategory.Message;\n break;\n default:\n throw new Error(`Invalid category '${entries[code]}' for code '${code}'`);\n }\n result[code] = category;\n }\n return result;\n}\n\nfunction filterDictByKey<A>(xs: Record<string, A>, predicate: (key: string) => boolean): Record<string, A> {\n const ret: Record<string, A> = {};\n for (const [key, value] of Object.entries(xs)) {\n if (predicate(key)) {\n ret[key] = value;\n }\n }\n return ret;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project-info.js","sourceRoot":"","sources":["../src/project-info.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAClC,mCAAmC;AACnC,qCAAoE;AACpE,iCAAiC;AACjC,iCAAiC;AACjC,iCAAiC;AAEjC,oDAA8D;AAC9D,uDAAmD;AACnD,yCAA+D;AAC/D,mCAAuD;AAEvD,qGAAqG;AACrG,MAAM,IAAI,GAAgB,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAE9D,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;AAkIlD,SAAgB,eAAe,CAAC,WAAmB;IACjD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAgB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IAE/E,MAAM,WAAW,GAAoB,EAAE,CAAC;IAExC,IAAI,kBAA0D,CAAC;IAC/D,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,kBAAkB,IAAI,GAAG,CAAC,mBAAmB,IAAI,EAAE,EAAE,CAAC;QAC3E,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,gCAAgC,IAAI,qEAAqE,CAC1G,CAAC;QACJ,CAAC;QAED,IAAI,GAAG,CAAC,gBAAgB,IAAI,IAAI,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,2DAA2D,CAAC,CAAC;Q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AAE,CAAC,WAAW,EAAE,EAAE,CAAC;YAC3C,KAAK,OAAO;gBACV,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC;gBACvC,MAAM;YACR,KAAK,SAAS;gBACZ,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBACzC,MAAM;YACR,KAAK,YAAY;gBACf,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,UAAU,CAAC;gBAC5C,MAAM;YACR,KAAK,SAAS;gBACZ,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBACzC,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,GAAG,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,eAAe,CAAI,EAAqB,EAAE,SAAmC;IACpF,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as spec from '@jsii/spec';\nimport { findAssemblyFile, loadAssemblyFromFile } from '@jsii/spec';\nimport * as log4js from 'log4js';\nimport * as semver from 'semver';\nimport * as ts from 'typescript';\n\nimport { findDependencyDirectory } from './common/find-utils';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport { TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport { parsePerson, parseRepository } from './utils';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\nconst spdx: Set<string> = require('spdx-license-list/simple');\n\nconst LOG = log4js.getLogger('jsii/package-info');\n\nexport type TSCompilerOptions = Partial<\n Pick<\n ts.CompilerOptions,\n // Directory preferences\n | 'outDir'\n | 'rootDir'\n // TypeScript path mapping\n | 'baseUrl'\n | 'paths'\n // Style preferences\n | 'forceConsistentCasingInFileNames'\n | 'noImplicitOverride'\n | 'noPropertyAccessFromIndexSignature'\n | 'noUncheckedIndexedAccess'\n // Source map preferences\n | 'declarationMap'\n | 'inlineSourceMap'\n | 'inlineSources'\n | 'sourceMap'\n // Types limitations\n | 'types'\n >\n>;\n\nexport interface ProjectInfo {\n readonly projectRoot: string;\n readonly packageJson: PackageJson;\n\n readonly name: string;\n readonly version: string;\n readonly author: spec.Person;\n readonly deprecated?: string;\n readonly stability?: spec.Stability;\n readonly license: string;\n readonly repository: {\n readonly type: string;\n readonly url: string;\n readonly directory?: string;\n };\n readonly keywords?: readonly string[];\n\n readonly main: string;\n readonly types: string;\n\n readonly dependencies: { readonly [name: string]: string };\n readonly peerDependencies: { readonly [name: string]: string };\n readonly dependencyClosure: readonly spec.Assembly[];\n readonly bundleDependencies?: { readonly [name: string]: string };\n readonly targets: spec.AssemblyTargets;\n readonly metadata?: { readonly [key: string]: any };\n readonly jsiiVersionFormat: 'short' | 'full';\n readonly diagnostics?: { readonly [code: string]: ts.DiagnosticCategory };\n readonly description?: string;\n readonly homepage?: string;\n readonly contributors?: readonly spec.Person[];\n readonly excludeTypescript: readonly string[];\n readonly projectReferences?: boolean;\n readonly tsc?: TSCompilerOptions;\n readonly bin?: { readonly [name: string]: string };\n readonly exports?: {\n readonly [name: string]: string | { readonly [name: string]: string };\n };\n\n // user-provided tsconfig\n readonly tsconfig?: string;\n readonly validateTsConfig?: TypeScriptConfigValidationRuleSet;\n}\n\nexport interface PackageJson {\n readonly description?: string;\n readonly homepage?: string;\n readonly name?: string;\n readonly version?: string;\n readonly keywords?: readonly string[];\n readonly license?: string;\n readonly private?: boolean;\n\n readonly exports?: { readonly [path: string]: string | { readonly [name: string]: string } };\n readonly main?: string;\n readonly types?: string;\n /**\n * @example { \"<4.0\": { \"*\": [\"ts3.9/*\"] } }\n * @example { \"<4.0\": { \"index.d.ts\": [\"index.ts3-9.d.ts\"] } }\n */\n readonly typesVersions?: {\n readonly [versionRange: string]: { readonly [pattern: string]: readonly string[] };\n };\n\n readonly bin?: { readonly [name: string]: string };\n\n readonly stability?: string;\n readonly deprecated?: string;\n\n readonly dependencies?: { readonly [name: string]: string };\n readonly devDependencies?: { readonly [name: string]: string };\n readonly peerDependencies?: { readonly [name: string]: string };\n\n readonly bundleDependencies?: readonly string[];\n readonly bundledDependencies?: readonly string[];\n\n readonly jsii?: {\n // main jsii config\n readonly diagnostics?: { readonly [id: string]: 'error' | 'warning' | 'suggestion' | 'message' };\n readonly metadata?: { readonly [key: string]: unknown };\n readonly targets?: { readonly [name: string]: unknown };\n readonly versionFormat?: 'short' | 'full';\n\n // Either user-provided config ...\n readonly tsconfig?: string;\n readonly validateTsConfig?: string;\n\n // ... or configure tsc here\n readonly excludeTypescript?: readonly string[];\n readonly projectReferences?: boolean;\n readonly tsc?: TSCompilerOptions;\n\n // unexpected options\n readonly [key: string]: unknown;\n };\n\n readonly [key: string]: unknown;\n}\n\nexport interface ProjectInfoResult {\n readonly projectInfo: ProjectInfo;\n readonly diagnostics: readonly ts.Diagnostic[];\n}\n\nexport function loadProjectInfo(projectRoot: string): ProjectInfoResult {\n const packageJsonPath = path.join(projectRoot, 'package.json');\n const pkg: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n\n const diagnostics: ts.Diagnostic[] = [];\n\n let bundleDependencies: { [name: string]: string } | undefined;\n for (const name of pkg.bundleDependencies ?? pkg.bundledDependencies ?? []) {\n const version = pkg.dependencies?.[name];\n if (!version) {\n throw new Error(\n `The \"package.json\" file has \"${name}\" in \"bundleDependencies\", but it is not declared in \"dependencies\"`,\n );\n }\n\n if (pkg.peerDependencies && name in pkg.peerDependencies) {\n throw new Error(`The \"package.json\" file has \"${name}\" in \"bundleDependencies\", and also in \"peerDependencies\"`);\n }\n\n bundleDependencies = bundleDependencies ?? {};\n bundleDependencies[name] = _resolveVersion(version, projectRoot).version;\n }\n\n // Check peerDependencies are also in devDependencies\n // You need this to write tests properly. There are probably cases where\n // it makes sense to have this different, so most of what this checking\n // produces is warnings, not errors.\n const devDependencies = pkg.devDependencies ?? {};\n for (const [name, rng] of Object.entries(pkg.peerDependencies ?? {})) {\n const range = new semver.Range(_resolveVersion(rng as string, projectRoot).version);\n const minVersion = semver.minVersion(range)?.raw;\n\n if (!(name in devDependencies) || devDependencies[name] !== `${minVersion}`) {\n diagnostics.push(\n JsiiDiagnostic.JSII_0006_MISSING_DEV_DEPENDENCY.createDetached(\n name,\n `${rng as any}`,\n `${minVersion}`,\n `${devDependencies[name]}`,\n ),\n );\n continue;\n }\n }\n\n const bundled = new Set(Object.keys(bundleDependencies ?? {}));\n const dependencies: Record<string, string> = filterDictByKey(\n pkg.dependencies ?? {},\n (depName) => !bundled.has(depName),\n );\n const peerDependencies: Record<string, string> = pkg.peerDependencies ?? {};\n\n const resolver = new DependencyResolver();\n const resolved = resolver.discoverDependencyTree(projectRoot, {\n ...dependencies,\n ...peerDependencies,\n });\n const transitiveDependencies = resolver.assemblyClosure(resolved);\n\n const metadata = mergeMetadata(\n {\n jsii: {\n pacmak: {\n // When `true`, `jsii-pacmak` will use the `Jsii$Default` implementation in code generation even for dependencies.\n hasDefaultInterfaces: true,\n },\n },\n },\n pkg.jsii?.metadata,\n );\n\n const projectInfo: ProjectInfo = {\n projectRoot,\n packageJson: pkg,\n\n name: _required(pkg.name, 'The \"package.json\" file must specify the \"name\" attribute'),\n version: _required(pkg.version, 'The \"package.json\" file must specify the \"version\" attribute'),\n deprecated: pkg.deprecated,\n stability: _validateStability(pkg.stability, pkg.deprecated),\n author: _toPerson(_required(pkg.author, 'The \"package.json\" file must specify the \"author\" attribute'), 'author'),\n repository: _toRepository(\n _required(pkg.repository, 'The \"package.json\" file must specify the \"repository\" attribute'),\n ),\n license: _validateLicense(pkg.license),\n keywords: pkg.keywords,\n\n main: _required(pkg.main, 'The \"package.json\" file must specify the \"main\" attribute'),\n types: _required(pkg.types, 'The \"package.json\" file must specify the \"types\" attribute'),\n\n dependencies,\n peerDependencies,\n dependencyClosure: transitiveDependencies,\n bundleDependencies,\n targets: {\n ..._required(pkg.jsii, 'The \"package.json\" file must specify the \"jsii\" attribute').targets,\n js: { npm: pkg.name },\n },\n metadata,\n jsiiVersionFormat: _validateVersionFormat(pkg.jsii?.versionFormat ?? 'full'),\n\n description: pkg.description,\n homepage: pkg.homepage,\n contributors: (pkg.contributors as any[])?.map((contrib, index) =>\n _toPerson(contrib, `contributors[${index}]`, 'contributor'),\n ),\n\n excludeTypescript: pkg.jsii?.excludeTypescript ?? [],\n projectReferences: pkg.jsii?.projectReferences,\n tsc: {\n outDir: pkg.jsii?.tsc?.outDir,\n rootDir: pkg.jsii?.tsc?.rootDir,\n baseUrl: pkg.jsii?.tsc?.baseUrl,\n paths: pkg.jsii?.tsc?.paths,\n forceConsistentCasingInFileNames: pkg.jsii?.tsc?.forceConsistentCasingInFileNames,\n noImplicitOverride: pkg.jsii?.tsc?.noImplicitOverride,\n noPropertyAccessFromIndexSignature: pkg.jsii?.tsc?.noPropertyAccessFromIndexSignature,\n noUncheckedIndexedAccess: pkg.jsii?.tsc?.noUncheckedIndexedAccess,\n ..._sourceMapPreferences(pkg.jsii?.tsc),\n types: pkg.jsii?.tsc?.types,\n },\n bin: pkg.bin,\n exports: pkg.exports,\n diagnostics: _loadDiagnostics(pkg.jsii?.diagnostics),\n\n // user-provided tsconfig\n tsconfig: pkg.jsii?.tsconfig,\n validateTsConfig: _validateTsConfigRuleSet(pkg.jsii?.validateTsConfig ?? 'strict'),\n };\n return { projectInfo, diagnostics };\n}\n\nfunction _guessRepositoryType(url: string): string {\n if (url.endsWith('.git')) {\n return 'git';\n }\n const parts = /^([^:]+):\\/\\//.exec(url);\n if (parts?.[1] !== 'http' && parts?.[1] !== 'https') {\n return parts![1];\n }\n throw new Error(`The \"package.json\" file must specify the \"repository.type\" attribute (could not guess from ${url})`);\n}\n\nfunction _sourceMapPreferences({ declarationMap, inlineSourceMap, inlineSources, sourceMap }: TSCompilerOptions = {}) {\n // If none of the options are specified, use the default configuration from jsii <= 1.58.0, which\n // means inline source maps with embedded source information.\n if (declarationMap == null && inlineSourceMap == null && inlineSources == null && sourceMap == null) {\n declarationMap = false;\n inlineSourceMap = true;\n inlineSources = true;\n sourceMap = undefined;\n }\n\n return {\n declarationMap,\n inlineSourceMap,\n inlineSources,\n sourceMap,\n };\n}\n\ninterface DependencyInfo {\n readonly assembly: spec.Assembly;\n readonly resolvedDependencies: Record<string, string>;\n}\n\nclass DependencyResolver {\n private readonly cache = new Map<string, DependencyInfo>();\n\n /**\n * Discover the dependency tree starting at 'root', validating versions as we go along\n *\n * This primes the data structures in this class and should be called first.\n *\n * Return the resolved jsii dependency paths\n */\n public discoverDependencyTree(root: string, dependencies: Record<string, string>): Record<string, string> {\n const ret: Record<string, string> = {};\n for (const [name, declaration] of Object.entries(dependencies)) {\n // eslint-disable-next-line no-await-in-loop\n let resolved;\n try {\n resolved = this.resolveDependency(root, name, declaration);\n } catch (e) {\n LOG.error(\n `Unable to find a JSII dependency named \"${name}\" as \"${declaration}\". If you meant to include a non-JSII dependency, try adding it to bundledDependencies instead.`,\n );\n throw e;\n }\n\n const actualVersion = resolved.dependencyInfo.assembly.version;\n if (!semver.satisfies(actualVersion, declaration)) {\n throw new Error(\n `Declared dependency on version ${declaration} of ${name}, but version ${actualVersion} was found`,\n );\n }\n\n ret[name] = resolved.resolvedFile;\n }\n return ret;\n }\n\n /**\n * From a set of resolved paths, recursively return all assemblies\n */\n public assemblyClosure(resolved: Record<string, string>): spec.Assembly[] {\n const closure = new Map<string, spec.Assembly>();\n const queue = Array.from(Object.values(resolved));\n while (queue.length > 0) {\n const next = queue.shift()!;\n const depInfo = this.cache.get(next);\n if (!depInfo) {\n throw new Error(`Path ${next} not seen before`);\n }\n if (closure.has(next)) {\n continue;\n }\n\n closure.set(next, depInfo.assembly);\n queue.push(...Object.values(depInfo.resolvedDependencies));\n }\n return Array.from(closure.values());\n }\n\n private resolveDependency(root: string, name: string, declaration: string) {\n const { version: versionString, localPackage } = _resolveVersion(declaration, root);\n const version = new semver.Range(versionString);\n if (!version) {\n throw new Error(`Invalid semver expression for ${name}: ${versionString}`);\n }\n const jsiiFile = _tryResolveAssembly(name, localPackage, root);\n LOG.debug(`Resolved dependency ${name} to ${jsiiFile}`);\n return {\n resolvedVersion: versionString,\n resolvedFile: jsiiFile,\n dependencyInfo: this.loadAssemblyAndRecurse(jsiiFile),\n };\n }\n\n private loadAssemblyAndRecurse(jsiiFile: string) {\n // Only recurse if we haven't seen this assembly yet\n if (this.cache.has(jsiiFile)) {\n return this.cache.get(jsiiFile)!;\n }\n\n const assembly = loadAssemblyFromFile(jsiiFile);\n\n // Continue loading any dependencies declared in the asm\n const resolvedDependencies = assembly.dependencies\n ? this.discoverDependencyTree(path.dirname(jsiiFile), assembly.dependencies)\n : {};\n\n const depInfo: DependencyInfo = {\n assembly,\n resolvedDependencies,\n };\n this.cache.set(jsiiFile, depInfo);\n return depInfo;\n }\n}\n\nfunction _required<T>(value: T | undefined, message: string): T {\n if (value == null) {\n throw new Error(message);\n }\n return value;\n}\n\nfunction _toPerson(value: any, field: string, defaultRole: string = field): spec.Person {\n if (typeof value === 'string') {\n value = parsePerson(value);\n }\n return {\n name: _required(value.name, `The \"package.json\" file must specify the \"${field}.name\" attribute`),\n roles: value.roles ? [...new Set(value.roles as string[])] : [defaultRole],\n email: value.email,\n url: value.url,\n organization: value.organization ? value.organization : undefined,\n };\n}\n\nfunction _toRepository(value: any): {\n type: string;\n url: string;\n directory?: string;\n} {\n if (typeof value === 'string') {\n value = parseRepository(value);\n }\n return {\n url: _required(value.url, 'The \"package.json\" file must specify the \"repository.url\" attribute'),\n type: value.type || _guessRepositoryType(value.url),\n directory: value.directory,\n };\n}\n\nfunction _tryResolveAssembly(mod: string, localPackage: string | undefined, searchPath: string): string {\n if (localPackage) {\n const result = findAssemblyFile(localPackage);\n if (!fs.existsSync(result)) {\n throw new Error(`Assembly does not exist: ${result}`);\n }\n return result;\n }\n try {\n const dependencyDir = findDependencyDirectory(mod, searchPath);\n return findAssemblyFile(dependencyDir);\n } catch (e: any) {\n throw new Error(\n `Unable to locate jsii assembly for \"${mod}\". If this module is not jsii-enabled, it must also be declared under bundledDependencies: ${e}`,\n );\n }\n}\n\nfunction _validateLicense(id: string | undefined): string {\n if (id == null) {\n throw new Error(\n 'No \"license\" was specified in \"package.json\", see valid license identifiers at https://spdx.org/licenses/',\n );\n }\n if (id === 'UNLICENSED') {\n return id;\n }\n if (!spdx.has(id)) {\n throw new Error(`Invalid license identifier \"${id}\", see valid license identifiers at https://spdx.org/licenses/`);\n }\n return id;\n}\n\nfunction _validateVersionFormat(format: string): 'short' | 'full' {\n if (format !== 'short' && format !== 'full') {\n throw new Error(`Invalid jsii.versionFormat \"${format}\", it must be either \"short\" or \"full\" (the default)`);\n }\n return format;\n}\n\nfunction _validateStability(stability: string | undefined, deprecated: string | undefined): spec.Stability | undefined {\n if (!stability && deprecated) {\n stability = spec.Stability.Deprecated;\n } else if (deprecated && stability !== spec.Stability.Deprecated) {\n console.warn(\n `Package is deprecated (${deprecated}), but it's stability is ${stability} and not ${spec.Stability.Deprecated}`,\n );\n }\n if (!stability) {\n return undefined;\n }\n if (!Object.values(spec.Stability).includes(stability as any)) {\n throw new Error(`Invalid stability \"${stability}\", it must be one of ${Object.values(spec.Stability).join(', ')}`);\n }\n return stability as spec.Stability;\n}\n\nfunction _validateTsConfigRuleSet(ruleSet: string): TypeScriptConfigValidationRuleSet | undefined {\n if (ruleSet == null) {\n return undefined;\n }\n if (!Object.values(TypeScriptConfigValidationRuleSet).includes(ruleSet as any)) {\n throw new Error(\n `Invalid validateTsConfig \"${ruleSet}\", it must be one of ${Object.values(TypeScriptConfigValidationRuleSet).join(\n ', ',\n )}`,\n );\n }\n\n return ruleSet as TypeScriptConfigValidationRuleSet;\n}\n\n/**\n * Resolves an NPM package specifier to a version range\n *\n * If it was already a version range, return it. If it the\n * package references a local file, return the version that\n * package is at.\n */\nfunction _resolveVersion(dep: string, searchPath: string): { version: string; localPackage?: string } {\n const matches = /^file:(.+)$/.exec(dep);\n if (!matches) {\n return { version: dep };\n }\n const localPackage = path.resolve(searchPath, matches[1]);\n return {\n // Rendering as a caret version to maintain uniformity against the \"standard\".\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n version: `^${JSON.parse(fs.readFileSync(path.join(localPackage, 'package.json'), 'utf-8')).version}`,\n localPackage,\n };\n}\n\n/**\n * Merges two metadata blocks together.\n *\n * @param base the base values\n * @param user the user-supplied values, which can override the `base` values\n *\n * @returns the merged metadata block\n */\nfunction mergeMetadata(\n base: NonNullable<ProjectInfo['metadata']>,\n user: ProjectInfo['metadata'],\n): ProjectInfo['metadata'] {\n if (user == null) {\n return base;\n }\n return mergeObjects(base, user);\n\n function mergeObjects(baseObj: Record<string, any>, override: Record<string, any>): Record<string, any> {\n const result: Record<string, any> = {};\n const allKeys = Array.from(new Set([...Object.keys(baseObj), ...Object.keys(override)])).sort();\n for (const key of allKeys) {\n const baseValue = baseObj[key];\n const overrideValue = override[key];\n\n if (typeof baseValue === 'object' && typeof overrideValue === 'object') {\n if (overrideValue != null) {\n result[key] = mergeObjects(baseValue, overrideValue);\n }\n } else {\n result[key] = overrideValue ?? baseValue;\n }\n }\n return result;\n }\n}\n\nfunction _loadDiagnostics(entries?: { [key: string]: string }):\n | {\n readonly [key: string]: ts.DiagnosticCategory;\n }\n | undefined {\n if (entries === undefined || Object.keys(entries).length === 0) {\n return undefined;\n }\n const result: { [key: string]: ts.DiagnosticCategory } = {};\n for (const code of Object.keys(entries)) {\n let category: ts.DiagnosticCategory;\n switch (entries[code].trim().toLowerCase()) {\n case 'error':\n category = ts.DiagnosticCategory.Error;\n break;\n case 'warning':\n category = ts.DiagnosticCategory.Warning;\n break;\n case 'suggestion':\n category = ts.DiagnosticCategory.Suggestion;\n break;\n case 'message':\n category = ts.DiagnosticCategory.Message;\n break;\n default:\n throw new Error(`Invalid category '${entries[code]}' for code '${code}'`);\n }\n result[code] = category;\n }\n return result;\n}\n\nfunction filterDictByKey<A>(xs: Record<string, A>, predicate: (key: string) => boolean): Record<string, A> {\n const ret: Record<string, A> = {};\n for (const [key, value] of Object.entries(xs)) {\n if (predicate(key)) {\n ret[key] = value;\n }\n }\n return ret;\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
export declare const BASE_COMPILER_OPTIONS: ts.CompilerOptions;
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to convert a TS enum into a list of allowed values,
|
|
5
|
+
* converting everything to camel case.
|
|
6
|
+
* This is used for example for the watch options
|
|
7
|
+
*/
|
|
8
|
+
export declare function enumAsCamel(enumData: Record<string, string | number>): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to convert a TS enum into a list of allowed values,
|
|
11
|
+
* converting everything to lower case.
|
|
12
|
+
* This is used for example for the "target" compiler option
|
|
13
|
+
*/
|
|
14
|
+
export declare function enumAsLower(enumData: Record<string, string | number>): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to convert a TS enum into a list of allowed values,
|
|
17
|
+
* converting everything to kebab case.
|
|
18
|
+
* This is used for example for the "jsx" compiler option
|
|
19
|
+
*/
|
|
20
|
+
export declare function enumAsKebab(enumData: Record<string, string | number>): string[];
|
|
21
|
+
/**
|
|
22
|
+
* The compilerOptions in the programmatic API are slightly differently than the format used in tsconfig.json
|
|
23
|
+
* This helper performs the necessary conversion from the programmatic API format the one used in tsconfig.json
|
|
24
|
+
*
|
|
25
|
+
* @param opt compilerOptions in programmatic API format
|
|
26
|
+
* @returns compilerOptions ready to be written on disk
|
|
27
|
+
*/
|
|
28
|
+
export declare function convertForJson(opt: ts.CompilerOptions): ts.CompilerOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Convert an internal enum value to what a user would write in tsconfig.json
|
|
31
|
+
* Possibly using a converter function to adjust casing.
|
|
32
|
+
* @param value The internal enum value
|
|
33
|
+
* @param enumObj The enum object to convert from
|
|
34
|
+
* @param converter The converter function, defaults to lowercase
|
|
35
|
+
* @returns The humanized version of the enum value
|
|
36
|
+
*/
|
|
37
|
+
export declare function convertEnumToJson<T>(value: keyof T, enumObj: T, converter?: (value: string) => string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Convert the internal lib strings to what a user would write in tsconfig.json
|
|
40
|
+
* @param input The input libs array
|
|
41
|
+
* @returns The humanized version lib array
|
|
42
|
+
*/
|
|
43
|
+
export declare function convertLibForJson(input: string[]): string[];
|
|
44
|
+
/**
|
|
45
|
+
* This is annoying - the values expected in the tsconfig.json file are not
|
|
46
|
+
* the same as the enum constant names, or their values. So we need this
|
|
47
|
+
* function to map the "compiler API version" to the "tsconfig.json version"
|
|
48
|
+
*
|
|
49
|
+
* @param newLine the compiler form of the new line configuration
|
|
50
|
+
*
|
|
51
|
+
* @return the equivalent value to put in tsconfig.json
|
|
52
|
+
*/
|
|
53
|
+
export declare function convertNewLineForJson(newLine: ts.NewLineKind): string;
|
|
54
|
+
//# sourceMappingURL=compiler-options.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertNewLineForJson = exports.convertLibForJson = exports.convertEnumToJson = exports.convertForJson = exports.enumAsKebab = exports.enumAsLower = exports.enumAsCamel = exports.BASE_COMPILER_OPTIONS = void 0;
|
|
4
|
+
const ts = require("typescript");
|
|
5
|
+
const Case = require("../case");
|
|
6
|
+
exports.BASE_COMPILER_OPTIONS = {
|
|
7
|
+
alwaysStrict: true,
|
|
8
|
+
declaration: true,
|
|
9
|
+
experimentalDecorators: true,
|
|
10
|
+
incremental: true,
|
|
11
|
+
lib: ['lib.es2020.d.ts'],
|
|
12
|
+
module: ts.ModuleKind.CommonJS,
|
|
13
|
+
noEmitOnError: true,
|
|
14
|
+
noFallthroughCasesInSwitch: true,
|
|
15
|
+
noImplicitAny: true,
|
|
16
|
+
noImplicitReturns: true,
|
|
17
|
+
noImplicitThis: true,
|
|
18
|
+
noUnusedLocals: true,
|
|
19
|
+
noUnusedParameters: true,
|
|
20
|
+
resolveJsonModule: true,
|
|
21
|
+
skipLibCheck: true,
|
|
22
|
+
strict: true,
|
|
23
|
+
strictNullChecks: true,
|
|
24
|
+
strictPropertyInitialization: true,
|
|
25
|
+
stripInternal: false,
|
|
26
|
+
target: ts.ScriptTarget.ES2020,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Helper function to convert a TS enum into a list of allowed values,
|
|
30
|
+
* converting everything to camel case.
|
|
31
|
+
* This is used for example for the watch options
|
|
32
|
+
*/
|
|
33
|
+
function enumAsCamel(enumData) {
|
|
34
|
+
return Object.keys(enumData)
|
|
35
|
+
.filter((v) => isNaN(Number(v)))
|
|
36
|
+
.map(Case.camel);
|
|
37
|
+
}
|
|
38
|
+
exports.enumAsCamel = enumAsCamel;
|
|
39
|
+
/**
|
|
40
|
+
* Helper function to convert a TS enum into a list of allowed values,
|
|
41
|
+
* converting everything to lower case.
|
|
42
|
+
* This is used for example for the "target" compiler option
|
|
43
|
+
*/
|
|
44
|
+
function enumAsLower(enumData) {
|
|
45
|
+
return Object.keys(enumData)
|
|
46
|
+
.filter((v) => isNaN(Number(v)) && v !== 'None')
|
|
47
|
+
.map((v) => v.toLowerCase());
|
|
48
|
+
}
|
|
49
|
+
exports.enumAsLower = enumAsLower;
|
|
50
|
+
/**
|
|
51
|
+
* Helper function to convert a TS enum into a list of allowed values,
|
|
52
|
+
* converting everything to kebab case.
|
|
53
|
+
* This is used for example for the "jsx" compiler option
|
|
54
|
+
*/
|
|
55
|
+
function enumAsKebab(enumData) {
|
|
56
|
+
return Object.keys(enumData)
|
|
57
|
+
.filter((v) => isNaN(Number(v)) && v !== 'None')
|
|
58
|
+
.map(Case.kebab);
|
|
59
|
+
}
|
|
60
|
+
exports.enumAsKebab = enumAsKebab;
|
|
61
|
+
/**
|
|
62
|
+
* The compilerOptions in the programmatic API are slightly differently than the format used in tsconfig.json
|
|
63
|
+
* This helper performs the necessary conversion from the programmatic API format the one used in tsconfig.json
|
|
64
|
+
*
|
|
65
|
+
* @param opt compilerOptions in programmatic API format
|
|
66
|
+
* @returns compilerOptions ready to be written on disk
|
|
67
|
+
*/
|
|
68
|
+
function convertForJson(opt) {
|
|
69
|
+
return {
|
|
70
|
+
...opt,
|
|
71
|
+
// Drop the "lib." prefix and ".d.ts" suffix before writing up the tsconfig.json file
|
|
72
|
+
...valueHelper('lib', opt.lib, convertLibForJson),
|
|
73
|
+
// Re-write the module, targets & jsx to be the JSON format instead of Programmatic API
|
|
74
|
+
...enumHelper('importsNotUsedAsValues', opt.importsNotUsedAsValues, ts.ImportsNotUsedAsValues),
|
|
75
|
+
...enumHelper('jsx', opt.jsx, ts.JsxEmit, Case.kebab),
|
|
76
|
+
...enumHelper('module', opt.module, ts.ModuleKind),
|
|
77
|
+
...enumHelper('moduleResolution', opt.moduleResolution, ts.ModuleResolutionKind),
|
|
78
|
+
...enumHelper('moduleDetection', opt.moduleDetection, ts.ModuleDetectionKind),
|
|
79
|
+
...enumHelper('target', opt.target, ts.ScriptTarget),
|
|
80
|
+
// rewrite newline to be the JSON format instead of Programmatic API
|
|
81
|
+
...valueHelper('newLine', opt.newLine, convertNewLineForJson),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
exports.convertForJson = convertForJson;
|
|
85
|
+
function valueHelper(name, value, converter) {
|
|
86
|
+
if (!value) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
return { [name]: converter(value) };
|
|
90
|
+
}
|
|
91
|
+
function enumHelper(name, value, enumObj, converter) {
|
|
92
|
+
if (!value) {
|
|
93
|
+
return {};
|
|
94
|
+
}
|
|
95
|
+
return { [name]: convertEnumToJson(value, enumObj, converter) };
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Convert an internal enum value to what a user would write in tsconfig.json
|
|
99
|
+
* Possibly using a converter function to adjust casing.
|
|
100
|
+
* @param value The internal enum value
|
|
101
|
+
* @param enumObj The enum object to convert from
|
|
102
|
+
* @param converter The converter function, defaults to lowercase
|
|
103
|
+
* @returns The humanized version of the enum value
|
|
104
|
+
*/
|
|
105
|
+
function convertEnumToJson(value, enumObj, converter = (v) => v.toLowerCase()) {
|
|
106
|
+
return converter(enumObj[value]);
|
|
107
|
+
}
|
|
108
|
+
exports.convertEnumToJson = convertEnumToJson;
|
|
109
|
+
/**
|
|
110
|
+
* Convert the internal lib strings to what a user would write in tsconfig.json
|
|
111
|
+
* @param input The input libs array
|
|
112
|
+
* @returns The humanized version lib array
|
|
113
|
+
*/
|
|
114
|
+
function convertLibForJson(input) {
|
|
115
|
+
return input.map((lib) => lib.slice(4, lib.length - 5));
|
|
116
|
+
}
|
|
117
|
+
exports.convertLibForJson = convertLibForJson;
|
|
118
|
+
/**
|
|
119
|
+
* This is annoying - the values expected in the tsconfig.json file are not
|
|
120
|
+
* the same as the enum constant names, or their values. So we need this
|
|
121
|
+
* function to map the "compiler API version" to the "tsconfig.json version"
|
|
122
|
+
*
|
|
123
|
+
* @param newLine the compiler form of the new line configuration
|
|
124
|
+
*
|
|
125
|
+
* @return the equivalent value to put in tsconfig.json
|
|
126
|
+
*/
|
|
127
|
+
function convertNewLineForJson(newLine) {
|
|
128
|
+
switch (newLine) {
|
|
129
|
+
case ts.NewLineKind.CarriageReturnLineFeed:
|
|
130
|
+
return 'crlf';
|
|
131
|
+
case ts.NewLineKind.LineFeed:
|
|
132
|
+
return 'lf';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.convertNewLineForJson = convertNewLineForJson;
|
|
136
|
+
//# sourceMappingURL=compiler-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-options.js","sourceRoot":"","sources":["../../src/tsconfig/compiler-options.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,gCAAgC;AAEnB,QAAA,qBAAqB,GAAuB;IACvD,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,IAAI;IACjB,sBAAsB,EAAE,IAAI;IAC5B,WAAW,EAAE,IAAI;IACjB,GAAG,EAAE,CAAC,iBAAiB,CAAC;IACxB,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ;IAC9B,aAAa,EAAE,IAAI;IACnB,0BAA0B,EAAE,IAAI;IAChC,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;IACvB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,IAAI;IACvB,YAAY,EAAE,IAAI;IAClB,MAAM,EAAE,IAAI;IACZ,gBAAgB,EAAE,IAAI;IACtB,4BAA4B,EAAE,IAAI;IAClC,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;CAC/B,CAAC;AAEF;;;;GAIG;AACH,SAAgB,WAAW,CAAC,QAAyC;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC;AAJD,kCAIC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,QAAyC;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,C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IAChB,CAAC;AACH,CAAC;AAPD,sDAOC","sourcesContent":["import * as ts from 'typescript';\nimport * as Case from '../case';\n\nexport const BASE_COMPILER_OPTIONS: ts.CompilerOptions = {\n alwaysStrict: true,\n declaration: true,\n experimentalDecorators: true,\n incremental: true,\n lib: ['lib.es2020.d.ts'],\n module: ts.ModuleKind.CommonJS,\n noEmitOnError: true,\n noFallthroughCasesInSwitch: true,\n noImplicitAny: true,\n noImplicitReturns: true,\n noImplicitThis: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n strict: true,\n strictNullChecks: true,\n strictPropertyInitialization: true,\n stripInternal: false,\n target: ts.ScriptTarget.ES2020,\n};\n\n/**\n * Helper function to convert a TS enum into a list of allowed values,\n * converting everything to camel case.\n * This is used for example for the watch options\n */\nexport function enumAsCamel(enumData: Record<string, string | number>): string[] {\n return Object.keys(enumData)\n .filter((v) => isNaN(Number(v)))\n .map(Case.camel);\n}\n\n/**\n * Helper function to convert a TS enum into a list of allowed values,\n * converting everything to lower case.\n * This is used for example for the \"target\" compiler option\n */\nexport function enumAsLower(enumData: Record<string, string | number>): string[] {\n return Object.keys(enumData)\n .filter((v) => isNaN(Number(v)) && v !== 'None')\n .map((v) => v.toLowerCase());\n}\n\n/**\n * Helper function to convert a TS enum into a list of allowed values,\n * converting everything to kebab case.\n * This is used for example for the \"jsx\" compiler option\n */\nexport function enumAsKebab(enumData: Record<string, string | number>): string[] {\n return Object.keys(enumData)\n .filter((v) => isNaN(Number(v)) && v !== 'None')\n .map(Case.kebab);\n}\n\n/**\n * The compilerOptions in the programmatic API are slightly differently than the format used in tsconfig.json\n * This helper performs the necessary conversion from the programmatic API format the one used in tsconfig.json\n *\n * @param opt compilerOptions in programmatic API format\n * @returns compilerOptions ready to be written on disk\n */\nexport function convertForJson(opt: ts.CompilerOptions): ts.CompilerOptions {\n return {\n ...opt,\n\n // Drop the \"lib.\" prefix and \".d.ts\" suffix before writing up the tsconfig.json file\n ...valueHelper('lib', opt.lib, convertLibForJson),\n\n // Re-write the module, targets & jsx to be the JSON format instead of Programmatic API\n ...enumHelper('importsNotUsedAsValues', opt.importsNotUsedAsValues, ts.ImportsNotUsedAsValues),\n ...enumHelper('jsx', opt.jsx, ts.JsxEmit, Case.kebab),\n ...enumHelper('module', opt.module, ts.ModuleKind),\n ...enumHelper('moduleResolution', opt.moduleResolution, ts.ModuleResolutionKind),\n ...enumHelper('moduleDetection', opt.moduleDetection, ts.ModuleDetectionKind),\n ...enumHelper('target', opt.target, ts.ScriptTarget),\n\n // rewrite newline to be the JSON format instead of Programmatic API\n ...valueHelper('newLine', opt.newLine, convertNewLineForJson),\n };\n}\n\nfunction valueHelper<T, U>(\n name: string,\n value: T | undefined,\n converter: (value: T) => U,\n): {\n [name: string]: U;\n} {\n if (!value) {\n return {};\n }\n return { [name]: converter(value) };\n}\n\nfunction enumHelper<T>(\n name: string,\n value: any,\n enumObj: T,\n converter?: (value: string) => string,\n): {\n [name: string]: string;\n} {\n if (!value) {\n return {};\n }\n return { [name]: convertEnumToJson(value, enumObj, converter) };\n}\n\n/**\n * Convert an internal enum value to what a user would write in tsconfig.json\n * Possibly using a converter function to adjust casing.\n * @param value The internal enum value\n * @param enumObj The enum object to convert from\n * @param converter The converter function, defaults to lowercase\n * @returns The humanized version of the enum value\n */\nexport function convertEnumToJson<T>(\n value: keyof T,\n enumObj: T,\n converter: (value: string) => string = (v) => v.toLowerCase(),\n): string {\n return converter(enumObj[value] as any);\n}\n\n/**\n * Convert the internal lib strings to what a user would write in tsconfig.json\n * @param input The input libs array\n * @returns The humanized version lib array\n */\nexport function convertLibForJson(input: string[]): string[] {\n return input.map((lib) => lib.slice(4, lib.length - 5));\n}\n\n/**\n * This is annoying - the values expected in the tsconfig.json file are not\n * the same as the enum constant names, or their values. So we need this\n * function to map the \"compiler API version\" to the \"tsconfig.json version\"\n *\n * @param newLine the compiler form of the new line configuration\n *\n * @return the equivalent value to put in tsconfig.json\n */\nexport function convertNewLineForJson(newLine: ts.NewLineKind): string {\n switch (newLine) {\n case ts.NewLineKind.CarriageReturnLineFeed:\n return 'crlf';\n case ts.NewLineKind.LineFeed:\n return 'lf';\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
export interface TypeScriptConfig {
|
|
3
|
+
files?: string[];
|
|
4
|
+
extends?: string | string[];
|
|
5
|
+
include?: string[];
|
|
6
|
+
exclude?: string[];
|
|
7
|
+
references?: ts.ProjectReference[];
|
|
8
|
+
compilerOptions: ts.CompilerOptions;
|
|
9
|
+
watchOptions?: ts.WatchOptions;
|
|
10
|
+
typeAcquisition?: ts.TypeAcquisition;
|
|
11
|
+
}
|
|
12
|
+
export declare enum TypeScriptConfigValidationRuleSet {
|
|
13
|
+
STRICT = "strict",
|
|
14
|
+
GENERATED = "generated",
|
|
15
|
+
MINIMAL = "minimal",
|
|
16
|
+
NONE = "off"
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|