@stencil/cli 5.0.0-beta.14 → 5.0.0-beta.15

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/README.md CHANGED
@@ -67,6 +67,6 @@ const flags = createConfigFlags({ task: 'build', dev: true });
67
67
  await runTask(coreCompiler, config, 'build', sys, flags);
68
68
  ```
69
69
 
70
- Valid `task` values: `'build'` | `'docs'` | `'generate'` | `'serve'` | `'prerender'` | `'info'` | `'migrate'` | `'init'` | `'add'` | `'telemetry'`
70
+ Valid `task` values: `'build'` | `'docs'` | `'generate'` | `'serve'` | `'prerender'` | `'info'` | `'migrate'` | `'init'` | `'add'`
71
71
 
72
72
  `flags` is optional - if omitted, defaults are derived from the task.
package/dist/index.d.mts CHANGED
@@ -4,13 +4,13 @@ import { ConfigCompat, LogLevel, OutputTarget } from "@stencil/core/compiler";
4
4
  /**
5
5
  * Supported CLI task commands
6
6
  */
7
- type TaskCommand = 'add' | 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'init' | 'migrate' | 'prerender' | 'serve' | 'telemetry' | 'version';
7
+ type TaskCommand = 'add' | 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'init' | 'migrate' | 'prerender' | 'serve' | 'version';
8
8
  //#endregion
9
9
  //#region src/config-flags.d.ts
10
10
  /**
11
11
  * All the Boolean options supported by the Stencil CLI
12
12
  */
13
- declare const BOOLEAN_CLI_FLAGS: readonly ["build", "cache", "ci", "debug", "dev", "docs", "dryRun", "help", "log", "open", "prerender", "profile", "serviceWorker", "serve", "ssr", "verbose", "version", "watch"];
13
+ declare const BOOLEAN_CLI_FLAGS: readonly ["cache", "ci", "debug", "dev", "docs", "dryRun", "help", "log", "open", "prerender", "profile", "serviceWorker", "serve", "ssr", "verbose", "version", "watch"];
14
14
  /**
15
15
  * All the Number options supported by the Stencil CLI
16
16
  */
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LOG_LEVELS } from "@stencil/core/compiler";
2
- import { buildError, catchError, hasError, isFunction, isOutputTargetDistLazy, isOutputTargetDocs, isOutputTargetSsr, isOutputTargetStandalone, isOutputTargetWww, isString, normalizePath, readOnlyArrayHasStringMember, result, shouldIgnoreError, toCamelCase, validateComponentTag } from "@stencil/core/compiler/utils";
2
+ import { buildError, catchError, hasError, isFunction, isOutputTargetDistLazy, isOutputTargetDocs, isOutputTargetStandalone, isOutputTargetWww, isString, normalizePath, readOnlyArrayHasStringMember, result, shouldIgnoreError, toCamelCase, validateComponentTag } from "@stencil/core/compiler/utils";
3
3
  import { basename, dirname, join, parse, relative, resolve } from "node:path";
4
4
  import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
5
5
  import * as p from "@clack/prompts";
@@ -20,7 +20,6 @@ import { start } from "@stencil/dev-server";
20
20
  * All the Boolean options supported by the Stencil CLI
21
21
  */
22
22
  const BOOLEAN_CLI_FLAGS = [
23
- "build",
24
23
  "cache",
25
24
  "ci",
26
25
  "debug",
@@ -769,7 +768,7 @@ async function openStencilConfig(configPath) {
769
768
  function toStringRecord(val) {
770
769
  return val !== null && typeof val === "object" ? val : {};
771
770
  }
772
- async function readJson$1(filePath) {
771
+ async function readJson(filePath) {
773
772
  try {
774
773
  return JSON.parse(await readFile(filePath, "utf8"));
775
774
  } catch {
@@ -809,7 +808,7 @@ async function loadOne(rootDir, packageName, loader) {
809
808
  * @returns Array of successfully loaded plugins, in dependency declaration order.
810
809
  */
811
810
  async function discoverPlugins(rootDir, loader = (url) => import(url)) {
812
- const pkg = await readJson$1(join(rootDir, "package.json"));
811
+ const pkg = await readJson(join(rootDir, "package.json"));
813
812
  if (!pkg) return [];
814
813
  const depNames = [.../* @__PURE__ */ new Set([...Object.keys(toStringRecord(pkg.dependencies)), ...Object.keys(toStringRecord(pkg.devDependencies))])];
815
814
  const plugins = (await Promise.allSettled(depNames.map((name) => loadOne(rootDir, name, loader)))).filter((r) => r.status === "fulfilled" && r.value !== null).map((r) => r.value);
@@ -830,7 +829,7 @@ async function discoverPlugins(rootDir, loader = (url) => import(url)) {
830
829
  async function findDevPackageName(wizardPath) {
831
830
  const dir = dirname(wizardPath);
832
831
  for (const candidate of [dir, resolve(dir, "..")]) {
833
- const pkg = await readJson$1(join(candidate, "package.json"));
832
+ const pkg = await readJson(join(candidate, "package.json"));
834
833
  if (typeof pkg?.name === "string") return pkg.name;
835
834
  }
836
835
  return basename(dir);
@@ -1210,7 +1209,7 @@ async function isExistingStencilProject(dir) {
1210
1209
  }
1211
1210
  //#endregion
1212
1211
  //#region src/wizard/splash.ts
1213
- const CLI_VERSION = "5.0.0-beta.14";
1212
+ const CLI_VERSION = "5.0.0-beta.15";
1214
1213
  const isTTY = process.stdout.isTTY;
1215
1214
  const noColor = !isTTY || "NO_COLOR" in process.env;
1216
1215
  const RESET = noColor ? "" : "\x1B[0m";
@@ -1344,10 +1343,10 @@ async function taskAdd(packages, strictConfig) {
1344
1343
  * @param config the Stencil configuration associated with the currently compiled project
1345
1344
  * @param currentVersion the Stencil compiler's version string
1346
1345
  * @param flags the CLI flags (owned by CLI, not part of core config)
1347
- * @returns a reference to `checkVersion`, or `null` if one does not exist on the current `CompilerSystem`
1346
+ * @returns a reference to `checkVersion`, or `null` if the check is skipped
1348
1347
  */
1349
1348
  const startCheckVersion = async (config, currentVersion, flags) => {
1350
- if (config.devMode && !flags.ci && !currentVersion.includes("-dev.") && isFunction(config.sys.checkVersion)) return config.sys.checkVersion(config.logger, currentVersion);
1349
+ if (config.devMode && !flags.ci && !currentVersion.includes("-dev.")) return config.sys.checkVersion(config.logger, currentVersion);
1351
1350
  return null;
1352
1351
  };
1353
1352
  /**
@@ -3143,7 +3142,6 @@ const taskWatch = async (coreCompiler, config, flags) => {
3143
3142
  const versionChecker = startCheckVersion(config, coreCompiler.version, flags);
3144
3143
  const compiler = await coreCompiler.createCompiler(config);
3145
3144
  const watcher = await compiler.createWatcher();
3146
- if (!config.sys.onProcessInterrupt) throw new Error(`Environment doesn't provide required function: onProcessInterrupt`);
3147
3145
  if (flags.serve) {
3148
3146
  const { start } = await import("@stencil/dev-server");
3149
3147
  devServer = await start(config.devServer, config.logger, watcher);
@@ -3173,473 +3171,6 @@ const taskWatch = async (coreCompiler, config, flags) => {
3173
3171
  if (exitCode > 0) return config.sys.exit(exitCode);
3174
3172
  };
3175
3173
  //#endregion
3176
- //#region src/telemetry/helpers.ts
3177
- const tryFn = async (fn, ...args) => {
3178
- try {
3179
- return await fn(...args);
3180
- } catch {}
3181
- return null;
3182
- };
3183
- const isInteractive = (sys, flags, object) => {
3184
- const terminalInfo = object || Object.freeze({
3185
- tty: sys.isTTY(),
3186
- ci: [
3187
- "CI",
3188
- "BUILD_ID",
3189
- "BUILD_NUMBER",
3190
- "BITBUCKET_COMMIT",
3191
- "CODEBUILD_BUILD_ARN"
3192
- ].filter((v) => !!sys.getEnvironmentVar?.(v)).length > 0 || !!flags.ci
3193
- });
3194
- return terminalInfo.tty && !terminalInfo.ci;
3195
- };
3196
- const UUID_REGEX = /* @__PURE__ */ new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i);
3197
- function uuidv4() {
3198
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
3199
- const r = Math.random() * 16 | 0;
3200
- return (c == "x" ? r : r & 3 | 8).toString(16);
3201
- });
3202
- }
3203
- /**
3204
- * Reads and parses a JSON file from the given `path`
3205
- * @param sys The system where the command is invoked
3206
- * @param path the path on the file system to read and parse
3207
- * @returns the parsed JSON
3208
- */
3209
- async function readJson(sys, path) {
3210
- const file = await sys.readFile(path);
3211
- return file ? JSON.parse(file) : null;
3212
- }
3213
- /**
3214
- * Does the command have the debug flag?
3215
- * @param flags The configuration flags passed into the Stencil command
3216
- * @returns true if --debug has been passed, otherwise false
3217
- */
3218
- function hasDebug(flags) {
3219
- return !!flags.debug;
3220
- }
3221
- /**
3222
- * Does the command have the verbose and debug flags?
3223
- * @param flags The configuration flags passed into the Stencil command
3224
- * @returns true if both --debug and --verbose have been passed, otherwise false
3225
- */
3226
- function hasVerbose(flags) {
3227
- return !!flags.verbose && hasDebug(flags);
3228
- }
3229
- //#endregion
3230
- //#region src/ionic-config.ts
3231
- const isTest = () => process.env.JEST_WORKER_ID !== void 0;
3232
- const defaultConfig = (sys) => sys.resolvePath(`${sys.homeDir()}/.ionic/${isTest() ? "tmp-config.json" : "config.json"}`);
3233
- const defaultConfigDirectory = (sys) => sys.resolvePath(`${sys.homeDir()}/.ionic`);
3234
- /**
3235
- * Reads an Ionic configuration file from disk, parses it, and performs any necessary corrections to it if certain
3236
- * values are deemed to be malformed
3237
- * @param sys The system where the command is invoked
3238
- * @returns the config read from disk that has been potentially been updated
3239
- */
3240
- async function readConfig(sys) {
3241
- let config = await readJson(sys, defaultConfig(sys));
3242
- if (!config) {
3243
- config = {
3244
- "tokens.telemetry": uuidv4(),
3245
- "telemetry.stencil": true
3246
- };
3247
- await writeConfig(sys, config);
3248
- } else if (!config["tokens.telemetry"] || !UUID_REGEX.test(config["tokens.telemetry"])) {
3249
- const newUuid = uuidv4();
3250
- await writeConfig(sys, {
3251
- ...config,
3252
- "tokens.telemetry": newUuid
3253
- });
3254
- config["tokens.telemetry"] = newUuid;
3255
- }
3256
- return config;
3257
- }
3258
- /**
3259
- * Writes an Ionic configuration file to disk.
3260
- * @param sys The system where the command is invoked
3261
- * @param config The config passed into the Stencil command
3262
- * @returns boolean If the command was successful
3263
- */
3264
- async function writeConfig(sys, config) {
3265
- let result = false;
3266
- try {
3267
- await sys.createDir(defaultConfigDirectory(sys), { recursive: true });
3268
- await sys.writeFile(defaultConfig(sys), JSON.stringify(config, null, 2));
3269
- result = true;
3270
- } catch (error) {
3271
- console.error(`Stencil Telemetry: couldn't write configuration file to ${defaultConfig(sys)} - ${error}.`);
3272
- }
3273
- return result;
3274
- }
3275
- /**
3276
- * Update a subset of the Ionic config.
3277
- * @param sys The system where the command is invoked
3278
- * @param newOptions The new options to save
3279
- * @returns boolean If the command was successful
3280
- */
3281
- async function updateConfig(sys, newOptions) {
3282
- const config = await readConfig(sys);
3283
- return await writeConfig(sys, Object.assign(config, newOptions));
3284
- }
3285
- //#endregion
3286
- //#region src/telemetry/shouldTrack.ts
3287
- /**
3288
- * Used to determine if tracking should occur.
3289
- * @param sys The system where the command is invoked
3290
- * @param flags The CLI flags (owned by CLI, not part of core config)
3291
- * @param ci whether or not the process is running in a Continuous Integration (CI) environment
3292
- * @returns true if telemetry should be sent, false otherwise
3293
- */
3294
- async function shouldTrack(sys, flags, ci) {
3295
- return !ci && isInteractive(sys, flags) && await checkTelemetry(sys);
3296
- }
3297
- //#endregion
3298
- //#region src/telemetry/telemetry.ts
3299
- /**
3300
- * Used to within taskBuild to provide the component_count property.
3301
- *
3302
- * @param sys The system where the command is invoked
3303
- * @param config The config passed into the Stencil command
3304
- * @param coreCompiler The compiler used to do builds
3305
- * @param result The results of a compiler build.
3306
- * @param flags The CLI flags (owned by CLI, not part of core config)
3307
- */
3308
- async function telemetryBuildFinishedAction(sys, config, coreCompiler, result, flags) {
3309
- if (!await shouldTrack(sys, flags, !!flags.ci)) return;
3310
- const component_count = result.componentGraph ? Object.keys(result.componentGraph).length : void 0;
3311
- const data = await prepareData(coreCompiler, config, sys, flags, result.duration, component_count);
3312
- await sendMetric(sys, flags, "stencil_cli_command", data);
3313
- config.logger.debug(`${config.logger.blue("Telemetry")}: ${config.logger.gray(JSON.stringify(data))}`);
3314
- }
3315
- /**
3316
- * A function to wrap a compiler task function around. Will send telemetry if, and only if, the machine allows.
3317
- *
3318
- * @param sys The system where the command is invoked
3319
- * @param config The config passed into the Stencil command
3320
- * @param coreCompiler The compiler used to do builds
3321
- * @param flags The CLI flags (owned by CLI, not part of core config)
3322
- * @param action A Promise-based function to call in order to get the duration of any given command.
3323
- * @returns void
3324
- */
3325
- async function telemetryAction(sys, config, coreCompiler, flags, action) {
3326
- const tracking = await shouldTrack(sys, flags, !!flags.ci);
3327
- let duration = void 0;
3328
- let error;
3329
- if (action) {
3330
- const start = /* @__PURE__ */ new Date();
3331
- try {
3332
- await action();
3333
- } catch (e) {
3334
- error = e;
3335
- }
3336
- duration = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
3337
- }
3338
- if (!tracking || flags.task == "build" && !flags.args.includes("--watch")) return;
3339
- const data = await prepareData(coreCompiler, config, sys, flags, duration);
3340
- await sendMetric(sys, flags, "stencil_cli_command", data);
3341
- config.logger.debug(`${config.logger.blue("Telemetry")}: ${config.logger.gray(JSON.stringify(data))}`);
3342
- if (error) throw error;
3343
- }
3344
- /**
3345
- * Helper function to determine if a Stencil configuration builds an application.
3346
- *
3347
- * This function is a rough approximation whether an application is generated as a part of a Stencil build, based on
3348
- * contents of the project's `stencil.config.ts` file.
3349
- *
3350
- * @param config the configuration used by the Stencil project
3351
- * @returns true if we believe the project generates an application, false otherwise
3352
- */
3353
- function hasAppTarget(config) {
3354
- return config.outputTargets.some((target) => isOutputTargetWww(target) && (!!target.serviceWorker || !!target.baseUrl && target.baseUrl !== "/"));
3355
- }
3356
- function isUsingYarn(sys) {
3357
- return sys.getEnvironmentVar?.("npm_execpath")?.includes("yarn") || false;
3358
- }
3359
- /**
3360
- * Build a list of the different types of output targets used in a Stencil configuration.
3361
- *
3362
- * Duplicate entries will not be returned from the list
3363
- *
3364
- * @param config the configuration used by the Stencil project
3365
- * @returns a unique list of output target types found in the Stencil configuration
3366
- */
3367
- function getActiveTargets(config) {
3368
- const result = config.outputTargets.map((t) => t.type);
3369
- return Array.from(new Set(result));
3370
- }
3371
- /**
3372
- * Prepare data for telemetry
3373
- *
3374
- * @param coreCompiler the core compiler
3375
- * @param config the current Stencil config
3376
- * @param sys the compiler system instance in use
3377
- * @param flags the CLI flags (owned by CLI, not part of core config)
3378
- * @param duration_ms the duration of the action being tracked
3379
- * @param component_count the number of components being built (optional)
3380
- * @returns a Promise wrapping data for the telemetry endpoint
3381
- */
3382
- const prepareData = async (coreCompiler, config, sys, flags, duration_ms, component_count = void 0) => {
3383
- const { typescript, rolldown } = coreCompiler.versions || {
3384
- typescript: "unknown",
3385
- rolldown: "unknown"
3386
- };
3387
- const { packages, packagesNoVersions } = await getInstalledPackages(sys, flags);
3388
- const targets = getActiveTargets(config);
3389
- const yarn = isUsingYarn(sys);
3390
- const stencil = coreCompiler.version || "unknown";
3391
- const system = `${sys.name} ${sys.version}`;
3392
- const os_name = sys.details?.platform;
3393
- const os_version = sys.details?.release;
3394
- const cpu_model = sys.details?.cpuModel;
3395
- const build = coreCompiler.buildId || "unknown";
3396
- const has_app_pwa_config = hasAppTarget(config);
3397
- const anonymizedConfig = anonymizeConfigForTelemetry(config);
3398
- return {
3399
- arguments: flags.args,
3400
- build,
3401
- component_count,
3402
- config: anonymizedConfig,
3403
- cpu_model,
3404
- duration_ms,
3405
- has_app_pwa_config,
3406
- os_name,
3407
- os_version,
3408
- packages,
3409
- packages_no_versions: packagesNoVersions,
3410
- rolldown,
3411
- stencil,
3412
- system,
3413
- system_major: getMajorVersion(system),
3414
- targets,
3415
- task: flags.task,
3416
- typescript,
3417
- yarn
3418
- };
3419
- };
3420
- const OUTPUT_TARGET_KEYS_TO_KEEP = ["type"];
3421
- const CONFIG_PROPS_TO_ANONYMIZE = [
3422
- "rootDir",
3423
- "fsNamespace",
3424
- "packageJsonFilePath",
3425
- "namespace",
3426
- "srcDir",
3427
- "srcIndexHtml",
3428
- "buildLogFilePath",
3429
- "cacheDir",
3430
- "configPath",
3431
- "tsconfig"
3432
- ];
3433
- const CONFIG_PROPS_TO_DELETE = [
3434
- "devServer",
3435
- "env",
3436
- "logger",
3437
- "rolldownConfig",
3438
- "sys",
3439
- "tsCompilerOptions"
3440
- ];
3441
- /**
3442
- * Anonymize the config for telemetry, replacing potentially revealing config props
3443
- * with a placeholder string if they are present (this lets us still track how frequently
3444
- * these config options are being used)
3445
- *
3446
- * @param config the config to anonymize
3447
- * @returns an anonymized copy of the same config
3448
- */
3449
- const anonymizeConfigForTelemetry = (config) => {
3450
- const anonymizedConfig = { ...config };
3451
- for (const prop of CONFIG_PROPS_TO_ANONYMIZE) if (anonymizedConfig[prop] !== void 0) anonymizedConfig[prop] = "omitted";
3452
- anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
3453
- const anonymizedOT = JSON.parse(JSON.stringify(target, (key, value) => {
3454
- if (!(typeof value === "string")) return value;
3455
- if (OUTPUT_TARGET_KEYS_TO_KEEP.includes(key)) return value;
3456
- return "omitted";
3457
- }));
3458
- if (isOutputTargetSsr(target) && target.external) anonymizedOT["external"] = target.external.concat();
3459
- return anonymizedOT;
3460
- });
3461
- for (const prop of CONFIG_PROPS_TO_DELETE) delete anonymizedConfig[prop];
3462
- return anonymizedConfig;
3463
- };
3464
- /**
3465
- * Reads package-lock.json, yarn.lock, and package.json files in order to cross-reference
3466
- * the dependencies and devDependencies properties. Pulls up the current installed version
3467
- * of each package under the @stencil, @ionic, and @capacitor scopes.
3468
- *
3469
- * @param sys the system instance where telemetry is invoked
3470
- * @param flags the CLI flags (owned by CLI, not part of core config)
3471
- * @returns an object listing all dev and production dependencies under the aforementioned scopes
3472
- */
3473
- async function getInstalledPackages(sys, flags) {
3474
- let packages = [];
3475
- let packagesNoVersions = [];
3476
- const yarn = isUsingYarn(sys);
3477
- try {
3478
- const appRootDir = sys.getCurrentDirectory();
3479
- const packageJson = await tryFn(readJson, sys, sys.resolvePath(appRootDir + "/package.json"));
3480
- if (!packageJson) return {
3481
- packages,
3482
- packagesNoVersions
3483
- };
3484
- const ionicPackages = Object.entries({
3485
- ...packageJson.devDependencies,
3486
- ...packageJson.dependencies
3487
- }).filter(([k]) => k.startsWith("@stencil/") || k.startsWith("@ionic/") || k.startsWith("@capacitor/"));
3488
- try {
3489
- packages = yarn ? await yarnPackages(sys, ionicPackages) : await npmPackages(sys, ionicPackages);
3490
- } catch {
3491
- packages = ionicPackages.map(([k, v]) => `${k}@${v.replace("^", "")}`);
3492
- }
3493
- packagesNoVersions = ionicPackages.map(([k]) => `${k}`);
3494
- return {
3495
- packages,
3496
- packagesNoVersions
3497
- };
3498
- } catch (err) {
3499
- if (hasDebug(flags)) console.error(err);
3500
- return {
3501
- packages,
3502
- packagesNoVersions
3503
- };
3504
- }
3505
- }
3506
- /**
3507
- * Visits the npm lock file to find the exact versions that are installed
3508
- * @param sys The system where the command is invoked
3509
- * @param ionicPackages a list of the found packages matching `@stencil`, `@capacitor`, or `@ionic` from the package.json file.
3510
- * @returns an array of strings of all the packages and their versions.
3511
- */
3512
- async function npmPackages(sys, ionicPackages) {
3513
- const appRootDir = sys.getCurrentDirectory();
3514
- const packageLockJson = await tryFn(readJson, sys, sys.resolvePath(appRootDir + "/package-lock.json"));
3515
- return ionicPackages.map(([k, v]) => {
3516
- let version = packageLockJson?.dependencies[k]?.version ?? packageLockJson?.devDependencies[k]?.version ?? v;
3517
- version = version.includes("file:") ? sanitizeDeclaredVersion(v) : version;
3518
- return `${k}@${version}`;
3519
- });
3520
- }
3521
- /**
3522
- * Visits the yarn lock file to find the exact versions that are installed
3523
- * @param sys The system where the command is invoked
3524
- * @param ionicPackages a list of the found packages matching `@stencil`, `@capacitor`, or `@ionic` from the package.json file.
3525
- * @returns an array of strings of all the packages and their versions.
3526
- */
3527
- async function yarnPackages(sys, ionicPackages) {
3528
- const appRootDir = sys.getCurrentDirectory();
3529
- const yarnLock = sys.readFileSync(sys.resolvePath(appRootDir + "/yarn.lock"));
3530
- const yarnLockYml = sys.parseYarnLockFile?.(yarnLock);
3531
- return ionicPackages.map(([k, v]) => {
3532
- const identifiedVersion = `${k}@${v}`;
3533
- let version = yarnLockYml?.object[identifiedVersion]?.version;
3534
- version = version && version.includes("undefined") ? sanitizeDeclaredVersion(identifiedVersion) : version;
3535
- return `${k}@${version}`;
3536
- });
3537
- }
3538
- /**
3539
- * This function is used for fallback purposes, where an npm or yarn lock file doesn't exist in the consumers directory.
3540
- * This will strip away '*', '^' and '~' from the declared package versions in a package.json.
3541
- * @param version the raw semver pattern identifier version string
3542
- * @returns a cleaned up representation without any qualifiers
3543
- */
3544
- function sanitizeDeclaredVersion(version) {
3545
- return version.replace(/[*^~]/g, "");
3546
- }
3547
- /**
3548
- * If telemetry is enabled, send a metric to an external data store
3549
- *
3550
- * @param sys the system instance where telemetry is invoked
3551
- * @param flags the CLI flags (owned by CLI, not part of core config)
3552
- * @param name the name of a trackable metric. Note this name is not necessarily a scalar value to track, like
3553
- * "Stencil Version". For example, "stencil_cli_command" is a name that is used to track all CLI command information.
3554
- * @param value the data to send to the external data store under the provided name argument
3555
- */
3556
- async function sendMetric(sys, flags, name, value) {
3557
- const session_id = await getTelemetryToken(sys);
3558
- await sendTelemetry(sys, flags, {
3559
- name,
3560
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3561
- source: "stencil_cli",
3562
- value,
3563
- session_id
3564
- });
3565
- }
3566
- /**
3567
- * Used to read the config file's tokens.telemetry property.
3568
- *
3569
- * @param sys The system where the command is invoked
3570
- * @returns string
3571
- */
3572
- async function getTelemetryToken(sys) {
3573
- const config = await readConfig(sys);
3574
- if (config["tokens.telemetry"] === void 0) {
3575
- config["tokens.telemetry"] = uuidv4();
3576
- await writeConfig(sys, config);
3577
- }
3578
- return config["tokens.telemetry"];
3579
- }
3580
- /**
3581
- * Issues a request to the telemetry server.
3582
- * @param sys The system where the command is invoked
3583
- * @param flags The CLI flags (owned by CLI, not part of core config)
3584
- * @param data Data to be tracked
3585
- */
3586
- async function sendTelemetry(sys, flags, data) {
3587
- try {
3588
- const now = (/* @__PURE__ */ new Date()).toISOString();
3589
- const body = {
3590
- metrics: [data],
3591
- sent_at: now
3592
- };
3593
- if (!sys.fetch) throw new Error("No fetch implementation available");
3594
- const response = await sys.fetch("https://api.ionicjs.com/events/metrics", {
3595
- method: "POST",
3596
- headers: { "Content-Type": "application/json" },
3597
- body: JSON.stringify(body)
3598
- });
3599
- if (hasVerbose(flags)) console.debug("\nSent %O metric to events service (status: %O)", data.name, response.status, "\n");
3600
- if (response.status !== 204 && hasVerbose(flags)) console.debug("\nBad response from events service. Request body: %O", response.body.toString(), "\n");
3601
- } catch (e) {
3602
- if (hasVerbose(flags)) console.debug("Telemetry request failed:", e);
3603
- }
3604
- }
3605
- /**
3606
- * Checks if telemetry is enabled on this machine
3607
- * @param sys The system where the command is invoked
3608
- * @returns true if telemetry is enabled, false otherwise
3609
- */
3610
- async function checkTelemetry(sys) {
3611
- const config = await readConfig(sys);
3612
- if (config["telemetry.stencil"] === void 0) {
3613
- config["telemetry.stencil"] = true;
3614
- await writeConfig(sys, config);
3615
- }
3616
- return config["telemetry.stencil"];
3617
- }
3618
- /**
3619
- * Writes to the config file, enabling telemetry for this machine.
3620
- * @param sys The system where the command is invoked
3621
- * @returns true if writing the file was successful, false otherwise
3622
- */
3623
- async function enableTelemetry(sys) {
3624
- return await updateConfig(sys, { "telemetry.stencil": true });
3625
- }
3626
- /**
3627
- * Writes to the config file, disabling telemetry for this machine.
3628
- * @param sys The system where the command is invoked
3629
- * @returns true if writing the file was successful, false otherwise
3630
- */
3631
- async function disableTelemetry(sys) {
3632
- return await updateConfig(sys, { "telemetry.stencil": false });
3633
- }
3634
- /**
3635
- * Takes in a semver string in order to return the major version.
3636
- * @param version The fully qualified semver version
3637
- * @returns a string of the major version
3638
- */
3639
- function getMajorVersion(version) {
3640
- return version.split(".")[0];
3641
- }
3642
- //#endregion
3643
3174
  //#region src/task-build.ts
