@atlaspack/cli 2.13.7-canary.44 → 2.13.7-canary.441
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/CHANGELOG.md +801 -0
- package/bin/atlaspack.js +12 -1
- package/dist/applyOptions.js +23 -0
- package/dist/cli.js +206 -0
- package/dist/handleUncaughtException.js +48 -0
- package/dist/makeDebugCommand.js +98 -0
- package/dist/normalizeOptions.js +176 -0
- package/dist/options.js +113 -0
- package/lib/applyOptions.js +3 -0
- package/lib/bin.js +3 -3
- package/lib/cli.js +6 -3
- package/lib/makeDebugCommand.js +2 -0
- package/lib/normalizeOptions.js +26 -4
- package/lib/options.js +4 -0
- package/lib/types/applyOptions.d.ts +5 -0
- package/lib/types/cli.d.ts +1 -0
- package/lib/types/handleUncaughtException.d.ts +2 -0
- package/lib/types/makeDebugCommand.d.ts +2 -0
- package/lib/types/normalizeOptions.d.ts +42 -0
- package/lib/types/options.d.ts +4 -0
- package/package.json +20 -20
- package/src/{applyOptions.js → applyOptions.ts} +5 -8
- package/src/bin.js +2 -12
- package/src/{cli.js → cli.ts} +8 -8
- package/src/{handleUncaughtException.js → handleUncaughtException.ts} +7 -6
- package/src/{makeDebugCommand.js → makeDebugCommand.ts} +12 -9
- package/src/{normalizeOptions.js → normalizeOptions.ts} +28 -7
- package/src/{options.js → options.ts} +9 -5
- package/tsconfig.json +45 -0
- package/tsconfig.tsbuildinfo +1 -0
package/lib/applyOptions.js
CHANGED
|
@@ -12,12 +12,15 @@ function _commander() {
|
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
package/lib/cli.js
CHANGED
|
@@ -92,7 +92,6 @@ program.on('--help', function () {
|
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
// Override to output option description if argument was missing
|
|
95
|
-
// $FlowFixMe[prop-missing]
|
|
96
95
|
_commander().default.Command.prototype.optionMissingArgument = function (option) {
|
|
97
96
|
_logger().INTERNAL_ORIGINAL_CONSOLE.error("error: option `%s' argument missing", option.flags);
|
|
98
97
|
_logger().INTERNAL_ORIGINAL_CONSOLE.log(program.createHelp().optionDescription(option));
|
|
@@ -106,7 +105,10 @@ if (!args[2] || !program.commands.some(c => c.name() === args[2])) {
|
|
|
106
105
|
args.splice(2, 0, 'serve');
|
|
107
106
|
}
|
|
108
107
|
program.parse(args);
|
|
108
|
+
|
|
109
|
+
// @ts-expect-error TS7019
|
|
109
110
|
function runCommand(...args) {
|
|
111
|
+
// @ts-expect-error TS2556
|
|
110
112
|
run(...args).catch(_handleUncaughtException.handleUncaughtException);
|
|
111
113
|
}
|
|
112
114
|
async function run(entries, _opts,
|
|
@@ -129,8 +131,10 @@ command) {
|
|
|
129
131
|
});
|
|
130
132
|
let disposable = new (_events().Disposable)();
|
|
131
133
|
let unsubscribe;
|
|
134
|
+
// @ts-expect-error TS7034
|
|
132
135
|
let isExiting;
|
|
133
136
|
async function exit(exitCode = 0) {
|
|
137
|
+
// @ts-expect-error TS7005
|
|
134
138
|
if (isExiting) {
|
|
135
139
|
return;
|
|
136
140
|
}
|
|
@@ -141,7 +145,6 @@ command) {
|
|
|
141
145
|
await atlaspack.stopProfiling();
|
|
142
146
|
}
|
|
143
147
|
if (process.stdin.isTTY && process.stdin.isRaw) {
|
|
144
|
-
// $FlowFixMe
|
|
145
148
|
process.stdin.setRawMode(false);
|
|
146
149
|
}
|
|
147
150
|
disposable.dispose();
|
|
@@ -149,7 +152,6 @@ command) {
|
|
|
149
152
|
}
|
|
150
153
|
const isWatching = command.name() === 'watch' || command.name() === 'serve';
|
|
151
154
|
if (process.stdin.isTTY) {
|
|
152
|
-
// $FlowFixMe
|
|
153
155
|
process.stdin.setRawMode(true);
|
|
154
156
|
require('readline').emitKeypressEvents(process.stdin);
|
|
155
157
|
let stream = process.stdin.on('keypress', async (char, key) => {
|
|
@@ -185,6 +187,7 @@ command) {
|
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
if (isWatching) {
|
|
190
|
+
// @ts-expect-error TS7006
|
|
188
191
|
({
|
|
189
192
|
unsubscribe
|
|
190
193
|
} = await atlaspack.watch(err => {
|
package/lib/makeDebugCommand.js
CHANGED
|
@@ -37,6 +37,8 @@ var _applyOptions = require("./applyOptions");
|
|
|
37
37
|
var _options = require("./options");
|
|
38
38
|
var _handleUncaughtException = require("./handleUncaughtException");
|
|
39
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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) => {
|
package/lib/normalizeOptions.js
CHANGED
|
@@ -32,6 +32,13 @@ function _path() {
|
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
+
function _os() {
|
|
36
|
+
const data = _interopRequireDefault(require("os"));
|
|
37
|
+
_os = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
35
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
43
|
function parsePort(portValue) {
|
|
37
44
|
let parsedPort = Number(portValue);
|
|
@@ -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
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/cli",
|
|
3
|
-
"version": "2.13.7-canary.
|
|
3
|
+
"version": "2.13.7-canary.441+71981eac2",
|
|
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.
|
|
17
|
+
"main": "./lib/bin.js",
|
|
18
|
+
"source": "./src/bin.ts",
|
|
19
|
+
"types": "./lib/types/bin.d.ts",
|
|
19
20
|
"scripts": {
|
|
20
|
-
"
|
|
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.
|
|
28
|
-
"@atlaspack/core": "2.16.2-canary.
|
|
29
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
30
|
-
"@atlaspack/events": "2.14.1-canary.
|
|
31
|
-
"@atlaspack/feature-flags": "2.14.1-canary.
|
|
32
|
-
"@atlaspack/fs": "2.14.5-canary.
|
|
33
|
-
"@atlaspack/logger": "2.14.5-canary.
|
|
34
|
-
"@atlaspack/package-manager": "2.14.5-canary.
|
|
35
|
-
"@atlaspack/reporter-cli": "2.15.1-canary.
|
|
36
|
-
"@atlaspack/reporter-dev-server": "2.14.5-canary.
|
|
37
|
-
"@atlaspack/reporter-tracer": "2.14.5-canary.
|
|
38
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
27
|
+
"@atlaspack/config-default": "3.1.5-canary.441+71981eac2",
|
|
28
|
+
"@atlaspack/core": "2.16.2-canary.441+71981eac2",
|
|
29
|
+
"@atlaspack/diagnostic": "2.14.1-canary.509+71981eac2",
|
|
30
|
+
"@atlaspack/events": "2.14.1-canary.509+71981eac2",
|
|
31
|
+
"@atlaspack/feature-flags": "2.14.1-canary.509+71981eac2",
|
|
32
|
+
"@atlaspack/fs": "2.14.5-canary.441+71981eac2",
|
|
33
|
+
"@atlaspack/logger": "2.14.5-canary.441+71981eac2",
|
|
34
|
+
"@atlaspack/package-manager": "2.14.5-canary.441+71981eac2",
|
|
35
|
+
"@atlaspack/reporter-cli": "2.15.1-canary.441+71981eac2",
|
|
36
|
+
"@atlaspack/reporter-dev-server": "2.14.5-canary.441+71981eac2",
|
|
37
|
+
"@atlaspack/reporter-tracer": "2.14.5-canary.441+71981eac2",
|
|
38
|
+
"@atlaspack/utils": "2.14.5-canary.441+71981eac2",
|
|
39
39
|
"chalk": "^4.1.0",
|
|
40
40
|
"commander": "^7.0.0",
|
|
41
41
|
"get-port": "^4.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@atlaspack/babel-register": "2.14.
|
|
44
|
+
"@atlaspack/babel-register": "2.14.4",
|
|
45
45
|
"@babel/core": "^7.22.11",
|
|
46
46
|
"rimraf": "^5.0.5"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
-
}
|
|
48
|
+
"gitHead": "71981eac258f7e6dfb40ec4b202d194f71c64ff1"
|
|
49
|
+
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
// @
|
|
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 |
|
|
5
|
+
[key: string]: string | unknown[] | commander.Option;
|
|
10
6
|
}
|
|
11
7
|
|
|
12
8
|
export function applyOptions(
|
|
13
|
-
cmd: commander
|
|
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
|
-
|
|
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');
|
package/src/{cli.js → cli.ts}
RENAMED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
1
|
import {BuildError} from '@atlaspack/core';
|
|
4
2
|
import {NodeFS} from '@atlaspack/fs';
|
|
5
3
|
import {openInBrowser} from '@atlaspack/utils';
|
|
@@ -97,8 +95,7 @@ program.on('--help', function () {
|
|
|
97
95
|
});
|
|
98
96
|
|
|
99
97
|
// Override to output option description if argument was missing
|
|
100
|
-
|
|
101
|
-
commander.Command.prototype.optionMissingArgument = function (option) {
|
|
98
|
+
commander.Command.prototype.optionMissingArgument = function (option: any) {
|
|
102
99
|
INTERNAL_ORIGINAL_CONSOLE.error(
|
|
103
100
|
"error: option `%s' argument missing",
|
|
104
101
|
option.flags,
|
|
@@ -117,7 +114,9 @@ if (!args[2] || !program.commands.some((c) => c.name() === args[2])) {
|
|
|
117
114
|
|
|
118
115
|
program.parse(args);
|
|
119
116
|
|
|
117
|
+
// @ts-expect-error TS7019
|
|
120
118
|
function runCommand(...args) {
|
|
119
|
+
// @ts-expect-error TS2556
|
|
121
120
|
run(...args).catch(handleUncaughtException);
|
|
122
121
|
}
|
|
123
122
|
|
|
@@ -145,9 +144,11 @@ async function run(
|
|
|
145
144
|
});
|
|
146
145
|
|
|
147
146
|
let disposable = new Disposable();
|
|
148
|
-
let unsubscribe: () => Promise<
|
|
147
|
+
let unsubscribe: () => Promise<unknown>;
|
|
148
|
+
// @ts-expect-error TS7034
|
|
149
149
|
let isExiting;
|
|
150
150
|
async function exit(exitCode: number = 0) {
|
|
151
|
+
// @ts-expect-error TS7005
|
|
151
152
|
if (isExiting) {
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
@@ -160,7 +161,6 @@ async function run(
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
if (process.stdin.isTTY && process.stdin.isRaw) {
|
|
163
|
-
// $FlowFixMe
|
|
164
164
|
process.stdin.setRawMode(false);
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -170,7 +170,6 @@ async function run(
|
|
|
170
170
|
|
|
171
171
|
const isWatching = command.name() === 'watch' || command.name() === 'serve';
|
|
172
172
|
if (process.stdin.isTTY) {
|
|
173
|
-
// $FlowFixMe
|
|
174
173
|
process.stdin.setRawMode(true);
|
|
175
174
|
require('readline').emitKeypressEvents(process.stdin);
|
|
176
175
|
|
|
@@ -212,6 +211,7 @@ async function run(
|
|
|
212
211
|
}
|
|
213
212
|
|
|
214
213
|
if (isWatching) {
|
|
214
|
+
// @ts-expect-error TS7006
|
|
215
215
|
({unsubscribe} = await atlaspack.watch((err) => {
|
|
216
216
|
if (err) {
|
|
217
217
|
throw err;
|
|
@@ -243,7 +243,7 @@ async function run(
|
|
|
243
243
|
} else {
|
|
244
244
|
try {
|
|
245
245
|
await atlaspack.run();
|
|
246
|
-
} catch (err) {
|
|
246
|
+
} catch (err: any) {
|
|
247
247
|
// If an exception is thrown during Atlaspack.build, it is given to reporters in a
|
|
248
248
|
// buildFailure event, and has been shown to the user.
|
|
249
249
|
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:
|
|
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(
|
|
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:
|
|
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
|
-
|
|
3
|
+
// @ts-expect-error TS2305
|
|
4
|
+
import commander, {commander$Command} from 'commander';
|
|
6
5
|
import path from 'path';
|
|
7
|
-
import {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
|
|
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 (
|
|
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
|
});
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import ThrowableDiagnostic from '@atlaspack/diagnostic';
|
|
4
2
|
import commander from 'commander';
|
|
5
3
|
import getPort from 'get-port';
|
|
@@ -8,6 +6,7 @@ import type {FeatureFlags} from '@atlaspack/feature-flags';
|
|
|
8
6
|
import type {InitialAtlaspackOptions, LogLevel} from '@atlaspack/types';
|
|
9
7
|
import {INTERNAL_ORIGINAL_CONSOLE} from '@atlaspack/logger';
|
|
10
8
|
import path from 'path';
|
|
9
|
+
import os from 'os';
|
|
11
10
|
|
|
12
11
|
function parsePort(portValue: string): number {
|
|
13
12
|
let parsedPort = Number(portValue);
|
|
@@ -37,6 +36,7 @@ export interface Options {
|
|
|
37
36
|
trace?: boolean;
|
|
38
37
|
cache?: boolean;
|
|
39
38
|
cacheDir?: string;
|
|
39
|
+
projectRoot?: string;
|
|
40
40
|
watchDir?: string;
|
|
41
41
|
watchBackend?:
|
|
42
42
|
| 'watchman'
|
|
@@ -48,8 +48,9 @@ export interface Options {
|
|
|
48
48
|
config?: string;
|
|
49
49
|
logLevel?: LogLevel;
|
|
50
50
|
profile?: boolean;
|
|
51
|
+
profileNative?: string | boolean;
|
|
51
52
|
contentHash?: boolean;
|
|
52
|
-
featureFlag?:
|
|
53
|
+
featureFlag?: Partial<FeatureFlags>;
|
|
53
54
|
optimize?: boolean;
|
|
54
55
|
sourceMaps?: boolean;
|
|
55
56
|
scopeHoist?: boolean;
|
|
@@ -59,10 +60,8 @@ export interface Options {
|
|
|
59
60
|
target: string[];
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
// $FlowFixMe
|
|
63
63
|
export interface CommandExt extends commander.Command, Options {}
|
|
64
64
|
|
|
65
|
-
// $FlowFixMe
|
|
66
65
|
function shouldUseProductionDefaults(command: CommandExt) {
|
|
67
66
|
return command.name() === 'build' || command.production === true;
|
|
68
67
|
}
|
|
@@ -86,6 +85,7 @@ export async function normalizeOptions(
|
|
|
86
85
|
|
|
87
86
|
let https = !!command.https;
|
|
88
87
|
if (command.cert != null && command.key != null) {
|
|
88
|
+
// @ts-expect-error TS2322
|
|
89
89
|
https = {
|
|
90
90
|
cert: command.cert,
|
|
91
91
|
key: command.key,
|
|
@@ -104,7 +104,7 @@ export async function normalizeOptions(
|
|
|
104
104
|
) {
|
|
105
105
|
try {
|
|
106
106
|
port = await getPort({port, host});
|
|
107
|
-
} catch (err) {
|
|
107
|
+
} catch (err: any) {
|
|
108
108
|
throw new ThrowableDiagnostic({
|
|
109
109
|
diagnostic: {
|
|
110
110
|
message: `Could not get available port: ${err.message}`,
|
|
@@ -129,6 +129,7 @@ export async function normalizeOptions(
|
|
|
129
129
|
if (command.name() === 'serve') {
|
|
130
130
|
let {publicUrl} = command;
|
|
131
131
|
|
|
132
|
+
// @ts-expect-error TS2322
|
|
132
133
|
serveOptions = {
|
|
133
134
|
https,
|
|
134
135
|
port,
|
|
@@ -154,7 +155,7 @@ export async function normalizeOptions(
|
|
|
154
155
|
|
|
155
156
|
let additionalReporters = [
|
|
156
157
|
{packageName: '@atlaspack/reporter-cli', resolveFrom: __filename},
|
|
157
|
-
...(command.reporter
|
|
158
|
+
...(command.reporter as Array<string>).map((packageName) => ({
|
|
158
159
|
packageName,
|
|
159
160
|
resolveFrom: path.join(inputFS.cwd(), 'index'),
|
|
160
161
|
})),
|
|
@@ -176,9 +177,26 @@ export async function normalizeOptions(
|
|
|
176
177
|
return input.split(',').map((value) => value.trim());
|
|
177
178
|
};
|
|
178
179
|
|
|
180
|
+
let nativeProfiler: 'instruments' | 'samply' | undefined;
|
|
181
|
+
if (typeof command.profileNative === 'string') {
|
|
182
|
+
if (
|
|
183
|
+
command.profileNative === 'instruments' ||
|
|
184
|
+
command.profileNative === 'samply'
|
|
185
|
+
) {
|
|
186
|
+
nativeProfiler = command.profileNative as 'instruments' | 'samply';
|
|
187
|
+
} else {
|
|
188
|
+
nativeProfiler = undefined;
|
|
189
|
+
}
|
|
190
|
+
} else if (command.profileNative) {
|
|
191
|
+
nativeProfiler = os.platform() === 'darwin' ? 'instruments' : 'samply';
|
|
192
|
+
} else {
|
|
193
|
+
nativeProfiler = undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
179
196
|
return {
|
|
180
197
|
shouldDisableCache: command.cache === false,
|
|
181
198
|
cacheDir: command.cacheDir,
|
|
199
|
+
projectRoot: command.projectRoot,
|
|
182
200
|
watchDir: command.watchDir,
|
|
183
201
|
watchBackend: command.watchBackend,
|
|
184
202
|
watchIgnore: command.watchIgnore,
|
|
@@ -186,11 +204,13 @@ export async function normalizeOptions(
|
|
|
186
204
|
mode,
|
|
187
205
|
hmrOptions,
|
|
188
206
|
shouldContentHash: hmrOptions ? false : command.contentHash,
|
|
207
|
+
// @ts-expect-error TS2322
|
|
189
208
|
serveOptions,
|
|
190
209
|
targets: command.target.length > 0 ? command.target : null,
|
|
191
210
|
shouldAutoInstall: command.autoinstall ?? true,
|
|
192
211
|
logLevel: command.logLevel,
|
|
193
212
|
shouldProfile: command.profile,
|
|
213
|
+
nativeProfiler,
|
|
194
214
|
shouldTrace: command.trace,
|
|
195
215
|
shouldBuildLazily: typeof command.lazy !== 'undefined',
|
|
196
216
|
lazyIncludes: normalizeIncludeExcludeList(command.lazy),
|
|
@@ -200,6 +220,7 @@ export async function normalizeOptions(
|
|
|
200
220
|
detailedReport:
|
|
201
221
|
command.detailedReport != null
|
|
202
222
|
? {
|
|
223
|
+
// @ts-expect-error TS2345
|
|
203
224
|
assetsPerBundle: parseInt(command.detailedReport, 10),
|
|
204
225
|
}
|
|
205
226
|
: null,
|