@depup/nestjs__cli 11.0.16-depup.1
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/LICENSE +24 -0
- package/README.md +42 -0
- package/actions/abstract.action.d.ts +4 -0
- package/actions/abstract.action.js +6 -0
- package/actions/add.action.d.ts +12 -0
- package/actions/add.action.js +113 -0
- package/actions/build.action.d.ts +22 -0
- package/actions/build.action.js +145 -0
- package/actions/generate.action.d.ts +5 -0
- package/actions/generate.action.js +97 -0
- package/actions/index.d.ts +7 -0
- package/actions/index.js +23 -0
- package/actions/info.action.d.ts +35 -0
- package/actions/info.action.js +181 -0
- package/actions/new.action.d.ts +7 -0
- package/actions/new.action.js +186 -0
- package/actions/start.action.d.ts +10 -0
- package/actions/start.action.js +122 -0
- package/bin/nest.d.ts +2 -0
- package/bin/nest.js +25 -0
- package/changes.json +54 -0
- package/commands/abstract.command.d.ts +7 -0
- package/commands/abstract.command.js +9 -0
- package/commands/add.command.d.ts +5 -0
- package/commands/add.command.js +36 -0
- package/commands/build.command.d.ts +5 -0
- package/commands/build.command.js +74 -0
- package/commands/command.input.d.ts +5 -0
- package/commands/command.input.js +2 -0
- package/commands/command.loader.d.ts +5 -0
- package/commands/command.loader.js +31 -0
- package/commands/generate.command.d.ts +9 -0
- package/commands/generate.command.js +107 -0
- package/commands/index.d.ts +2 -0
- package/commands/index.js +18 -0
- package/commands/info.command.d.ts +5 -0
- package/commands/info.command.js +16 -0
- package/commands/new.command.d.ts +5 -0
- package/commands/new.command.js +61 -0
- package/commands/start.command.d.ts +5 -0
- package/commands/start.command.js +104 -0
- package/lib/compiler/assets-manager.d.ts +15 -0
- package/lib/compiler/assets-manager.js +129 -0
- package/lib/compiler/base-compiler.d.ts +9 -0
- package/lib/compiler/base-compiler.js +26 -0
- package/lib/compiler/compiler.d.ts +12 -0
- package/lib/compiler/compiler.js +61 -0
- package/lib/compiler/defaults/swc-defaults.d.ts +61 -0
- package/lib/compiler/defaults/swc-defaults.js +57 -0
- package/lib/compiler/defaults/webpack-defaults.d.ts +3 -0
- package/lib/compiler/defaults/webpack-defaults.js +104 -0
- package/lib/compiler/helpers/append-extension.d.ts +1 -0
- package/lib/compiler/helpers/append-extension.js +7 -0
- package/lib/compiler/helpers/copy-path-resolve.d.ts +7 -0
- package/lib/compiler/helpers/copy-path-resolve.js +25 -0
- package/lib/compiler/helpers/delete-out-dir.d.ts +2 -0
- package/lib/compiler/helpers/delete-out-dir.js +12 -0
- package/lib/compiler/helpers/get-builder.d.ts +21 -0
- package/lib/compiler/helpers/get-builder.js +19 -0
- package/lib/compiler/helpers/get-tsc-config.path.d.ts +10 -0
- package/lib/compiler/helpers/get-tsc-config.path.js +24 -0
- package/lib/compiler/helpers/get-value-or-default.d.ts +4 -0
- package/lib/compiler/helpers/get-value-or-default.js +66 -0
- package/lib/compiler/helpers/get-webpack-config-path.d.ts +10 -0
- package/lib/compiler/helpers/get-webpack-config-path.js +23 -0
- package/lib/compiler/helpers/manual-restart.d.ts +2 -0
- package/lib/compiler/helpers/manual-restart.js +17 -0
- package/lib/compiler/helpers/tsconfig-provider.d.ts +11 -0
- package/lib/compiler/helpers/tsconfig-provider.js +22 -0
- package/lib/compiler/hooks/tsconfig-paths.hook.d.ts +2 -0
- package/lib/compiler/hooks/tsconfig-paths.hook.js +76 -0
- package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +10 -0
- package/lib/compiler/interfaces/readonly-visitor.interface.js +2 -0
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +58 -0
- package/lib/compiler/plugins/plugin-metadata-generator.js +84 -0
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +17 -0
- package/lib/compiler/plugins/plugin-metadata-printer.js +51 -0
- package/lib/compiler/plugins/plugins-loader.d.ts +30 -0
- package/lib/compiler/plugins/plugins-loader.js +70 -0
- package/lib/compiler/swc/constants.d.ts +9 -0
- package/lib/compiler/swc/constants.js +13 -0
- package/lib/compiler/swc/forked-type-checker.d.ts +1 -0
- package/lib/compiler/swc/forked-type-checker.js +63 -0
- package/lib/compiler/swc/swc-compiler.d.ts +25 -0
- package/lib/compiler/swc/swc-compiler.js +231 -0
- package/lib/compiler/swc/type-checker-host.d.ts +14 -0
- package/lib/compiler/swc/type-checker-host.js +90 -0
- package/lib/compiler/typescript-loader.d.ts +6 -0
- package/lib/compiler/typescript-loader.js +31 -0
- package/lib/compiler/watch-compiler.d.ts +22 -0
- package/lib/compiler/watch-compiler.js +89 -0
- package/lib/compiler/webpack-compiler.d.ts +21 -0
- package/lib/compiler/webpack-compiler.js +99 -0
- package/lib/configuration/configuration.d.ts +91 -0
- package/lib/configuration/configuration.js +2 -0
- package/lib/configuration/configuration.loader.d.ts +4 -0
- package/lib/configuration/configuration.loader.js +2 -0
- package/lib/configuration/defaults.d.ts +6 -0
- package/lib/configuration/defaults.js +86 -0
- package/lib/configuration/index.d.ts +3 -0
- package/lib/configuration/index.js +19 -0
- package/lib/configuration/nest-configuration.loader.d.ts +8 -0
- package/lib/configuration/nest-configuration.loader.js +61 -0
- package/lib/package-managers/abstract.package-manager.d.ts +25 -0
- package/lib/package-managers/abstract.package-manager.js +151 -0
- package/lib/package-managers/index.d.ts +8 -0
- package/lib/package-managers/index.js +24 -0
- package/lib/package-managers/npm.package-manager.d.ts +7 -0
- package/lib/package-managers/npm.package-manager.js +26 -0
- package/lib/package-managers/package-manager-commands.d.ts +9 -0
- package/lib/package-managers/package-manager-commands.js +2 -0
- package/lib/package-managers/package-manager.d.ts +5 -0
- package/lib/package-managers/package-manager.factory.d.ts +6 -0
- package/lib/package-managers/package-manager.factory.js +41 -0
- package/lib/package-managers/package-manager.js +9 -0
- package/lib/package-managers/pnpm.package-manager.d.ts +7 -0
- package/lib/package-managers/pnpm.package-manager.js +27 -0
- package/lib/package-managers/project.dependency.d.ts +4 -0
- package/lib/package-managers/project.dependency.js +2 -0
- package/lib/package-managers/yarn.package-manager.d.ts +7 -0
- package/lib/package-managers/yarn.package-manager.js +26 -0
- package/lib/questions/questions.d.ts +9 -0
- package/lib/questions/questions.js +27 -0
- package/lib/readers/file-system.reader.d.ts +8 -0
- package/lib/readers/file-system.reader.js +46 -0
- package/lib/readers/index.d.ts +2 -0
- package/lib/readers/index.js +18 -0
- package/lib/readers/reader.d.ts +10 -0
- package/lib/readers/reader.js +11 -0
- package/lib/runners/abstract.runner.d.ts +11 -0
- package/lib/runners/abstract.runner.js +47 -0
- package/lib/runners/git.runner.d.ts +4 -0
- package/lib/runners/git.runner.js +10 -0
- package/lib/runners/index.d.ts +3 -0
- package/lib/runners/index.js +19 -0
- package/lib/runners/npm.runner.d.ts +4 -0
- package/lib/runners/npm.runner.js +10 -0
- package/lib/runners/pnpm.runner.d.ts +4 -0
- package/lib/runners/pnpm.runner.js +10 -0
- package/lib/runners/runner.d.ts +6 -0
- package/lib/runners/runner.factory.d.ts +8 -0
- package/lib/runners/runner.factory.js +26 -0
- package/lib/runners/runner.js +10 -0
- package/lib/runners/schematic.runner.d.ts +6 -0
- package/lib/runners/schematic.runner.js +21 -0
- package/lib/runners/yarn.runner.d.ts +4 -0
- package/lib/runners/yarn.runner.js +10 -0
- package/lib/schematics/abstract.collection.d.ts +12 -0
- package/lib/schematics/abstract.collection.js +23 -0
- package/lib/schematics/collection.d.ts +3 -0
- package/lib/schematics/collection.factory.d.ts +5 -0
- package/lib/schematics/collection.factory.js +19 -0
- package/lib/schematics/collection.js +7 -0
- package/lib/schematics/custom.collection.d.ts +10 -0
- package/lib/schematics/custom.collection.js +33 -0
- package/lib/schematics/index.d.ts +4 -0
- package/lib/schematics/index.js +20 -0
- package/lib/schematics/nest.collection.d.ts +15 -0
- package/lib/schematics/nest.collection.js +126 -0
- package/lib/schematics/schematic.option.d.ts +8 -0
- package/lib/schematics/schematic.option.js +44 -0
- package/lib/ui/banner.d.ts +1 -0
- package/lib/ui/banner.js +12 -0
- package/lib/ui/emojis.d.ts +19 -0
- package/lib/ui/emojis.js +23 -0
- package/lib/ui/errors.d.ts +4 -0
- package/lib/ui/errors.js +8 -0
- package/lib/ui/index.d.ts +5 -0
- package/lib/ui/index.js +21 -0
- package/lib/ui/messages.d.ts +24 -0
- package/lib/ui/messages.js +32 -0
- package/lib/ui/prefixes.d.ts +2 -0
- package/lib/ui/prefixes.js +6 -0
- package/lib/utils/formatting.d.ts +8 -0
- package/lib/utils/formatting.js +18 -0
- package/lib/utils/get-default-tsconfig-path.d.ts +1 -0
- package/lib/utils/get-default-tsconfig-path.js +12 -0
- package/lib/utils/gracefully-exit-on-prompt-error.d.ts +1 -0
- package/lib/utils/gracefully-exit-on-prompt-error.js +11 -0
- package/lib/utils/is-module-available.d.ts +1 -0
- package/lib/utils/is-module-available.js +12 -0
- package/lib/utils/load-configuration.d.ts +2 -0
- package/lib/utils/load-configuration.js +9 -0
- package/lib/utils/local-binaries.d.ts +3 -0
- package/lib/utils/local-binaries.js +15 -0
- package/lib/utils/os-info.utils.d.ts +1 -0
- package/lib/utils/os-info.utils.js +23 -0
- package/lib/utils/project-utils.d.ts +11 -0
- package/lib/utils/project-utils.js +83 -0
- package/lib/utils/remaining-flags.d.ts +2 -0
- package/lib/utils/remaining-flags.js +36 -0
- package/lib/utils/tree-kill.d.ts +1 -0
- package/lib/utils/tree-kill.js +68 -0
- package/lib/utils/type-assertions.d.ts +1 -0
- package/lib/utils/type-assertions.js +8 -0
- package/package.json +161 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildCommand = void 0;
|
|
4
|
+
const ui_1 = require("../lib/ui");
|
|
5
|
+
const abstract_command_1 = require("./abstract.command");
|
|
6
|
+
class BuildCommand extends abstract_command_1.AbstractCommand {
|
|
7
|
+
load(program) {
|
|
8
|
+
program
|
|
9
|
+
.command('build [apps...]')
|
|
10
|
+
.option('-c, --config [path]', 'Path to nest-cli configuration file.')
|
|
11
|
+
.option('-p, --path [path]', 'Path to tsconfig file.')
|
|
12
|
+
.option('-w, --watch', 'Run in watch mode (live-reload).')
|
|
13
|
+
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
|
|
14
|
+
.option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
|
|
15
|
+
.option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).')
|
|
16
|
+
.option('--type-check', 'Enable type checking (when SWC is used).')
|
|
17
|
+
.option('--webpackPath [path]', 'Path to webpack configuration.')
|
|
18
|
+
.option('--tsc', 'Use typescript compiler for compilation.')
|
|
19
|
+
.option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
|
|
20
|
+
.option('--all', 'Build all projects in a monorepo.')
|
|
21
|
+
.description('Build Nest application.')
|
|
22
|
+
.action(async (apps, command) => {
|
|
23
|
+
const options = [];
|
|
24
|
+
options.push({
|
|
25
|
+
name: 'config',
|
|
26
|
+
value: command.config,
|
|
27
|
+
});
|
|
28
|
+
const isWebpackEnabled = command.tsc ? false : command.webpack;
|
|
29
|
+
options.push({ name: 'webpack', value: isWebpackEnabled });
|
|
30
|
+
options.push({ name: 'watch', value: !!command.watch });
|
|
31
|
+
options.push({ name: 'watchAssets', value: !!command.watchAssets });
|
|
32
|
+
options.push({
|
|
33
|
+
name: 'path',
|
|
34
|
+
value: command.path,
|
|
35
|
+
});
|
|
36
|
+
options.push({
|
|
37
|
+
name: 'webpackPath',
|
|
38
|
+
value: command.webpackPath,
|
|
39
|
+
});
|
|
40
|
+
const availableBuilders = ['tsc', 'webpack', 'swc'];
|
|
41
|
+
if (command.builder && !availableBuilders.includes(command.builder)) {
|
|
42
|
+
console.error(ui_1.ERROR_PREFIX +
|
|
43
|
+
` Invalid builder option: ${command.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
options.push({
|
|
47
|
+
name: 'builder',
|
|
48
|
+
value: command.builder,
|
|
49
|
+
});
|
|
50
|
+
options.push({
|
|
51
|
+
name: 'typeCheck',
|
|
52
|
+
value: command.typeCheck,
|
|
53
|
+
});
|
|
54
|
+
options.push({
|
|
55
|
+
name: 'preserveWatchOutput',
|
|
56
|
+
value: !!command.preserveWatchOutput &&
|
|
57
|
+
!!command.watch &&
|
|
58
|
+
!isWebpackEnabled,
|
|
59
|
+
});
|
|
60
|
+
options.push({ name: 'all', value: !!command.all });
|
|
61
|
+
const inputs = apps.map((app) => ({
|
|
62
|
+
name: 'app',
|
|
63
|
+
value: app,
|
|
64
|
+
}));
|
|
65
|
+
// Handle the default project for `nest build` with no args
|
|
66
|
+
// The action instance will pick up the default project when value is `undefined`
|
|
67
|
+
if (inputs.length === 0) {
|
|
68
|
+
inputs.push({ name: 'app', value: undefined });
|
|
69
|
+
}
|
|
70
|
+
await this.action.handle(inputs, options);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.BuildCommand = BuildCommand;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandLoader = void 0;
|
|
4
|
+
const ansis_1 = require("ansis");
|
|
5
|
+
const actions_1 = require("../actions");
|
|
6
|
+
const ui_1 = require("../lib/ui");
|
|
7
|
+
const add_command_1 = require("./add.command");
|
|
8
|
+
const build_command_1 = require("./build.command");
|
|
9
|
+
const generate_command_1 = require("./generate.command");
|
|
10
|
+
const info_command_1 = require("./info.command");
|
|
11
|
+
const new_command_1 = require("./new.command");
|
|
12
|
+
const start_command_1 = require("./start.command");
|
|
13
|
+
class CommandLoader {
|
|
14
|
+
static async load(program) {
|
|
15
|
+
new new_command_1.NewCommand(new actions_1.NewAction()).load(program);
|
|
16
|
+
new build_command_1.BuildCommand(new actions_1.BuildAction()).load(program);
|
|
17
|
+
new start_command_1.StartCommand(new actions_1.StartAction()).load(program);
|
|
18
|
+
new info_command_1.InfoCommand(new actions_1.InfoAction()).load(program);
|
|
19
|
+
new add_command_1.AddCommand(new actions_1.AddAction()).load(program);
|
|
20
|
+
await new generate_command_1.GenerateCommand(new actions_1.GenerateAction()).load(program);
|
|
21
|
+
this.handleInvalidCommand(program);
|
|
22
|
+
}
|
|
23
|
+
static handleInvalidCommand(program) {
|
|
24
|
+
program.on('command:*', () => {
|
|
25
|
+
console.error(`\n${ui_1.ERROR_PREFIX} Invalid command: ${(0, ansis_1.red) `%s`}`, program.args.join(' '));
|
|
26
|
+
console.log(`See ${(0, ansis_1.red) `--help`} for a list of available commands.\n`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.CommandLoader = CommandLoader;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CommanderStatic } from 'commander';
|
|
2
|
+
import { AbstractCommand } from './abstract.command';
|
|
3
|
+
export declare class GenerateCommand extends AbstractCommand {
|
|
4
|
+
load(program: CommanderStatic): Promise<void>;
|
|
5
|
+
private buildDescription;
|
|
6
|
+
private buildSchematicsListAsTable;
|
|
7
|
+
private getCollection;
|
|
8
|
+
private getSchematics;
|
|
9
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenerateCommand = void 0;
|
|
4
|
+
const ansis_1 = require("ansis");
|
|
5
|
+
const Table = require("cli-table3");
|
|
6
|
+
const schematics_1 = require("../lib/schematics");
|
|
7
|
+
const load_configuration_1 = require("../lib/utils/load-configuration");
|
|
8
|
+
const abstract_command_1 = require("./abstract.command");
|
|
9
|
+
class GenerateCommand extends abstract_command_1.AbstractCommand {
|
|
10
|
+
async load(program) {
|
|
11
|
+
program
|
|
12
|
+
.command('generate <schematic> [name] [path]')
|
|
13
|
+
.alias('g')
|
|
14
|
+
.description(await this.buildDescription())
|
|
15
|
+
.option('-d, --dry-run', 'Report actions that would be taken without writing out results.')
|
|
16
|
+
.option('-p, --project [project]', 'Project in which to generate files.')
|
|
17
|
+
.option('--flat', 'Enforce flat structure of generated element.', () => true)
|
|
18
|
+
.option('--no-flat', 'Enforce that directories are generated.', () => false)
|
|
19
|
+
.option('--spec', 'Enforce spec files generation.', () => {
|
|
20
|
+
return { value: true, passedAsInput: true };
|
|
21
|
+
}, true)
|
|
22
|
+
.option('--spec-file-suffix [suffix]', 'Use a custom suffix for spec files.')
|
|
23
|
+
.option('--skip-import', 'Skip importing', () => true, false)
|
|
24
|
+
.option('--no-spec', 'Disable spec files generation.', () => {
|
|
25
|
+
return { value: false, passedAsInput: true };
|
|
26
|
+
})
|
|
27
|
+
.option('-c, --collection [collectionName]', 'Schematics collection to use.')
|
|
28
|
+
.action(async (schematic, name, path, command) => {
|
|
29
|
+
const options = [];
|
|
30
|
+
options.push({ name: 'dry-run', value: !!command.dryRun });
|
|
31
|
+
if (command.flat !== undefined) {
|
|
32
|
+
options.push({ name: 'flat', value: command.flat });
|
|
33
|
+
}
|
|
34
|
+
options.push({
|
|
35
|
+
name: 'spec',
|
|
36
|
+
value: typeof command.spec === 'boolean'
|
|
37
|
+
? command.spec
|
|
38
|
+
: command.spec.value,
|
|
39
|
+
options: {
|
|
40
|
+
passedAsInput: typeof command.spec === 'boolean'
|
|
41
|
+
? false
|
|
42
|
+
: command.spec.passedAsInput,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
options.push({
|
|
46
|
+
name: 'specFileSuffix',
|
|
47
|
+
value: command.specFileSuffix,
|
|
48
|
+
});
|
|
49
|
+
options.push({
|
|
50
|
+
name: 'collection',
|
|
51
|
+
value: command.collection,
|
|
52
|
+
});
|
|
53
|
+
options.push({
|
|
54
|
+
name: 'project',
|
|
55
|
+
value: command.project,
|
|
56
|
+
});
|
|
57
|
+
options.push({
|
|
58
|
+
name: 'skipImport',
|
|
59
|
+
value: command.skipImport,
|
|
60
|
+
});
|
|
61
|
+
const inputs = [];
|
|
62
|
+
inputs.push({ name: 'schematic', value: schematic });
|
|
63
|
+
inputs.push({ name: 'name', value: name });
|
|
64
|
+
inputs.push({ name: 'path', value: path });
|
|
65
|
+
await this.action.handle(inputs, options);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async buildDescription() {
|
|
69
|
+
const collection = await this.getCollection();
|
|
70
|
+
return ('Generate a Nest element.\n' +
|
|
71
|
+
` Schematics available on ${(0, ansis_1.bold)(collection)} collection:\n` +
|
|
72
|
+
this.buildSchematicsListAsTable(await this.getSchematics(collection)));
|
|
73
|
+
}
|
|
74
|
+
buildSchematicsListAsTable(schematics) {
|
|
75
|
+
const leftMargin = ' ';
|
|
76
|
+
const tableConfig = {
|
|
77
|
+
head: ['name', 'alias', 'description'],
|
|
78
|
+
chars: {
|
|
79
|
+
'left': leftMargin.concat('│'),
|
|
80
|
+
'top-left': leftMargin.concat('┌'),
|
|
81
|
+
'bottom-left': leftMargin.concat('└'),
|
|
82
|
+
'mid': '',
|
|
83
|
+
'left-mid': '',
|
|
84
|
+
'mid-mid': '',
|
|
85
|
+
'right-mid': '',
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
const table = new Table(tableConfig);
|
|
89
|
+
for (const schematic of schematics) {
|
|
90
|
+
table.push([
|
|
91
|
+
(0, ansis_1.green)(schematic.name),
|
|
92
|
+
(0, ansis_1.cyan)(schematic.alias),
|
|
93
|
+
schematic.description,
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
return table.toString();
|
|
97
|
+
}
|
|
98
|
+
async getCollection() {
|
|
99
|
+
const configuration = await (0, load_configuration_1.loadConfiguration)();
|
|
100
|
+
return configuration.collection;
|
|
101
|
+
}
|
|
102
|
+
async getSchematics(collection) {
|
|
103
|
+
const abstractCollection = schematics_1.CollectionFactory.create(collection);
|
|
104
|
+
return abstractCollection.getSchematics();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.GenerateCommand = GenerateCommand;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./command.loader"), exports);
|
|
18
|
+
__exportStar(require("./command.input"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoCommand = void 0;
|
|
4
|
+
const abstract_command_1 = require("./abstract.command");
|
|
5
|
+
class InfoCommand extends abstract_command_1.AbstractCommand {
|
|
6
|
+
load(program) {
|
|
7
|
+
program
|
|
8
|
+
.command('info')
|
|
9
|
+
.alias('i')
|
|
10
|
+
.description('Display Nest project details.')
|
|
11
|
+
.action(async () => {
|
|
12
|
+
await this.action.handle();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.InfoCommand = InfoCommand;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NewCommand = void 0;
|
|
4
|
+
const schematics_1 = require("../lib/schematics");
|
|
5
|
+
const abstract_command_1 = require("./abstract.command");
|
|
6
|
+
class NewCommand extends abstract_command_1.AbstractCommand {
|
|
7
|
+
load(program) {
|
|
8
|
+
program
|
|
9
|
+
.command('new [name]')
|
|
10
|
+
.alias('n')
|
|
11
|
+
.description('Generate Nest application.')
|
|
12
|
+
.option('--directory [directory]', 'Specify the destination directory')
|
|
13
|
+
.option('-d, --dry-run', 'Report actions that would be performed without writing out results.', false)
|
|
14
|
+
.option('-g, --skip-git', 'Skip git repository initialization.', false)
|
|
15
|
+
.option('-s, --skip-install', 'Skip package installation.', false)
|
|
16
|
+
.option('-p, --package-manager [packageManager]', 'Specify package manager.')
|
|
17
|
+
.option('-l, --language [language]', 'Programming language to be used (TypeScript or JavaScript)', 'TypeScript')
|
|
18
|
+
.option('-c, --collection [collectionName]', 'Schematics collection to use', schematics_1.Collection.NESTJS)
|
|
19
|
+
.option('--strict', 'Enables strict mode in TypeScript.', false)
|
|
20
|
+
.action(async (name, command) => {
|
|
21
|
+
const options = [];
|
|
22
|
+
const availableLanguages = ['js', 'ts', 'javascript', 'typescript'];
|
|
23
|
+
options.push({ name: 'directory', value: command.directory });
|
|
24
|
+
options.push({ name: 'dry-run', value: command.dryRun });
|
|
25
|
+
options.push({ name: 'skip-git', value: command.skipGit });
|
|
26
|
+
options.push({ name: 'skip-install', value: command.skipInstall });
|
|
27
|
+
options.push({ name: 'strict', value: command.strict });
|
|
28
|
+
options.push({
|
|
29
|
+
name: 'packageManager',
|
|
30
|
+
value: command.packageManager,
|
|
31
|
+
});
|
|
32
|
+
options.push({ name: 'collection', value: command.collection });
|
|
33
|
+
if (!!command.language) {
|
|
34
|
+
const lowercasedLanguage = command.language.toLowerCase();
|
|
35
|
+
const langMatch = availableLanguages.includes(lowercasedLanguage);
|
|
36
|
+
if (!langMatch) {
|
|
37
|
+
throw new Error(`Invalid language "${command.language}" selected. Available languages are "typescript" or "javascript"`);
|
|
38
|
+
}
|
|
39
|
+
switch (lowercasedLanguage) {
|
|
40
|
+
case 'javascript':
|
|
41
|
+
command.language = 'js';
|
|
42
|
+
break;
|
|
43
|
+
case 'typescript':
|
|
44
|
+
command.language = 'ts';
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
command.language = lowercasedLanguage;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
options.push({
|
|
52
|
+
name: 'language',
|
|
53
|
+
value: command.language,
|
|
54
|
+
});
|
|
55
|
+
const inputs = [];
|
|
56
|
+
inputs.push({ name: 'name', value: name });
|
|
57
|
+
await this.action.handle(inputs, options);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.NewCommand = NewCommand;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StartCommand = void 0;
|
|
4
|
+
const ui_1 = require("../lib/ui");
|
|
5
|
+
const remaining_flags_1 = require("../lib/utils/remaining-flags");
|
|
6
|
+
const abstract_command_1 = require("./abstract.command");
|
|
7
|
+
class StartCommand extends abstract_command_1.AbstractCommand {
|
|
8
|
+
load(program) {
|
|
9
|
+
const collect = (value, previous) => {
|
|
10
|
+
return previous.concat([value]);
|
|
11
|
+
};
|
|
12
|
+
program
|
|
13
|
+
.command('start [app]')
|
|
14
|
+
.allowUnknownOption()
|
|
15
|
+
.option('-c, --config [path]', 'Path to nest-cli configuration file.')
|
|
16
|
+
.option('-p, --path [path]', 'Path to tsconfig file.')
|
|
17
|
+
.option('-w, --watch', 'Run in watch mode (live-reload).')
|
|
18
|
+
.option('-b, --builder [name]', 'Builder to be used (tsc, webpack, swc).')
|
|
19
|
+
.option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.')
|
|
20
|
+
.option('-d, --debug [hostport] ', 'Run in debug mode (with --inspect flag).')
|
|
21
|
+
.option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).')
|
|
22
|
+
.option('--webpackPath [path]', 'Path to webpack configuration.')
|
|
23
|
+
.option('--type-check', 'Enable type checking (when SWC is used).')
|
|
24
|
+
.option('--tsc', 'Use typescript compiler for compilation.')
|
|
25
|
+
.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.')
|
|
26
|
+
.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.")
|
|
27
|
+
.option('-e, --exec [binary]', 'Binary to run (default: "node").')
|
|
28
|
+
.option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
|
|
29
|
+
.option('--shell', "Spawn child processes within a shell (see node's child_process.spawn() method docs). Default: true.", true)
|
|
30
|
+
.option('--no-shell', 'Do not spawn child processes within a shell.')
|
|
31
|
+
.option('--env-file [path]', 'Path to an env file (.env) to be loaded into the environment.', collect, [])
|
|
32
|
+
.description('Run Nest application.')
|
|
33
|
+
.action(async (app, command) => {
|
|
34
|
+
const options = [];
|
|
35
|
+
options.push({
|
|
36
|
+
name: 'config',
|
|
37
|
+
value: command.config,
|
|
38
|
+
});
|
|
39
|
+
const isWebpackEnabled = command.tsc ? false : command.webpack;
|
|
40
|
+
options.push({ name: 'webpack', value: isWebpackEnabled });
|
|
41
|
+
options.push({ name: 'debug', value: command.debug });
|
|
42
|
+
options.push({ name: 'watch', value: !!command.watch });
|
|
43
|
+
options.push({ name: 'watchAssets', value: !!command.watchAssets });
|
|
44
|
+
options.push({
|
|
45
|
+
name: 'path',
|
|
46
|
+
value: command.path,
|
|
47
|
+
});
|
|
48
|
+
options.push({
|
|
49
|
+
name: 'webpackPath',
|
|
50
|
+
value: command.webpackPath,
|
|
51
|
+
});
|
|
52
|
+
options.push({
|
|
53
|
+
name: 'exec',
|
|
54
|
+
value: command.exec,
|
|
55
|
+
});
|
|
56
|
+
options.push({
|
|
57
|
+
name: 'sourceRoot',
|
|
58
|
+
value: command.sourceRoot,
|
|
59
|
+
});
|
|
60
|
+
options.push({
|
|
61
|
+
name: 'entryFile',
|
|
62
|
+
value: command.entryFile,
|
|
63
|
+
});
|
|
64
|
+
options.push({
|
|
65
|
+
name: 'preserveWatchOutput',
|
|
66
|
+
value: !!command.preserveWatchOutput &&
|
|
67
|
+
!!command.watch &&
|
|
68
|
+
!isWebpackEnabled,
|
|
69
|
+
});
|
|
70
|
+
options.push({
|
|
71
|
+
name: 'shell',
|
|
72
|
+
value: !!command.shell,
|
|
73
|
+
});
|
|
74
|
+
options.push({
|
|
75
|
+
name: 'envFile',
|
|
76
|
+
value: command.envFile,
|
|
77
|
+
});
|
|
78
|
+
const availableBuilders = ['tsc', 'webpack', 'swc'];
|
|
79
|
+
if (command.builder && !availableBuilders.includes(command.builder)) {
|
|
80
|
+
console.error(ui_1.ERROR_PREFIX +
|
|
81
|
+
` Invalid builder option: ${command.builder}. Available builders: ${availableBuilders.join(', ')}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
options.push({
|
|
85
|
+
name: 'builder',
|
|
86
|
+
value: command.builder,
|
|
87
|
+
});
|
|
88
|
+
options.push({
|
|
89
|
+
name: 'typeCheck',
|
|
90
|
+
value: command.typeCheck,
|
|
91
|
+
});
|
|
92
|
+
const inputs = [];
|
|
93
|
+
inputs.push({ name: 'app', value: app });
|
|
94
|
+
const flags = (0, remaining_flags_1.getRemainingFlags)(program);
|
|
95
|
+
try {
|
|
96
|
+
await this.action.handle(inputs, options, flags);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.StartCommand = StartCommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Configuration } from '../configuration';
|
|
2
|
+
export declare class AssetsManager {
|
|
3
|
+
private watchAssetsKeyValue;
|
|
4
|
+
private watchers;
|
|
5
|
+
private actionInProgress;
|
|
6
|
+
/**
|
|
7
|
+
* Using on `nest build` to close file watch or the build process will not end
|
|
8
|
+
* Interval like process
|
|
9
|
+
* If no action has been taken recently close watchers
|
|
10
|
+
* If action has been taken recently flag and try again
|
|
11
|
+
*/
|
|
12
|
+
closeWatchers(): void;
|
|
13
|
+
copyAssets(configuration: Required<Configuration>, appName: string | undefined, outDir: string, watchAssetsMode: boolean): void;
|
|
14
|
+
private actionOnFile;
|
|
15
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssetsManager = void 0;
|
|
4
|
+
const chokidar = require("chokidar");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const glob_1 = require("glob");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const copy_path_resolve_1 = require("./helpers/copy-path-resolve");
|
|
9
|
+
const get_value_or_default_1 = require("./helpers/get-value-or-default");
|
|
10
|
+
class AssetsManager {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.watchAssetsKeyValue = {};
|
|
13
|
+
this.watchers = [];
|
|
14
|
+
this.actionInProgress = false;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Using on `nest build` to close file watch or the build process will not end
|
|
18
|
+
* Interval like process
|
|
19
|
+
* If no action has been taken recently close watchers
|
|
20
|
+
* If action has been taken recently flag and try again
|
|
21
|
+
*/
|
|
22
|
+
closeWatchers() {
|
|
23
|
+
// Consider adjusting this for larger files
|
|
24
|
+
const timeoutMs = 500;
|
|
25
|
+
const closeFn = () => {
|
|
26
|
+
if (this.actionInProgress) {
|
|
27
|
+
this.actionInProgress = false;
|
|
28
|
+
setTimeout(closeFn, timeoutMs);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.watchers.forEach((watcher) => watcher.close());
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
setTimeout(closeFn, timeoutMs);
|
|
35
|
+
}
|
|
36
|
+
copyAssets(configuration, appName, outDir, watchAssetsMode) {
|
|
37
|
+
const assets = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.assets', appName) || [];
|
|
38
|
+
if (assets.length <= 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
let sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName);
|
|
43
|
+
sourceRoot = (0, path_1.join)(process.cwd(), sourceRoot);
|
|
44
|
+
const filesToCopy = assets.map((item) => {
|
|
45
|
+
let includePath = typeof item === 'string' ? item : item.include;
|
|
46
|
+
let excludePath = typeof item !== 'string' && item.exclude ? item.exclude : undefined;
|
|
47
|
+
includePath = (0, path_1.join)(sourceRoot, includePath).replace(/\\/g, '/');
|
|
48
|
+
excludePath = excludePath
|
|
49
|
+
? (0, path_1.join)(sourceRoot, excludePath).replace(/\\/g, '/')
|
|
50
|
+
: undefined;
|
|
51
|
+
return {
|
|
52
|
+
outDir: typeof item !== 'string' ? item.outDir || outDir : outDir,
|
|
53
|
+
glob: includePath,
|
|
54
|
+
exclude: excludePath,
|
|
55
|
+
flat: typeof item !== 'string' ? item.flat : undefined, // deprecated field
|
|
56
|
+
watchAssets: typeof item !== 'string' ? item.watchAssets : undefined,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
const isWatchEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.watchAssets', appName) || watchAssetsMode;
|
|
60
|
+
for (const item of filesToCopy) {
|
|
61
|
+
const option = {
|
|
62
|
+
action: 'change',
|
|
63
|
+
item,
|
|
64
|
+
path: '',
|
|
65
|
+
sourceRoot,
|
|
66
|
+
watchAssetsMode: isWatchEnabled,
|
|
67
|
+
};
|
|
68
|
+
if (isWatchEnabled || item.watchAssets) {
|
|
69
|
+
// prettier-ignore
|
|
70
|
+
const watcher = chokidar
|
|
71
|
+
.watch((0, glob_1.sync)(item.glob, {
|
|
72
|
+
ignore: item.exclude,
|
|
73
|
+
dot: true,
|
|
74
|
+
}))
|
|
75
|
+
.on('add', (path) => this.actionOnFile({ ...option, path, action: 'change' }))
|
|
76
|
+
.on('change', (path) => this.actionOnFile({ ...option, path, action: 'change' }))
|
|
77
|
+
.on('unlink', (path) => this.actionOnFile({ ...option, path, action: 'unlink' }));
|
|
78
|
+
this.watchers.push(watcher);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const matchedPaths = (0, glob_1.sync)(item.glob, {
|
|
82
|
+
ignore: item.exclude,
|
|
83
|
+
dot: true,
|
|
84
|
+
});
|
|
85
|
+
const files = item.glob.endsWith('*')
|
|
86
|
+
? matchedPaths.filter((matched) => (0, fs_1.statSync)(matched).isFile())
|
|
87
|
+
: matchedPaths.flatMap((matched) => {
|
|
88
|
+
if ((0, fs_1.statSync)(matched).isDirectory()) {
|
|
89
|
+
return (0, glob_1.sync)(`${matched}/**/*`, {
|
|
90
|
+
ignore: item.exclude,
|
|
91
|
+
}).filter((file) => (0, fs_1.statSync)(file).isFile());
|
|
92
|
+
}
|
|
93
|
+
return matched;
|
|
94
|
+
});
|
|
95
|
+
for (const path of files) {
|
|
96
|
+
this.actionOnFile({ ...option, path, action: 'change' });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
throw new Error(`An error occurred during the assets copying process. ${err.message}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
actionOnFile(option) {
|
|
106
|
+
const { action, item, path, sourceRoot, watchAssetsMode } = option;
|
|
107
|
+
const isWatchEnabled = watchAssetsMode || item.watchAssets;
|
|
108
|
+
const assetCheckKey = path + (item.outDir ?? '');
|
|
109
|
+
// Allow to do action for the first time before check watchMode
|
|
110
|
+
if (!isWatchEnabled && this.watchAssetsKeyValue[assetCheckKey]) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Set path value to true for watching the first time
|
|
114
|
+
this.watchAssetsKeyValue[assetCheckKey] = true;
|
|
115
|
+
// Set action to true to avoid watches getting cutoff
|
|
116
|
+
this.actionInProgress = true;
|
|
117
|
+
const dest = (0, copy_path_resolve_1.copyPathResolve)(path, item.outDir, sourceRoot.split(path_1.sep).length);
|
|
118
|
+
// Copy to output dir if file is changed or added
|
|
119
|
+
if (action === 'change') {
|
|
120
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(dest), { recursive: true });
|
|
121
|
+
(0, fs_1.copyFileSync)(path, dest);
|
|
122
|
+
}
|
|
123
|
+
else if (action === 'unlink') {
|
|
124
|
+
// Remove from output dir if file is deleted
|
|
125
|
+
(0, fs_1.rmSync)(dest, { force: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.AssetsManager = AssetsManager;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Configuration } from '../configuration';
|
|
2
|
+
import { PluginsLoader } from './plugins/plugins-loader';
|
|
3
|
+
export declare abstract class BaseCompiler<T = Record<string, any>> {
|
|
4
|
+
private readonly pluginsLoader;
|
|
5
|
+
constructor(pluginsLoader: PluginsLoader);
|
|
6
|
+
abstract run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras?: T, onSuccess?: () => void): any;
|
|
7
|
+
loadPlugins(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined): import("./plugins/plugins-loader").MultiNestCompilerPlugins;
|
|
8
|
+
getPathToSource(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCompiler = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const get_value_or_default_1 = require("./helpers/get-value-or-default");
|
|
6
|
+
class BaseCompiler {
|
|
7
|
+
constructor(pluginsLoader) {
|
|
8
|
+
this.pluginsLoader = pluginsLoader;
|
|
9
|
+
}
|
|
10
|
+
loadPlugins(configuration, tsConfigPath, appName) {
|
|
11
|
+
const pluginsConfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.plugins', appName);
|
|
12
|
+
const pathToSource = this.getPathToSource(configuration, tsConfigPath, appName);
|
|
13
|
+
const plugins = this.pluginsLoader.load(pluginsConfig, { pathToSource });
|
|
14
|
+
return plugins;
|
|
15
|
+
}
|
|
16
|
+
getPathToSource(configuration, tsConfigPath, appName) {
|
|
17
|
+
const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot');
|
|
18
|
+
const cwd = process.cwd();
|
|
19
|
+
const relativeRootPath = (0, path_1.dirname)((0, path_1.relative)(cwd, tsConfigPath));
|
|
20
|
+
const pathToSource = (0, path_1.normalize)(sourceRoot).indexOf((0, path_1.normalize)(relativeRootPath)) >= 0
|
|
21
|
+
? (0, path_1.join)(cwd, sourceRoot)
|
|
22
|
+
: (0, path_1.join)(cwd, relativeRootPath, sourceRoot);
|
|
23
|
+
return pathToSource;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.BaseCompiler = BaseCompiler;
|