3644
3175
  const taskBuild = async (coreCompiler, config, flags) => {
3645
3176
  if (flags.watch) {
@@ -3669,7 +3200,6 @@ const taskBuild = async (coreCompiler, config, flags) => {
3669
3200
  const versionChecker = startCheckVersion(config, coreCompiler.version, flags);
3670
3201
  const compiler = await coreCompiler.createCompiler(config);
3671
3202
  const results = await compiler.build();
3672
- await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results, flags);
3673
3203
  await compiler.destroy();
3674
3204
  if (results.hasError) {
3675
3205
  const migrationResult = await detectMigrations(coreCompiler, config);
@@ -3972,50 +3502,13 @@ const taskGenerate = async (config, flags) => {
3972
3502
  p.outro(`stencil generate ${input}`);
3973
3503
  };
3974
3504
  //#endregion
3975
- //#region src/task-telemetry.ts
3976
- /**
3977
- * Entrypoint for the Telemetry task
3978
- * @param flags configuration flags provided to Stencil when a task was called (either this task or a task that invokes
3979
- * telemetry)
3980
- * @param sys the abstraction for interfacing with the operating system
3981
- * @param logger a logging implementation to log the results out to the user
3982
- */
3983
- const taskTelemetry = async (flags, sys, logger) => {
3984
- const prompt = logger.dim(sys.details?.platform === "windows" ? ">" : "$");
3985
- const isEnabling = flags.args.includes("on");
3986
- const isDisabling = flags.args.includes("off");
3987
- const INFORMATION = `Opt in or out of telemetry. Information about the data we collect is available on our website: ${logger.bold("https://stenciljs.com/telemetry")}`;
3988
- const ENABLED_MESSAGE = `${logger.green("Enabled")}. Thank you for helping to make Stencil better! 💖\n\n`;
3989
- const DISABLED_MESSAGE = `${logger.red("Disabled")}\n\n`;
3990
- const hasTelemetry = await checkTelemetry(sys);
3991
- if (isEnabling) {
3992
- if (await enableTelemetry(sys)) console.log(`\n ${logger.bold("Telemetry is now ") + ENABLED_MESSAGE}`);
3993
- else console.log(`Something went wrong when enabling Telemetry.`);
3994
- return;
3995
- }
3996
- if (isDisabling) {
3997
- if (await disableTelemetry(sys)) console.log(`\n ${logger.bold("Telemetry is now ") + DISABLED_MESSAGE}`);
3998
- else console.log(`Something went wrong when disabling Telemetry.`);
3999
- return;
4000
- }
4001
- console.log(` ${logger.bold("Telemetry:")} ${logger.dim(INFORMATION)}`);
4002
- console.log(`\n ${logger.bold("Status")}: ${hasTelemetry ? ENABLED_MESSAGE : DISABLED_MESSAGE}`);
4003
- console.log(` ${prompt} ${logger.green("stencil telemetry [off|on]")}
4004
-
4005
- ${logger.cyan("off")} ${logger.dim(".............")} Disable sharing anonymous usage data
4006
- ${logger.cyan("on")} ${logger.dim("..............")} Enable sharing anonymous usage data
4007
- `);
4008
- };
4009
- //#endregion
4010
3505
  //#region src/task-help.ts
4011
3506
  /**
4012
3507
  * Entrypoint for the Help task, providing Stencil usage context to the user
4013
- * @param flags configuration flags provided to Stencil when a task was call (either this task or a task that invokes
4014
- * telemetry)
4015
3508
  * @param logger a logging implementation to log the results out to the user
4016
3509
  * @param sys the abstraction for interfacing with the operating system
4017
3510
  */
4018
- const taskHelp = async (flags, logger, sys) => {
3511
+ const taskHelp = async (logger, sys) => {
4019
3512
  const prompt = logger.dim(sys.details?.platform === "windows" ? ">" : "$");
4020
3513
  console.log(`
4021
3514
  ${logger.bold("Init:")} ${logger.dim("Scaffold a new project, or add capabilities to an existing one.")}
@@ -4089,7 +3582,6 @@ const taskHelp = async (flags, logger, sys) => {
4089
3582
  ${prompt} ${logger.green("stencil version")} or ${logger.green("stencil --version")}
4090
3583
 
4091
3584
  `);
4092
- await taskTelemetry(flags, sys, logger);
4093
3585
  console.log(`
4094
3586
  ${logger.bold("Examples:")}
4095
3587
 
@@ -4099,7 +3591,6 @@ const taskHelp = async (flags, logger, sys) => {
4099
3591
  ${prompt} ${logger.green("stencil build --prerender")}
4100
3592
  ${prompt} ${logger.green("stencil serve --root www")}
4101
3593
  ${prompt} ${logger.green("stencil migrate --dry-run")}
4102
- ${prompt} ${logger.green("stencil telemetry on")}
4103
3594
  `);
4104
3595
  };
4105
3596
  //#endregion
@@ -4546,7 +4037,6 @@ const taskServe = async (config, flags) => {
4546
4037
  config.devServer.websocket = false;
4547
4038
  config.maxConcurrentWorkers = 1;
4548
4039
  config.devServer.root = isString(flags.root) ? flags.root : config.sys.getCurrentDirectory();
4549
- if (!config.sys.onProcessInterrupt) throw new Error(`Environment doesn't provide required function: onProcessInterrupt`);
4550
4040
  const devServer = await start(config.devServer, config.logger);
4551
4041
  console.log(`${config.logger.cyan(" Root:")} ${devServer.root}`);
4552
4042
  console.log(`${config.logger.cyan(" Address:")} ${devServer.address}`);
@@ -4579,17 +4069,13 @@ const run = async (init) => {
4579
4069
  const task = flags.task;
4580
4070
  if (flags.debug || flags.verbose) logger.setLevel("debug");
4581
4071
  if (flags.ci) logger.enableColors(false);
4582
- if (isFunction(sys.applyGlobalPatch)) sys.applyGlobalPatch(sys.getCurrentDirectory());
4583
4072
  if (task && task === "version" || flags.version) {
4584
4073
  const coreCompiler = await loadCoreCompiler(sys);
4585
4074
  console.log(coreCompiler.version);
4586
4075
  return;
4587
4076
  }
4588
4077
  if (!task || task === "help" || flags.help) {
4589
- await taskHelp(createConfigFlags({
4590
- task: "help",
4591
- args
4592
- }), logger, sys);
4078
+ await taskHelp(logger, sys);
4593
4079
  return;
4594
4080
  }
4595
4081
  if (task === "test") {
@@ -4659,10 +4145,7 @@ const run = async (init) => {
4659
4145
  logger.printDiagnostics(validated.diagnostics);
4660
4146
  if (hasError(validated.diagnostics)) return sys.exit(1);
4661
4147
  }
4662
- if (isFunction(sys.applyGlobalPatch)) sys.applyGlobalPatch(validated.config.rootDir);
4663
- await telemetryAction(sys, validated.config, coreCompiler, flags, async () => {
4664
- await runTask(coreCompiler, validated.config, task, sys, flags);
4665
- });
4148
+ await runTask(coreCompiler, validated.config, task, sys, flags);
4666
4149
  } catch (e) {
4667
4150
  if (!shouldIgnoreError(e)) {
4668
4151
  const details = `${logger.getLevel() === "debug" && e instanceof Error ? e.stack : ""}`;
@@ -4702,7 +4185,7 @@ const runTask = async (coreCompiler, config, task, sys, flags) => {
4702
4185
  await taskGenerate(strictConfig, resolvedFlags);
4703
4186
  break;
4704
4187
  case "help":
4705
- await taskHelp(resolvedFlags, strictConfig.logger, sys);
4188
+ await taskHelp(strictConfig.logger, sys);
4706
4189
  break;
4707
4190
  case "init":
4708
4191
  await taskInit(coreCompiler, strictConfig);
@@ -4716,15 +4199,12 @@ const runTask = async (coreCompiler, config, task, sys, flags) => {
4716
4199
  case "serve":
4717
4200
  await taskServe(strictConfig, resolvedFlags);
4718
4201
  break;
4719
- case "telemetry":
4720
- await taskTelemetry(resolvedFlags, sys, strictConfig.logger);
4721
- break;
4722
4202
  case "version":
4723
4203
  console.log(coreCompiler.version);
4724
4204
  break;
4725
4205
  default:
4726
4206
  strictConfig.logger.error(`${strictConfig.logger.emoji("❌ ")}Invalid stencil command, please see the options below:`);
4727
- await taskHelp(resolvedFlags, strictConfig.logger, sys);
4207
+ await taskHelp(strictConfig.logger, sys);
4728
4208
  return configWithFlags.sys.exit(1);
4729
4209
  }
4730
4210
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/cli",
3
- "version": "5.0.0-beta.14",
3
+ "version": "5.0.0-beta.15",
4
4
  "description": "CLI for Stencil - Web component compiler",
5
5
  "keywords": [
6
6
  "components",
@@ -42,16 +42,16 @@
42
42
  "nypm": "^0.3.12",
43
43
  "std-env": "^3.10.0",
44
44
  "typescript": ">5.0.0 <7.0.0",
45
- "@stencil/dev-server": "5.0.0-beta.14",
46
- "@stencil/templates": "5.0.0-beta.14"
45
+ "@stencil/templates": "5.0.0-beta.15",
46
+ "@stencil/dev-server": "5.0.0-beta.15"
47
47
  },
48
48
  "devDependencies": {
49
49
  "tsdown": "^0.22.14",
50
50
  "vitest": "^4.1.10",
51
- "@stencil/core": "5.0.0-beta.14"
51
+ "@stencil/core": "5.0.0-beta.15"
52
52
  },
53
53
  "peerDependencies": {
54
- "@stencil/core": "^5.0.0 || 5.0.0-beta.14"
54
+ "@stencil/core": "^5.0.0 || 5.0.0-beta.15"
55
55
  },
56
56
  "volta": {
57
57
  "extends": "../../package.json"