@atlaspack/cli
Advanced tools
Comparing version
@@ -220,6 +220,6 @@ "use strict"; | ||
} | ||
let serve = program.command('serve [input...]').description('starts a development server').option('--public-url <url>', 'the path prefix for absolute urls').option('--open [browser]', 'automatically open in specified browser, defaults to default browser').option('--watch-for-stdin', 'exit when stdin closes').option('--lazy [includes]', 'Build async bundles on demand, when requested in the browser. Defaults to all async bundles, unless a comma separated list of source file globs is provided. Only async bundles whose entry points match these globs will be built lazily').option('--lazy-exclude <excludes>', 'Can only be used in combination with --lazy. Comma separated list of source file globs, async bundles whose entry points match these globs will not be built lazily').action(runCommand); | ||
let serve = program.command('serve [input...]').description('starts a development server').option('--public-url <url>', 'the path prefix for absolute urls').option('--open [browser]', 'automatically open in specified browser, defaults to default browser').option('--watch-for-stdin', 'exit when stdin closes').option('--lazy [includes]', 'Build async bundles on demand, when requested in the browser. Defaults to all async bundles, unless a comma separated list of source file globs is provided. Only async bundles whose entry points match these globs will be built lazily').option('--lazy-exclude <excludes>', 'Can only be used in combination with --lazy. Comma separated list of source file globs, async bundles whose entry points match these globs will not be built lazily').option('--production', 'Run with production mode defaults').action(runCommand); | ||
applyOptions(serve, hmrOptions); | ||
applyOptions(serve, commonOptions); | ||
let watch = program.command('watch [input...]').description('starts the bundler in watch mode').option('--public-url <url>', 'the path prefix for absolute urls').option('--no-content-hash', 'disable content hashing').option('--watch-for-stdin', 'exit when stdin closes').action(runCommand); | ||
let watch = program.command('watch [input...]').description('starts the bundler in watch mode').option('--public-url <url>', 'the path prefix for absolute urls').option('--no-content-hash', 'disable content hashing').option('--watch-for-stdin', 'exit when stdin closes').option('--production', 'Run with production mode defaults').action(runCommand); | ||
applyOptions(watch, hmrOptions); | ||
@@ -419,5 +419,8 @@ applyOptions(watch, commonOptions); | ||
} | ||
function shouldUseProductionDefaults(command) { | ||
return command.name() === 'build' || command.production === true; | ||
} | ||
async function normalizeOptions(command, inputFS) { | ||
let nodeEnv; | ||
if (command.name() === 'build') { | ||
if (shouldUseProductionDefaults(command)) { | ||
nodeEnv = process.env.NODE_ENV || 'production'; | ||
@@ -448,3 +451,3 @@ // Autoinstall unless explicitly disabled or we detect a CI environment. | ||
let originalPort = port; | ||
if (command.name() === 'serve' || command.hmr) { | ||
if (!shouldUseProductionDefaults(command) && (command.name() === 'serve' || command.hmr)) { | ||
try { | ||
@@ -487,3 +490,3 @@ port = await (0, _getPort().default)({ | ||
let hmrOptions = null; | ||
if (command.name() !== 'build' && command.hmr !== false) { | ||
if (!shouldUseProductionDefaults(command) && command.hmr !== false) { | ||
let hmrport = command.hmrPort ? parsePort(command.hmrPort) : port; | ||
@@ -512,3 +515,3 @@ let hmrhost = command.hmrHost ? command.hmrHost : host; | ||
} | ||
let mode = command.name() === 'build' ? 'production' : 'development'; | ||
let mode = shouldUseProductionDefaults(command) ? 'production' : 'development'; | ||
const normalizeIncludeExcludeList = input => { | ||
@@ -515,0 +518,0 @@ if (typeof input !== 'string') return []; |
{ | ||
"name": "@atlaspack/cli", | ||
"version": "2.12.1-dev.3450+58845ef87", | ||
"version": "2.12.1-dev.3460+340817991", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -26,14 +26,14 @@ "license": "(MIT OR Apache-2.0)", | ||
"dependencies": { | ||
"@atlaspack/config-default": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/core": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/diagnostic": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/events": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/feature-flags": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/fs": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/logger": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/package-manager": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/reporter-cli": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/reporter-dev-server": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/reporter-tracer": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/utils": "2.12.1-dev.3450+58845ef87", | ||
"@atlaspack/config-default": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/core": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/diagnostic": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/events": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/feature-flags": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/fs": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/logger": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/package-manager": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/reporter-cli": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/reporter-dev-server": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/reporter-tracer": "2.12.1-dev.3460+340817991", | ||
"@atlaspack/utils": "2.12.1-dev.3460+340817991", | ||
"chalk": "^4.1.0", | ||
@@ -48,3 +48,3 @@ "commander": "^7.0.0", | ||
}, | ||
"gitHead": "58845ef87446fcedb7d7d8876440c64184645cbb" | ||
"gitHead": "3408179911d6c67e2bdad99e545dd7a0a9a6782c" | ||
} |
@@ -50,6 +50,6 @@ // @flow | ||
// A hack to definitely ensure we logged the uncaught exception | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
await new Promise((resolve) => setTimeout(resolve, 100)); | ||
} | ||
const handleUncaughtException = async exception => { | ||
const handleUncaughtException = async (exception) => { | ||
try { | ||
@@ -104,3 +104,3 @@ await logUncaughtError(exception); | ||
`list of directories watcher should not be tracking for changes. defaults to ['.git', '.hg']`, | ||
dirs => dirs.split(','), | ||
(dirs) => dirs.split(','), | ||
], | ||
@@ -208,2 +208,3 @@ '--watch-backend': new commander.Option( | ||
) | ||
.option('--production', 'Run with production mode defaults') | ||
.action(runCommand); | ||
@@ -220,2 +221,3 @@ | ||
.option('--watch-for-stdin', 'exit when stdin closes') | ||
.option('--production', 'Run with production mode defaults') | ||
.action(runCommand); | ||
@@ -250,3 +252,3 @@ | ||
} | ||
entries = entries.map(entry => path.resolve(entry)); | ||
entries = entries.map((entry) => path.resolve(entry)); | ||
@@ -289,3 +291,3 @@ Object.assign(command, opts); | ||
.action(function (command) { | ||
let cmd = program.commands.find(c => c.name() === command) || program; | ||
let cmd = program.commands.find((c) => c.name() === command) || program; | ||
cmd.help(); | ||
@@ -319,3 +321,3 @@ }); | ||
if (!args[2] || !program.commands.some(c => c.name() === args[2])) { | ||
if (!args[2] || !program.commands.some((c) => c.name() === args[2])) { | ||
args.splice(2, 0, 'serve'); | ||
@@ -339,3 +341,3 @@ } | ||
entries = entries.map(entry => path.resolve(entry)); | ||
entries = entries.map((entry) => path.resolve(entry)); | ||
@@ -422,3 +424,3 @@ let Atlaspack = require('@atlaspack/core').default; | ||
if (isWatching) { | ||
({unsubscribe} = await atlaspack.watch(err => { | ||
({unsubscribe} = await atlaspack.watch((err) => { | ||
if (err) { | ||
@@ -486,2 +488,6 @@ throw err; | ||
function shouldUseProductionDefaults(command) { | ||
return command.name() === 'build' || command.production === true; | ||
} | ||
async function normalizeOptions( | ||
@@ -492,3 +498,3 @@ command, | ||
let nodeEnv; | ||
if (command.name() === 'build') { | ||
if (shouldUseProductionDefaults(command)) { | ||
nodeEnv = process.env.NODE_ENV || 'production'; | ||
@@ -519,3 +525,6 @@ // Autoinstall unless explicitly disabled or we detect a CI environment. | ||
let originalPort = port; | ||
if (command.name() === 'serve' || command.hmr) { | ||
if ( | ||
!shouldUseProductionDefaults(command) && | ||
(command.name() === 'serve' || command.hmr) | ||
) { | ||
try { | ||
@@ -557,3 +566,3 @@ port = await getPort({port, host}); | ||
let hmrOptions = null; | ||
if (command.name() !== 'build' && command.hmr !== false) { | ||
if (!shouldUseProductionDefaults(command) && command.hmr !== false) { | ||
let hmrport = command.hmrPort ? parsePort(command.hmrPort) : port; | ||
@@ -574,3 +583,3 @@ let hmrhost = command.hmrHost ? command.hmrHost : host; | ||
{packageName: '@atlaspack/reporter-cli', resolveFrom: __filename}, | ||
...(command.reporter: Array<string>).map(packageName => ({ | ||
...(command.reporter: Array<string>).map((packageName) => ({ | ||
packageName, | ||
@@ -588,7 +597,9 @@ resolveFrom: path.join(inputFS.cwd(), 'index'), | ||
let mode = command.name() === 'build' ? 'production' : 'development'; | ||
let mode = shouldUseProductionDefaults(command) | ||
? 'production' | ||
: 'development'; | ||
const normalizeIncludeExcludeList = (input?: string): string[] => { | ||
if (typeof input !== 'string') return []; | ||
return input.split(',').map(value => value.trim()); | ||
return input.split(',').map((value) => value.trim()); | ||
}; | ||
@@ -595,0 +606,0 @@ |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
54797
1.24%1124
1.17%