@stencil/core 2.17.2-0 → 2.17.2

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/cli/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil CLI (CommonJS) v2.17.2-0 | MIT Licensed | https://stenciljs.com
2
+ Stencil CLI (CommonJS) v2.17.2 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  'use strict';
5
5
 
@@ -543,11 +543,12 @@ const createConfigFlags = (init = {}) => {
543
543
  /**
544
544
  * Parse command line arguments into a structured `ConfigFlags` object
545
545
  *
546
- * @param args an array of config flags
547
- * @param sys an optional compiler system
546
+ * @param args an array of CLI flags
547
+ * @param _sys an optional compiler system
548
548
  * @returns a structured ConfigFlags object
549
549
  */
550
- const parseFlags = (args, sys) => {
550
+ const parseFlags = (args, _sys) => {
551
+ // TODO(STENCIL-509): remove the _sys parameter here ^^ (for v3)
551
552
  const flags = createConfigFlags();
552
553
  // cmd line has more priority over npm scripts cmd
553
554
  flags.args = Array.isArray(args) ? args.slice() : [];
@@ -555,24 +556,19 @@ const parseFlags = (args, sys) => {
555
556
  flags.task = flags.args[0];
556
557
  }
557
558
  parseArgs(flags, flags.args);
558
- if (sys && sys.name === 'node') {
559
- const envArgs = getNpmConfigEnvArgs(sys);
560
- parseArgs(flags, envArgs);
561
- envArgs.forEach((envArg) => {
562
- if (!flags.args.includes(envArg)) {
563
- flags.args.push(envArg);
564
- }
565
- });
566
- }
567
559
  if (flags.task != null) {
568
560
  const i = flags.args.indexOf(flags.task);
569
561
  if (i > -1) {
570
562
  flags.args.splice(i, 1);
571
563
  }
572
564
  }
573
- flags.unknownArgs = flags.args.filter((arg) => {
574
- return !flags.knownArgs.includes(arg);
575
- });
565
+ // to find unknown / unrecognized arguments we filter `args`, including only
566
+ // arguments whose normalized form is not found in `knownArgs`. `knownArgs`
567
+ // is populated during the call to `parseArgs` above. For arguments like
568
+ // `--foobar` the string `"--foobar"` will be added, while for more
569
+ // complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
570
+ // string `"--bizBoz"` will be added.
571
+ flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
576
572
  return flags;
577
573
  };
578
574
  /**
@@ -758,17 +754,17 @@ const getValue = (args, configCaseName) => {
758
754
  let matchingArg;
759
755
  args.forEach((arg, i) => {
760
756
  if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
761
- value = getEqualsValue(arg);
762
- matchingArg = arg;
757
+ // our argument was passed at the command-line in the format --argName=arg-value
758
+ [matchingArg, value] = parseEqualsArg(arg);
763
759
  }
764
760
  else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
761
+ // the next value in the array is assumed to be a value for this argument
765
762
  value = args[i + 1];
766
763
  matchingArg = arg;
767
764
  }
768
765
  else if (alias) {
769
766
  if (arg.startsWith(`-${alias}=`)) {
770
- value = getEqualsValue(arg);
771
- matchingArg = arg;
767
+ [matchingArg, value] = parseEqualsArg(arg);
772
768
  }
773
769
  else if (arg === `-${alias}`) {
774
770
  value = args[i + 1];
@@ -779,13 +775,42 @@ const getValue = (args, configCaseName) => {
779
775
  return { value, matchingArg };
780
776
  };
781
777
  /**
782
- * When a parameter is set in the format `--foobar=12` at the CLI (as opposed to
783
- * `--foobar 12`) we want to get the value after the `=` sign
778
+ * Parse an 'equals' argument, which is a CLI argument-value pair in the
779
+ * format `--foobar=12` (as opposed to a space-separated format like
780
+ * `--foobar 12`).
781
+ *
782
+ * To parse this we split on the `=`, returning the first part as the argument
783
+ * name and the second part as the value. We join the value on `"="` in case
784
+ * there is another `"="` in the argument.
785
+ *
786
+ * This function is safe to call with any arg, and can therefore be used as
787
+ * an argument 'normalizer'. If CLI argument is not an 'equals' argument then
788
+ * the return value will be a tuple of the original argument and an empty
789
+ * string `""` for the value.
790
+ *
791
+ * In code terms, if you do:
792
+ *
793
+ * ```ts
794
+ * const [arg, value] = parseEqualsArg("--myArgument")
795
+ * ```
796
+ *
797
+ * Then `arg` will be `"--myArgument"` and `value` will be `""`, whereas if
798
+ * you do:
799
+ *
800
+ *
801
+ * ```ts
802
+ * const [arg, value] = parseEqualsArg("--myArgument=myValue")
803
+ * ```
804
+ *
805
+ * Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
784
806
  *
785
- * @param commandArgument the arg in question
786
- * @returns the value after the `=`
807
+ * @param arg the arg in question
808
+ * @returns a tuple containing the arg name and the value (if present)
787
809
  */
788
- const getEqualsValue = (commandArgument) => commandArgument.split('=').slice(1).join('=');
810
+ const parseEqualsArg = (arg) => {
811
+ const [originalArg, ...value] = arg.split('=');
812
+ return [originalArg, value.join('=')];
813
+ };
789
814
  /**
790
815
  * Small helper for getting type-system-level assurance that a `string` can be
791
816
  * narrowed to a `LogLevel`
@@ -800,27 +825,11 @@ const isLogLevel = (maybeLogLevel) =>
800
825
  //
801
826
  // see microsoft/TypeScript#31018 for some discussion of this
802
827
  LOG_LEVELS.includes(maybeLogLevel);
803
- const getNpmConfigEnvArgs = (sys) => {
804
- // process.env.npm_config_argv
805
- // {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
806
- let args = [];
807
- try {
808
- const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
809
- if (npmConfigArgs) {
810
- args = JSON.parse(npmConfigArgs).original;
811
- if (args[0] === 'run') {
812
- args = args.slice(2);
813
- }
814
- }
815
- }
816
- catch (e) { }
817
- return args;
818
- };
819
828
 
820
829
  const dependencies = [
821
830
  {
822
831
  name: "@stencil/core",
823
- version: "2.17.2-0",
832
+ version: "2.17.2",
824
833
  main: "compiler/stencil.js",
825
834
  resources: [
826
835
  "package.json",
@@ -1316,6 +1325,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
1316
1325
  throw error;
1317
1326
  }
1318
1327
  }
1328
+ /**
1329
+ * Helper function to determine if a Stencil configuration builds an application.
1330
+ *
1331
+ * This function is a rough approximation whether an application is generated as a part of a Stencil build, based on
1332
+ * contents of the project's `stencil.config.ts` file.
1333
+ *
1334
+ * @param config the configuration used by the Stencil project
1335
+ * @returns true if we believe the project generates an application, false otherwise
1336
+ */
1319
1337
  function hasAppTarget(config) {
1320
1338
  return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
1321
1339
  }
@@ -1323,7 +1341,15 @@ function isUsingYarn(sys) {
1323
1341
  var _a;
1324
1342
  return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
1325
1343
  }
1326
- async function getActiveTargets(config) {
1344
+ /**
1345
+ * Build a list of the different types of output targets used in a Stencil configuration.
1346
+ *
1347
+ * Duplicate entries will not be returned from the list
1348
+ *
1349
+ * @param config the configuration used by the Stencil project
1350
+ * @returns a unique list of output target types found in the Stencil configuration
1351
+ */
1352
+ function getActiveTargets(config) {
1327
1353
  const result = config.outputTargets.map((t) => t.type);
1328
1354
  return Array.from(new Set(result));
1329
1355
  }
@@ -1340,7 +1366,7 @@ async function getActiveTargets(config) {
1340
1366
  const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
1341
1367
  const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
1342
1368
  const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
1343
- const targets = await getActiveTargets(config);
1369
+ const targets = getActiveTargets(config);
1344
1370
  const yarn = isUsingYarn(sys);
1345
1371
  const stencil = coreCompiler.version || 'unknown';
1346
1372
  const system = `${sys.name} ${sys.version}`;
@@ -1403,14 +1429,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
1403
1429
  * @returns an anonymized copy of the same config
1404
1430
  */
1405
1431
  const anonymizeConfigForTelemetry = (config) => {
1406
- var _a;
1407
1432
  const anonymizedConfig = { ...config };
1408
1433
  for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
1409
1434
  if (anonymizedConfig[prop] !== undefined) {
1410
1435
  anonymizedConfig[prop] = 'omitted';
1411
1436
  }
1412
1437
  }
1413
- anonymizedConfig.outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).map((target) => {
1438
+ anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
1414
1439
  // Anonymize the outputTargets on our configuration, taking advantage of the
1415
1440
  // optional 2nd argument to `JSON.stringify`. If anything is not a string
1416
1441
  // we retain it so that any nested properties are handled, else we check
@@ -1631,7 +1656,7 @@ function getMajorVersion(version) {
1631
1656
  return parts[0];
1632
1657
  }
1633
1658
 
1634
- const taskBuild = async (coreCompiler, config, sys) => {
1659
+ const taskBuild = async (coreCompiler, config) => {
1635
1660
  if (config.flags.watch) {
1636
1661
  // watch build
1637
1662
  await taskWatch(coreCompiler, config);
@@ -1644,10 +1669,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
1644
1669
  const versionChecker = startCheckVersion(config, coreCompiler.version);
1645
1670
  const compiler = await coreCompiler.createCompiler(config);
1646
1671
  const results = await compiler.build();
1647
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
1648
- if (sys) {
1649
- await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
1650
- }
1672
+ await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
1651
1673
  await compiler.destroy();
1652
1674
  if (results.hasError) {
1653
1675
  exitCode = 1;
@@ -2013,10 +2035,7 @@ const taskHelp = async (flags, logger, sys) => {
2013
2035
  ${prompt} ${logger.green('stencil generate')} or ${logger.green('stencil g')}
2014
2036
 
2015
2037
  `);
2016
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
2017
- if (sys) {
2018
- await taskTelemetry(flags, sys, logger);
2019
- }
2038
+ await taskTelemetry(flags, sys, logger);
2020
2039
  console.log(`
2021
2040
  ${logger.bold('Examples:')}
2022
2041
 
@@ -2214,7 +2233,7 @@ const BLUE = `#3498db`;
2214
2233
  const run = async (init) => {
2215
2234
  const { args, logger, sys } = init;
2216
2235
  try {
2217
- const flags = parseFlags(args, sys);
2236
+ const flags = parseFlags(args);
2218
2237
  const task = flags.task;
2219
2238
  if (flags.debug || flags.verbose) {
2220
2239
  logger.setLevel('debug');
@@ -2252,9 +2271,7 @@ const run = async (init) => {
2252
2271
  startupLogVersion(logger, task, coreCompiler);
2253
2272
  loadedCompilerLog(sys, logger, flags, coreCompiler);
2254
2273
  if (task === 'info') {
2255
- await telemetryAction(sys, { flags: createConfigFlags({ task: 'info' }), logger }, coreCompiler, async () => {
2256
- await taskInfo(coreCompiler, sys, logger);
2257
- });
2274
+ taskInfo(coreCompiler, sys, logger);
2258
2275
  return;
2259
2276
  }
2260
2277
  const validated = await coreCompiler.loadConfig({
@@ -2287,14 +2304,27 @@ const run = async (init) => {
2287
2304
  }
2288
2305
  }
2289
2306
  };
2307
+ /**
2308
+ * Run a specified task
2309
+ * @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
2310
+ * @param config a configuration for the Stencil project to apply to the task run
2311
+ * @param task the task to run
2312
+ * @param sys the {@link CompilerSystem} for interacting with the operating system
2313
+ * @public
2314
+ */
2290
2315
  const runTask = async (coreCompiler, config, task, sys) => {
2291
- var _a, _b;
2316
+ var _a, _b, _c;
2292
2317
  const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
2293
- const strictConfig = { ...config, flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }), logger };
2294
- strictConfig.outputTargets = strictConfig.outputTargets || [];
2318
+ const strictConfig = {
2319
+ ...config,
2320
+ flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
2321
+ logger,
2322
+ outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
2323
+ sys: sys !== null && sys !== void 0 ? sys : coreCompiler.createSystem({ logger }),
2324
+ };
2295
2325
  switch (task) {
2296
2326
  case 'build':
2297
- await taskBuild(coreCompiler, strictConfig, sys);
2327
+ await taskBuild(coreCompiler, strictConfig);
2298
2328
  break;
2299
2329
  case 'docs':
2300
2330
  await taskDocs(coreCompiler, strictConfig);
@@ -2313,10 +2343,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
2313
2343
  await taskServe(strictConfig);
2314
2344
  break;
2315
2345
  case 'telemetry':
2316
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
2317
- if (sys) {
2318
- await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2319
- }
2346
+ await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2320
2347
  break;
2321
2348
  case 'test':
2322
2349
  await taskTest(strictConfig);
package/cli/index.d.ts CHANGED
@@ -12,5 +12,5 @@ export declare function run(init: CliInitOptions): Promise<void>;
12
12
  * @param task The task command to run, such as `build`.
13
13
  */
14
14
  export declare function runTask(coreCompiler: any, config: Config, task: TaskCommand): Promise<void>;
15
- export declare function parseFlags(args: string[], sys?: CompilerSystem): ConfigFlags;
15
+ export declare function parseFlags(args: string[], _sys?: CompilerSystem): ConfigFlags;
16
16
  export { CompilerSystem, Config, ConfigFlags, Logger, TaskCommand };
package/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil CLI v2.17.2-0 | MIT Licensed | https://stenciljs.com
2
+ Stencil CLI v2.17.2 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  /**
5
5
  * This sets the log level hierarchy for our terminal logger, ranging from
@@ -519,11 +519,12 @@ const createConfigFlags = (init = {}) => {
519
519
  /**
520
520
  * Parse command line arguments into a structured `ConfigFlags` object
521
521
  *
522
- * @param args an array of config flags
523
- * @param sys an optional compiler system
522
+ * @param args an array of CLI flags
523
+ * @param _sys an optional compiler system
524
524
  * @returns a structured ConfigFlags object
525
525
  */
526
- const parseFlags = (args, sys) => {
526
+ const parseFlags = (args, _sys) => {
527
+ // TODO(STENCIL-509): remove the _sys parameter here ^^ (for v3)
527
528
  const flags = createConfigFlags();
528
529
  // cmd line has more priority over npm scripts cmd
529
530
  flags.args = Array.isArray(args) ? args.slice() : [];
@@ -531,24 +532,19 @@ const parseFlags = (args, sys) => {
531
532
  flags.task = flags.args[0];
532
533
  }
533
534
  parseArgs(flags, flags.args);
534
- if (sys && sys.name === 'node') {
535
- const envArgs = getNpmConfigEnvArgs(sys);
536
- parseArgs(flags, envArgs);
537
- envArgs.forEach((envArg) => {
538
- if (!flags.args.includes(envArg)) {
539
- flags.args.push(envArg);
540
- }
541
- });
542
- }
543
535
  if (flags.task != null) {
544
536
  const i = flags.args.indexOf(flags.task);
545
537
  if (i > -1) {
546
538
  flags.args.splice(i, 1);
547
539
  }
548
540
  }
549
- flags.unknownArgs = flags.args.filter((arg) => {
550
- return !flags.knownArgs.includes(arg);
551
- });
541
+ // to find unknown / unrecognized arguments we filter `args`, including only
542
+ // arguments whose normalized form is not found in `knownArgs`. `knownArgs`
543
+ // is populated during the call to `parseArgs` above. For arguments like
544
+ // `--foobar` the string `"--foobar"` will be added, while for more
545
+ // complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
546
+ // string `"--bizBoz"` will be added.
547
+ flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
552
548
  return flags;
553
549
  };
554
550
  /**
@@ -734,17 +730,17 @@ const getValue = (args, configCaseName) => {
734
730
  let matchingArg;
735
731
  args.forEach((arg, i) => {
736
732
  if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
737
- value = getEqualsValue(arg);
738
- matchingArg = arg;
733
+ // our argument was passed at the command-line in the format --argName=arg-value
734
+ [matchingArg, value] = parseEqualsArg(arg);
739
735
  }
740
736
  else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
737
+ // the next value in the array is assumed to be a value for this argument
741
738
  value = args[i + 1];
742
739
  matchingArg = arg;
743
740
  }
744
741
  else if (alias) {
745
742
  if (arg.startsWith(`-${alias}=`)) {
746
- value = getEqualsValue(arg);
747
- matchingArg = arg;
743
+ [matchingArg, value] = parseEqualsArg(arg);
748
744
  }
749
745
  else if (arg === `-${alias}`) {
750
746
  value = args[i + 1];
@@ -755,13 +751,42 @@ const getValue = (args, configCaseName) => {
755
751
  return { value, matchingArg };
756
752
  };
757
753
  /**
758
- * When a parameter is set in the format `--foobar=12` at the CLI (as opposed to
759
- * `--foobar 12`) we want to get the value after the `=` sign
754
+ * Parse an 'equals' argument, which is a CLI argument-value pair in the
755
+ * format `--foobar=12` (as opposed to a space-separated format like
756
+ * `--foobar 12`).
757
+ *
758
+ * To parse this we split on the `=`, returning the first part as the argument
759
+ * name and the second part as the value. We join the value on `"="` in case
760
+ * there is another `"="` in the argument.
761
+ *
762
+ * This function is safe to call with any arg, and can therefore be used as
763
+ * an argument 'normalizer'. If CLI argument is not an 'equals' argument then
764
+ * the return value will be a tuple of the original argument and an empty
765
+ * string `""` for the value.
766
+ *
767
+ * In code terms, if you do:
768
+ *
769
+ * ```ts
770
+ * const [arg, value] = parseEqualsArg("--myArgument")
771
+ * ```
772
+ *
773
+ * Then `arg` will be `"--myArgument"` and `value` will be `""`, whereas if
774
+ * you do:
775
+ *
776
+ *
777
+ * ```ts
778
+ * const [arg, value] = parseEqualsArg("--myArgument=myValue")
779
+ * ```
780
+ *
781
+ * Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
760
782
  *
761
- * @param commandArgument the arg in question
762
- * @returns the value after the `=`
783
+ * @param arg the arg in question
784
+ * @returns a tuple containing the arg name and the value (if present)
763
785
  */
764
- const getEqualsValue = (commandArgument) => commandArgument.split('=').slice(1).join('=');
786
+ const parseEqualsArg = (arg) => {
787
+ const [originalArg, ...value] = arg.split('=');
788
+ return [originalArg, value.join('=')];
789
+ };
765
790
  /**
766
791
  * Small helper for getting type-system-level assurance that a `string` can be
767
792
  * narrowed to a `LogLevel`
@@ -776,27 +801,11 @@ const isLogLevel = (maybeLogLevel) =>
776
801
  //
777
802
  // see microsoft/TypeScript#31018 for some discussion of this
778
803
  LOG_LEVELS.includes(maybeLogLevel);
779
- const getNpmConfigEnvArgs = (sys) => {
780
- // process.env.npm_config_argv
781
- // {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
782
- let args = [];
783
- try {
784
- const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
785
- if (npmConfigArgs) {
786
- args = JSON.parse(npmConfigArgs).original;
787
- if (args[0] === 'run') {
788
- args = args.slice(2);
789
- }
790
- }
791
- }
792
- catch (e) { }
793
- return args;
794
- };
795
804
 
796
805
  const dependencies = [
797
806
  {
798
807
  name: "@stencil/core",
799
- version: "2.17.2-0",
808
+ version: "2.17.2",
800
809
  main: "compiler/stencil.js",
801
810
  resources: [
802
811
  "package.json",
@@ -1292,6 +1301,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
1292
1301
  throw error;
1293
1302
  }
1294
1303
  }
1304
+ /**
1305
+ * Helper function to determine if a Stencil configuration builds an application.
1306
+ *
1307
+ * This function is a rough approximation whether an application is generated as a part of a Stencil build, based on
1308
+ * contents of the project's `stencil.config.ts` file.
1309
+ *
1310
+ * @param config the configuration used by the Stencil project
1311
+ * @returns true if we believe the project generates an application, false otherwise
1312
+ */
1295
1313
  function hasAppTarget(config) {
1296
1314
  return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
1297
1315
  }
@@ -1299,7 +1317,15 @@ function isUsingYarn(sys) {
1299
1317
  var _a;
1300
1318
  return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
1301
1319
  }
1302
- async function getActiveTargets(config) {
1320
+ /**
1321
+ * Build a list of the different types of output targets used in a Stencil configuration.
1322
+ *
1323
+ * Duplicate entries will not be returned from the list
1324
+ *
1325
+ * @param config the configuration used by the Stencil project
1326
+ * @returns a unique list of output target types found in the Stencil configuration
1327
+ */
1328
+ function getActiveTargets(config) {
1303
1329
  const result = config.outputTargets.map((t) => t.type);
1304
1330
  return Array.from(new Set(result));
1305
1331
  }
@@ -1316,7 +1342,7 @@ async function getActiveTargets(config) {
1316
1342
  const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
1317
1343
  const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
1318
1344
  const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
1319
- const targets = await getActiveTargets(config);
1345
+ const targets = getActiveTargets(config);
1320
1346
  const yarn = isUsingYarn(sys);
1321
1347
  const stencil = coreCompiler.version || 'unknown';
1322
1348
  const system = `${sys.name} ${sys.version}`;
@@ -1379,14 +1405,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
1379
1405
  * @returns an anonymized copy of the same config
1380
1406
  */
1381
1407
  const anonymizeConfigForTelemetry = (config) => {
1382
- var _a;
1383
1408
  const anonymizedConfig = { ...config };
1384
1409
  for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
1385
1410
  if (anonymizedConfig[prop] !== undefined) {
1386
1411
  anonymizedConfig[prop] = 'omitted';
1387
1412
  }
1388
1413
  }
1389
- anonymizedConfig.outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).map((target) => {
1414
+ anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
1390
1415
  // Anonymize the outputTargets on our configuration, taking advantage of the
1391
1416
  // optional 2nd argument to `JSON.stringify`. If anything is not a string
1392
1417
  // we retain it so that any nested properties are handled, else we check
@@ -1607,7 +1632,7 @@ function getMajorVersion(version) {
1607
1632
  return parts[0];
1608
1633
  }
1609
1634
 
1610
- const taskBuild = async (coreCompiler, config, sys) => {
1635
+ const taskBuild = async (coreCompiler, config) => {
1611
1636
  if (config.flags.watch) {
1612
1637
  // watch build
1613
1638
  await taskWatch(coreCompiler, config);
@@ -1620,10 +1645,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
1620
1645
  const versionChecker = startCheckVersion(config, coreCompiler.version);
1621
1646
  const compiler = await coreCompiler.createCompiler(config);
1622
1647
  const results = await compiler.build();
1623
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
1624
- if (sys) {
1625
- await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
1626
- }
1648
+ await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
1627
1649
  await compiler.destroy();
1628
1650
  if (results.hasError) {
1629
1651
  exitCode = 1;
@@ -1989,10 +2011,7 @@ const taskHelp = async (flags, logger, sys) => {
1989
2011
  ${prompt} ${logger.green('stencil generate')} or ${logger.green('stencil g')}
1990
2012
 
1991
2013
  `);
1992
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
1993
- if (sys) {
1994
- await taskTelemetry(flags, sys, logger);
1995
- }
2014
+ await taskTelemetry(flags, sys, logger);
1996
2015
  console.log(`
1997
2016
  ${logger.bold('Examples:')}
1998
2017
 
@@ -2190,7 +2209,7 @@ const BLUE = `#3498db`;
2190
2209
  const run = async (init) => {
2191
2210
  const { args, logger, sys } = init;
2192
2211
  try {
2193
- const flags = parseFlags(args, sys);
2212
+ const flags = parseFlags(args);
2194
2213
  const task = flags.task;
2195
2214
  if (flags.debug || flags.verbose) {
2196
2215
  logger.setLevel('debug');
@@ -2228,9 +2247,7 @@ const run = async (init) => {
2228
2247
  startupLogVersion(logger, task, coreCompiler);
2229
2248
  loadedCompilerLog(sys, logger, flags, coreCompiler);
2230
2249
  if (task === 'info') {
2231
- await telemetryAction(sys, { flags: createConfigFlags({ task: 'info' }), logger }, coreCompiler, async () => {
2232
- await taskInfo(coreCompiler, sys, logger);
2233
- });
2250
+ taskInfo(coreCompiler, sys, logger);
2234
2251
  return;
2235
2252
  }
2236
2253
  const validated = await coreCompiler.loadConfig({
@@ -2263,14 +2280,27 @@ const run = async (init) => {
2263
2280
  }
2264
2281
  }
2265
2282
  };
2283
+ /**
2284
+ * Run a specified task
2285
+ * @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
2286
+ * @param config a configuration for the Stencil project to apply to the task run
2287
+ * @param task the task to run
2288
+ * @param sys the {@link CompilerSystem} for interacting with the operating system
2289
+ * @public
2290
+ */
2266
2291
  const runTask = async (coreCompiler, config, task, sys) => {
2267
- var _a, _b;
2292
+ var _a, _b, _c;
2268
2293
  const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
2269
- const strictConfig = { ...config, flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }), logger };
2270
- strictConfig.outputTargets = strictConfig.outputTargets || [];
2294
+ const strictConfig = {
2295
+ ...config,
2296
+ flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
2297
+ logger,
2298
+ outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
2299
+ sys: sys !== null && sys !== void 0 ? sys : coreCompiler.createSystem({ logger }),
2300
+ };
2271
2301
  switch (task) {
2272
2302
  case 'build':
2273
- await taskBuild(coreCompiler, strictConfig, sys);
2303
+ await taskBuild(coreCompiler, strictConfig);
2274
2304
  break;
2275
2305
  case 'docs':
2276
2306
  await taskDocs(coreCompiler, strictConfig);
@@ -2289,10 +2319,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
2289
2319
  await taskServe(strictConfig);
2290
2320
  break;
2291
2321
  case 'telemetry':
2292
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
2293
- if (sys) {
2294
- await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2295
- }
2322
+ await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2296
2323
  break;
2297
2324
  case 'test':
2298
2325
  await taskTest(strictConfig);
package/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/cli",
3
- "version": "2.17.2-0",
3
+ "version": "2.17.2",
4
4
  "description": "Stencil CLI.",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/compiler",
3
- "version": "2.17.2-0",
3
+ "version": "2.17.2",
4
4
  "description": "Stencil Compiler.",
5
5
  "main": "./stencil.js",
6
6
  "types": "./stencil.d.ts",