@nestjs/cli
Advanced tools
Comparing version 10.0.5 to 10.1.0-next.1
@@ -18,4 +18,4 @@ import { Input } from '../commands'; | ||
protected readonly workspaceUtils: WorkspaceUtils; | ||
handle(inputs: Input[], options: Input[]): Promise<void>; | ||
runBuild(inputs: Input[], options: Input[], watchMode: boolean, watchAssetsMode: boolean, isDebugEnabled?: boolean, onSuccess?: () => void): Promise<void>; | ||
handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>; | ||
runBuild(commandInputs: Input[], commandOptions: Input[], watchMode: boolean, watchAssetsMode: boolean, isDebugEnabled?: boolean, onSuccess?: () => void): Promise<void>; | ||
private runSwc; | ||
@@ -22,0 +22,0 @@ private runWebpack; |
@@ -8,3 +8,6 @@ "use strict"; | ||
const compiler_1 = require("../lib/compiler/compiler"); | ||
const get_builder_1 = require("../lib/compiler/helpers/get-builder"); | ||
const get_tsc_config_path_1 = require("../lib/compiler/helpers/get-tsc-config.path"); | ||
const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default"); | ||
const get_webpack_config_path_1 = require("../lib/compiler/helpers/get-webpack-config-path"); | ||
const tsconfig_provider_1 = require("../lib/compiler/helpers/tsconfig-provider"); | ||
@@ -33,9 +36,9 @@ const plugins_loader_1 = require("../lib/compiler/plugins/plugins-loader"); | ||
} | ||
async handle(inputs, options) { | ||
async handle(commandInputs, commandOptions) { | ||
try { | ||
const watchModeOption = options.find((option) => option.name === 'watch'); | ||
const watchModeOption = commandOptions.find((option) => option.name === 'watch'); | ||
const watchMode = !!(watchModeOption && watchModeOption.value); | ||
const watchAssetsModeOption = options.find((option) => option.name === 'watchAssets'); | ||
const watchAssetsModeOption = commandOptions.find((option) => option.name === 'watchAssets'); | ||
const watchAssetsMode = !!(watchAssetsModeOption && watchAssetsModeOption.value); | ||
await this.runBuild(inputs, options, watchMode, watchAssetsMode); | ||
await this.runBuild(commandInputs, commandOptions, watchMode, watchAssetsMode); | ||
} | ||
@@ -52,24 +55,23 @@ catch (err) { | ||
} | ||
async runBuild(inputs, options, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) { | ||
const configFileName = options.find((option) => option.name === 'config') | ||
.value; | ||
async runBuild(commandInputs, commandOptions, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) { | ||
const configFileName = commandOptions.find((option) => option.name === 'config').value; | ||
const configuration = await this.loader.load(configFileName); | ||
const appName = inputs.find((input) => input.name === 'app') | ||
const appName = commandInputs.find((input) => input.name === 'app') | ||
.value; | ||
const pathToTsconfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options); | ||
const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName); | ||
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig); | ||
const outDir = tsOptions.outDir || defaults_1.defaultOutDir; | ||
const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', options); | ||
const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', commandOptions); | ||
const builder = isWebpackEnabled | ||
? 'webpack' | ||
: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName, 'builder', options, 'tsc'); | ||
? { type: 'webpack' } | ||
: (0, get_builder_1.getBuilder)(configuration, commandOptions, appName); | ||
await this.workspaceUtils.deleteOutDirIfEnabled(configuration, appName, outDir); | ||
this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode); | ||
switch (builder) { | ||
switch (builder.type) { | ||
case 'tsc': | ||
return this.runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess); | ||
return this.runTsc(watchMode, commandOptions, configuration, pathToTsconfig, appName, onSuccess); | ||
case 'webpack': | ||
return this.runWebpack(configuration, appName, options, pathToTsconfig, isDebugEnabled, watchMode, onSuccess); | ||
return this.runWebpack(configuration, appName, commandOptions, pathToTsconfig, isDebugEnabled, watchMode, onSuccess); | ||
case 'swc': | ||
return this.runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions, onSuccess); | ||
return this.runSwc(configuration, appName, pathToTsconfig, watchMode, commandOptions, tsOptions, onSuccess); | ||
} | ||
@@ -86,8 +88,8 @@ } | ||
} | ||
runWebpack(configuration, appName, inputs, pathToTsconfig, debug, watchMode, onSuccess) { | ||
runWebpack(configuration, appName, commandOptions, pathToTsconfig, debug, watchMode, onSuccess) { | ||
const webpackCompiler = new webpack_compiler_1.WebpackCompiler(this.pluginsLoader); | ||
const webpackPath = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpackConfigPath', appName, 'webpackPath', inputs); | ||
const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, configuration.compilerOptions.webpackConfigPath); | ||
const webpackPath = (0, get_webpack_config_path_1.getWebpackConfigPath)(configuration, commandOptions, appName); | ||
const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, defaults_1.defaultWebpackConfigFilename); | ||
return webpackCompiler.run(configuration, pathToTsconfig, appName, { | ||
inputs, | ||
inputs: commandOptions, | ||
webpackConfigFactoryOrConfig, | ||
@@ -94,0 +96,0 @@ debug, |
import { Input } from '../commands'; | ||
import { BuildAction } from './build.action'; | ||
export declare class StartAction extends BuildAction { | ||
handle(inputs: Input[], options: Input[]): Promise<void>; | ||
handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>; | ||
createOnSuccessHook(entryFile: string, sourceRoot: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun: string): () => void; | ||
@@ -6,0 +6,0 @@ private spawnChildProcess; |
@@ -9,29 +9,29 @@ "use strict"; | ||
const killProcess = require("tree-kill"); | ||
const tree_kill_1 = require("../lib/utils/tree-kill"); | ||
const get_tsc_config_path_1 = require("../lib/compiler/helpers/get-tsc-config.path"); | ||
const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default"); | ||
const defaults_1 = require("../lib/configuration/defaults"); | ||
const ui_1 = require("../lib/ui"); | ||
const tree_kill_1 = require("../lib/utils/tree-kill"); | ||
const build_action_1 = require("./build.action"); | ||
class StartAction extends build_action_1.BuildAction { | ||
async handle(inputs, options) { | ||
async handle(commandInputs, commandOptions) { | ||
try { | ||
const configFileName = options.find((option) => option.name === 'config') | ||
.value; | ||
const configFileName = commandOptions.find((option) => option.name === 'config').value; | ||
const configuration = await this.loader.load(configFileName); | ||
const appName = inputs.find((input) => input.name === 'app') | ||
const appName = commandInputs.find((input) => input.name === 'app') | ||
.value; | ||
const pathToTsconfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options); | ||
const debugModeOption = options.find((option) => option.name === 'debug'); | ||
const watchModeOption = options.find((option) => option.name === 'watch'); | ||
const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName); | ||
const debugModeOption = commandOptions.find((option) => option.name === 'debug'); | ||
const watchModeOption = commandOptions.find((option) => option.name === 'watch'); | ||
const isWatchEnabled = !!(watchModeOption && watchModeOption.value); | ||
const watchAssetsModeOption = options.find((option) => option.name === 'watchAssets'); | ||
const watchAssetsModeOption = commandOptions.find((option) => option.name === 'watchAssets'); | ||
const isWatchAssetsEnabled = !!(watchAssetsModeOption && watchAssetsModeOption.value); | ||
const debugFlag = debugModeOption && debugModeOption.value; | ||
const binaryToRun = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'exec', appName, 'exec', options, defaults_1.defaultConfiguration.exec); | ||
const binaryToRun = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'exec', appName, 'exec', commandOptions, defaults_1.defaultConfiguration.exec); | ||
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig); | ||
const outDir = tsOptions.outDir || defaults_1.defaultOutDir; | ||
const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', options, defaults_1.defaultConfiguration.entryFile); | ||
const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', options, defaults_1.defaultConfiguration.sourceRoot); | ||
const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', commandOptions, defaults_1.defaultConfiguration.entryFile); | ||
const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', commandOptions, defaults_1.defaultConfiguration.sourceRoot); | ||
const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun); | ||
await this.runBuild(inputs, options, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess); | ||
await this.runBuild(commandInputs, commandOptions, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess); | ||
} | ||
@@ -38,0 +38,0 @@ catch (err) { |
@@ -15,3 +15,3 @@ "use strict"; | ||
.option('--watchAssets', 'Watch non-ts (e.g., .graphql) files mode.') | ||
.option('--webpack', 'Use webpack for compilation (deprecated option, use --build instead).') | ||
.option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).') | ||
.option('--type-check', 'Enable type checking (when SWC is used).') | ||
@@ -18,0 +18,0 @@ .option('--webpackPath [path]', 'Path to webpack configuration.') |
@@ -17,3 +17,3 @@ "use strict"; | ||
.option('-d, --debug [hostport] ', 'Run in debug mode (with --inspect flag).') | ||
.option('--webpack', 'Use webpack for compilation (deprecated option, use --build instead).') | ||
.option('--webpack', 'Use webpack for compilation (deprecated option, use --builder instead).') | ||
.option('--webpackPath [path]', 'Path to webpack configuration.') | ||
@@ -20,0 +20,0 @@ .option('--type-check', 'Enable type checking (when SWC is used).') |
import * as ts from 'typescript'; | ||
export declare const swcDefaultsFactory: (tsOptions: ts.CompilerOptions) => { | ||
import { Configuration } from '../../configuration'; | ||
export declare const swcDefaultsFactory: (tsOptions: ts.CompilerOptions, configuration: Configuration) => { | ||
swcOptions: { | ||
@@ -30,7 +31,27 @@ module: { | ||
extensions: string[]; | ||
copyFiles: boolean; | ||
includeDotfiles: boolean; | ||
quiet: boolean; | ||
watch: boolean; | ||
} | { | ||
swcrcPath?: string | undefined; | ||
outDir: string; | ||
filenames: string[]; | ||
sync: boolean; | ||
extensions: string[]; | ||
copyFiles: boolean; | ||
includeDotfiles: boolean; | ||
quiet: boolean; | ||
watch: boolean; | ||
} | { | ||
configPath?: string | undefined; | ||
outDir: string; | ||
filenames: string[]; | ||
sync: boolean; | ||
extensions: string[]; | ||
copyFiles: boolean; | ||
includeDotfiles: boolean; | ||
quiet: boolean; | ||
watch: boolean; | ||
}; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.swcDefaultsFactory = void 0; | ||
const swcDefaultsFactory = (tsOptions) => { | ||
const swcDefaultsFactory = (tsOptions, configuration) => { | ||
const builderOptions = typeof configuration.compilerOptions?.builder !== 'string' | ||
? configuration.compilerOptions?.builder?.options | ||
: {}; | ||
return { | ||
@@ -29,10 +32,11 @@ swcOptions: { | ||
cliOptions: { | ||
outDir: 'dist', | ||
filenames: ['src'], | ||
outDir: tsOptions.outDir ?? 'dist', | ||
filenames: [configuration?.sourceRoot ?? 'src'], | ||
sync: false, | ||
extensions: ['.js', '.ts'], | ||
watch: false, | ||
copyFiles: false, | ||
includeDotfiles: false, | ||
quiet: false, | ||
watch: false, | ||
...builderOptions, | ||
}, | ||
@@ -39,0 +43,0 @@ }; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const nodeExternals = require("webpack-node-externals"); | ||
const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultConfiguration.compilerOptions.tsConfigPath, plugins) => { | ||
const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultTsconfigFilename, plugins) => { | ||
const isPluginRegistered = isAnyPluginRegistered(plugins); | ||
@@ -13,0 +13,0 @@ const webpackConfiguration = { |
@@ -13,2 +13,3 @@ "use strict"; | ||
const swc_defaults_1 = require("../defaults/swc-defaults"); | ||
const get_value_or_default_1 = require("../helpers/get-value-or-default"); | ||
const plugin_metadata_generator_1 = require("../plugins/plugin-metadata-generator"); | ||
@@ -24,3 +25,4 @@ const constants_1 = require("./constants"); | ||
async run(configuration, tsConfigPath, appName, extras, onSuccess) { | ||
const swcOptions = (0, swc_defaults_1.swcDefaultsFactory)(extras.tsOptions); | ||
const swcOptions = (0, swc_defaults_1.swcDefaultsFactory)(extras.tsOptions, configuration); | ||
const swcrcFilePath = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder.swcrcPath', appName) ?? '.swcrc'; | ||
if (extras.watch) { | ||
@@ -30,3 +32,3 @@ if (extras.typeCheck) { | ||
} | ||
await this.runSwc(swcOptions, extras); | ||
await this.runSwc(swcOptions, extras, swcrcFilePath); | ||
if (onSuccess) { | ||
@@ -43,3 +45,3 @@ onSuccess(); | ||
} | ||
await this.runSwc(swcOptions, extras); | ||
await this.runSwc(swcOptions, extras, swcrcFilePath); | ||
if (onSuccess) { | ||
@@ -102,6 +104,6 @@ onSuccess(); | ||
} | ||
async runSwc(options, extras) { | ||
async runSwc(options, extras, swcrcFilePath) { | ||
process.nextTick(() => console.log(constants_1.SWC_LOG_PREFIX, chalk.cyan('Running...'))); | ||
const swcCli = this.loadSwcCliBinary(); | ||
const swcRcFile = await this.getSwcRcFileContentIfExists(); | ||
const swcRcFile = await this.getSwcRcFileContentIfExists(swcrcFilePath); | ||
const swcOptions = this.deepMerge(options.swcOptions, swcRcFile); | ||
@@ -127,5 +129,5 @@ await swcCli.default({ | ||
} | ||
getSwcRcFileContentIfExists() { | ||
getSwcRcFileContentIfExists(swcrcFilePath) { | ||
try { | ||
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), '.swcrc'), 'utf8')); | ||
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), swcrcFilePath), 'utf8')); | ||
} | ||
@@ -132,0 +134,0 @@ catch (err) { |
@@ -17,5 +17,41 @@ export type Asset = 'string' | AssetEntry; | ||
} | ||
interface CompilerOptions { | ||
export interface SwcBuilderOptions { | ||
swcrcPath?: string; | ||
outDir?: string; | ||
filenames?: string[]; | ||
sync?: boolean; | ||
extensions?: string[]; | ||
copyFiles?: boolean; | ||
includeDotfiles?: boolean; | ||
quiet?: boolean; | ||
} | ||
export interface WebpackBuilderOptions { | ||
configPath?: string; | ||
} | ||
export interface TscBuilderOptions { | ||
configPath?: string; | ||
} | ||
export type BuilderVariant = 'tsc' | 'swc' | 'webpack'; | ||
export type Builder = BuilderVariant | { | ||
type: 'webpack'; | ||
options?: WebpackBuilderOptions; | ||
} | { | ||
type: 'swc'; | ||
options?: SwcBuilderOptions; | ||
} | { | ||
type: 'tsc'; | ||
options?: TscBuilderOptions; | ||
}; | ||
export interface CompilerOptions { | ||
/** | ||
* @deprecated Use `builder.options.configPath` instead. | ||
*/ | ||
tsConfigPath?: string; | ||
/** | ||
* @deprecated Use `builder` instead. | ||
*/ | ||
webpack?: boolean; | ||
/** | ||
* @deprecated Use `builder.options.configPath` instead. | ||
*/ | ||
webpackConfigPath?: string; | ||
@@ -26,8 +62,9 @@ plugins?: string[] | PluginOptions[]; | ||
manualRestart?: boolean; | ||
builder?: Builder; | ||
} | ||
interface PluginOptions { | ||
export interface PluginOptions { | ||
name: string; | ||
options: Record<string, any>[]; | ||
} | ||
interface GenerateOptions { | ||
export interface GenerateOptions { | ||
spec?: boolean | Record<string, boolean>; | ||
@@ -59,2 +96,1 @@ flat?: boolean; | ||
} | ||
export {}; |
import { Configuration } from './configuration'; | ||
export declare const defaultConfiguration: Required<Configuration>; | ||
export declare const defaultTsconfigFilename: string; | ||
export declare const defaultWebpackConfigFilename = "webpack.config.js"; | ||
export declare const defaultOutDir = "dist"; | ||
export declare const defaultGitIgnore = "# compiled output\n/dist\n/node_modules\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\npnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# OS\n.DS_Store\n\n# Tests\n/coverage\n/.nyc_output\n\n# IDEs and editors\n/.idea\n.project\n.classpath\n.c9/\n*.launch\n.settings/\n*.sublime-workspace\n\n# IDE - VSCode\n.vscode/*\n!.vscode/settings.json\n!.vscode/tasks.json\n!.vscode/launch.json\n!.vscode/extensions.json"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defaultGitIgnore = exports.defaultOutDir = exports.defaultConfiguration = void 0; | ||
exports.defaultGitIgnore = exports.defaultOutDir = exports.defaultWebpackConfigFilename = exports.defaultTsconfigFilename = exports.defaultConfiguration = void 0; | ||
const get_default_tsconfig_path_1 = require("../utils/get-default-tsconfig-path"); | ||
@@ -14,5 +14,9 @@ exports.defaultConfiguration = { | ||
compilerOptions: { | ||
tsConfigPath: (0, get_default_tsconfig_path_1.getDefaultTsconfigPath)(), | ||
builder: { | ||
type: 'tsc', | ||
options: { | ||
configPath: (0, get_default_tsconfig_path_1.getDefaultTsconfigPath)(), | ||
}, | ||
}, | ||
webpack: false, | ||
webpackConfigPath: 'webpack.config.js', | ||
plugins: [], | ||
@@ -24,2 +28,4 @@ assets: [], | ||
}; | ||
exports.defaultTsconfigFilename = (0, get_default_tsconfig_path_1.getDefaultTsconfigPath)(); | ||
exports.defaultWebpackConfigFilename = 'webpack.config.js'; | ||
exports.defaultOutDir = 'dist'; | ||
@@ -26,0 +32,0 @@ exports.defaultGitIgnore = `# compiled output |
{ | ||
"name": "@nestjs/cli", | ||
"version": "10.0.5", | ||
"version": "10.1.0-next.1", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@cli)", | ||
@@ -75,4 +75,4 @@ "publishConfig": { | ||
"@types/webpack-node-externals": "3.0.0", | ||
"@typescript-eslint/eslint-plugin": "5.60.0", | ||
"@typescript-eslint/parser": "5.60.0", | ||
"@typescript-eslint/eslint-plugin": "5.60.1", | ||
"@typescript-eslint/parser": "5.60.1", | ||
"delete-empty": "3.0.0", | ||
@@ -79,0 +79,0 @@ "eslint": "8.43.0", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
236510
212
4922
1