@stencil/core 2.8.1 → 2.11.0-0
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 +239 -209
- package/cli/index.js +239 -209
- package/cli/package.json +1 -1
- package/compiler/lib.dom.d.ts +263 -648
- package/compiler/lib.dom.iterable.d.ts +1 -5
- package/compiler/lib.es2015.core.d.ts +2 -2
- package/compiler/lib.es2015.iterable.d.ts +1 -1
- package/compiler/lib.es2015.symbol.wellknown.d.ts +10 -10
- package/compiler/lib.es2018.asynciterable.d.ts +1 -1
- package/compiler/lib.es2020.bigint.d.ts +1 -1
- package/compiler/lib.es2020.intl.d.ts +6 -7
- package/compiler/lib.es2020.symbol.wellknown.d.ts +1 -1
- package/compiler/lib.es2021.d.ts +24 -0
- package/compiler/lib.es2021.full.d.ts +25 -0
- package/compiler/lib.es2021.promise.d.ts +43 -0
- package/compiler/lib.es2021.string.d.ts +35 -0
- package/compiler/lib.es2021.weakref.d.ts +75 -0
- package/compiler/lib.es5.d.ts +9 -9
- package/compiler/lib.esnext.d.ts +1 -4
- package/compiler/lib.esnext.promise.d.ts +26 -26
- package/compiler/lib.esnext.string.d.ts +18 -18
- package/compiler/lib.esnext.weakref.d.ts +58 -58
- package/compiler/lib.webworker.d.ts +98 -153
- package/compiler/lib.webworker.iterable.d.ts +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +1244 -456
- package/compiler/stencil.min.js +2 -2
- package/dependencies.json +6 -1
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +119 -102
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/shadow-css.js +9 -10
- package/internal/hydrate/index.js +44 -40
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/shadow-css.js +59 -62
- package/internal/index.js +1 -0
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +125 -5
- package/internal/stencil-public-compiler.d.ts +15 -2
- package/internal/testing/index.js +54 -47
- package/internal/testing/package.json +1 -1
- package/internal/testing/shadow-css.js +54 -57
- package/mock-doc/index.cjs +4 -1
- package/mock-doc/index.d.ts +7 -6
- package/mock-doc/index.js +4 -1
- package/mock-doc/package.json +1 -1
- package/package.json +16 -6
- package/readme.md +2 -2
- package/screenshot/index.js +1 -1
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +4435 -425
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +23 -18
- package/testing/mocks.d.ts +1 -5
- package/testing/package.json +1 -1
- package/testing/testing-sys.d.ts +6 -1
- package/bin/cli.ts +0 -20
- package/screenshot/index.js.map +0 -1
- package/sys/deno/index.js +0 -1791
- package/sys/deno/node-compat.js +0 -2654
- package/sys/deno/worker.js +0 -44
package/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI v2.
|
|
2
|
+
Stencil CLI v2.11.0-0 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
const toLowerCase = (str) => str.toLowerCase();
|
|
5
5
|
const dashToPascalCase = (str) => toLowerCase(str)
|
|
@@ -206,6 +206,11 @@ const pathComponents = (path, rootLength) => {
|
|
|
206
206
|
return [root, ...rest];
|
|
207
207
|
};
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Validates that a component tag meets required naming conventions to be used for a web component
|
|
211
|
+
* @param tag the tag to validate
|
|
212
|
+
* @returns an error message if the tag has an invalid name, undefined if the tag name passes all checks
|
|
213
|
+
*/
|
|
209
214
|
const validateComponentTag = (tag) => {
|
|
210
215
|
if (tag !== tag.trim()) {
|
|
211
216
|
return `Tag can not contain white spaces`;
|
|
@@ -461,7 +466,7 @@ const getNpmConfigEnvArgs = (sys) => {
|
|
|
461
466
|
const dependencies = [
|
|
462
467
|
{
|
|
463
468
|
name: "@stencil/core",
|
|
464
|
-
version: "2.
|
|
469
|
+
version: "2.11.0-0",
|
|
465
470
|
main: "compiler/stencil.js",
|
|
466
471
|
resources: [
|
|
467
472
|
"package.json",
|
|
@@ -509,6 +514,11 @@ const dependencies = [
|
|
|
509
514
|
"compiler/lib.es2020.sharedmemory.d.ts",
|
|
510
515
|
"compiler/lib.es2020.string.d.ts",
|
|
511
516
|
"compiler/lib.es2020.symbol.wellknown.d.ts",
|
|
517
|
+
"compiler/lib.es2021.d.ts",
|
|
518
|
+
"compiler/lib.es2021.full.d.ts",
|
|
519
|
+
"compiler/lib.es2021.promise.d.ts",
|
|
520
|
+
"compiler/lib.es2021.string.d.ts",
|
|
521
|
+
"compiler/lib.es2021.weakref.d.ts",
|
|
512
522
|
"compiler/lib.es5.d.ts",
|
|
513
523
|
"compiler/lib.es6.d.ts",
|
|
514
524
|
"compiler/lib.esnext.d.ts",
|
|
@@ -558,7 +568,7 @@ const dependencies = [
|
|
|
558
568
|
},
|
|
559
569
|
{
|
|
560
570
|
name: "typescript",
|
|
561
|
-
version: "4.
|
|
571
|
+
version: "4.3.5",
|
|
562
572
|
main: "lib/typescript.js"
|
|
563
573
|
}
|
|
564
574
|
];
|
|
@@ -771,82 +781,6 @@ const taskWatch = async (coreCompiler, config) => {
|
|
|
771
781
|
}
|
|
772
782
|
};
|
|
773
783
|
|
|
774
|
-
class StencilCLIConfig {
|
|
775
|
-
constructor(options) {
|
|
776
|
-
this._args = (options === null || options === void 0 ? void 0 : options.args) || [];
|
|
777
|
-
this._logger = options === null || options === void 0 ? void 0 : options.logger;
|
|
778
|
-
this._sys = options === null || options === void 0 ? void 0 : options.sys;
|
|
779
|
-
this._flags = (options === null || options === void 0 ? void 0 : options.flags) || undefined;
|
|
780
|
-
this._validatedConfig = (options === null || options === void 0 ? void 0 : options.validatedConfig) || undefined;
|
|
781
|
-
}
|
|
782
|
-
static getInstance(options) {
|
|
783
|
-
if (!StencilCLIConfig.instance) {
|
|
784
|
-
StencilCLIConfig.instance = new StencilCLIConfig(options);
|
|
785
|
-
}
|
|
786
|
-
return StencilCLIConfig.instance;
|
|
787
|
-
}
|
|
788
|
-
resetInstance() {
|
|
789
|
-
delete StencilCLIConfig.instance;
|
|
790
|
-
}
|
|
791
|
-
get logger() {
|
|
792
|
-
return this._logger;
|
|
793
|
-
}
|
|
794
|
-
set logger(logger) {
|
|
795
|
-
this._logger = logger;
|
|
796
|
-
}
|
|
797
|
-
get sys() {
|
|
798
|
-
return this._sys;
|
|
799
|
-
}
|
|
800
|
-
set sys(sys) {
|
|
801
|
-
this._sys = sys;
|
|
802
|
-
}
|
|
803
|
-
get args() {
|
|
804
|
-
return this._args;
|
|
805
|
-
}
|
|
806
|
-
set args(args) {
|
|
807
|
-
this._args = args;
|
|
808
|
-
}
|
|
809
|
-
get task() {
|
|
810
|
-
return this._task;
|
|
811
|
-
}
|
|
812
|
-
set task(task) {
|
|
813
|
-
this._task = task;
|
|
814
|
-
}
|
|
815
|
-
get flags() {
|
|
816
|
-
return this._flags;
|
|
817
|
-
}
|
|
818
|
-
set flags(flags) {
|
|
819
|
-
this._flags = flags;
|
|
820
|
-
}
|
|
821
|
-
get coreCompiler() {
|
|
822
|
-
return this._coreCompiler;
|
|
823
|
-
}
|
|
824
|
-
set coreCompiler(coreCompiler) {
|
|
825
|
-
this._coreCompiler = coreCompiler;
|
|
826
|
-
}
|
|
827
|
-
get validatedConfig() {
|
|
828
|
-
return this._validatedConfig;
|
|
829
|
-
}
|
|
830
|
-
set validatedConfig(validatedConfig) {
|
|
831
|
-
this._validatedConfig = validatedConfig;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
function initializeStencilCLIConfig(options) {
|
|
835
|
-
return StencilCLIConfig.getInstance(options);
|
|
836
|
-
}
|
|
837
|
-
function getStencilCLIConfig() {
|
|
838
|
-
return StencilCLIConfig.getInstance();
|
|
839
|
-
}
|
|
840
|
-
function getCompilerSystem() {
|
|
841
|
-
return getStencilCLIConfig().sys;
|
|
842
|
-
}
|
|
843
|
-
function getLogger() {
|
|
844
|
-
return getStencilCLIConfig().logger;
|
|
845
|
-
}
|
|
846
|
-
function getCoreCompiler() {
|
|
847
|
-
return getStencilCLIConfig().coreCompiler;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
784
|
const tryFn = async (fn, ...args) => {
|
|
851
785
|
try {
|
|
852
786
|
return await fn(...args);
|
|
@@ -856,12 +790,12 @@ const tryFn = async (fn, ...args) => {
|
|
|
856
790
|
}
|
|
857
791
|
return null;
|
|
858
792
|
};
|
|
859
|
-
const isInteractive = (object) => {
|
|
860
|
-
var _a
|
|
793
|
+
const isInteractive = (sys, config, object) => {
|
|
794
|
+
var _a;
|
|
861
795
|
const terminalInfo = object ||
|
|
862
796
|
Object.freeze({
|
|
863
|
-
tty:
|
|
864
|
-
ci: ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN'].filter((v) => !!
|
|
797
|
+
tty: sys.isTTY() ? true : false,
|
|
798
|
+
ci: ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN'].filter((v) => !!sys.getEnvironmentVar(v)).length > 0 || !!((_a = config.flags) === null || _a === void 0 ? void 0 : _a.ci),
|
|
865
799
|
});
|
|
866
800
|
return terminalInfo.tty && !terminalInfo.ci;
|
|
867
801
|
};
|
|
@@ -876,93 +810,134 @@ function uuidv4() {
|
|
|
876
810
|
}
|
|
877
811
|
/**
|
|
878
812
|
* Reads and parses a JSON file from the given `path`
|
|
813
|
+
* @param sys The system where the command is invoked
|
|
879
814
|
* @param path the path on the file system to read and parse
|
|
880
815
|
* @returns the parsed JSON
|
|
881
816
|
*/
|
|
882
|
-
async function readJson(path) {
|
|
883
|
-
const file = await
|
|
817
|
+
async function readJson(sys, path) {
|
|
818
|
+
const file = await sys.readFile(path);
|
|
884
819
|
return !!file && JSON.parse(file);
|
|
885
820
|
}
|
|
886
|
-
|
|
887
|
-
|
|
821
|
+
/**
|
|
822
|
+
* Does the command have the debug flag?
|
|
823
|
+
* @param config The config passed into the Stencil command
|
|
824
|
+
* @returns true if --debug has been passed, otherwise false
|
|
825
|
+
*/
|
|
826
|
+
function hasDebug(config) {
|
|
827
|
+
return config.flags.debug;
|
|
888
828
|
}
|
|
889
|
-
|
|
890
|
-
|
|
829
|
+
/**
|
|
830
|
+
* Does the command have the verbose and debug flags?
|
|
831
|
+
* @param config The config passed into the Stencil command
|
|
832
|
+
* @returns true if both --debug and --verbose have been passed, otherwise false
|
|
833
|
+
*/
|
|
834
|
+
function hasVerbose(config) {
|
|
835
|
+
return config.flags.verbose && hasDebug(config);
|
|
891
836
|
}
|
|
892
837
|
|
|
893
838
|
/**
|
|
894
839
|
* Used to determine if tracking should occur.
|
|
840
|
+
* @param config The config passed into the Stencil command
|
|
841
|
+
* @param sys The system where the command is invoked
|
|
895
842
|
* @param ci whether or not the process is running in a Continuous Integration (CI) environment
|
|
896
843
|
* @returns true if telemetry should be sent, false otherwise
|
|
897
844
|
*/
|
|
898
|
-
async function shouldTrack(ci) {
|
|
899
|
-
return !ci && isInteractive() && (await checkTelemetry());
|
|
845
|
+
async function shouldTrack(config, sys, ci) {
|
|
846
|
+
return !ci && isInteractive(sys, config) && (await checkTelemetry(sys));
|
|
900
847
|
}
|
|
901
848
|
|
|
902
849
|
const isTest$1 = () => process.env.JEST_WORKER_ID !== undefined;
|
|
903
|
-
const defaultConfig = () =>
|
|
904
|
-
const defaultConfigDirectory = () =>
|
|
850
|
+
const defaultConfig = (sys) => sys.resolvePath(`${sys.homeDir()}/.ionic/${isTest$1() ? 'tmp-config.json' : 'config.json'}`);
|
|
851
|
+
const defaultConfigDirectory = (sys) => sys.resolvePath(`${sys.homeDir()}/.ionic`);
|
|
905
852
|
/**
|
|
906
|
-
* Reads an Ionic configuration file from disk, parses it, and performs any necessary corrections to it if
|
|
853
|
+
* Reads an Ionic configuration file from disk, parses it, and performs any necessary corrections to it if certain
|
|
907
854
|
* values are deemed to be malformed
|
|
855
|
+
* @param sys The system where the command is invoked
|
|
908
856
|
* @returns the config read from disk that has been potentially been updated
|
|
909
857
|
*/
|
|
910
|
-
async function readConfig() {
|
|
911
|
-
let config = await readJson(defaultConfig());
|
|
858
|
+
async function readConfig(sys) {
|
|
859
|
+
let config = await readJson(sys, defaultConfig(sys));
|
|
912
860
|
if (!config) {
|
|
913
861
|
config = {
|
|
914
862
|
'tokens.telemetry': uuidv4(),
|
|
915
863
|
'telemetry.stencil': true,
|
|
916
864
|
};
|
|
917
|
-
await writeConfig(config);
|
|
865
|
+
await writeConfig(sys, config);
|
|
918
866
|
}
|
|
919
867
|
else if (!UUID_REGEX.test(config['tokens.telemetry'])) {
|
|
920
868
|
const newUuid = uuidv4();
|
|
921
|
-
await writeConfig({ ...config, 'tokens.telemetry': newUuid });
|
|
869
|
+
await writeConfig(sys, { ...config, 'tokens.telemetry': newUuid });
|
|
922
870
|
config['tokens.telemetry'] = newUuid;
|
|
923
871
|
}
|
|
924
872
|
return config;
|
|
925
873
|
}
|
|
926
|
-
|
|
874
|
+
/**
|
|
875
|
+
* Writes an Ionic configuration file to disk.
|
|
876
|
+
* @param sys The system where the command is invoked
|
|
877
|
+
* @param config The config passed into the Stencil command
|
|
878
|
+
* @returns boolean If the command was successful
|
|
879
|
+
*/
|
|
880
|
+
async function writeConfig(sys, config) {
|
|
927
881
|
let result = false;
|
|
928
882
|
try {
|
|
929
|
-
await
|
|
930
|
-
await
|
|
883
|
+
await sys.createDir(defaultConfigDirectory(sys), { recursive: true });
|
|
884
|
+
await sys.writeFile(defaultConfig(sys), JSON.stringify(config, null, 2));
|
|
931
885
|
result = true;
|
|
932
886
|
}
|
|
933
887
|
catch (error) {
|
|
934
|
-
console.error(`Stencil Telemetry: couldn't write configuration file to ${defaultConfig()} - ${error}.`);
|
|
888
|
+
console.error(`Stencil Telemetry: couldn't write configuration file to ${defaultConfig(sys)} - ${error}.`);
|
|
935
889
|
}
|
|
936
890
|
return result;
|
|
937
891
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
892
|
+
/**
|
|
893
|
+
* Update a subset of the Ionic config.
|
|
894
|
+
* @param sys The system where the command is invoked
|
|
895
|
+
* @param newOptions The new options to save
|
|
896
|
+
* @returns boolean If the command was successful
|
|
897
|
+
*/
|
|
898
|
+
async function updateConfig(sys, newOptions) {
|
|
899
|
+
const config = await readConfig(sys);
|
|
900
|
+
return await writeConfig(sys, Object.assign(config, newOptions));
|
|
941
901
|
}
|
|
942
902
|
|
|
903
|
+
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
904
|
+
const DOCS_CUSTOM = 'docs-custom';
|
|
905
|
+
const DOCS_JSON = `docs-json`;
|
|
906
|
+
const DOCS_README = `docs-readme`;
|
|
907
|
+
const DOCS_VSCODE = `docs-vscode`;
|
|
908
|
+
const WWW = `www`;
|
|
909
|
+
|
|
943
910
|
/**
|
|
944
911
|
* Used to within taskBuild to provide the component_count property.
|
|
912
|
+
*
|
|
913
|
+
* @param sys The system where the command is invoked
|
|
914
|
+
* @param config The config passed into the Stencil command
|
|
915
|
+
* @param logger The tool used to do logging
|
|
916
|
+
* @param coreCompiler The compiler used to do builds
|
|
945
917
|
* @param result The results of a compiler build.
|
|
946
918
|
*/
|
|
947
|
-
async function telemetryBuildFinishedAction(result) {
|
|
948
|
-
const
|
|
949
|
-
const tracking = await shouldTrack(flags.ci);
|
|
919
|
+
async function telemetryBuildFinishedAction(sys, config, logger, coreCompiler, result) {
|
|
920
|
+
const tracking = await shouldTrack(config, sys, config.flags.ci);
|
|
950
921
|
if (!tracking) {
|
|
951
922
|
return;
|
|
952
923
|
}
|
|
953
924
|
const component_count = Object.keys(result.componentGraph).length;
|
|
954
|
-
const data = await prepareData(result.duration, component_count);
|
|
955
|
-
await sendMetric('stencil_cli_command', data);
|
|
925
|
+
const data = await prepareData(coreCompiler, config, sys, result.duration, component_count);
|
|
926
|
+
await sendMetric(sys, config, 'stencil_cli_command', data);
|
|
956
927
|
logger.debug(`${logger.blue('Telemetry')}: ${logger.gray(JSON.stringify(data))}`);
|
|
957
928
|
}
|
|
958
929
|
/**
|
|
959
930
|
* A function to wrap a compiler task function around. Will send telemetry if, and only if, the machine allows.
|
|
931
|
+
* @param sys The system where the command is invoked
|
|
932
|
+
* @param config The config passed into the Stencil command
|
|
933
|
+
* @param logger The tool used to do logging
|
|
934
|
+
* @param coreCompiler The compiler used to do builds
|
|
960
935
|
* @param action A Promise-based function to call in order to get the duration of any given command.
|
|
961
936
|
* @returns void
|
|
962
937
|
*/
|
|
963
|
-
async function telemetryAction(action) {
|
|
964
|
-
|
|
965
|
-
const tracking = await shouldTrack(!!flags.ci);
|
|
938
|
+
async function telemetryAction(sys, config, logger, coreCompiler, action) {
|
|
939
|
+
var _a;
|
|
940
|
+
const tracking = await shouldTrack(config, sys, !!((_a = config === null || config === void 0 ? void 0 : config.flags) === null || _a === void 0 ? void 0 : _a.ci));
|
|
966
941
|
let duration = undefined;
|
|
967
942
|
let error;
|
|
968
943
|
if (action) {
|
|
@@ -977,51 +952,51 @@ async function telemetryAction(action) {
|
|
|
977
952
|
duration = end.getTime() - start.getTime();
|
|
978
953
|
}
|
|
979
954
|
// We'll get componentCount details inside the taskBuild, so let's not send two messages.
|
|
980
|
-
if (!tracking || (flags.task == 'build' && !flags.args.includes('--watch'))) {
|
|
955
|
+
if (!tracking || (config.flags.task == 'build' && !config.flags.args.includes('--watch'))) {
|
|
981
956
|
return;
|
|
982
957
|
}
|
|
983
|
-
const data = await prepareData(duration);
|
|
984
|
-
await sendMetric('stencil_cli_command', data);
|
|
958
|
+
const data = await prepareData(coreCompiler, config, sys, duration);
|
|
959
|
+
await sendMetric(sys, config, 'stencil_cli_command', data);
|
|
985
960
|
logger.debug(`${logger.blue('Telemetry')}: ${logger.gray(JSON.stringify(data))}`);
|
|
986
961
|
if (error) {
|
|
987
962
|
throw error;
|
|
988
963
|
}
|
|
989
964
|
}
|
|
990
|
-
function hasAppTarget() {
|
|
991
|
-
return
|
|
965
|
+
function hasAppTarget(config) {
|
|
966
|
+
return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
|
|
992
967
|
}
|
|
993
|
-
function isUsingYarn() {
|
|
968
|
+
function isUsingYarn(sys) {
|
|
994
969
|
var _a;
|
|
995
|
-
return ((_a =
|
|
970
|
+
return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
|
|
996
971
|
}
|
|
997
|
-
async function getActiveTargets() {
|
|
998
|
-
const result =
|
|
972
|
+
async function getActiveTargets(config) {
|
|
973
|
+
const result = config.outputTargets.map((t) => t.type);
|
|
999
974
|
return Array.from(new Set(result));
|
|
1000
975
|
}
|
|
1001
|
-
const prepareData = async (duration_ms, component_count = undefined) => {
|
|
1002
|
-
|
|
1003
|
-
const {
|
|
1004
|
-
const
|
|
1005
|
-
const
|
|
1006
|
-
const
|
|
1007
|
-
const yarn = isUsingYarn();
|
|
1008
|
-
const stencil = ((_b = getCoreCompiler()) === null || _b === void 0 ? void 0 : _b.version) || 'unknown';
|
|
976
|
+
const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
|
|
977
|
+
const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
|
|
978
|
+
const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
|
|
979
|
+
const targets = await getActiveTargets(config);
|
|
980
|
+
const yarn = isUsingYarn(sys);
|
|
981
|
+
const stencil = coreCompiler.version || 'unknown';
|
|
1009
982
|
const system = `${sys.name} ${sys.version}`;
|
|
1010
983
|
const os_name = sys.details.platform;
|
|
1011
984
|
const os_version = sys.details.release;
|
|
1012
985
|
const cpu_model = sys.details.cpuModel;
|
|
1013
|
-
const build =
|
|
1014
|
-
const has_app_pwa_config = hasAppTarget();
|
|
986
|
+
const build = coreCompiler.buildId || 'unknown';
|
|
987
|
+
const has_app_pwa_config = hasAppTarget(config);
|
|
1015
988
|
return {
|
|
1016
989
|
yarn,
|
|
1017
990
|
duration_ms,
|
|
1018
991
|
component_count,
|
|
1019
992
|
targets,
|
|
1020
993
|
packages,
|
|
1021
|
-
|
|
1022
|
-
|
|
994
|
+
packages_no_versions: packagesNoVersions,
|
|
995
|
+
arguments: config.flags.args,
|
|
996
|
+
task: config.flags.task,
|
|
1023
997
|
stencil,
|
|
1024
998
|
system,
|
|
999
|
+
system_major: getMajorVersion(system),
|
|
1025
1000
|
os_name,
|
|
1026
1001
|
os_version,
|
|
1027
1002
|
cpu_model,
|
|
@@ -1032,41 +1007,92 @@ const prepareData = async (duration_ms, component_count = undefined) => {
|
|
|
1032
1007
|
};
|
|
1033
1008
|
};
|
|
1034
1009
|
/**
|
|
1035
|
-
* Reads package-lock.json and package.json files in order to cross
|
|
1010
|
+
* Reads package-lock.json, yarn.lock, and package.json files in order to cross reference
|
|
1011
|
+
* the dependencies and devDependencies properties. Pulls up the current installed version
|
|
1012
|
+
* of each package under the @stencil, @ionic, and @capacitor scopes.
|
|
1036
1013
|
* @returns string[]
|
|
1037
1014
|
*/
|
|
1038
|
-
async function getInstalledPackages() {
|
|
1015
|
+
async function getInstalledPackages(sys, config) {
|
|
1016
|
+
let packages = [];
|
|
1017
|
+
let packagesNoVersions = [];
|
|
1018
|
+
const yarn = isUsingYarn(sys);
|
|
1039
1019
|
try {
|
|
1040
1020
|
// Read package.json and package-lock.json
|
|
1041
|
-
const appRootDir =
|
|
1042
|
-
const packageJson = await tryFn(readJson,
|
|
1043
|
-
const packageLockJson = await tryFn(readJson, getCompilerSystem().resolvePath(appRootDir + '/package-lock.json'));
|
|
1021
|
+
const appRootDir = sys.getCurrentDirectory();
|
|
1022
|
+
const packageJson = await tryFn(readJson, sys, sys.resolvePath(appRootDir + '/package.json'));
|
|
1044
1023
|
// They don't have a package.json for some reason? Eject button.
|
|
1045
1024
|
if (!packageJson) {
|
|
1046
|
-
return
|
|
1025
|
+
return { packages, packagesNoVersions };
|
|
1047
1026
|
}
|
|
1048
|
-
const
|
|
1027
|
+
const rawPackages = Object.entries({
|
|
1049
1028
|
...packageJson.devDependencies,
|
|
1050
1029
|
...packageJson.dependencies,
|
|
1051
1030
|
});
|
|
1052
1031
|
// Collect packages only in the stencil, ionic, or capacitor org's:
|
|
1053
1032
|
// https://www.npmjs.com/org/stencil
|
|
1054
|
-
const ionicPackages =
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1033
|
+
const ionicPackages = rawPackages.filter(([k]) => k.startsWith('@stencil/') || k.startsWith('@ionic/') || k.startsWith('@capacitor/'));
|
|
1034
|
+
try {
|
|
1035
|
+
packages = yarn ? await yarnPackages(sys, ionicPackages) : await npmPackages(sys, ionicPackages);
|
|
1036
|
+
}
|
|
1037
|
+
catch (e) {
|
|
1038
|
+
packages = ionicPackages.map(([k, v]) => `${k}@${v.replace('^', '')}`);
|
|
1039
|
+
}
|
|
1040
|
+
packagesNoVersions = ionicPackages.map(([k]) => `${k}`);
|
|
1041
|
+
return { packages, packagesNoVersions };
|
|
1059
1042
|
}
|
|
1060
1043
|
catch (err) {
|
|
1061
|
-
hasDebug() && console.error(err);
|
|
1062
|
-
return
|
|
1044
|
+
hasDebug(config) && console.error(err);
|
|
1045
|
+
return { packages, packagesNoVersions };
|
|
1063
1046
|
}
|
|
1064
1047
|
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Visits the npm lock file to find the exact versions that are installed
|
|
1050
|
+
* @param sys The system where the command is invoked
|
|
1051
|
+
* @param ionicPackages a list of the found packages matching `@stencil`, `@capacitor`, or `@ionic` from the package.json file.
|
|
1052
|
+
* @returns an array of strings of all the packages and their versions.
|
|
1053
|
+
*/
|
|
1054
|
+
async function npmPackages(sys, ionicPackages) {
|
|
1055
|
+
const appRootDir = sys.getCurrentDirectory();
|
|
1056
|
+
const packageLockJson = await tryFn(readJson, sys, sys.resolvePath(appRootDir + '/package-lock.json'));
|
|
1057
|
+
return ionicPackages.map(([k, v]) => {
|
|
1058
|
+
var _a, _b, _c, _d;
|
|
1059
|
+
let version = (_d = (_b = (_a = packageLockJson === null || packageLockJson === void 0 ? void 0 : packageLockJson.dependencies[k]) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : (_c = packageLockJson === null || packageLockJson === void 0 ? void 0 : packageLockJson.devDependencies[k]) === null || _c === void 0 ? void 0 : _c.version) !== null && _d !== void 0 ? _d : v;
|
|
1060
|
+
version = version.includes('file:') ? sanitizeDeclaredVersion(v) : version;
|
|
1061
|
+
return `${k}@${version}`;
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Visits the yarn lock file to find the exact versions that are installed
|
|
1066
|
+
* @param sys The system where the command is invoked
|
|
1067
|
+
* @param ionicPackages a list of the found packages matching `@stencil`, `@capacitor`, or `@ionic` from the package.json file.
|
|
1068
|
+
* @returns an array of strings of all the packages and their versions.
|
|
1069
|
+
*/
|
|
1070
|
+
async function yarnPackages(sys, ionicPackages) {
|
|
1071
|
+
const appRootDir = sys.getCurrentDirectory();
|
|
1072
|
+
const yarnLock = sys.readFileSync(sys.resolvePath(appRootDir + '/yarn.lock'));
|
|
1073
|
+
const yarnLockYml = sys.parseYarnLockFile(yarnLock);
|
|
1074
|
+
return ionicPackages.map(([k, v]) => {
|
|
1075
|
+
var _a;
|
|
1076
|
+
const identifiedVersion = `${k}@${v}`;
|
|
1077
|
+
let version = (_a = yarnLockYml.object[identifiedVersion]) === null || _a === void 0 ? void 0 : _a.version;
|
|
1078
|
+
version = version.includes('undefined') ? sanitizeDeclaredVersion(identifiedVersion) : version;
|
|
1079
|
+
return `${k}@${version}`;
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* This function is used for fallback purposes, where an npm or yarn lock file doesn't exist in the consumers directory.
|
|
1084
|
+
* This will strip away '*', '^' and '~' from the declared package versions in a package.json.
|
|
1085
|
+
* @param version the raw semver pattern identifier version string
|
|
1086
|
+
* @returns a cleaned up representation without any qualifiers
|
|
1087
|
+
*/
|
|
1088
|
+
function sanitizeDeclaredVersion(version) {
|
|
1089
|
+
return version.replace(/[*^~]/g, '');
|
|
1090
|
+
}
|
|
1065
1091
|
/**
|
|
1066
1092
|
* If telemetry is enabled, send a metric via IPC to a forked process for uploading.
|
|
1067
1093
|
*/
|
|
1068
|
-
async function sendMetric(name, value) {
|
|
1069
|
-
const session_id = await getTelemetryToken();
|
|
1094
|
+
async function sendMetric(sys, config, name, value) {
|
|
1095
|
+
const session_id = await getTelemetryToken(sys);
|
|
1070
1096
|
const message = {
|
|
1071
1097
|
name,
|
|
1072
1098
|
timestamp: new Date().toISOString(),
|
|
@@ -1074,25 +1100,28 @@ async function sendMetric(name, value) {
|
|
|
1074
1100
|
value,
|
|
1075
1101
|
session_id,
|
|
1076
1102
|
};
|
|
1077
|
-
await sendTelemetry({ type: 'telemetry', message });
|
|
1103
|
+
await sendTelemetry(sys, config, { type: 'telemetry', message });
|
|
1078
1104
|
}
|
|
1079
1105
|
/**
|
|
1080
1106
|
* Used to read the config file's tokens.telemetry property.
|
|
1107
|
+
* @param sys The system where the command is invoked
|
|
1081
1108
|
* @returns string
|
|
1082
1109
|
*/
|
|
1083
|
-
async function getTelemetryToken() {
|
|
1084
|
-
const config = await readConfig();
|
|
1110
|
+
async function getTelemetryToken(sys) {
|
|
1111
|
+
const config = await readConfig(sys);
|
|
1085
1112
|
if (config['tokens.telemetry'] === undefined) {
|
|
1086
1113
|
config['tokens.telemetry'] = uuidv4();
|
|
1087
|
-
await writeConfig(config);
|
|
1114
|
+
await writeConfig(sys, config);
|
|
1088
1115
|
}
|
|
1089
1116
|
return config['tokens.telemetry'];
|
|
1090
1117
|
}
|
|
1091
1118
|
/**
|
|
1092
1119
|
* Issues a request to the telemetry server.
|
|
1120
|
+
* @param sys The system where the command is invoked
|
|
1121
|
+
* @param config The config passed into the Stencil command
|
|
1093
1122
|
* @param data Data to be tracked
|
|
1094
1123
|
*/
|
|
1095
|
-
async function sendTelemetry(data) {
|
|
1124
|
+
async function sendTelemetry(sys, config, data) {
|
|
1096
1125
|
try {
|
|
1097
1126
|
const now = new Date().toISOString();
|
|
1098
1127
|
const body = {
|
|
@@ -1100,52 +1129,64 @@ async function sendTelemetry(data) {
|
|
|
1100
1129
|
sent_at: now,
|
|
1101
1130
|
};
|
|
1102
1131
|
// This request is only made if telemetry is on.
|
|
1103
|
-
const response = await
|
|
1132
|
+
const response = await sys.fetch('https://api.ionicjs.com/events/metrics', {
|
|
1104
1133
|
method: 'POST',
|
|
1105
1134
|
headers: {
|
|
1106
1135
|
'Content-Type': 'application/json',
|
|
1107
1136
|
},
|
|
1108
1137
|
body: JSON.stringify(body),
|
|
1109
1138
|
});
|
|
1110
|
-
hasVerbose() &&
|
|
1139
|
+
hasVerbose(config) &&
|
|
1111
1140
|
console.debug('\nSent %O metric to events service (status: %O)', data.message.name, response.status, '\n');
|
|
1112
1141
|
if (response.status !== 204) {
|
|
1113
|
-
hasVerbose() &&
|
|
1142
|
+
hasVerbose(config) &&
|
|
1114
1143
|
console.debug('\nBad response from events service. Request body: %O', response.body.toString(), '\n');
|
|
1115
1144
|
}
|
|
1116
1145
|
}
|
|
1117
1146
|
catch (e) {
|
|
1118
|
-
hasVerbose() && console.debug('Telemetry request failed:', e);
|
|
1147
|
+
hasVerbose(config) && console.debug('Telemetry request failed:', e);
|
|
1119
1148
|
}
|
|
1120
1149
|
}
|
|
1121
1150
|
/**
|
|
1122
1151
|
* Checks if telemetry is enabled on this machine
|
|
1152
|
+
* @param sys The system where the command is invoked
|
|
1123
1153
|
* @returns true if telemetry is enabled, false otherwise
|
|
1124
1154
|
*/
|
|
1125
|
-
async function checkTelemetry() {
|
|
1126
|
-
const config = await readConfig();
|
|
1155
|
+
async function checkTelemetry(sys) {
|
|
1156
|
+
const config = await readConfig(sys);
|
|
1127
1157
|
if (config['telemetry.stencil'] === undefined) {
|
|
1128
1158
|
config['telemetry.stencil'] = true;
|
|
1129
|
-
await writeConfig(config);
|
|
1159
|
+
await writeConfig(sys, config);
|
|
1130
1160
|
}
|
|
1131
1161
|
return config['telemetry.stencil'];
|
|
1132
1162
|
}
|
|
1133
1163
|
/**
|
|
1134
1164
|
* Writes to the config file, enabling telemetry for this machine.
|
|
1165
|
+
* @param sys The system where the command is invoked
|
|
1135
1166
|
* @returns true if writing the file was successful, false otherwise
|
|
1136
1167
|
*/
|
|
1137
|
-
async function enableTelemetry() {
|
|
1138
|
-
return await updateConfig({ 'telemetry.stencil': true });
|
|
1168
|
+
async function enableTelemetry(sys) {
|
|
1169
|
+
return await updateConfig(sys, { 'telemetry.stencil': true });
|
|
1139
1170
|
}
|
|
1140
1171
|
/**
|
|
1141
1172
|
* Writes to the config file, disabling telemetry for this machine.
|
|
1173
|
+
* @param sys The system where the command is invoked
|
|
1142
1174
|
* @returns true if writing the file was successful, false otherwise
|
|
1143
1175
|
*/
|
|
1144
|
-
async function disableTelemetry() {
|
|
1145
|
-
return await updateConfig({ 'telemetry.stencil': false });
|
|
1176
|
+
async function disableTelemetry(sys) {
|
|
1177
|
+
return await updateConfig(sys, { 'telemetry.stencil': false });
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Takes in a semver string in order to return the major version.
|
|
1181
|
+
* @param version The fully qualified semver version
|
|
1182
|
+
* @returns a string of the major version
|
|
1183
|
+
*/
|
|
1184
|
+
function getMajorVersion(version) {
|
|
1185
|
+
const parts = version.split('.');
|
|
1186
|
+
return parts[0];
|
|
1146
1187
|
}
|
|
1147
1188
|
|
|
1148
|
-
const taskBuild = async (coreCompiler, config) => {
|
|
1189
|
+
const taskBuild = async (coreCompiler, config, sys) => {
|
|
1149
1190
|
if (config.flags.watch) {
|
|
1150
1191
|
// watch build
|
|
1151
1192
|
await taskWatch(coreCompiler, config);
|
|
@@ -1158,7 +1199,10 @@ const taskBuild = async (coreCompiler, config) => {
|
|
|
1158
1199
|
const versionChecker = startCheckVersion(config, coreCompiler.version);
|
|
1159
1200
|
const compiler = await coreCompiler.createCompiler(config);
|
|
1160
1201
|
const results = await compiler.build();
|
|
1161
|
-
|
|
1202
|
+
// TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
|
|
1203
|
+
if (sys) {
|
|
1204
|
+
await telemetryBuildFinishedAction(sys, config, config.logger, coreCompiler, results);
|
|
1205
|
+
}
|
|
1162
1206
|
await compiler.destroy();
|
|
1163
1207
|
if (results.hasError) {
|
|
1164
1208
|
exitCode = 1;
|
|
@@ -1181,12 +1225,6 @@ const taskBuild = async (coreCompiler, config) => {
|
|
|
1181
1225
|
}
|
|
1182
1226
|
};
|
|
1183
1227
|
|
|
1184
|
-
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
1185
|
-
const DOCS_CUSTOM = 'docs-custom';
|
|
1186
|
-
const DOCS_JSON = `docs-json`;
|
|
1187
|
-
const DOCS_README = `docs-readme`;
|
|
1188
|
-
const DOCS_VSCODE = `docs-vscode`;
|
|
1189
|
-
|
|
1190
1228
|
const taskDocs = async (coreCompiler, config) => {
|
|
1191
1229
|
config.devServer = null;
|
|
1192
1230
|
config.outputTargets = config.outputTargets.filter(isOutputTargetDocs);
|
|
@@ -1197,9 +1235,7 @@ const taskDocs = async (coreCompiler, config) => {
|
|
|
1197
1235
|
await compiler.destroy();
|
|
1198
1236
|
};
|
|
1199
1237
|
|
|
1200
|
-
const
|
|
1201
|
-
const IS_NODE_ENV = !IS_DENO_ENV &&
|
|
1202
|
-
typeof global !== 'undefined' &&
|
|
1238
|
+
const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
1203
1239
|
typeof require === 'function' &&
|
|
1204
1240
|
!!global.process &&
|
|
1205
1241
|
typeof __filename === 'string' &&
|
|
@@ -1371,25 +1407,24 @@ describe('${name}', () => {
|
|
|
1371
1407
|
*/
|
|
1372
1408
|
const toPascalCase = (str) => str.split('-').reduce((res, part) => res + part[0].toUpperCase() + part.substr(1), '');
|
|
1373
1409
|
|
|
1374
|
-
const taskTelemetry = async () => {
|
|
1375
|
-
const
|
|
1376
|
-
const
|
|
1377
|
-
const
|
|
1378
|
-
const isDisabling = getStencilCLIConfig().flags.args.includes('off');
|
|
1410
|
+
const taskTelemetry = async (config, sys, logger) => {
|
|
1411
|
+
const prompt = logger.dim(sys.details.platform === 'windows' ? '>' : '$');
|
|
1412
|
+
const isEnabling = config.flags.args.includes('on');
|
|
1413
|
+
const isDisabling = config.flags.args.includes('off');
|
|
1379
1414
|
const INFORMATION = `Opt in or our of telemetry. Information about the data we collect is available on our website: ${logger.bold('https://stenciljs.com/telemetry')}`;
|
|
1380
1415
|
const THANK_YOU = `Thank you for helping to make Stencil better! 💖`;
|
|
1381
1416
|
const ENABLED_MESSAGE = `${logger.green('Enabled')}. ${THANK_YOU}\n\n`;
|
|
1382
1417
|
const DISABLED_MESSAGE = `${logger.red('Disabled')}\n\n`;
|
|
1383
|
-
const hasTelemetry = await checkTelemetry();
|
|
1418
|
+
const hasTelemetry = await checkTelemetry(sys);
|
|
1384
1419
|
if (isEnabling) {
|
|
1385
|
-
const result = await enableTelemetry();
|
|
1420
|
+
const result = await enableTelemetry(sys);
|
|
1386
1421
|
result
|
|
1387
1422
|
? console.log(`\n ${logger.bold('Telemetry is now ') + ENABLED_MESSAGE}`)
|
|
1388
1423
|
: console.log(`Something went wrong when enabling Telemetry.`);
|
|
1389
1424
|
return;
|
|
1390
1425
|
}
|
|
1391
1426
|
if (isDisabling) {
|
|
1392
|
-
const result = await disableTelemetry();
|
|
1427
|
+
const result = await disableTelemetry(sys);
|
|
1393
1428
|
result
|
|
1394
1429
|
? console.log(`\n ${logger.bold('Telemetry is now ') + DISABLED_MESSAGE}`)
|
|
1395
1430
|
: console.log(`Something went wrong when disabling Telemetry.`);
|
|
@@ -1404,9 +1439,7 @@ const taskTelemetry = async () => {
|
|
|
1404
1439
|
`);
|
|
1405
1440
|
};
|
|
1406
1441
|
|
|
1407
|
-
const taskHelp = async () => {
|
|
1408
|
-
const logger = getLogger();
|
|
1409
|
-
const sys = getCompilerSystem();
|
|
1442
|
+
const taskHelp = async (config, logger, sys) => {
|
|
1410
1443
|
const prompt = logger.dim(sys.details.platform === 'windows' ? '>' : '$');
|
|
1411
1444
|
console.log(`
|
|
1412
1445
|
${logger.bold('Build:')} ${logger.dim('Build components for development or production.')}
|
|
@@ -1437,11 +1470,13 @@ const taskHelp = async () => {
|
|
|
1437
1470
|
${prompt} ${logger.green('stencil generate')} or ${logger.green('stencil g')}
|
|
1438
1471
|
|
|
1439
1472
|
`);
|
|
1440
|
-
|
|
1473
|
+
// TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
|
|
1474
|
+
if (sys) {
|
|
1475
|
+
await taskTelemetry(config, sys, logger);
|
|
1476
|
+
}
|
|
1441
1477
|
console.log(`
|
|
1442
1478
|
${logger.bold('Examples:')}
|
|
1443
1479
|
|
|
1444
|
-
|
|
1445
1480
|
${prompt} ${logger.green('stencil build --dev --watch --serve')}
|
|
1446
1481
|
${prompt} ${logger.green('stencil build --prerender')}
|
|
1447
1482
|
${prompt} ${logger.green('stencil test --spec --e2e')}
|
|
@@ -1542,8 +1577,6 @@ const taskTest = async (config) => {
|
|
|
1542
1577
|
|
|
1543
1578
|
const run = async (init) => {
|
|
1544
1579
|
const { args, logger, sys } = init;
|
|
1545
|
-
// Initialize the singleton so we can use this throughout the lifecycle of the CLI.
|
|
1546
|
-
const stencilCLIConfig = initializeStencilCLIConfig({ args, logger, sys });
|
|
1547
1580
|
try {
|
|
1548
1581
|
const flags = parseFlags(args, sys);
|
|
1549
1582
|
const task = flags.task;
|
|
@@ -1556,13 +1589,8 @@ const run = async (init) => {
|
|
|
1556
1589
|
if (isFunction(sys.applyGlobalPatch)) {
|
|
1557
1590
|
sys.applyGlobalPatch(sys.getCurrentDirectory());
|
|
1558
1591
|
}
|
|
1559
|
-
// Update singleton with modifications
|
|
1560
|
-
stencilCLIConfig.logger = logger;
|
|
1561
|
-
stencilCLIConfig.task = task;
|
|
1562
|
-
stencilCLIConfig.sys = sys;
|
|
1563
|
-
stencilCLIConfig.flags = flags;
|
|
1564
1592
|
if (task === 'help' || flags.help) {
|
|
1565
|
-
taskHelp();
|
|
1593
|
+
await taskHelp({ flags: { task: 'help', args }, outputTargets: [] }, logger, sys);
|
|
1566
1594
|
return;
|
|
1567
1595
|
}
|
|
1568
1596
|
startupLog(logger, task);
|
|
@@ -1581,7 +1609,6 @@ const run = async (init) => {
|
|
|
1581
1609
|
return sys.exit(1);
|
|
1582
1610
|
}
|
|
1583
1611
|
const coreCompiler = await loadCoreCompiler(sys);
|
|
1584
|
-
stencilCLIConfig.coreCompiler = coreCompiler;
|
|
1585
1612
|
if (task === 'version' || flags.version) {
|
|
1586
1613
|
console.log(coreCompiler.version);
|
|
1587
1614
|
return;
|
|
@@ -1589,7 +1616,7 @@ const run = async (init) => {
|
|
|
1589
1616
|
startupLogVersion(logger, task, coreCompiler);
|
|
1590
1617
|
loadedCompilerLog(sys, logger, flags, coreCompiler);
|
|
1591
1618
|
if (task === 'info') {
|
|
1592
|
-
await telemetryAction(async () => {
|
|
1619
|
+
await telemetryAction(sys, { flags: { task: 'info' }, outputTargets: [] }, logger, coreCompiler, async () => {
|
|
1593
1620
|
await taskInfo(coreCompiler, sys, logger);
|
|
1594
1621
|
});
|
|
1595
1622
|
return;
|
|
@@ -1608,13 +1635,12 @@ const run = async (init) => {
|
|
|
1608
1635
|
return sys.exit(1);
|
|
1609
1636
|
}
|
|
1610
1637
|
}
|
|
1611
|
-
stencilCLIConfig.validatedConfig = validated;
|
|
1612
1638
|
if (isFunction(sys.applyGlobalPatch)) {
|
|
1613
1639
|
sys.applyGlobalPatch(validated.config.rootDir);
|
|
1614
1640
|
}
|
|
1615
1641
|
await sys.ensureResources({ rootDir: validated.config.rootDir, logger, dependencies: dependencies });
|
|
1616
|
-
await telemetryAction(async () => {
|
|
1617
|
-
await runTask(coreCompiler, validated.config, task);
|
|
1642
|
+
await telemetryAction(sys, validated.config, logger, coreCompiler, async () => {
|
|
1643
|
+
await runTask(coreCompiler, validated.config, task, sys);
|
|
1618
1644
|
});
|
|
1619
1645
|
}
|
|
1620
1646
|
catch (e) {
|
|
@@ -1624,12 +1650,12 @@ const run = async (init) => {
|
|
|
1624
1650
|
}
|
|
1625
1651
|
}
|
|
1626
1652
|
};
|
|
1627
|
-
const runTask = async (coreCompiler, config, task) => {
|
|
1628
|
-
config.flags = config.flags || {};
|
|
1653
|
+
const runTask = async (coreCompiler, config, task, sys) => {
|
|
1654
|
+
config.flags = config.flags || { task };
|
|
1629
1655
|
config.outputTargets = config.outputTargets || [];
|
|
1630
1656
|
switch (task) {
|
|
1631
1657
|
case 'build':
|
|
1632
|
-
await taskBuild(coreCompiler, config);
|
|
1658
|
+
await taskBuild(coreCompiler, config, sys);
|
|
1633
1659
|
break;
|
|
1634
1660
|
case 'docs':
|
|
1635
1661
|
await taskDocs(coreCompiler, config);
|
|
@@ -1639,7 +1665,7 @@ const runTask = async (coreCompiler, config, task) => {
|
|
|
1639
1665
|
await taskGenerate(coreCompiler, config);
|
|
1640
1666
|
break;
|
|
1641
1667
|
case 'help':
|
|
1642
|
-
taskHelp();
|
|
1668
|
+
taskHelp(config, config.logger, sys);
|
|
1643
1669
|
break;
|
|
1644
1670
|
case 'prerender':
|
|
1645
1671
|
await taskPrerender(coreCompiler, config);
|
|
@@ -1648,7 +1674,10 @@ const runTask = async (coreCompiler, config, task) => {
|
|
|
1648
1674
|
await taskServe(config);
|
|
1649
1675
|
break;
|
|
1650
1676
|
case 'telemetry':
|
|
1651
|
-
|
|
1677
|
+
// TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
|
|
1678
|
+
if (sys) {
|
|
1679
|
+
await taskTelemetry(config, sys, config.logger);
|
|
1680
|
+
}
|
|
1652
1681
|
break;
|
|
1653
1682
|
case 'test':
|
|
1654
1683
|
await taskTest(config);
|
|
@@ -1658,9 +1687,10 @@ const runTask = async (coreCompiler, config, task) => {
|
|
|
1658
1687
|
break;
|
|
1659
1688
|
default:
|
|
1660
1689
|
config.logger.error(`${config.logger.emoji('❌ ')}Invalid stencil command, please see the options below:`);
|
|
1661
|
-
taskHelp();
|
|
1690
|
+
taskHelp(config, config.logger, sys);
|
|
1662
1691
|
return config.sys.exit(1);
|
|
1663
1692
|
}
|
|
1664
1693
|
};
|
|
1665
1694
|
|
|
1666
1695
|
export { parseFlags, run, runTask };
|
|
1696
|
+
//# sourceMappingURL=index.js.map
|