@atlaspack/cli 2.13.7-canary.47 → 2.13.7-canary.471

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.
@@ -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?: $Partial<FeatureFlags>;
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: Array<string>).map((packageName) => ({
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,
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import {INTERNAL_ORIGINAL_CONSOLE} from '@atlaspack/logger';
4
2
  import commander from 'commander';
5
3
  import {DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
@@ -20,6 +18,7 @@ switch (process.platform) {
20
18
  watcherBackendChoices.push('watchman', 'windows');
21
19
  break;
22
20
  }
21
+ // @ts-expect-error TS2367
23
22
  case 'freebsd' || 'openbsd': {
24
23
  watcherBackendChoices.push('watchman');
25
24
  break;
@@ -35,6 +34,8 @@ export const commonOptions: OptionsDefinition = {
35
34
  '--config <path>':
36
35
  'specify which config to use. can be a path or a package name',
37
36
  '--cache-dir <path>': 'set the cache directory. defaults to ".parcel-cache"',
37
+ '--project-root <path>':
38
+ 'set the project root directory. defaults to nearest directory with lockfiles or version control, falls back to cwd',
38
39
  '--watch-dir <path>':
39
40
  'set the root watch directory. defaults to nearest lockfile or source control dir.',
40
41
  '--watch-ignore [path]': [
@@ -48,7 +49,7 @@ export const commonOptions: OptionsDefinition = {
48
49
  '--no-source-maps': 'disable sourcemaps',
49
50
  '--target [name]': [
50
51
  'only build given target(s)',
51
- (val, list) => list.concat([val]),
52
+ (val: any, list: any) => list.concat([val]),
52
53
  [],
53
54
  ],
54
55
  '--log-level <level>': new commander.Option(
@@ -59,6 +60,8 @@ export const commonOptions: OptionsDefinition = {
59
60
  'output directory to write to when unspecified by targets',
60
61
  '--no-autoinstall': 'disable autoinstall',
61
62
  '--profile': 'enable sampling build profiling',
63
+ '--profile-native [instruments|samply]':
64
+ 'enable native build profiling (defaults to instruments on macOS, samply otherwise)',
62
65
  '--trace': 'enable build tracing',
63
66
  '-V, --version': 'output the version number',
64
67
  '--detailed-report [count]': [
@@ -67,7 +70,7 @@ export const commonOptions: OptionsDefinition = {
67
70
  ],
68
71
  '--reporter <name>': [
69
72
  'additional reporters to run',
70
- (val, acc) => {
73
+ (val: any, acc: any) => {
71
74
  acc.push(val);
72
75
  return acc;
73
76
  },
@@ -75,10 +78,11 @@ export const commonOptions: OptionsDefinition = {
75
78
  ],
76
79
  '--feature-flag <name=value>': [
77
80
  'sets the value of a feature flag',
78
- (value, previousValue) => {
81
+ (value: any, previousValue: any) => {
79
82
  let [name, val] = value.split('=');
80
83
  if (name in DEFAULT_FEATURE_FLAGS) {
81
84
  let featureFlagValue;
85
+ // @ts-expect-error TS7053
82
86
  if (typeof DEFAULT_FEATURE_FLAGS[name] === 'boolean') {
83
87
  if (val !== 'true' && val !== 'false') {
84
88
  throw new Error(
package/tsconfig.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "include": ["./src/", "./package.json"],
4
+ "compilerOptions": {
5
+ "composite": true
6
+ },
7
+ "references": [
8
+ {
9
+ "path": "../../dev/babel-register/tsconfig.json"
10
+ },
11
+ {
12
+ "path": "../../reporters/cli/tsconfig.json"
13
+ },
14
+ {
15
+ "path": "../../reporters/dev-server/tsconfig.json"
16
+ },
17
+ {
18
+ "path": "../../reporters/tracer/tsconfig.json"
19
+ },
20
+ {
21
+ "path": "../../utils/events/tsconfig.json"
22
+ },
23
+ {
24
+ "path": "../core/tsconfig.json"
25
+ },
26
+ {
27
+ "path": "../diagnostic/tsconfig.json"
28
+ },
29
+ {
30
+ "path": "../feature-flags/tsconfig.json"
31
+ },
32
+ {
33
+ "path": "../fs/tsconfig.json"
34
+ },
35
+ {
36
+ "path": "../logger/tsconfig.json"
37
+ },
38
+ {
39
+ "path": "../package-manager/tsconfig.json"
40
+ },
41
+ {
42
+ "path": "../utils/tsconfig.json"
43
+ }
44
+ ]
45
+ }