@atlaspack/cli 2.12.1-dev.3502 → 2.12.1-dev.3520

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.
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyOptions = applyOptions;
7
+ function _commander() {
8
+ const data = _interopRequireDefault(require("commander"));
9
+ _commander = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function applyOptions(cmd, options) {
16
+ for (let opt in options) {
17
+ const option = options[opt];
18
+ if (option instanceof _commander().default.Option) {
19
+ cmd.addOption(option);
20
+ } else if (Array.isArray(option)) {
21
+ cmd.option(opt, ...option);
22
+ } else if (typeof option === 'string') {
23
+ cmd.option(opt, option);
24
+ }
25
+ }
26
+ }
package/lib/cli.js CHANGED
@@ -14,13 +14,6 @@ function _fs() {
14
14
  };
15
15
  return data;
16
16
  }
17
- function _diagnostic() {
18
- const data = _interopRequireDefault(require("@atlaspack/diagnostic"));
19
- _diagnostic = function () {
20
- return data;
21
- };
22
- return data;
23
- }
24
17
  function _utils() {
25
18
  const data = require("@atlaspack/utils");
26
19
  _utils = function () {
@@ -63,21 +56,12 @@ function _path() {
63
56
  };
64
57
  return data;
65
58
  }
66
- function _getPort() {
67
- const data = _interopRequireDefault(require("get-port"));
68
- _getPort = function () {
69
- return data;
70
- };
71
- return data;
72
- }
73
59
  var _package = require("../package.json");
74
- function _featureFlags() {
75
- const data = require("@atlaspack/feature-flags");
76
- _featureFlags = function () {
77
- return data;
78
- };
79
- return data;
80
- }
60
+ var _applyOptions = require("./applyOptions");
61
+ var _makeDebugCommand = require("./makeDebugCommand");
62
+ var _normalizeOptions = require("./normalizeOptions");
63
+ var _handleUncaughtException = require("./handleUncaughtException");
64
+ var _options = require("./options");
81
65
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
82
66
  const program = new (_commander().default.Command)();
83
67
 
@@ -85,213 +69,18 @@ const program = new (_commander().default.Command)();
85
69
  // 128 + signal value
86
70
  // https://tldp.org/LDP/abs/html/exitcodes.html
87
71
  const SIGINT_EXIT_CODE = 130;
88
- async function logUncaughtError(e) {
89
- if (e instanceof _diagnostic().default) {
90
- for (let diagnostic of e.diagnostics) {
91
- let {
92
- message,
93
- codeframe,
94
- stack,
95
- hints,
96
- documentation
97
- } = await (0, _utils().prettyDiagnostic)(diagnostic);
98
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.red(message));
99
- if (codeframe || stack) {
100
- _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
101
- }
102
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(codeframe);
103
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(stack);
104
- if ((stack || codeframe) && hints.length > 0) {
105
- _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
106
- }
107
- for (let h of hints) {
108
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.blue(h));
109
- }
110
- if (documentation) {
111
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.magenta.bold(documentation));
112
- }
113
- }
114
- } else {
115
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(e);
116
- }
117
-
118
- // A hack to definitely ensure we logged the uncaught exception
119
- await new Promise(resolve => setTimeout(resolve, 100));
120
- }
121
- const handleUncaughtException = async exception => {
122
- try {
123
- await logUncaughtError(exception);
124
- } catch (err) {
125
- console.error(exception);
126
- console.error(err);
127
- }
128
- process.exit(1);
129
- };
130
- process.on('unhandledRejection', handleUncaughtException);
72
+ process.on('unhandledRejection', _handleUncaughtException.handleUncaughtException);
131
73
  program.storeOptionsAsProperties();
132
74
  program.version(_package.version);
