@atlaspack/cli 2.13.7-canary.48 → 2.13.7-canary.481

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.
@@ -11,13 +11,16 @@ function _commander() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ // @ts-expect-error TS2305
16
+
15
17
  function applyOptions(cmd, options) {
16
18
  for (let opt in options) {
17
19
  const option = options[opt];
18
20
  if (option instanceof _commander().default.Option) {
19
21
  cmd.addOption(option);
20
22
  } else if (Array.isArray(option)) {
23
+ // @ts-expect-error TS2345
21
24
  cmd.option(opt, ...option);
22
25
  } else if (typeof option === 'string') {
23
26
  cmd.option(opt, option);
package/lib/bin.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
2
- 'use strict';
1
+ "use strict";
3
2
 
4
- require('./cli');
3
+ // This file exists for atlaspack-link support
4
+ require('../bin/atlaspack.js');
package/lib/cli.js CHANGED
@@ -43,7 +43,7 @@ function _chalk() {
43
43
  return data;
44
44
  }
45
45
  function _commander() {
46
- const data = _interopRequireDefault(require("commander"));
46
+ const data = require("commander");
47
47
  _commander = function () {
48
48
  return data;
49
49
  };
@@ -62,8 +62,8 @@ var _makeDebugCommand = require("./makeDebugCommand");
62
62
  var _normalizeOptions = require("./normalizeOptions");
63
63
  var _handleUncaughtException = require("./handleUncaughtException");
64
64
  var _options = require("./options");
65
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
66
- const program = new (_commander().default.Command)();
65
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
66
+ const program = new (_commander().Command)();
67
67
 
68
68
  // Exit codes in response to signals are traditionally
69
69
  // 128 + signal value
@@ -92,8 +92,8 @@ program.on('--help', function () {
92
92
  });
93
93
 
94
94
  // Override to output option description if argument was missing
95
- // $FlowFixMe[prop-missing]
96
- _commander().default.Command.prototype.optionMissingArgument = function (option) {
95
+ // @ts-expect-error optionMissingArgument is not in commander 8 typings but exists at runtime
96
+ _commander().Command.prototype.optionMissingArgument = function (option) {
97
97
  _logger().INTERNAL_ORIGINAL_CONSOLE.error("error: option `%s' argument missing", option.flags);
98
98
  _logger().INTERNAL_ORIGINAL_CONSOLE.log(program.createHelp().optionDescription(option));
99
99
  process.exit(1);
@@ -106,7 +106,10 @@ if (!args[2] || !program.commands.some(c => c.name() === args[2])) {
106
106
  args.splice(2, 0, 'serve');
107
107
  }
108
108
  program.parse(args);
109
+
110
+ // @ts-expect-error TS7019
109
111
  function runCommand(...args) {
112
+ // @ts-expect-error TS2556
110
113
  run(...args).catch(_handleUncaughtException.handleUncaughtException);
111
114
  }
112
115
  async function run(entries, _opts,
@@ -129,8 +132,10 @@ command) {
129
132
  });
130
133
  let disposable = new (_events().Disposable)();
131
134
  let unsubscribe;
135
+ // @ts-expect-error TS7034
132
136
  let isExiting;
133
137
  async function exit(exitCode = 0) {
138
+ // @ts-expect-error TS7005
134
139
  if (isExiting) {
135
140
  return;
136
141
  }
@@ -141,7 +146,6 @@ command) {
141
146
  await atlaspack.stopProfiling();
142
147
  }
143
148
  if (process.stdin.isTTY && process.stdin.isRaw) {
144
- // $FlowFixMe
145
149
  process.stdin.setRawMode(false);
146
150
  }
147
151
  disposable.dispose();
@@ -149,7 +153,6 @@ command) {
149
153
  }
150
154
  const isWatching = command.name() === 'watch' || command.name() === 'serve';
151
155
  if (process.stdin.isTTY) {
152
- // $FlowFixMe
153
156
  process.stdin.setRawMode(true);
154
157
  require('readline').emitKeypressEvents(process.stdin);
155
158
  let stream = process.stdin.on('keypress', async (char, key) => {
@@ -185,6 +188,7 @@ command) {
185
188
  });
186
189
  }
187
190
  if (isWatching) {
191
+ // @ts-expect-error TS7006
188
192
  ({
189
193
  unsubscribe
190
194
  } = await atlaspack.watch(err => {
@@ -33,7 +33,7 @@ function _chalk() {
33
33
  };
34
34
  return data;
35
35
  }
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
37
37
  async function logUncaughtError(e) {
38
38
  if (e instanceof _diagnostic().default) {
39
39
  for (let diagnostic of e.diagnostics) {
@@ -36,7 +36,9 @@ var _normalizeOptions = require("./normalizeOptions");
36
36
  var _applyOptions = require("./applyOptions");
37
37
  var _options = require("./options");
38
38
  var _handleUncaughtException = require("./handleUncaughtException");
39
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
40
+ // @ts-expect-error TS2305
41
+
40
42
  function makeDebugCommand() {
41
43
  const debug = new (_commander().default.Command)('debug').description('Debug commands for atlaspack');
42
44
  const getInstance = async (args, opts, command) => {
@@ -32,7 +32,14 @@ function _path() {
32
32
  };
33
33
  return data;
34
34
  }
35
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
+ function _os() {
36
+ const data = _interopRequireDefault(require("os"));
37
+ _os = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
36
43
  function parsePort(portValue) {
37
44
  let parsedPort = Number(portValue);
38
45
 
@@ -42,10 +49,6 @@ function parsePort(portValue) {
42
49
  }
43
50
  return parsedPort;
44
51
  }
45
-
46
- // $FlowFixMe
47
-
48
- // $FlowFixMe
49
52
  function shouldUseProductionDefaults(command) {
50
53
  return command.name() === 'build' || command.production === true;
51
54
  }
@@ -64,6 +67,7 @@ async function normalizeOptions(command, inputFS) {
64
67
  process.env.NODE_ENV = nodeEnv;
65
68
  let https = !!command.https;
66
69
  if (command.cert != null && command.key != null) {
70
+ // @ts-expect-error TS2322
67
71
  https = {
68
72
  cert: command.cert,
69
73
  key: command.key
@@ -107,6 +111,8 @@ async function normalizeOptions(command, inputFS) {
107
111
  let {
108
112
  publicUrl
109
113
  } = command;
114
+
115
+ // @ts-expect-error TS2322
110
116
  serveOptions = {
111
117
  https,
112
118
  port,
@@ -144,9 +150,22 @@ async function normalizeOptions(command, inputFS) {
144
150
  if (typeof input !== 'string') return [];
145
151
  return input.split(',').map(value => value.trim());
146
152
  };
153
+ let nativeProfiler;
154
+ if (typeof command.profileNative === 'string') {
155
+ if (command.profileNative === 'instruments' || command.profileNative === 'samply') {
156
+ nativeProfiler = command.profileNative;
157
+ } else {
158
+ nativeProfiler = undefined;
159
+ }
160
+ } else if (command.profileNative) {
161
+ nativeProfiler = _os().default.platform() === 'darwin' ? 'instruments' : 'samply';
162
+ } else {
163
+ nativeProfiler = undefined;
164
+ }
147
165
  return {
148
166
  shouldDisableCache: command.cache === false,
149
167
  cacheDir: command.cacheDir,
168
+ projectRoot: command.projectRoot,
150
169
  watchDir: command.watchDir,
151
170
  watchBackend: command.watchBackend,
152
171
  watchIgnore: command.watchIgnore,
@@ -154,17 +173,20 @@ async function normalizeOptions(command, inputFS) {
154
173
  mode,
155
174
  hmrOptions,
156
175
  shouldContentHash: hmrOptions ? false : command.contentHash,
176
+ // @ts-expect-error TS2322
157
177
  serveOptions,
158
178
  targets: command.target.length > 0 ? command.target : null,
159
179
  shouldAutoInstall: command.autoinstall ?? true,
160
180
  logLevel: command.logLevel,
161
181
  shouldProfile: command.profile,
182
+ nativeProfiler,
162
183
  shouldTrace: command.trace,
163
184
  shouldBuildLazily: typeof command.lazy !== 'undefined',
164
185
  lazyIncludes: normalizeIncludeExcludeList(command.lazy),
165
186
  lazyExcludes: normalizeIncludeExcludeList(command.lazyExclude),
166
187
  shouldBundleIncrementally: process.env.ATLASPACK_INCREMENTAL_BUNDLING === 'false' ? false : true,
167
188
  detailedReport: command.detailedReport != null ? {
189
+ // @ts-expect-error TS2345
168
190
  assetsPerBundle: parseInt(command.detailedReport, 10)
169
191
  } : null,
170
192
  env: {
package/lib/options.js CHANGED
@@ -25,7 +25,7 @@ function _featureFlags() {
25
25
  };
26
26
  return data;
27
27
  }
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
29
29
  // Only display choices available to callers OS
30
30
  let watcherBackendChoices = exports.watcherBackendChoices = ['brute-force'];
31
31
  switch (process.platform) {
@@ -44,6 +44,7 @@ switch (process.platform) {
44
44
  watcherBackendChoices.push('watchman', 'windows');
45
45
  break;
46
46
  }
47
+ // @ts-expect-error TS2367
47
48
  case 'freebsd' || 'openbsd':
48
49
  {
49
50
  watcherBackendChoices.push('watchman');
@@ -59,6 +60,7 @@ const commonOptions = exports.commonOptions = {
59
60
  '--no-cache': 'disable the filesystem cache',
60
61
  '--config <path>': 'specify which config to use. can be a path or a package name',
61
62
  '--cache-dir <path>': 'set the cache directory. defaults to ".parcel-cache"',
63
+ '--project-root <path>': 'set the project root directory. defaults to nearest directory with lockfiles or version control, falls back to cwd',
62
64
  '--watch-dir <path>': 'set the root watch directory. defaults to nearest lockfile or source control dir.',
63
65
  '--watch-ignore [path]': [`list of directories watcher should not be tracking for changes. defaults to ['.git', '.hg']`, dirs => dirs.split(',')],
64
66
  '--watch-backend': new (_commander().default.Option)('--watch-backend <name>', 'set watcher backend').choices(watcherBackendChoices),
@@ -68,6 +70,7 @@ const commonOptions = exports.commonOptions = {
68
70
  '--dist-dir <dir>': 'output directory to write to when unspecified by targets',
69
71
  '--no-autoinstall': 'disable autoinstall',
70
72
  '--profile': 'enable sampling build profiling',
73
+ '--profile-native [instruments|samply]': 'enable native build profiling (defaults to instruments on macOS, samply otherwise)',
71
74
  '--trace': 'enable build tracing',
72
75
  '-V, --version': 'output the version number',
73
76
  '--detailed-report [count]': ['print the asset timings and sizes in the build report', parseOptionInt],
@@ -79,6 +82,7 @@ const commonOptions = exports.commonOptions = {
79
82
  let [name, val] = value.split('=');
80
83
  if (name in _featureFlags().DEFAULT_FEATURE_FLAGS) {
81
84
  let featureFlagValue;
85
+ // @ts-expect-error TS7053
82
86
  if (typeof _featureFlags().DEFAULT_FEATURE_FLAGS[name] === 'boolean') {
83
87
  if (val !== 'true' && val !== 'false') {
84
88
  throw new Error(`Feature flag ${name} must be set to true or false`);
@@ -0,0 +1,5 @@
1
+ import commander from 'commander';
2
+ export interface OptionsDefinition {
3
+ [key: string]: string | unknown[] | commander.Option;
4
+ }
5
+ export declare function applyOptions(cmd: commander.Command, options: OptionsDefinition): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function logUncaughtError(e: unknown): Promise<void>;
2
+ export declare function handleUncaughtException(exception: unknown): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import commander from 'commander';
2
+ export declare function makeDebugCommand(): commander.Command;
@@ -0,0 +1,42 @@
1
+ import commander from 'commander';
2
+ import type { FileSystem } from '@atlaspack/fs';
3
+ import type { FeatureFlags } from '@atlaspack/feature-flags';
4
+ import type { InitialAtlaspackOptions, LogLevel } from '@atlaspack/types';
5
+ export interface Options {
6
+ production?: boolean;
7
+ autoinstall?: boolean;
8
+ https?: boolean;
9
+ cert?: string;
10
+ key?: string;
11
+ host: string;
12
+ port?: string;
13
+ hmr?: boolean;
14
+ hmrPort?: string;
15
+ hmrHost?: string;
16
+ publicUrl?: string;
17
+ detailedReport?: boolean | string;
18
+ reporter: string[];
19
+ trace?: boolean;
20
+ cache?: boolean;
21
+ cacheDir?: string;
22
+ projectRoot?: string;
23
+ watchDir?: string;
24
+ watchBackend?: 'watchman' | 'fs-events' | 'inotify' | 'brute-force' | 'windows';
25
+ watchIgnore?: string[];
26
+ config?: string;
27
+ logLevel?: LogLevel;
28
+ profile?: boolean;
29
+ profileNative?: string | boolean;
30
+ contentHash?: boolean;
31
+ featureFlag?: Partial<FeatureFlags>;
32
+ optimize?: boolean;
33
+ sourceMaps?: boolean;
34
+ scopeHoist?: boolean;
35
+ distDir?: string;
36
+ lazy?: string;
37
+ lazyExclude?: string;
38
+ target: string[];
39
+ }
40
+ export interface CommandExt extends commander.Command, Options {
41
+ }
42
+ export declare function normalizeOptions(command: CommandExt, inputFS: FileSystem): Promise<InitialAtlaspackOptions>;
@@ -0,0 +1,4 @@
1
+ import type { OptionsDefinition } from './applyOptions';
2
+ export declare let watcherBackendChoices: string[];
3
+ export declare const commonOptions: OptionsDefinition;
4
+ export declare const hmrOptions: OptionsDefinition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/cli",
3
- "version": "2.13.7-canary.48+3af500201",
3
+ "version": "2.13.7-canary.481+a1d772935",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "type": "commonjs",
@@ -14,36 +14,36 @@
14
14
  "bin": {
15
15
  "atlaspack": "bin/atlaspack.js"
16
16
  },
17
- "main": "lib/bin.js",
18
- "source": "src/bin.js",
17
+ "main": "./lib/bin.js",
18
+ "source": "./src/bin.ts",
19
+ "types": "./lib/types/bin.d.ts",
19
20
  "scripts": {
20
- "prepack": "./ensure-no-dev-lib.sh",
21
- "dev:prepare": "rimraf ./lib/ && mkdir -p lib && cp ./bin/dev-bin.js ./lib/bin.js"
21
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
22
22
  },
23
23
  "engines": {
24
24
  "node": ">= 16.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@atlaspack/config-default": "3.1.5-canary.48+3af500201",
28
- "@atlaspack/core": "2.16.2-canary.48+3af500201",
29
- "@atlaspack/diagnostic": "2.14.1-canary.116+3af500201",
30
- "@atlaspack/events": "2.14.1-canary.116+3af500201",
31
- "@atlaspack/feature-flags": "2.14.1-canary.116+3af500201",
32
- "@atlaspack/fs": "2.14.5-canary.48+3af500201",
33
- "@atlaspack/logger": "2.14.5-canary.48+3af500201",
34
- "@atlaspack/package-manager": "2.14.5-canary.48+3af500201",
35
- "@atlaspack/reporter-cli": "2.15.1-canary.48+3af500201",
36
- "@atlaspack/reporter-dev-server": "2.14.5-canary.48+3af500201",
37
- "@atlaspack/reporter-tracer": "2.14.5-canary.48+3af500201",
38
- "@atlaspack/utils": "2.14.5-canary.48+3af500201",
27
+ "@atlaspack/config-default": "3.1.5-canary.481+a1d772935",
28
+ "@atlaspack/core": "2.16.2-canary.481+a1d772935",
29
+ "@atlaspack/diagnostic": "2.14.1-canary.549+a1d772935",
30
+ "@atlaspack/events": "2.14.1-canary.549+a1d772935",
31
+ "@atlaspack/feature-flags": "2.14.1-canary.549+a1d772935",
32
+ "@atlaspack/fs": "2.14.5-canary.481+a1d772935",
33
+ "@atlaspack/logger": "2.14.5-canary.481+a1d772935",
34
+ "@atlaspack/package-manager": "2.14.5-canary.481+a1d772935",
35
+ "@atlaspack/reporter-cli": "2.15.1-canary.481+a1d772935",
36
+ "@atlaspack/reporter-dev-server": "2.14.5-canary.481+a1d772935",
37
+ "@atlaspack/reporter-tracer": "2.14.5-canary.481+a1d772935",
38
+ "@atlaspack/utils": "2.14.5-canary.481+a1d772935",
39
39
  "chalk": "^4.1.0",
40
- "commander": "^7.0.0",
41
- "get-port": "^4.2.0"
40
+ "commander": "^8.3.0",
41
+ "get-port": "^5.1.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@atlaspack/babel-register": "2.14.1",
44
+ "@atlaspack/babel-register": "2.14.5",
45
45
  "@babel/core": "^7.22.11",
46
- "rimraf": "^5.0.5"
46
+ "rimraf": "^3.0.2"
47
47
  },
48
- "gitHead": "3af5002017ed237c1bcfed5c5cf3f0da5b3a9f92"
49
- }
48
+ "gitHead": "a1d772935c9ed74c6d8eafbee6b65eb91ddc38fd"
49
+ }
@@ -1,16 +1,12 @@
1
- // @flow strict-local
2
-
3
- import commander, {
4
- type commander$Command,
5
- type commander$Option,
6
- } from 'commander';
1
+ // @ts-expect-error TS2305
2
+ import commander, {commander$Command, commander$Option} from 'commander';
7
3
 
8
4
  export interface OptionsDefinition {
9
- [key: string]: string | mixed[] | commander$Option;
5
+ [key: string]: string | unknown[] | commander.Option;
10
6
  }
11
7
 
12
8
  export function applyOptions(
13
- cmd: commander$Command,
9
+ cmd: commander.Command,
14
10
  options: OptionsDefinition,
15
11
  ) {
16
12
  for (let opt in options) {
@@ -18,6 +14,7 @@ export function applyOptions(
18
14
  if (option instanceof commander.Option) {
19
15
  cmd.addOption(option);
20
16
  } else if (Array.isArray(option)) {
17
+ // @ts-expect-error TS2345
21
18
  cmd.option(opt, ...option);
22
19
  } else if (typeof option === 'string') {
23
20
  cmd.option(opt, option);
package/src/bin.js CHANGED
@@ -1,12 +1,2 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
-
5
- if (
6
- process.env.ATLASPACK_BUILD_ENV !== 'production' ||
7
- process.env.ATLASPACK_SELF_BUILD
8
- ) {
9
- require('@atlaspack/babel-register');
10
- }
11
-
12
- require('./cli');
1
+ // This file exists for atlaspack-link support
2
+ require('../bin/atlaspack.js');
@@ -1,12 +1,10 @@
1
- // @flow
2
-
3
1
  import {BuildError} from '@atlaspack/core';
4
2
  import {NodeFS} from '@atlaspack/fs';
5
3
  import {openInBrowser} from '@atlaspack/utils';
6
4
  import {Disposable} from '@atlaspack/events';
7
5
  import {INTERNAL_ORIGINAL_CONSOLE} from '@atlaspack/logger';
8
6
  import chalk from 'chalk';
9
- import commander from 'commander';
7
+ import {Command} from 'commander';
10
8
  import path from 'path';
11
9
  import {version} from '../package.json';
12
10
  import {applyOptions} from './applyOptions';
@@ -18,7 +16,7 @@ import {
18
16
  } from './handleUncaughtException';
19
17
  import {commonOptions, hmrOptions} from './options';
20
18
 
21
- const program = new commander.Command();
19
+ const program = new Command();
22
20
 
23
21
  // Exit codes in response to signals are traditionally
24
22
  // 128 + signal value
@@ -97,8 +95,8 @@ program.on('--help', function () {
97
95
  });
98
96
 
99
97
  // Override to output option description if argument was missing
100
- // $FlowFixMe[prop-missing]
101
- commander.Command.prototype.optionMissingArgument = function (option) {
98
+ // @ts-expect-error optionMissingArgument is not in commander 8 typings but exists at runtime
99
+ Command.prototype.optionMissingArgument = function (option: any) {
102
100
  INTERNAL_ORIGINAL_CONSOLE.error(
103
101
  "error: option `%s' argument missing",
104
102
  option.flags,
@@ -117,7 +115,9 @@ if (!args[2] || !program.commands.some((c) => c.name() === args[2])) {
117
115
 
118
116
  program.parse(args);
119
117
 
118
+ // @ts-expect-error TS7019
120
119
  function runCommand(...args) {
120
+ // @ts-expect-error TS2556
121
121
  run(...args).catch(handleUncaughtException);
122
122
  }
123
123
 
@@ -145,9 +145,11 @@ async function run(
145
145
  });
146
146
 
147
147
  let disposable = new Disposable();
148
- let unsubscribe: () => Promise<mixed>;
148
+ let unsubscribe: () => Promise<unknown>;
149
+ // @ts-expect-error TS7034
149
150
  let isExiting;
150
151
  async function exit(exitCode: number = 0) {
152
+ // @ts-expect-error TS7005
151
153
  if (isExiting) {
152
154
  return;
153
155
  }
@@ -160,7 +162,6 @@ async function run(
160
162
  }
161
163
 
162
164
  if (process.stdin.isTTY && process.stdin.isRaw) {
163
- // $FlowFixMe
164
165
  process.stdin.setRawMode(false);
165
166
  }
166
167
 
@@ -170,7 +171,6 @@ async function run(
170
171
 
171
172
  const isWatching = command.name() === 'watch' || command.name() === 'serve';
172
173
  if (process.stdin.isTTY) {
173
- // $FlowFixMe
174
174
  process.stdin.setRawMode(true);
175
175
  require('readline').emitKeypressEvents(process.stdin);
176
176
 
@@ -212,6 +212,7 @@ async function run(
212
212
  }
213
213
 
214
214
  if (isWatching) {
215
+ // @ts-expect-error TS7006
215
216
  ({unsubscribe} = await atlaspack.watch((err) => {
216
217
  if (err) {
217
218
  throw err;
@@ -243,7 +244,7 @@ async function run(
243
244
  } else {
244
245
  try {
245
246
  await atlaspack.run();
246
- } catch (err) {
247
+ } catch (err: any) {
247
248
  // If an exception is thrown during Atlaspack.build, it is given to reporters in a
248
249
  // buildFailure event, and has been shown to the user.
249
250
  if (!(err instanceof BuildError)) {
@@ -1,11 +1,9 @@
1
- // @flow strict-local
2
-
3
1
  import ThrowableDiagnostic from '@atlaspack/diagnostic';
4
2
  import {prettyDiagnostic} from '@atlaspack/utils';
5
3
  import {INTERNAL_ORIGINAL_CONSOLE} from '@atlaspack/logger';
6
4
  import chalk from 'chalk';
7
5
 
8
- export async function logUncaughtError(e: mixed) {
6
+ export async function logUncaughtError(e: unknown) {
9
7
  if (e instanceof ThrowableDiagnostic) {
10
8
  for (let diagnostic of e.diagnostics) {
11
9
  let {message, codeframe, stack, hints, documentation} =
@@ -31,13 +29,16 @@ export async function logUncaughtError(e: mixed) {
31
29
  }
32
30
 
33
31
  // A hack to definitely ensure we logged the uncaught exception
34
- await new Promise((resolve) => setTimeout(resolve, 100));
32
+ await new Promise(
33
+ (resolve: (result: Promise<undefined> | undefined) => void) =>
34
+ setTimeout(resolve, 100),
35
+ );
35
36
  }
36
37
 
37
- export async function handleUncaughtException(exception: mixed) {
38
+ export async function handleUncaughtException(exception: unknown) {
38
39
  try {
39
40
  await logUncaughtError(exception);
40
- } catch (err) {
41
+ } catch (err: any) {
41
42
  console.error(exception);
42
43
  console.error(err);
43
44
  }
@@ -1,20 +1,23 @@
1
- // @flow strict-local
2
-
3
1
  import {NodeFS} from '@atlaspack/fs';
4
2
  import logger from '@atlaspack/logger';
5
- import commander, {type commander$Command} from 'commander';
3
+ // @ts-expect-error TS2305
4
+ import commander, {commander$Command} from 'commander';
6
5
  import path from 'path';
7
- import {normalizeOptions, type Options} from './normalizeOptions';
6
+ import {normalizeOptions, Options} from './normalizeOptions';
8
7
  import type {CommandExt} from './normalizeOptions';
9
8
  import {applyOptions} from './applyOptions';
10
9
  import {commonOptions} from './options';
11
10
  import {handleUncaughtException} from './handleUncaughtException';
12
11
 
13
- export function makeDebugCommand(): commander$Command {
12
+ export function makeDebugCommand(): commander.Command {
14
13
  const debug = new commander.Command('debug').description(
15
14
  'Debug commands for atlaspack',
16
15
  );
17
- const getInstance = async (args, opts, command) => {
16
+ const getInstance = async (
17
+ args: Array<string>,
18
+ opts: Options,
19
+ command: CommandExt,
20
+ ) => {
18
21
  let entries = args;
19
22
 
20
23
  if (entries.length === 0) {
@@ -58,7 +61,7 @@ export function makeDebugCommand(): commander$Command {
58
61
  message: 'Done invalidating cache',
59
62
  origin: '@atlaspack/cli',
60
63
  });
61
- } catch (err) {
64
+ } catch (err: any) {
62
65
  handleUncaughtException(err);
63
66
  }
64
67
  });
@@ -77,7 +80,7 @@ export function makeDebugCommand(): commander$Command {
77
80
  origin: '@atlaspack/cli',
78
81
  });
79
82
  process.exit(0);
80
- } catch (err) {
83
+ } catch (err: any) {
81
84
  handleUncaughtException(err);
82
85
  }
83
86
  });
@@ -95,7 +98,7 @@ export function makeDebugCommand(): commander$Command {
95
98
  origin: '@atlaspack/cli',
96
99
  });
97
100
  process.exit(0);
98
- } catch (err) {
101
+ } catch (err: any) {
99
102
  handleUncaughtException(err);
100
103
  }
101
104
  });