@stencil/core 2.18.0 → 2.19.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 +275 -218
- package/cli/index.d.ts +3 -0
- package/cli/index.js +275 -218
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.d.ts +2 -2
- package/compiler/stencil.js +49510 -47947
- package/compiler/stencil.min.js +2 -2
- package/dependencies.json +1 -1
- package/dev-server/client/index.d.ts +2 -2
- package/dev-server/client/index.js +241 -241
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +3 -3
- package/dev-server/index.d.ts +1 -1
- package/dev-server/index.js +2 -2
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +1230 -1199
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +2 -2
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +619 -601
- 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/polyfills/css-shim.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/index.js +119 -119
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.d.ts +1 -1
- package/internal/hydrate/runner.js +100 -100
- package/internal/package.json +1 -1
- package/internal/stencil-core/index.d.ts +8 -10
- package/internal/stencil-private.d.ts +104 -42
- package/internal/stencil-public-compiler.d.ts +12 -2
- package/internal/stencil-public-docs.d.ts +20 -0
- package/internal/stencil-public-runtime.d.ts +20 -4
- package/internal/testing/index.js +148 -148
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +655 -645
- package/mock-doc/index.js +655 -645
- package/mock-doc/package.json +1 -1
- package/package.json +29 -37
- package/readme.md +27 -33
- package/screenshot/index.d.ts +1 -1
- package/screenshot/index.js +3 -3
- package/screenshot/package.json +1 -1
- package/screenshot/pixel-match.js +983 -849
- package/sys/node/autoprefixer.js +5 -5
- package/sys/node/glob.js +1 -1
- package/sys/node/graceful-fs.js +1 -1
- package/sys/node/index.d.ts +4 -0
- package/sys/node/index.js +373 -374
- package/sys/node/package.json +1 -1
- package/sys/node/prompts.js +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.d.ts +6 -6
- package/testing/index.js +468 -467
- package/testing/jest/jest-config.d.ts +1 -1
- package/testing/matchers/index.d.ts +3 -3
- package/testing/mock-fetch.d.ts +1 -1
- package/testing/mocks.d.ts +2 -2
- package/testing/package.json +1 -1
- package/testing/puppeteer/puppeteer-element.d.ts +2 -2
- package/testing/puppeteer/puppeteer-events.d.ts +1 -1
- package/testing/testing-logger.d.ts +1 -1
- package/testing/testing.d.ts +1 -1
package/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI (CommonJS) v2.
|
|
2
|
+
Stencil CLI (CommonJS) v2.19.0 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -25,29 +25,6 @@ function _interopNamespace(e) {
|
|
|
25
25
|
return Object.freeze(n);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* This sets the log level hierarchy for our terminal logger, ranging from
|
|
30
|
-
* most to least verbose.
|
|
31
|
-
*
|
|
32
|
-
* Ordering the levels like this lets us easily check whether we should log a
|
|
33
|
-
* message at a given time. For instance, if the log level is set to `'warn'`,
|
|
34
|
-
* then anything passed to the logger with level `'warn'` or `'error'` should
|
|
35
|
-
* be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
|
|
36
|
-
*
|
|
37
|
-
* If we have a current log level `currentLevel` and a message with level
|
|
38
|
-
* `msgLevel` is passed to the logger, we can determine whether or not we should
|
|
39
|
-
* log it by checking if the log level on the message is further up or at the
|
|
40
|
-
* same level in the hierarchy than `currentLevel`, like so:
|
|
41
|
-
*
|
|
42
|
-
* ```ts
|
|
43
|
-
* LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* NOTE: for the reasons described above, do not change the order of the entries
|
|
47
|
-
* in this array without good reason!
|
|
48
|
-
*/
|
|
49
|
-
const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
|
|
50
|
-
|
|
51
28
|
/**
|
|
52
29
|
* Convert a string from PascalCase to dash-case
|
|
53
30
|
*
|
|
@@ -297,6 +274,22 @@ const pathComponents = (path, rootLength) => {
|
|
|
297
274
|
return [root, ...rest];
|
|
298
275
|
};
|
|
299
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Check whether a string is a member of a ReadonlyArray<string>
|
|
279
|
+
*
|
|
280
|
+
* We need a little helper for this because unfortunately `includes` is typed
|
|
281
|
+
* on `ReadonlyArray<T>` as `(el: T): boolean` so a `string` cannot be passed
|
|
282
|
+
* to `includes` on a `ReadonlyArray` 😢 thus we have a little helper function
|
|
283
|
+
* where we do the type coercion just once.
|
|
284
|
+
*
|
|
285
|
+
* see microsoft/TypeScript#31018 for some discussion of this
|
|
286
|
+
*
|
|
287
|
+
* @param readOnlyArray the array we're checking
|
|
288
|
+
* @param maybeMember a value which is possibly a member of the array
|
|
289
|
+
* @returns whether the array contains the member or not
|
|
290
|
+
*/
|
|
291
|
+
const readOnlyArrayHasStringMember = (readOnlyArray, maybeMember) => readOnlyArray.includes(maybeMember);
|
|
292
|
+
|
|
300
293
|
/**
|
|
301
294
|
* Validates that a component tag meets required naming conventions to be used for a web component
|
|
302
295
|
* @param tag the tag to validate
|
|
@@ -341,6 +334,29 @@ const validateComponentTag = (tag) => {
|
|
|
341
334
|
return undefined;
|
|
342
335
|
};
|
|
343
336
|
|
|
337
|
+
/**
|
|
338
|
+
* This sets the log level hierarchy for our terminal logger, ranging from
|
|
339
|
+
* most to least verbose.
|
|
340
|
+
*
|
|
341
|
+
* Ordering the levels like this lets us easily check whether we should log a
|
|
342
|
+
* message at a given time. For instance, if the log level is set to `'warn'`,
|
|
343
|
+
* then anything passed to the logger with level `'warn'` or `'error'` should
|
|
344
|
+
* be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
|
|
345
|
+
*
|
|
346
|
+
* If we have a current log level `currentLevel` and a message with level
|
|
347
|
+
* `msgLevel` is passed to the logger, we can determine whether or not we should
|
|
348
|
+
* log it by checking if the log level on the message is further up or at the
|
|
349
|
+
* same level in the hierarchy than `currentLevel`, like so:
|
|
350
|
+
*
|
|
351
|
+
* ```ts
|
|
352
|
+
* LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* NOTE: for the reasons described above, do not change the order of the entries
|
|
356
|
+
* in this array without good reason!
|
|
357
|
+
*/
|
|
358
|
+
const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
|
|
359
|
+
|
|
344
360
|
/**
|
|
345
361
|
* All the Boolean options supported by the Stencil CLI
|
|
346
362
|
*/
|
|
@@ -818,18 +834,12 @@ const parseEqualsArg = (arg) => {
|
|
|
818
834
|
* @param maybeLogLevel the string to check
|
|
819
835
|
* @returns whether this is a `LogLevel`
|
|
820
836
|
*/
|
|
821
|
-
const isLogLevel = (maybeLogLevel) =>
|
|
822
|
-
// unfortunately `includes` is typed on `ReadonlyArray<T>` as `(el: T):
|
|
823
|
-
// boolean` so a `string` cannot be passed to `includes` on a
|
|
824
|
-
// `ReadonlyArray` 😢 thus we `as any`
|
|
825
|
-
//
|
|
826
|
-
// see microsoft/TypeScript#31018 for some discussion of this
|
|
827
|
-
LOG_LEVELS.includes(maybeLogLevel);
|
|
837
|
+
const isLogLevel = (maybeLogLevel) => readOnlyArrayHasStringMember(LOG_LEVELS, maybeLogLevel);
|
|
828
838
|
|
|
829
839
|
const dependencies = [
|
|
830
840
|
{
|
|
831
841
|
name: "@stencil/core",
|
|
832
|
-
version: "2.
|
|
842
|
+
version: "2.19.0",
|
|
833
843
|
main: "compiler/stencil.js",
|
|
834
844
|
resources: [
|
|
835
845
|
"package.json",
|
|
@@ -946,6 +956,102 @@ const dependencies = [
|
|
|
946
956
|
}
|
|
947
957
|
];
|
|
948
958
|
|
|
959
|
+
const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
960
|
+
typeof require === 'function' &&
|
|
961
|
+
!!global.process &&
|
|
962
|
+
typeof __filename === 'string' &&
|
|
963
|
+
(!global.origin || typeof global.origin !== 'string');
|
|
964
|
+
const IS_BROWSER_ENV = typeof location !== 'undefined' && typeof navigator !== 'undefined' && typeof XMLHttpRequest !== 'undefined';
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Creates an instance of a logger
|
|
968
|
+
* @returns the new logger instance
|
|
969
|
+
*/
|
|
970
|
+
const createLogger = () => {
|
|
971
|
+
let useColors = IS_BROWSER_ENV;
|
|
972
|
+
let level = 'info';
|
|
973
|
+
return {
|
|
974
|
+
enableColors: (uc) => (useColors = uc),
|
|
975
|
+
getLevel: () => level,
|
|
976
|
+
setLevel: (l) => (level = l),
|
|
977
|
+
emoji: (e) => e,
|
|
978
|
+
info: console.log.bind(console),
|
|
979
|
+
warn: console.warn.bind(console),
|
|
980
|
+
error: console.error.bind(console),
|
|
981
|
+
debug: console.debug.bind(console),
|
|
982
|
+
red: (msg) => msg,
|
|
983
|
+
green: (msg) => msg,
|
|
984
|
+
yellow: (msg) => msg,
|
|
985
|
+
blue: (msg) => msg,
|
|
986
|
+
magenta: (msg) => msg,
|
|
987
|
+
cyan: (msg) => msg,
|
|
988
|
+
gray: (msg) => msg,
|
|
989
|
+
bold: (msg) => msg,
|
|
990
|
+
dim: (msg) => msg,
|
|
991
|
+
bgRed: (msg) => msg,
|
|
992
|
+
createTimeSpan: (_startMsg, _debug = false) => ({
|
|
993
|
+
duration: () => 0,
|
|
994
|
+
finish: () => 0,
|
|
995
|
+
}),
|
|
996
|
+
printDiagnostics(diagnostics) {
|
|
997
|
+
diagnostics.forEach((diagnostic) => logDiagnostic(diagnostic, useColors));
|
|
998
|
+
},
|
|
999
|
+
};
|
|
1000
|
+
};
|
|
1001
|
+
const logDiagnostic = (diagnostic, useColors) => {
|
|
1002
|
+
let color = BLUE;
|
|
1003
|
+
let prefix = 'Build';
|
|
1004
|
+
let msg = '';
|
|
1005
|
+
if (diagnostic.level === 'error') {
|
|
1006
|
+
color = RED;
|
|
1007
|
+
prefix = 'Error';
|
|
1008
|
+
}
|
|
1009
|
+
else if (diagnostic.level === 'warn') {
|
|
1010
|
+
color = YELLOW;
|
|
1011
|
+
prefix = 'Warning';
|
|
1012
|
+
}
|
|
1013
|
+
if (diagnostic.header) {
|
|
1014
|
+
prefix = diagnostic.header;
|
|
1015
|
+
}
|
|
1016
|
+
const filePath = diagnostic.relFilePath || diagnostic.absFilePath;
|
|
1017
|
+
if (filePath) {
|
|
1018
|
+
msg += filePath;
|
|
1019
|
+
if (typeof diagnostic.lineNumber === 'number' && diagnostic.lineNumber > 0) {
|
|
1020
|
+
msg += ', line ' + diagnostic.lineNumber;
|
|
1021
|
+
if (typeof diagnostic.columnNumber === 'number' && diagnostic.columnNumber > 0) {
|
|
1022
|
+
msg += ', column ' + diagnostic.columnNumber;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
msg += '\n';
|
|
1026
|
+
}
|
|
1027
|
+
msg += diagnostic.messageText;
|
|
1028
|
+
if (diagnostic.lines && diagnostic.lines.length > 0) {
|
|
1029
|
+
diagnostic.lines.forEach((l) => {
|
|
1030
|
+
msg += '\n' + l.lineNumber + ': ' + l.text;
|
|
1031
|
+
});
|
|
1032
|
+
msg += '\n';
|
|
1033
|
+
}
|
|
1034
|
+
if (useColors) {
|
|
1035
|
+
const styledPrefix = [
|
|
1036
|
+
'%c' + prefix,
|
|
1037
|
+
`background: ${color}; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;`,
|
|
1038
|
+
];
|
|
1039
|
+
console.log(...styledPrefix, msg);
|
|
1040
|
+
}
|
|
1041
|
+
else if (diagnostic.level === 'error') {
|
|
1042
|
+
console.error(msg);
|
|
1043
|
+
}
|
|
1044
|
+
else if (diagnostic.level === 'warn') {
|
|
1045
|
+
console.warn(msg);
|
|
1046
|
+
}
|
|
1047
|
+
else {
|
|
1048
|
+
console.log(msg);
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
const YELLOW = `#f39c12`;
|
|
1052
|
+
const RED = `#c0392b`;
|
|
1053
|
+
const BLUE = `#3498db`;
|
|
1054
|
+
|
|
949
1055
|
/**
|
|
950
1056
|
* Attempt to find a Stencil configuration file on the file system
|
|
951
1057
|
* @param opts the options needed to find the configuration file
|
|
@@ -954,11 +1060,7 @@ const dependencies = [
|
|
|
954
1060
|
const findConfig = async (opts) => {
|
|
955
1061
|
const sys = opts.sys;
|
|
956
1062
|
const cwd = sys.getCurrentDirectory();
|
|
957
|
-
const
|
|
958
|
-
configPath: null,
|
|
959
|
-
rootDir: normalizePath(cwd),
|
|
960
|
-
diagnostics: [],
|
|
961
|
-
};
|
|
1063
|
+
const rootDir = normalizePath(cwd);
|
|
962
1064
|
let configPath = opts.configPath;
|
|
963
1065
|
if (isString(configPath)) {
|
|
964
1066
|
if (!sys.platformPath.isAbsolute(configPath)) {
|
|
@@ -973,8 +1075,13 @@ const findConfig = async (opts) => {
|
|
|
973
1075
|
}
|
|
974
1076
|
else {
|
|
975
1077
|
// nothing was passed in, use the current working directory
|
|
976
|
-
configPath =
|
|
1078
|
+
configPath = rootDir;
|
|
977
1079
|
}
|
|
1080
|
+
const results = {
|
|
1081
|
+
configPath,
|
|
1082
|
+
rootDir: normalizePath(cwd),
|
|
1083
|
+
diagnostics: [],
|
|
1084
|
+
};
|
|
978
1085
|
const stat = await sys.stat(configPath);
|
|
979
1086
|
if (stat.error) {
|
|
980
1087
|
const diagnostic = buildError(results.diagnostics);
|
|
@@ -1007,12 +1114,33 @@ const loadCoreCompiler = async (sys) => {
|
|
|
1007
1114
|
return globalThis.stencil;
|
|
1008
1115
|
};
|
|
1009
1116
|
|
|
1117
|
+
/**
|
|
1118
|
+
* Log the name of this package (`@stencil/core`) to an output stream
|
|
1119
|
+
*
|
|
1120
|
+
* The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
|
|
1121
|
+
*
|
|
1122
|
+
* The name of the package may not be logged, by design, for certain `task` types and logging levels
|
|
1123
|
+
*
|
|
1124
|
+
* @param logger the logging entity to use to output the name of the package
|
|
1125
|
+
* @param task the current task
|
|
1126
|
+
*/
|
|
1010
1127
|
const startupLog = (logger, task) => {
|
|
1011
1128
|
if (task === 'info' || task === 'serve' || task === 'version') {
|
|
1012
1129
|
return;
|
|
1013
1130
|
}
|
|
1014
1131
|
logger.info(logger.cyan(`@stencil/core`));
|
|
1015
1132
|
};
|
|
1133
|
+
/**
|
|
1134
|
+
* Log this package's version to an output stream
|
|
1135
|
+
*
|
|
1136
|
+
* The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
|
|
1137
|
+
*
|
|
1138
|
+
* The package version may not be logged, by design, for certain `task` types and logging levels
|
|
1139
|
+
*
|
|
1140
|
+
* @param logger the logging entity to use for output
|
|
1141
|
+
* @param task the current task
|
|
1142
|
+
* @param coreCompiler the compiler instance to derive version information from
|
|
1143
|
+
*/
|
|
1016
1144
|
const startupLogVersion = (logger, task, coreCompiler) => {
|
|
1017
1145
|
if (task === 'info' || task === 'serve' || task === 'version') {
|
|
1018
1146
|
return;
|
|
@@ -1028,11 +1156,25 @@ const startupLogVersion = (logger, task, coreCompiler) => {
|
|
|
1028
1156
|
startupMsg += logger.emoji(' ' + coreCompiler.vermoji);
|
|
1029
1157
|
logger.info(startupMsg);
|
|
1030
1158
|
};
|
|
1159
|
+
/**
|
|
1160
|
+
* Log details from a {@link CompilerSystem} used by Stencil to an output stream
|
|
1161
|
+
*
|
|
1162
|
+
* The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
|
|
1163
|
+
*
|
|
1164
|
+
* @param sys the `CompilerSystem` to report details on
|
|
1165
|
+
* @param logger the logging entity to use for output
|
|
1166
|
+
* @param flags user set flags for the current invocation of Stencil
|
|
1167
|
+
* @param coreCompiler the compiler instance being used for this invocation of Stencil
|
|
1168
|
+
*/
|
|
1031
1169
|
const loadedCompilerLog = (sys, logger, flags, coreCompiler) => {
|
|
1032
1170
|
const sysDetails = sys.details;
|
|
1033
1171
|
const runtimeInfo = `${sys.name} ${sys.version}`;
|
|
1034
|
-
const platformInfo =
|
|
1035
|
-
|
|
1172
|
+
const platformInfo = sysDetails
|
|
1173
|
+
? `${sysDetails.platform}, ${sysDetails.cpuModel}`
|
|
1174
|
+
: `Unknown Platform, Unknown CPU Model`;
|
|
1175
|
+
const statsInfo = sysDetails
|
|
1176
|
+
? `cpus: ${sys.hardwareConcurrency}, freemem: ${Math.round(sysDetails.freemem() / 1000000)}MB, totalmem: ${Math.round(sysDetails.totalmem / 1000000)}MB`
|
|
1177
|
+
: 'Unknown CPU Core Count, Unknown Memory';
|
|
1036
1178
|
if (logger.getLevel() === 'debug') {
|
|
1037
1179
|
logger.debug(runtimeInfo);
|
|
1038
1180
|
logger.debug(platformInfo);
|
|
@@ -1046,6 +1188,14 @@ const loadedCompilerLog = (sys, logger, flags, coreCompiler) => {
|
|
|
1046
1188
|
logger.info(statsInfo);
|
|
1047
1189
|
}
|
|
1048
1190
|
};
|
|
1191
|
+
/**
|
|
1192
|
+
* Log various warnings to an output stream
|
|
1193
|
+
*
|
|
1194
|
+
* The output stream is determined by the {@link Logger} instance attached to the `config` argument to this function
|
|
1195
|
+
*
|
|
1196
|
+
* @param coreCompiler the compiler instance being used for this invocation of Stencil
|
|
1197
|
+
* @param config a validated configuration object to be used for this run of Stencil
|
|
1198
|
+
*/
|
|
1049
1199
|
const startupCompilerLog = (coreCompiler, config) => {
|
|
1050
1200
|
if (config.suppressLogs === true) {
|
|
1051
1201
|
return;
|
|
@@ -1067,6 +1217,21 @@ const startupCompilerLog = (coreCompiler, config) => {
|
|
|
1067
1217
|
}
|
|
1068
1218
|
};
|
|
1069
1219
|
|
|
1220
|
+
const startCheckVersion = async (config, currentVersion) => {
|
|
1221
|
+
if (config.devMode && !config.flags.ci && !currentVersion.includes('-dev.') && isFunction(config.sys.checkVersion)) {
|
|
1222
|
+
return config.sys.checkVersion(config.logger, currentVersion);
|
|
1223
|
+
}
|
|
1224
|
+
return null;
|
|
1225
|
+
};
|
|
1226
|
+
const printCheckVersionResults = async (versionChecker) => {
|
|
1227
|
+
if (versionChecker) {
|
|
1228
|
+
const checkVersionResults = await versionChecker;
|
|
1229
|
+
if (isFunction(checkVersionResults)) {
|
|
1230
|
+
checkVersionResults();
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
|
|
1070
1235
|
const taskPrerender = async (coreCompiler, config) => {
|
|
1071
1236
|
startupCompilerLog(coreCompiler, config);
|
|
1072
1237
|
const hydrateAppFilePath = config.flags.unknownArgs[0];
|
|
@@ -1098,21 +1263,6 @@ const runPrerenderTask = async (coreCompiler, config, hydrateAppFilePath, compon
|
|
|
1098
1263
|
return diagnostics;
|
|
1099
1264
|
};
|
|
1100
1265
|
|
|
1101
|
-
const startCheckVersion = async (config, currentVersion) => {
|
|
1102
|
-
if (config.devMode && !config.flags.ci && !currentVersion.includes('-dev.') && isFunction(config.sys.checkVersion)) {
|
|
1103
|
-
return config.sys.checkVersion(config.logger, currentVersion);
|
|
1104
|
-
}
|
|
1105
|
-
return null;
|
|
1106
|
-
};
|
|
1107
|
-
const printCheckVersionResults = async (versionChecker) => {
|
|
1108
|
-
if (versionChecker) {
|
|
1109
|
-
const checkVersionResults = await versionChecker;
|
|
1110
|
-
if (isFunction(checkVersionResults)) {
|
|
1111
|
-
checkVersionResults();
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
};
|
|
1115
|
-
|
|
1116
1266
|
const taskWatch = async (coreCompiler, config) => {
|
|
1117
1267
|
let devServer = null;
|
|
1118
1268
|
let exitCode = 0;
|
|
@@ -1159,6 +1309,15 @@ const taskWatch = async (coreCompiler, config) => {
|
|
|
1159
1309
|
}
|
|
1160
1310
|
};
|
|
1161
1311
|
|
|
1312
|
+
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
1313
|
+
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
1314
|
+
const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
|
|
1315
|
+
const DOCS_CUSTOM = 'docs-custom';
|
|
1316
|
+
const DOCS_JSON = 'docs-json';
|
|
1317
|
+
const DOCS_README = 'docs-readme';
|
|
1318
|
+
const DOCS_VSCODE = 'docs-vscode';
|
|
1319
|
+
const WWW = 'www';
|
|
1320
|
+
|
|
1162
1321
|
const tryFn = async (fn, ...args) => {
|
|
1163
1322
|
try {
|
|
1164
1323
|
return await fn(...args);
|
|
@@ -1172,7 +1331,7 @@ const isInteractive = (sys, flags, object) => {
|
|
|
1172
1331
|
const terminalInfo = object ||
|
|
1173
1332
|
Object.freeze({
|
|
1174
1333
|
tty: sys.isTTY() ? true : false,
|
|
1175
|
-
ci: ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN'].filter((v) => !!sys.getEnvironmentVar(v)).length > 0 || !!flags.ci,
|
|
1334
|
+
ci: ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN'].filter((v) => { var _a; return !!((_a = sys.getEnvironmentVar) === null || _a === void 0 ? void 0 : _a.call(sys, v)); }).length > 0 || !!flags.ci,
|
|
1176
1335
|
});
|
|
1177
1336
|
return terminalInfo.tty && !terminalInfo.ci;
|
|
1178
1337
|
};
|
|
@@ -1201,7 +1360,7 @@ async function readJson(sys, path) {
|
|
|
1201
1360
|
* @returns true if --debug has been passed, otherwise false
|
|
1202
1361
|
*/
|
|
1203
1362
|
function hasDebug(flags) {
|
|
1204
|
-
return flags.debug;
|
|
1363
|
+
return !!flags.debug;
|
|
1205
1364
|
}
|
|
1206
1365
|
/**
|
|
1207
1366
|
* Does the command have the verbose and debug flags?
|
|
@@ -1209,18 +1368,7 @@ function hasDebug(flags) {
|
|
|
1209
1368
|
* @returns true if both --debug and --verbose have been passed, otherwise false
|
|
1210
1369
|
*/
|
|
1211
1370
|
function hasVerbose(flags) {
|
|
1212
|
-
return flags.verbose && hasDebug(flags);
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
/**
|
|
1216
|
-
* Used to determine if tracking should occur.
|
|
1217
|
-
* @param config The config passed into the Stencil command
|
|
1218
|
-
* @param sys The system where the command is invoked
|
|
1219
|
-
* @param ci whether or not the process is running in a Continuous Integration (CI) environment
|
|
1220
|
-
* @returns true if telemetry should be sent, false otherwise
|
|
1221
|
-
*/
|
|
1222
|
-
async function shouldTrack(config, sys, ci) {
|
|
1223
|
-
return !ci && isInteractive(sys, config.flags) && (await checkTelemetry(sys));
|
|
1371
|
+
return !!flags.verbose && hasDebug(flags);
|
|
1224
1372
|
}
|
|
1225
1373
|
|
|
1226
1374
|
const isTest$1 = () => process.env.JEST_WORKER_ID !== undefined;
|
|
@@ -1241,7 +1389,7 @@ async function readConfig(sys) {
|
|
|
1241
1389
|
};
|
|
1242
1390
|
await writeConfig(sys, config);
|
|
1243
1391
|
}
|
|
1244
|
-
else if (!UUID_REGEX.test(config['tokens.telemetry'])) {
|
|
1392
|
+
else if (!config['tokens.telemetry'] || !UUID_REGEX.test(config['tokens.telemetry'])) {
|
|
1245
1393
|
const newUuid = uuidv4();
|
|
1246
1394
|
await writeConfig(sys, { ...config, 'tokens.telemetry': newUuid });
|
|
1247
1395
|
config['tokens.telemetry'] = newUuid;
|
|
@@ -1277,14 +1425,16 @@ async function updateConfig(sys, newOptions) {
|
|
|
1277
1425
|
return await writeConfig(sys, Object.assign(config, newOptions));
|
|
1278
1426
|
}
|
|
1279
1427
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1428
|
+
/**
|
|
1429
|
+
* Used to determine if tracking should occur.
|
|
1430
|
+
* @param config The config passed into the Stencil command
|
|
1431
|
+
* @param sys The system where the command is invoked
|
|
1432
|
+
* @param ci whether or not the process is running in a Continuous Integration (CI) environment
|
|
1433
|
+
* @returns true if telemetry should be sent, false otherwise
|
|
1434
|
+
*/
|
|
1435
|
+
async function shouldTrack(config, sys, ci) {
|
|
1436
|
+
return !ci && isInteractive(sys, config.flags) && (await checkTelemetry(sys));
|
|
1437
|
+
}
|
|
1288
1438
|
|
|
1289
1439
|
/**
|
|
1290
1440
|
* Used to within taskBuild to provide the component_count property.
|
|
@@ -1295,11 +1445,11 @@ const WWW = 'www';
|
|
|
1295
1445
|
* @param result The results of a compiler build.
|
|
1296
1446
|
*/
|
|
1297
1447
|
async function telemetryBuildFinishedAction(sys, config, coreCompiler, result) {
|
|
1298
|
-
const tracking = await shouldTrack(config, sys, config.flags.ci);
|
|
1448
|
+
const tracking = await shouldTrack(config, sys, !!config.flags.ci);
|
|
1299
1449
|
if (!tracking) {
|
|
1300
1450
|
return;
|
|
1301
1451
|
}
|
|
1302
|
-
const component_count = Object.keys(result.componentGraph).length;
|
|
1452
|
+
const component_count = result.componentGraph ? Object.keys(result.componentGraph).length : undefined;
|
|
1303
1453
|
const data = await prepareData(coreCompiler, config, sys, result.duration, component_count);
|
|
1304
1454
|
await sendMetric(sys, config, 'stencil_cli_command', data);
|
|
1305
1455
|
config.logger.debug(`${config.logger.blue('Telemetry')}: ${config.logger.gray(JSON.stringify(data))}`);
|
|
@@ -1378,38 +1528,41 @@ function getActiveTargets(config) {
|
|
|
1378
1528
|
* @returns a Promise wrapping data for the telemetry endpoint
|
|
1379
1529
|
*/
|
|
1380
1530
|
const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
|
|
1531
|
+
var _a, _b, _c;
|
|
1381
1532
|
const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
|
|
1382
1533
|
const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
|
|
1383
1534
|
const targets = getActiveTargets(config);
|
|
1384
1535
|
const yarn = isUsingYarn(sys);
|
|
1385
1536
|
const stencil = coreCompiler.version || 'unknown';
|
|
1386
1537
|
const system = `${sys.name} ${sys.version}`;
|
|
1387
|
-
const os_name = sys.details.platform;
|
|
1388
|
-
const os_version = sys.details.release;
|
|
1389
|
-
const cpu_model = sys.details.cpuModel;
|
|
1538
|
+
const os_name = (_a = sys.details) === null || _a === void 0 ? void 0 : _a.platform;
|
|
1539
|
+
const os_version = (_b = sys.details) === null || _b === void 0 ? void 0 : _b.release;
|
|
1540
|
+
const cpu_model = (_c = sys.details) === null || _c === void 0 ? void 0 : _c.cpuModel;
|
|
1390
1541
|
const build = coreCompiler.buildId || 'unknown';
|
|
1391
1542
|
const has_app_pwa_config = hasAppTarget(config);
|
|
1392
1543
|
const anonymizedConfig = anonymizeConfigForTelemetry(config);
|
|
1544
|
+
const is_browser_env = IS_BROWSER_ENV;
|
|
1393
1545
|
return {
|
|
1394
|
-
|
|
1395
|
-
|
|
1546
|
+
arguments: config.flags.args,
|
|
1547
|
+
build,
|
|
1396
1548
|
component_count,
|
|
1397
|
-
|
|
1549
|
+
config: anonymizedConfig,
|
|
1550
|
+
cpu_model,
|
|
1551
|
+
duration_ms,
|
|
1552
|
+
has_app_pwa_config,
|
|
1553
|
+
is_browser_env,
|
|
1554
|
+
os_name,
|
|
1555
|
+
os_version,
|
|
1398
1556
|
packages,
|
|
1399
1557
|
packages_no_versions: packagesNoVersions,
|
|
1400
|
-
|
|
1401
|
-
task: config.flags.task,
|
|
1558
|
+
rollup,
|
|
1402
1559
|
stencil,
|
|
1403
1560
|
system,
|
|
1404
1561
|
system_major: getMajorVersion(system),
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
cpu_model,
|
|
1408
|
-
build,
|
|
1562
|
+
targets,
|
|
1563
|
+
task: config.flags.task,
|
|
1409
1564
|
typescript,
|
|
1410
|
-
|
|
1411
|
-
has_app_pwa_config,
|
|
1412
|
-
config: anonymizedConfig,
|
|
1565
|
+
yarn,
|
|
1413
1566
|
};
|
|
1414
1567
|
};
|
|
1415
1568
|
// props in output targets for which we retain their original values when
|
|
@@ -1716,13 +1869,6 @@ const taskDocs = async (coreCompiler, config) => {
|
|
|
1716
1869
|
await compiler.destroy();
|
|
1717
1870
|
};
|
|
1718
1871
|
|
|
1719
|
-
const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
1720
|
-
typeof require === 'function' &&
|
|
1721
|
-
!!global.process &&
|
|
1722
|
-
typeof __filename === 'string' &&
|
|
1723
|
-
(!global.origin || typeof global.origin !== 'string');
|
|
1724
|
-
const IS_BROWSER_ENV = typeof location !== 'undefined' && typeof navigator !== 'undefined' && typeof XMLHttpRequest !== 'undefined';
|
|
1725
|
-
|
|
1726
1872
|
/**
|
|
1727
1873
|
* Task to generate component boilerplate and write it to disk. This task can
|
|
1728
1874
|
* cause the program to exit with an error under various circumstances, such as
|
|
@@ -1983,7 +2129,7 @@ const taskTelemetry = async (flags, sys, logger) => {
|
|
|
1983
2129
|
const prompt = logger.dim(sys.details.platform === 'windows' ? '>' : '$');
|
|
1984
2130
|
const isEnabling = flags.args.includes('on');
|
|
1985
2131
|
const isDisabling = flags.args.includes('off');
|
|
1986
|
-
const INFORMATION = `Opt in or
|
|
2132
|
+
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')}`;
|
|
1987
2133
|
const THANK_YOU = `Thank you for helping to make Stencil better! 💖`;
|
|
1988
2134
|
const ENABLED_MESSAGE = `${logger.green('Enabled')}. ${THANK_YOU}\n\n`;
|
|
1989
2135
|
const DISABLED_MESSAGE = `${logger.red('Disabled')}\n\n`;
|
|
@@ -2114,32 +2260,32 @@ const taskTest = async (config) => {
|
|
|
2114
2260
|
config.logger.error(`"test" command is currently only implemented for a NodeJS environment`);
|
|
2115
2261
|
return config.sys.exit(1);
|
|
2116
2262
|
}
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
if
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
config.logger.warn(config.logger.yellow(`EXPERIMENTAL: screenshot visual diff testing is currently under heavy development and has not reached a stable status. However, any assistance testing would be appreciated.`));
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
// ensure we've got the required modules installed
|
|
2138
|
-
const diagnostics = await config.sys.lazyRequire.ensure(config.rootDir, ensureModuleIds);
|
|
2139
|
-
if (diagnostics.length > 0) {
|
|
2140
|
-
config.logger.printDiagnostics(diagnostics);
|
|
2141
|
-
return config.sys.exit(1);
|
|
2263
|
+
config.buildDocs = false;
|
|
2264
|
+
const testingRunOpts = {
|
|
2265
|
+
e2e: !!config.flags.e2e,
|
|
2266
|
+
screenshot: !!config.flags.screenshot,
|
|
2267
|
+
spec: !!config.flags.spec,
|
|
2268
|
+
updateScreenshot: !!config.flags.updateScreenshot,
|
|
2269
|
+
};
|
|
2270
|
+
// always ensure we have jest modules installed
|
|
2271
|
+
const ensureModuleIds = ['@types/jest', 'jest', 'jest-cli'];
|
|
2272
|
+
if (testingRunOpts.e2e) {
|
|
2273
|
+
// if it's an e2e test, also make sure we're got
|
|
2274
|
+
// puppeteer modules installed and if browserExecutablePath is provided don't download Chromium use only puppeteer-core instead
|
|
2275
|
+
const puppeteer = config.testing.browserExecutablePath ? 'puppeteer-core' : 'puppeteer';
|
|
2276
|
+
ensureModuleIds.push(puppeteer);
|
|
2277
|
+
if (testingRunOpts.screenshot) {
|
|
2278
|
+
// ensure we've got pixelmatch for screenshots
|
|
2279
|
+
config.logger.warn(config.logger.yellow(`EXPERIMENTAL: screenshot visual diff testing is currently under heavy development and has not reached a stable status. However, any assistance testing would be appreciated.`));
|
|
2142
2280
|
}
|
|
2281
|
+
}
|
|
2282
|
+
// ensure we've got the required modules installed
|
|
2283
|
+
const diagnostics = await config.sys.lazyRequire.ensure(config.rootDir, ensureModuleIds);
|
|
2284
|
+
if (diagnostics.length > 0) {
|
|
2285
|
+
config.logger.printDiagnostics(diagnostics);
|
|
2286
|
+
return config.sys.exit(1);
|
|
2287
|
+
}
|
|
2288
|
+
try {
|
|
2143
2289
|
// let's test!
|
|
2144
2290
|
const { createTesting } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('../testing/index.js')); });
|
|
2145
2291
|
const testing = await createTesting(config);
|
|
@@ -2155,95 +2301,6 @@ const taskTest = async (config) => {
|
|
|
2155
2301
|
}
|
|
2156
2302
|
};
|
|
2157
2303
|
|
|
2158
|
-
/**
|
|
2159
|
-
* Creates an instance of a logger
|
|
2160
|
-
* @returns the new logger instance
|
|
2161
|
-
*/
|
|
2162
|
-
const createLogger = () => {
|
|
2163
|
-
let useColors = IS_BROWSER_ENV;
|
|
2164
|
-
let level = 'info';
|
|
2165
|
-
return {
|
|
2166
|
-
enableColors: (uc) => (useColors = uc),
|
|
2167
|
-
getLevel: () => level,
|
|
2168
|
-
setLevel: (l) => (level = l),
|
|
2169
|
-
emoji: (e) => e,
|
|
2170
|
-
info: console.log.bind(console),
|
|
2171
|
-
warn: console.warn.bind(console),
|
|
2172
|
-
error: console.error.bind(console),
|
|
2173
|
-
debug: console.debug.bind(console),
|
|
2174
|
-
red: (msg) => msg,
|
|
2175
|
-
green: (msg) => msg,
|
|
2176
|
-
yellow: (msg) => msg,
|
|
2177
|
-
blue: (msg) => msg,
|
|
2178
|
-
magenta: (msg) => msg,
|
|
2179
|
-
cyan: (msg) => msg,
|
|
2180
|
-
gray: (msg) => msg,
|
|
2181
|
-
bold: (msg) => msg,
|
|
2182
|
-
dim: (msg) => msg,
|
|
2183
|
-
bgRed: (msg) => msg,
|
|
2184
|
-
createTimeSpan: (_startMsg, _debug = false) => ({
|
|
2185
|
-
duration: () => 0,
|
|
2186
|
-
finish: () => 0,
|
|
2187
|
-
}),
|
|
2188
|
-
printDiagnostics(diagnostics) {
|
|
2189
|
-
diagnostics.forEach((diagnostic) => logDiagnostic(diagnostic, useColors));
|
|
2190
|
-
},
|
|
2191
|
-
};
|
|
2192
|
-
};
|
|
2193
|
-
const logDiagnostic = (diagnostic, useColors) => {
|
|
2194
|
-
let color = BLUE;
|
|
2195
|
-
let prefix = 'Build';
|
|
2196
|
-
let msg = '';
|
|
2197
|
-
if (diagnostic.level === 'error') {
|
|
2198
|
-
color = RED;
|
|
2199
|
-
prefix = 'Error';
|
|
2200
|
-
}
|
|
2201
|
-
else if (diagnostic.level === 'warn') {
|
|
2202
|
-
color = YELLOW;
|
|
2203
|
-
prefix = 'Warning';
|
|
2204
|
-
}
|
|
2205
|
-
if (diagnostic.header) {
|
|
2206
|
-
prefix = diagnostic.header;
|
|
2207
|
-
}
|
|
2208
|
-
const filePath = diagnostic.relFilePath || diagnostic.absFilePath;
|
|
2209
|
-
if (filePath) {
|
|
2210
|
-
msg += filePath;
|
|
2211
|
-
if (typeof diagnostic.lineNumber === 'number' && diagnostic.lineNumber > 0) {
|
|
2212
|
-
msg += ', line ' + diagnostic.lineNumber;
|
|
2213
|
-
if (typeof diagnostic.columnNumber === 'number' && diagnostic.columnNumber > 0) {
|
|
2214
|
-
msg += ', column ' + diagnostic.columnNumber;
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
msg += '\n';
|
|
2218
|
-
}
|
|
2219
|
-
msg += diagnostic.messageText;
|
|
2220
|
-
if (diagnostic.lines && diagnostic.lines.length > 0) {
|
|
2221
|
-
diagnostic.lines.forEach((l) => {
|
|
2222
|
-
msg += '\n' + l.lineNumber + ': ' + l.text;
|
|
2223
|
-
});
|
|
2224
|
-
msg += '\n';
|
|
2225
|
-
}
|
|
2226
|
-
if (useColors) {
|
|
2227
|
-
const styledPrefix = [
|
|
2228
|
-
'%c' + prefix,
|
|
2229
|
-
`background: ${color}; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;`,
|
|
2230
|
-
];
|
|
2231
|
-
console.log(...styledPrefix, msg);
|
|
2232
|
-
}
|
|
2233
|
-
else if (diagnostic.level === 'error') {
|
|
2234
|
-
console.error(msg);
|
|
2235
|
-
}
|
|
2236
|
-
else if (diagnostic.level === 'warn') {
|
|
2237
|
-
console.warn(msg);
|
|
2238
|
-
}
|
|
2239
|
-
else {
|
|
2240
|
-
console.log(msg);
|
|
2241
|
-
}
|
|
2242
|
-
};
|
|
2243
|
-
const YELLOW = `#f39c12`;
|
|
2244
|
-
const RED = `#c0392b`;
|
|
2245
|
-
const BLUE = `#3498db`;
|
|
2246
|
-
|
|
2247
2304
|
const run = async (init) => {
|
|
2248
2305
|
const { args, logger, sys } = init;
|
|
2249
2306
|
try {
|
|
@@ -2258,7 +2315,7 @@ const run = async (init) => {
|
|
|
2258
2315
|
if (isFunction(sys.applyGlobalPatch)) {
|
|
2259
2316
|
sys.applyGlobalPatch(sys.getCurrentDirectory());
|
|
2260
2317
|
}
|
|
2261
|
-
if (task === 'help' || flags.help) {
|
|
2318
|
+
if (!task || task === 'help' || flags.help) {
|
|
2262
2319
|
await taskHelp(createConfigFlags({ task: 'help', args }), logger, sys);
|
|
2263
2320
|
return;
|
|
2264
2321
|
}
|