133
-
134
- // Only display choices available to callers OS
135
- let watcherBackendChoices = ['brute-force'];
136
- switch (process.platform) {
137
- case 'darwin':
138
- {
139
- watcherBackendChoices.push('watchman', 'fs-events');
140
- break;
141
- }
142
- case 'linux':
143
- {
144
- watcherBackendChoices.push('watchman', 'inotify');
145
- break;
146
- }
147
- case 'win32':
148
- {
149
- watcherBackendChoices.push('watchman', 'windows');
150
- break;
151
- }
152
- case 'freebsd' || 'openbsd':
153
- {
154
- watcherBackendChoices.push('watchman');
155
- break;
156
- }
157
- default:
158
- break;
159
- }
160
-
161
- // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
162
- // --no-content-hash, --experimental-scope-hoisting, --detailed-report
163
- const commonOptions = {
164
- '--no-cache': 'disable the filesystem cache',
165
- '--config <path>': 'specify which config to use. can be a path or a package name',
166
- '--cache-dir <path>': 'set the cache directory. defaults to ".parcel-cache"',
167
- '--watch-dir <path>': 'set the root watch directory. defaults to nearest lockfile or source control dir.',
168
- '--watch-ignore [path]': [`list of directories watcher should not be tracking for changes. defaults to ['.git', '.hg']`, dirs => dirs.split(',')],
169
- '--watch-backend': new (_commander().default.Option)('--watch-backend <name>', 'set watcher backend').choices(watcherBackendChoices),
170
- '--no-source-maps': 'disable sourcemaps',
171
- '--target [name]': ['only build given target(s)', (val, list) => list.concat([val]), []],
172
- '--log-level <level>': new (_commander().default.Option)('--log-level <level>', 'set the log level').choices(['none', 'error', 'warn', 'info', 'verbose']),
173
- '--dist-dir <dir>': 'output directory to write to when unspecified by targets',
174
- '--no-autoinstall': 'disable autoinstall',
175
- '--profile': 'enable sampling build profiling',
176
- '--trace': 'enable build tracing',
177
- '-V, --version': 'output the version number',
178
- '--detailed-report [count]': ['print the asset timings and sizes in the build report', parseOptionInt],
179
- '--reporter <name>': ['additional reporters to run', (val, acc) => {
180
- acc.push(val);
181
- return acc;
182
- }, []],
183
- '--feature-flag <name=value>': ['sets the value of a feature flag', (value, previousValue) => {
184
- let [name, val] = value.split('=');
185
- if (name in _featureFlags().DEFAULT_FEATURE_FLAGS) {
186
- let featureFlagValue;
187
- if (typeof _featureFlags().DEFAULT_FEATURE_FLAGS[name] === 'boolean') {
188
- if (val !== 'true' && val !== 'false') {
189
- throw new Error(`Feature flag ${name} must be set to true or false`);
190
- }
191
- featureFlagValue = val === 'true';
192
- }
193
- previousValue[name] = featureFlagValue ?? String(val);
194
- } else {
195
- _logger().INTERNAL_ORIGINAL_CONSOLE.warn(`Unknown feature flag ${name} specified, it will be ignored`);
196
- }
197
- return previousValue;
198
- }, {}]
199
- };
200
- var hmrOptions = {
201
- '--no-hmr': 'disable hot module replacement',
202
- '-p, --port <port>': ['set the port to serve on. defaults to $PORT or 1234', process.env.PORT],
203
- '--host <host>': 'set the host to listen on, defaults to listening on all interfaces',
204
- '--https': 'serves files over HTTPS',
205
- '--cert <path>': 'path to certificate to use with HTTPS',
206
- '--key <path>': 'path to private key to use with HTTPS',
207
- '--hmr-port <port>': ['hot module replacement port', process.env.HMR_PORT],
208
- '--hmr-host <host>': ['hot module replacement host', process.env.HMR_HOST]
209
- };
210
- function applyOptions(cmd, options) {
211
- for (let opt in options) {
212
- const option = options[opt];
213
- if (option instanceof _commander().default.Option) {
214
- cmd.addOption(option);
215
- } else {
216
- cmd.option(opt, ...(Array.isArray(option) ? option : [option]));
217
- }
218
- }
219
- }
220
75
  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);
221
- applyOptions(serve, hmrOptions);
222
- applyOptions(serve, commonOptions);
76
+ (0, _applyOptions.applyOptions)(serve, _options.hmrOptions);
77
+ (0, _applyOptions.applyOptions)(serve, _options.commonOptions);
223
78
  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);
