@nestjs/cli 11.0.0-next.4 → 11.0.0-next.6

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.
@@ -2,6 +2,9 @@ import { Input } from '../commands';
2
2
  import { BuildAction } from './build.action';
3
3
  export declare class StartAction extends BuildAction {
4
4
  handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>;
5
- createOnSuccessHook(entryFile: string, sourceRoot: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun: string, useShell: boolean): () => void;
5
+ createOnSuccessHook(entryFile: string, sourceRoot: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun: string, options: {
6
+ shell: boolean;
7
+ envFile?: string;
8
+ }): () => void;
6
9
  private spawnChildProcess;
7
10
  }
@@ -33,7 +33,12 @@ class StartAction extends build_action_1.BuildAction {
33
33
  const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', commandOptions, defaults_1.defaultConfiguration.sourceRoot);
34
34
  const shellOption = commandOptions.find((option) => option.name === 'shell');
35
35
  const useShell = !!shellOption?.value;
36
- const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun, useShell);
36
+ const envFileOption = commandOptions.find((option) => option.name === 'envFile');
37
+ const envFile = envFileOption?.value;
38
+ const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun, {
39
+ shell: useShell,
40
+ envFile,
41
+ });
37
42
  await this.runBuild(commandInputs, commandOptions, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
38
43
  }
39
44
  catch (err) {
@@ -45,21 +50,27 @@ class StartAction extends build_action_1.BuildAction {
45
50
  }
46
51
  }
47
52
  }
48
- createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, useShell) {
53
+ createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, options) {
49
54
  let childProcessRef;
50
55
  process.on('exit', () => childProcessRef && (0, tree_kill_1.treeKillSync)(childProcessRef.pid));
51
56
  return () => {
52
57
  if (childProcessRef) {
53
58
  childProcessRef.removeAllListeners('exit');
54
59
  childProcessRef.on('exit', () => {
55
- childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, useShell);
60
+ childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, {
61
+ shell: options.shell,
62
+ envFile: options.envFile,
63
+ });
56
64
  childProcessRef.on('exit', () => (childProcessRef = undefined));
57
65
  });
58
66
  childProcessRef.stdin && childProcessRef.stdin.pause();
59
67
  killProcess(childProcessRef.pid);
60
68
  }
61
69
  else {
62
- childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, useShell);
70
+ childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, {
71
+ shell: options.shell,
72
+ envFile: options.envFile,
73
+ });
63
74
  childProcessRef.on('exit', (code) => {
64
75
  process.exitCode = code;
65
76
  childProcessRef = undefined;
@@ -67,7 +78,7 @@ class StartAction extends build_action_1.BuildAction {
67
78
  }
68
79
  };
69
80
  }
70
- spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun, useShell) {
81
+ spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun, options) {
71
82
  let outputFilePath = (0, path_1.join)(outDirName, sourceRoot, entryFile);
72
83
  if (!fs.existsSync(outputFilePath + '.js')) {
73
84
  outputFilePath = (0, path_1.join)(outDirName, entryFile);
@@ -91,10 +102,13 @@ class StartAction extends build_action_1.BuildAction {
91
102
  const inspectFlag = typeof debug === 'string' ? `--inspect=${debug}` : '--inspect';
92
103
  processArgs.unshift(inspectFlag);
93
104
  }
105
+ if (options.envFile) {
106
+ processArgs.unshift(`--env-file=${options.envFile}`);
107
+ }
94
108
  processArgs.unshift('--enable-source-maps');
95
109
  return (0, child_process_1.spawn)(binaryToRun, processArgs, {
96
110
  stdio: 'inherit',
97
- shell: useShell,
111
+ shell: options.shell,
98
112
  });
99
113
  }
100
114
  }
@@ -25,6 +25,7 @@ class StartCommand extends abstract_command_1.AbstractCommand {
25
25
  .option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
26
26
  .option('--shell', "Spawn child processes within a shell (see node's child_process.spawn() method docs). Default: true.", true)
27
27
  .option('--no-shell', 'Do not spawn child processes within a shell.')
28
+ .option('--env-file [path]', 'Path to an env file (.env) to be loaded into the environment.')
28
29
  .description('Run Nest application.')
29
30
  .action(async (app, command) => {
30
31
  const options = [];
@@ -67,6 +68,10 @@ class StartCommand extends abstract_command_1.AbstractCommand {
67
68
  name: 'shell',
68
69
  value: !!command.shell,
69
70
  });
71
+ options.push({
72
+ name: 'envFile',
73
+ value: command.envFile,
74
+ });
70
75
  const availableBuilders = ['tsc', 'webpack', 'swc'];
71
76
  if (command.builder && !availableBuilders.includes(command.builder)) {
72
77
  console.error(ui_1.ERROR_PREFIX +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "11.0.0-next.4",
3
+ "version": "11.0.0-next.6",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -42,7 +42,7 @@
42
42
  "@angular-devkit/schematics": "19.0.1",
43
43
  "@angular-devkit/schematics-cli": "19.0.1",
44
44
  "@inquirer/prompts": "5.3.8",
45
- "@nestjs/schematics": "^10.0.1",
45
+ "@nestjs/schematics": "next",
46
46
  "chalk": "4.1.2",
47
47
  "chokidar": "4.0.1",
48
48
  "cli-table3": "0.6.5",