@nestjs/cli 10.0.0-next.2 → 10.0.0-next.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.
@@ -71,7 +71,7 @@ class BuildAction extends abstract_action_1.AbstractAction {
71
71
  const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', options);
72
72
  const builder = isWebpackEnabled
73
73
  ? 'webpack'
74
- : (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName, 'builder', options);
74
+ : (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName, 'builder', options, 'tsc');
75
75
  yield this.workspaceUtils.deleteOutDirIfEnabled(configuration, appName, outDir);
76
76
  this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
77
77
  switch (builder) {
@@ -22,12 +22,11 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
22
22
  .option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
23
23
  .option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
24
24
  .option('--webpack', 'Use webpack for compilation (deprecated option, use --build instead).')
25
- .option('--type-check', 'Enable type checking (when SWC is used).', false)
25
+ .option('--type-check', 'Enable type checking (when SWC is used).')
26
26
  .option('--webpackPath [path]', 'Path to webpack configuration.')
27
27
  .option('--tsc', 'Use tsc for compilation.')
28
28
  .description('Build Nest application.')
29
29
  .action((app, command) => __awaiter(this, void 0, void 0, function* () {
30
- var _a;
31
30
  const options = [];
32
31
  options.push({
33
32
  name: 'config',
@@ -53,7 +52,7 @@ class BuildCommand extends abstract_command_1.AbstractCommand {
53
52
  }
54
53
  options.push({
55
54
  name: 'builder',
56
- value: (_a = command.builder) !== null && _a !== void 0 ? _a : (isWebpackEnabled ? 'webpack' : 'tsc'),
55
+ value: command.builder,
57
56
  });
58
57
  if (command.typeCheck && command.builder !== 'swc') {
59
58
  console.warn(ui_1.INFO_PREFIX +
@@ -25,7 +25,7 @@ class StartCommand extends abstract_command_1.AbstractCommand {
25
25
  .option('-d, --debug [hostport] ', 'Run in debug mode (with --inspect flag).')
26
26
  .option('--webpack', 'Use webpack for compilation (deprecated option, use --build instead).')
27
27
  .option('--webpackPath [path]', 'Path to webpack configuration.')
28
- .option('--type-check', 'Enable type checking (when SWC is used).', false)
28
+ .option('--type-check', 'Enable type checking (when SWC is used).')
29
29
  .option('--tsc', 'Use tsc for compilation.')
30
30
  .option('--sourceRoot [sourceRoot]', 'Points at the root of the source code for the single project in standard mode structures, or the default project in monorepo mode structures.')
31
31
  .option('--entryFile [entryFile]', "Path to the entry file where this command will work with. Defaults to the one defined at your Nest's CLI config file.")
@@ -33,7 +33,6 @@ class StartCommand extends abstract_command_1.AbstractCommand {
33
33
  .option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when tsc watch mode.')
34
34
  .description('Run Nest application.')
35
35
  .action((app, command) => __awaiter(this, void 0, void 0, function* () {
36
- var _a;
37
36
  const options = [];
38
37
  options.push({
39
38
  name: 'config',
@@ -78,7 +77,7 @@ class StartCommand extends abstract_command_1.AbstractCommand {
78
77
  }
79
78
  options.push({
80
79
  name: 'builder',
81
- value: (_a = command.builder) !== null && _a !== void 0 ? _a : (isWebpackEnabled ? 'webpack' : 'tsc'),
80
+ value: command.builder,
82
81
  });
83
82
  if (command.typeCheck && command.builder !== 'swc') {
84
83
  console.warn(ui_1.INFO_PREFIX +
@@ -5,5 +5,5 @@ export type DeepPluginMeta = ts.ObjectLiteralExpression | {
5
5
  export interface ReadonlyVisitor {
6
6
  key: string;
7
7
  visit(program: ts.Program, sf: ts.SourceFile): void;
8
- collect(): Array<[ts.CallExpression, DeepPluginMeta]>;
8
+ collect(): Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>;
9
9
  }
@@ -18,7 +18,7 @@ class PluginMetadataGenerator {
18
18
  }
19
19
  this.typeCheckerHost.run(tsconfigPath, {
20
20
  watch,
21
- onSuccess: (program) => {
21
+ onTypeCheck: (program) => {
22
22
  this.traverseAndPrintMetadata(program, visitors, outputDir, filename);
23
23
  },
24
24
  });
@@ -5,6 +5,6 @@ export interface PluginMetadataPrintOptions {
5
5
  filename?: string;
6
6
  }
7
7
  export declare class PluginMetadataPrinter {
8
- print(metadata: Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>, options: PluginMetadataPrintOptions): void;
8
+ print(metadata: Record<string, Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>>, options: PluginMetadataPrintOptions): void;
9
9
  private recursivelyCreatePropertyAssignment;
10
10
  }
@@ -27,21 +27,23 @@ class ForkedTypeChecker extends base_compiler_1.BaseCompiler {
27
27
  const { readonlyVisitors } = this.loadPlugins(configuration, tsConfigPath, appName);
28
28
  const outputDir = this.getPathToSource(configuration, tsConfigPath, appName);
29
29
  try {
30
+ const onTypeCheckOrProgramInit = (program) => {
31
+ if (readonlyVisitors.length > 0) {
32
+ console.log(constants_1.FOUND_NO_ISSUES_GENERATING_METADATA);
33
+ this.pluginMetadataGenerator.generate({
34
+ outputDir,
35
+ visitors: readonlyVisitors,
36
+ tsProgramRef: program,
37
+ });
38
+ }
39
+ else {
40
+ console.log(constants_1.FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED);
41
+ }
42
+ };
30
43
  this.typeCheckerHost.run(tsConfigPath, {
31
44
  watch: extras.watch,
32
- onSuccess: (program) => {
33
- if (readonlyVisitors.length > 0) {
34
- console.log(constants_1.FOUND_NO_ISSUES_GENERATING_METADATA);
35
- this.pluginMetadataGenerator.generate({
36
- outputDir,
37
- visitors: readonlyVisitors,
38
- tsProgramRef: program,
39
- });
40
- }
41
- else {
42
- console.log(constants_1.FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED);
43
- }
44
- },
45
+ onTypeCheck: onTypeCheckOrProgramInit,
46
+ onProgramInit: onTypeCheckOrProgramInit,
45
47
  });
46
48
  }
47
49
  catch (err) {
@@ -72,7 +72,7 @@ class SwcCompiler extends base_compiler_1.BaseCompiler {
72
72
  try {
73
73
  this.typeCheckerHost.run(tsConfigPath, {
74
74
  watch: extras.watch,
75
- onSuccess: (program) => {
75
+ onTypeCheck: (program) => {
76
76
  if (!fulfilled) {
77
77
  fulfilled = true;
78
78
  resolve();
@@ -1,7 +1,8 @@
1
1
  import * as ts from 'typescript';
2
2
  export interface TypeCheckerHostRunOptions {
3
3
  watch?: boolean;
4
- onSuccess?: (program: ts.Program) => void;
4
+ onTypeCheck?: (program: ts.Program) => void;
5
+ onProgramInit?: (program: ts.Program) => void;
5
6
  }
6
7
  export declare class TypeCheckerHost {
7
8
  private readonly typescriptLoader;
@@ -32,6 +32,7 @@ class TypeCheckerHost {
32
32
  spinner.succeed();
33
33
  }
34
34
  runInWatchMode(tsconfigPath, tsBinary, options) {
35
+ var _a;
35
36
  const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(tsconfigPath);
36
37
  let builderProgram = undefined;
37
38
  const reportWatchStatusCallback = (diagnostic) => {
@@ -46,10 +47,11 @@ class TypeCheckerHost {
46
47
  return;
47
48
  }
48
49
  const tsProgram = builderProgram.getProgram().getProgram();
49
- (_b = options.onSuccess) === null || _b === void 0 ? void 0 : _b.call(options, tsProgram);
50
+ (_b = options.onTypeCheck) === null || _b === void 0 ? void 0 : _b.call(options, tsProgram);
50
51
  };
51
52
  const host = this.createWatchCompilerHost(tsBinary, tsconfigPath, tsOptions, reportWatchStatusCallback);
52
53
  builderProgram = tsBinary.createWatchProgram(host);
54
+ (_a = options.onProgramInit) === null || _a === void 0 ? void 0 : _a.call(options, builderProgram.getProgram().getProgram());
53
55
  }
54
56
  runOnce(tsconfigPath, tsBinary, options) {
55
57
  var _a, _b;
@@ -74,7 +76,7 @@ class TypeCheckerHost {
74
76
  console.log(tsBinary.formatDiagnosticsWithColorAndContext(diagnostics, formatDiagnosticsHost));
75
77
  process.exit(1);
76
78
  }
77
- (_b = options.onSuccess) === null || _b === void 0 ? void 0 : _b.call(options, programRef);
79
+ (_b = options.onTypeCheck) === null || _b === void 0 ? void 0 : _b.call(options, programRef);
78
80
  }
79
81
  createWatchCompilerHost(tsBinary, tsConfigPath, options, reportWatchStatusCallback) {
80
82
  const origDiagnosticReporter = tsBinary.createDiagnosticReporter(tsBinary.sys, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "10.0.0-next.2",
3
+ "version": "10.0.0-next.3",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"