224
- applyOptions(watch, hmrOptions);
225
- applyOptions(watch, commonOptions);
79
+ (0, _applyOptions.applyOptions)(watch, _options.hmrOptions);
80
+ (0, _applyOptions.applyOptions)(watch, _options.commonOptions);
226
81
  let build = program.command('build [input...]').description('bundles for production').option('--no-optimize', 'disable minification').option('--no-scope-hoist', 'disable scope-hoisting').option('--public-url <url>', 'the path prefix for absolute urls').option('--no-content-hash', 'disable content hashing').action(runCommand);
227
- applyOptions(build, commonOptions);
228
- function makeDebugCommand() {
229
- const debug = new (_commander().default.Command)('debug').description('Debug commands for atlaspack');
230
- const invalidate = debug.command('invalidate [input...]').description('Run cache invalidation, then exit').action(async (entries, opts, command) => {
231
- try {
232
- if (entries.length === 0) {
233
- entries = ['.'];
234
- }
235
- entries = entries.map(entry => _path().default.resolve(entry));
236
- Object.assign(command, opts);
237
- const fs = new (_fs().NodeFS)();
238
- const options = await normalizeOptions(command, fs);
239
- const Atlaspack = require('@atlaspack/core').default;
240
- const atlaspack = new Atlaspack({
241
- entries,
242
- defaultConfig: require.resolve('@atlaspack/config-default', {
243
- paths: [fs.cwd(), __dirname]
244
- }),
245
- shouldPatchConsole: false,
246
- ...options,
247
- shouldBuildLazily: true,
248
- watchBackend: 'watchman'
249
- });
250
- console.log('Created atlaspack instance');
251
- await atlaspack.unstable_invalidate();
252
- console.log('Done invalidating cache');
253
- } catch (err) {
254
- handleUncaughtException(err);
255
- }
256
- });
257
- applyOptions(invalidate, commonOptions);
258
- const buildAssetGraph = debug.command('build-asset-graph [input...]').description('Build the asset graph then exit').action(async (entries, opts, command) => {
259
- try {
260
- if (entries.length === 0) {
261
- entries = ['.'];
262
- }
263
- entries = entries.map(entry => _path().default.resolve(entry));
264
- Object.assign(command, opts);
265
- const fs = new (_fs().NodeFS)();
266
- const options = await normalizeOptions(command, fs);
267
- const Atlaspack = require('@atlaspack/core').default;
268
- const atlaspack = new Atlaspack({
269
- entries,
270
- defaultConfig: require.resolve('@atlaspack/config-default', {
271
- paths: [fs.cwd(), __dirname]
272
- }),
273
- shouldPatchConsole: false,
274
- ...options,
275
- shouldBuildLazily: true,
276
- watchBackend: 'watchman',
277
- featureFlags: {
278
- ...options.featureFlags,
279
- fixQuadraticCacheInvalidation: 'NEW',
280
- useLmdbJsLite: true
281
- }
282
- });
283
- console.log('Created atlaspack instance');
284
- await atlaspack.unstable_buildAssetGraph();
285
- console.log('Done building asset graph');
286
- process.exit(0);
287
- } catch (err) {
288
- handleUncaughtException(err);
289
- }
290
- });
291
- applyOptions(buildAssetGraph, commonOptions);
292
- return debug;
293
- }
294
- program.addCommand(makeDebugCommand());
82
+ (0, _applyOptions.applyOptions)(build, _options.commonOptions);
83
+ program.addCommand((0, _makeDebugCommand.makeDebugCommand)());
295
84
  program.command('help [command]').description('display help information for a command').action(function (command) {
296
85
  let cmd = program.commands.find(c => c.name() === command) || program;
297
86
  cmd.help();
@@ -318,7 +107,7 @@ if (!args[2] || !program.commands.some(c => c.name() === args[2])) {
318
107
  }
319
108
  program.parse(args);
320
109
  function runCommand(...args) {
321
- run(...args).catch(handleUncaughtException);
110
+ run(...args).catch(_handleUncaughtException.handleUncaughtException);
322
111
  }
323
112
  async function run(entries, _opts,
324
113
  // using pre v7 Commander options as properties
@@ -329,7 +118,7 @@ command) {
329
118
  entries = entries.map(entry => _path().default.resolve(entry));
330
119
  let Atlaspack = require('@atlaspack/core').default;
331
120
  let fs = new (_fs().NodeFS)();
332
- let options = await normalizeOptions(command, fs);
121
+ let options = await (0, _normalizeOptions.normalizeOptions)(command, fs);
333
122
  let atlaspack = new Atlaspack({
334
123
  entries,
335
124
  defaultConfig: require.resolve('@atlaspack/config-default', {
@@ -425,161 +214,10 @@ command) {
425
214
  // If an exception is thrown during Atlaspack.build, it is given to reporters in a
426
215
  // buildFailure event, and has been shown to the user.
427
216
  if (!(err instanceof _core().BuildError)) {
428
- await logUncaughtError(err);
217
+ await (0, _handleUncaughtException.logUncaughtError)(err);
429
218
  }
430
219
  await exit(1);
431
220
  }
432
221
  await exit();
433
222
  }
434
- }
435
- function parsePort(portValue) {
436
- let parsedPort = Number(portValue);
437
-
438
- // Throw an error if port value is invalid...
439
- if (!Number.isInteger(parsedPort)) {
440
- throw new Error(`Port ${portValue} is not a valid integer.`);
441
- }
442
- return parsedPort;
443
- }
444
- function parseOptionInt(value) {
445
- const parsedValue = parseInt(value, 10);
446
- if (isNaN(parsedValue)) {
447
- throw new (_commander().default.InvalidOptionArgumentError)('Must be an integer.');
448
- }
449
- return parsedValue;
450
- }
451
- function shouldUseProductionDefaults(command) {
452
- return command.name() === 'build' || command.production === true;
453
- }
454
- async function normalizeOptions(command, inputFS) {
455
- let nodeEnv;
456
- if (shouldUseProductionDefaults(command)) {
457
- nodeEnv = process.env.NODE_ENV || 'production';
458
- // Autoinstall unless explicitly disabled or we detect a CI environment.
459
- command.autoinstall = !(command.autoinstall === false || process.env.CI);
460
- } else {
461
- nodeEnv = process.env.NODE_ENV || 'development';
462
- }
463
-
464
- // Set process.env.NODE_ENV to a default if undefined so that it is
465
- // available in JS configs and plugins.
466
- process.env.NODE_ENV = nodeEnv;
467
- let https = !!command.https;
468
- if (command.cert && command.key) {
469
- https = {
470
- cert: command.cert,
471
- key: command.key
472
- };
473
- }
474
- let serveOptions = false;
475
- let {
476
- host
477
- } = command;
478
-
479
- // Ensure port is valid and available
480
- let port = parsePort(command.port || '1234');
481
- let originalPort = port;
482
- if (!shouldUseProductionDefaults(command) && (command.name() === 'serve' || command.hmr)) {
483
- try {
484
- port = await (0, _getPort().default)({
485
- port,
486
- host
487
- });
488
- } catch (err) {
489
- throw new (_diagnostic().default)({
490
- diagnostic: {
491
- message: `Could not get available port: ${err.message}`,
492
- origin: 'atlaspack',
493
- stack: err.stack
494
- }
495
- });
496
- }
497
- if (port !== originalPort) {
498
- let errorMessage = `Port "${originalPort}" could not be used`;
499
- if (command.port != null) {
500
- // Throw the error if the user defined a custom port
501
- throw new Error(errorMessage);
502
- } else {
503
- // Atlaspack logger is not set up at this point, so just use native INTERNAL_ORIGINAL_CONSOLE
504
- _logger().INTERNAL_ORIGINAL_CONSOLE.warn(errorMessage);
505
- }
506
- }
507
- }
508
- if (command.name() === 'serve') {
509
- let {
510
- publicUrl
511
- } = command;
512
- serveOptions = {
513
- https,
514
- port,
515
- host,
516
- publicUrl
517
- };
518
- }
519
- let hmrOptions = null;
520
- if (!shouldUseProductionDefaults(command) && command.hmr !== false) {
521
- let hmrport = command.hmrPort ? parsePort(command.hmrPort) : port;
522
- let hmrhost = command.hmrHost ? command.hmrHost : host;
523
- hmrOptions = {
524
- port: hmrport,
525
- host: hmrhost
526
- };
527
- }
528
- if (command.detailedReport === true) {
529
- command.detailedReport = '10';
530
- }
531
- let additionalReporters = [{
532
- packageName: '@atlaspack/reporter-cli',
533
- resolveFrom: __filename
534
- }, ...command.reporter.map(packageName => ({
535
- packageName,
536
- resolveFrom: _path().default.join(inputFS.cwd(), 'index')
537
- }))];
538
- if (command.trace) {
539
- additionalReporters.unshift({
540
- packageName: '@atlaspack/reporter-tracer',
541
- resolveFrom: __filename
542
- });
543
- }
544
- let mode = shouldUseProductionDefaults(command) ? 'production' : 'development';
545
- const normalizeIncludeExcludeList = input => {
546
- if (typeof input !== 'string') return [];
547
- return input.split(',').map(value => value.trim());
548
- };
549
- return {
550
- shouldDisableCache: command.cache === false,
551
- cacheDir: command.cacheDir,
552
- watchDir: command.watchDir,
553
- watchBackend: command.watchBackend,
554
- watchIgnore: command.watchIgnore,
555
- config: command.config,
556
- mode,
557
- hmrOptions,
558
- shouldContentHash: hmrOptions ? false : command.contentHash,
559
- serveOptions,
560
- targets: command.target.length > 0 ? command.target : null,
561
- shouldAutoInstall: command.autoinstall ?? true,
562
- logLevel: command.logLevel,
563
- shouldProfile: command.profile,
564
- shouldTrace: command.trace,
565
- shouldBuildLazily: typeof command.lazy !== 'undefined',
566
- lazyIncludes: normalizeIncludeExcludeList(command.lazy),
567
- lazyExcludes: normalizeIncludeExcludeList(command.lazyExclude),
568
- shouldBundleIncrementally: process.env.ATLASPACK_INCREMENTAL_BUNDLING === 'false' ? false : true,
569
- detailedReport: command.detailedReport != null ? {
570
- assetsPerBundle: parseInt(command.detailedReport, 10)
571
- } : null,
572
- env: {
573
- NODE_ENV: nodeEnv
574
- },
575
- additionalReporters,
576
- defaultTargetOptions: {
577
- shouldOptimize: command.optimize != null ? command.optimize : mode === 'production',
578
- sourceMaps: command.sourceMaps ?? true,
579
- shouldScopeHoist: command.scopeHoist,
580
- publicUrl: command.publicUrl,
581
- distDir: command.distDir
582
- },
583
- featureFlags: command.featureFlag
584
- };
585
223
  }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleUncaughtException = handleUncaughtException;
7
+ exports.logUncaughtError = logUncaughtError;
8
+ function _diagnostic() {
9
+ const data = _interopRequireDefault(require("@atlaspack/diagnostic"));
10
+ _diagnostic = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ function _utils() {
16
+ const data = require("@atlaspack/utils");
17
+ _utils = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _logger() {
23
+ const data = require("@atlaspack/logger");
24
+ _logger = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
29
+ function _chalk() {
30
+ const data = _interopRequireDefault(require("chalk"));
31
+ _chalk = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
36
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
+ async function logUncaughtError(e) {
38
+ if (e instanceof _diagnostic().default) {
39
+ for (let diagnostic of e.diagnostics) {
40
+ let {
41
+ message,
42
+ codeframe,
43
+ stack,
44
+ hints,
45
+ documentation
46
+ } = await (0, _utils().prettyDiagnostic)(diagnostic);
47
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.red(message));
48
+ if (codeframe || stack) {
49
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
50
+ }
51
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(codeframe);
52
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(stack);
53
+ if ((stack || codeframe) && hints.length > 0) {
54
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
55
+ }
56
+ for (let h of hints) {
57
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.blue(h));
58
+ }
59
+ if (documentation) {
60
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.magenta.bold(documentation));
61
+ }
62
+ }
63
+ } else {
64
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(e);
65
+ }
66
+
67
+ // A hack to definitely ensure we logged the uncaught exception
68
+ await new Promise(resolve => setTimeout(resolve, 100));
69
+ }
70
+ async function handleUncaughtException(exception) {
71
+ try {
72
+ await logUncaughtError(exception);
73
+ } catch (err) {
74
+ console.error(exception);
75
+ console.error(err);
76
+ }
77
+ process.exit(1);
78
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.makeDebugCommand = makeDebugCommand;
7
+ function _fs() {
8
+ const data = require("@atlaspack/fs");
9
+ _fs = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _commander() {
15
+ const data = _interopRequireDefault(require("commander"));
16
+ _commander = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _path() {
22
+ const data = _interopRequireDefault(require("path"));
23
+ _path = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ var _normalizeOptions = require("./normalizeOptions");
29
+ var _applyOptions = require("./applyOptions");
30
+ var _options = require("./options");
31
+ var _handleUncaughtException = require("./handleUncaughtException");
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
+ function makeDebugCommand() {
34
+ const debug = new (_commander().default.Command)('debug').description('Debug commands for atlaspack');
35
+ const invalidate = debug.command('invalidate [input...]').description('Run cache invalidation, then exit').action(async (args, opts, command) => {
36
+ try {
37
+ let entries = args;
38
+ if (entries.length === 0) {
39
+ entries = ['.'];
40
+ }
41
+ entries = entries.map(entry => _path().default.resolve(entry));
42
+ Object.assign(command, opts);
43
+ const fs = new (_fs().NodeFS)();
44
+ const options = await (0, _normalizeOptions.normalizeOptions)(command, fs);
45
+ const Atlaspack = require('@atlaspack/core').default;
46
+ const atlaspack = new Atlaspack({
47
+ entries,
48
+ defaultConfig: require.resolve('@atlaspack/config-default', {
49
+ paths: [fs.cwd(), __dirname]
50
+ }),
51
+ shouldPatchConsole: false,
52
+ ...options,
53
+ shouldBuildLazily: true,
54
+ watchBackend: 'watchman'
55
+ });
56
+ console.log('Created atlaspack instance');
57
+ await atlaspack.unstable_invalidate();
58
+ console.log('Done invalidating cache');
59
+ } catch (err) {
60
+ (0, _handleUncaughtException.handleUncaughtException)(err);
61
+ }
62
+ });
63
+ (0, _applyOptions.applyOptions)(invalidate, _options.commonOptions);
64
+ const buildAssetGraph = debug.command('build-asset-graph [input...]').description('Build the asset graph then exit').action(async (args, opts, command) => {
65
+ try {
66
+ let entries = args;
67
+ if (entries.length === 0) {
68
+ entries = ['.'];
69
+ }
70
+ entries = entries.map(entry => _path().default.resolve(entry));
71
+ Object.assign(command, opts);
72
+ const fs = new (_fs().NodeFS)();
73
+ const options = await (0, _normalizeOptions.normalizeOptions)(command, fs);
74
+ const Atlaspack = require('@atlaspack/core').default;
75
+ const atlaspack = new Atlaspack({
76
+ entries,
77
+ defaultConfig: require.resolve('@atlaspack/config-default', {
78
+ paths: [fs.cwd(), __dirname]
79
+ }),
80
+ shouldPatchConsole: false,
81
+ ...options,
82
+ shouldBuildLazily: true,
83
+ watchBackend: 'watchman',
84
+ featureFlags: {
85
+ ...options.featureFlags,
86
+ fixQuadraticCacheInvalidation: 'NEW',
87
+ useLmdbJsLite: true
88
+ }
89
+ });
90
+ console.log('Created atlaspack instance');
91
+ await atlaspack.unstable_buildAssetGraph();
92
+ console.log('Done building asset graph');
93
+ process.exit(0);
94
+ } catch (err) {
95
+ (0, _handleUncaughtException.handleUncaughtException)(err);
96
+ }
97
+ });
98
+ (0, _applyOptions.applyOptions)(buildAssetGraph, _options.commonOptions);
99
+ return debug;
100
+ }