@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.js
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI v2.
|
|
2
|
+
Stencil CLI v2.19.0 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
|
-
/**
|
|
5
|
-
* This sets the log level hierarchy for our terminal logger, ranging from
|
|
6
|
-
* most to least verbose.
|
|
7
|
-
*
|
|
8
|
-
* Ordering the levels like this lets us easily check whether we should log a
|
|
9
|
-
* message at a given time. For instance, if the log level is set to `'warn'`,
|
|
10
|
-
* then anything passed to the logger with level `'warn'` or `'error'` should
|
|
11
|
-
* be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
|
|
12
|
-
*
|
|
13
|
-
* If we have a current log level `currentLevel` and a message with level
|
|
14
|
-
* `msgLevel` is passed to the logger, we can determine whether or not we should
|
|
15
|
-
* log it by checking if the log level on the message is further up or at the
|
|
16
|
-
* same level in the hierarchy than `currentLevel`, like so:
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* NOTE: for the reasons described above, do not change the order of the entries
|
|
23
|
-
* in this array without good reason!
|
|
24
|
-
*/
|
|
25
|
-
const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
|
|
26
|
-
|
|
27
4
|
/**
|
|
28
5
|
* Convert a string from PascalCase to dash-case
|
|
29
6
|
*
|
|
@@ -273,6 +250,22 @@ const pathComponents = (path, rootLength) => {
|
|
|
273
250
|
return [root, ...rest];
|
|
274
251
|
};
|
|
275
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Check whether a string is a member of a ReadonlyArray<string>
|
|
255
|
+
*
|
|
256
|
+
* We need a little helper for this because unfortunately `includes` is typed
|
|
257
|
+
* on `ReadonlyArray<T>` as `(el: T): boolean` so a `string` cannot be passed
|
|
258
|
+
* to `includes` on a `ReadonlyArray` 😢 thus we have a little helper function
|
|
259
|
+
* where we do the type coercion just once.
|
|
260
|
+
*
|
|
261
|
+
* see microsoft/TypeScript#31018 for some discussion of this
|
|
262
|
+
*
|
|
263
|
+
* @param readOnlyArray the array we're checking
|
|
264
|
+
* @param maybeMember a value which is possibly a member of the array
|
|
265
|
+
* @returns whether the array contains the member or not
|
|
266
|
+
*/
|
|
267
|
+
const readOnlyArrayHasStringMember = (readOnlyArray, maybeMember) => readOnlyArray.includes(maybeMember);
|
|
268
|
+
|
|
276
269
|
/**
|
|
277
270
|
* Validates that a component tag meets required naming conventions to be used for a web component
|
|
278
271
|
* @param tag the tag to validate
|
|
@@ -317,6 +310,29 @@ const validateComponentTag = (tag) => {
|
|
|
317
310
|
return undefined;
|
|
318
311
|
};
|
|
319
312
|
|
|
313
|
+
/**
|
|
314
|
+
* This sets the log level hierarchy for our terminal logger, ranging from
|
|
315
|
+
* most to least verbose.
|
|
316
|
+
*
|
|
317
|
+
* Ordering the levels like this lets us easily check whether we should log a
|
|
318
|
+
* message at a given time. For instance, if the log level is set to `'warn'`,
|
|
319
|
+
* then anything passed to the logger with level `'warn'` or `'error'` should
|
|
320
|
+
* be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
|
|
321
|
+
*
|
|
322
|
+
* If we have a current log level `currentLevel` and a message with level
|
|
323
|
+
* `msgLevel` is passed to the logger, we can determine whether or not we should
|
|
324
|
+
* log it by checking if the log level on the message is further up or at the
|
|
325
|
+
* same level in the hierarchy than `currentLevel`, like so:
|
|
326
|
+
*
|
|
327
|
+
* ```ts
|
|
328
|
+
* LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* NOTE: for the reasons described above, do not change the order of the entries
|
|
332
|
+
* in this array without good reason!
|
|
333
|
+
*/
|
|
334
|
+
const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
|
|
335
|
+
|
|
320
336
|
/**
|
|
321
337
|
* All the Boolean options supported by the Stencil CLI
|
|
322
338
|
*/
|
|
@@ -794,18 +810,12 @@ const parseEqualsArg = (arg) => {
|
|
|
794
810
|
* @param maybeLogLevel the string to check
|
|
795
811
|
* @returns whether this is a `LogLevel`
|
|
796
812
|
*/
|
|
797
|
-
const isLogLevel = (maybeLogLevel) =>
|
|
798
|
-
// unfortunately `includes` is typed on `ReadonlyArray<T>` as `(el: T):
|
|
799
|
-
// boolean` so a `string` cannot be passed to `includes` on a
|
|
800
|
-
// `ReadonlyArray` 😢 thus we `as any`
|
|
801
|
-
//
|
|
802
|
-
// see microsoft/TypeScript#31018 for some discussion of this
|
|
803
|
-
LOG_LEVELS.includes(maybeLogLevel);
|
|
813
|
+
const isLogLevel = (maybeLogLevel) => readOnlyArrayHasStringMember(LOG_LEVELS, maybeLogLevel);
|
|
804
814
|
|
|
805
815
|
const dependencies = [
|
|
806
816
|
{
|
|
807
817
|
name: "@stencil/core",
|
|
808
|
-
version: "2.
|
|
818
|
+
version: "2.19.0",
|
|
809
819
|
main: "compiler/stencil.js",
|
|
810
820
|
resources: [
|
|
811
821
|
"package.json",
|
|
@@ -922,6 +932,102 @@ const dependencies = [
|
|
|
922
932
|
}
|
|
923
933
|
];
|
|
924
934
|
|
|
935
|
+
const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
936
|
+
typeof require === 'function' &&
|
|
937
|
+
!!global.process &&
|
|
938
|
+
typeof __filename === 'string' &&
|
|
939
|
+
(!global.origin || typeof global.origin !== 'string');
|
|
940
|
+
const IS_BROWSER_ENV = typeof location !== 'undefined' && typeof navigator !== 'undefined' && typeof XMLHttpRequest !== 'undefined';
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Creates an instance of a logger
|
|
944
|
+
* @returns the new logger instance
|
|
945
|
+
*/
|
|
946
|
+
const createLogger = () => {
|
|
947
|
+
let useColors = IS_BROWSER_ENV;
|
|
948
|
+
let level = 'info';
|
|
949
|
+
return {
|
|
950
|
+
enableColors: (uc) => (useColors = uc),
|
|
951
|
+
getLevel: () => level,
|
|
952
|
+
setLevel: (l) => (level = l),
|
|
953
|
+
emoji: (e) => e,
|
|
954
|
+
info: console.log.bind(console),
|
|
955
|
+
warn: console.warn.bind(console),
|
|
956
|
+
error: console.error.bind(console),
|
|
957
|
+
debug: console.debug.bind(console),
|
|
958
|
+
red: (msg) => msg,
|
|
959
|
+
green: (msg) => msg,
|
|
960
|
+
yellow: (msg) => msg,
|
|
961
|
+
blue: (msg) => msg,
|
|
962
|
+
magenta: (msg) => msg,
|
|
963
|
+
cyan: (msg) => msg,
|
|
964
|
+
gray: (msg) => msg,
|
|
965
|
+
bold: (msg) => msg,
|
|
966
|
+
dim: (msg) => msg,
|
|
967
|
+
bgRed: (msg) => msg,
|
|
968
|
+
createTimeSpan: (_startMsg, _debug = false) => ({
|
|
969
|
+
duration: () => 0,
|
|
970
|
+
finish: () => 0,
|
|
971
|
+
}),
|
|
972
|
+
printDiagnostics(diagnostics) {
|
|
973
|
+
diagnostics.forEach((diagnostic) => logDiagnostic(diagnostic, useColors));
|
|
974
|
+
},
|
|
975
|
+
};
|
|
976
|
+
};
|
|
977
|
+
const logDiagnostic = (diagnostic, useColors) => {
|
|
978
|
+
let color = BLUE;
|
|
979
|
+
let prefix = 'Build';
|
|
980
|
+
let msg = '';
|
|
981
|
+
if (diagnostic.level === 'error') {
|
|
982
|
+
color = RED;
|
|
983
|
+
prefix = 'Error';
|
|
984
|
+
}
|
|
985
|
+
else if (diagnostic.level === 'warn') {
|
|
986
|
+
color = YELLOW;
|
|
987
|
+
prefix = 'Warning';
|
|
988
|
+
}
|
|
989
|
+
if (diagnostic.header) {
|
|
990
|
+
prefix = diagnostic.header;
|
|
991
|
+
}
|
|
992
|
+
const filePath = diagnostic.relFilePath || diagnostic.absFilePath;
|
|
993
|
+
if (filePath) {
|
|
994
|
+
msg += filePath;
|
|
995
|
+
if (typeof diagnostic.lineNumber === 'number' && diagnostic.lineNumber > 0) {
|
|
996
|
+
msg += ', line ' + diagnostic.lineNumber;
|
|
997
|
+
if (typeof diagnostic.columnNumber === 'number' && diagnostic.columnNumber > 0) {
|
|
998
|
+
msg += ', column ' + diagnostic.columnNumber;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
msg += '\n';
|
|
1002
|
+
}
|
|
1003
|
+
msg += diagnostic.messageText;
|
|
1004
|
+
if (diagnostic.lines && diagnostic.lines.length > 0) {
|
|
1005
|
+
diagnostic.lines.forEach((l) => {
|
|
1006
|
+
msg += '\n' + l.lineNumber + ': ' + l.text;
|
|
1007
|
+
});
|
|
1008
|
+
msg += '\n';
|
|
1009
|
+
}
|
|
1010
|
+
if (useColors) {
|
|
1011
|
+
const styledPrefix = [
|
|
1012
|
+
'%c' + prefix,
|
|
1013
|
+
`background: ${color}; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;`,
|
|
1014
|
+
];
|
|
1015
|
+
console.log(...styledPrefix, msg);
|
|
1016
|
+
}
|
|
1017
|
+
else if (diagnostic.level === 'error') {
|
|
1018
|
+
console.error(msg);
|
|
1019
|
+
}
|
|
1020
|
+
else if (diagnostic.level === 'warn') {
|
|
1021
|
+
console.warn(msg);
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
console.log(msg);
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
const YELLOW = `#f39c12`;
|
|
1028
|
+
const RED = `#c0392b`;
|
|
1029
|
+
const BLUE = `#3498db`;
|
|
1030
|
+
|
|
925
1031
|
/**
|
|
926
1032
|
* Attempt to find a Stencil configuration file on the file system
|
|
927
1033
|
* @param opts the options needed to find the configuration file
|
|
@@ -930,11 +1036,7 @@ const dependencies = [
|
|
|
930
1036
|
const findConfig = async (opts) => {
|
|
931
1037
|
const sys = opts.sys;
|
|
932
1038
|
const cwd = sys.getCurrentDirectory();
|
|
933
|
-
const
|
|
934
|
-
configPath: null,
|
|
935
|
-
rootDir: normalizePath(cwd),
|
|
936
|
-
diagnostics: [],
|
|
937
|
-
};
|
|
1039
|
+
const rootDir = normalizePath(cwd);
|
|
938
1040
|
let configPath = opts.configPath;
|
|
939
1041
|
if (isString(configPath)) {
|
|
940
1042
|
if (!sys.platformPath.isAbsolute(configPath)) {
|
|
@@ -949,8 +1051,13 @@ const findConfig = async (opts) => {
|
|
|
949
1051
|
}
|
|
950
1052
|
else {
|
|
951
1053
|
// nothing was passed in, use the current working directory
|
|
952
|
-
configPath =
|
|
1054
|
+
configPath = rootDir;
|
|
953
1055
|
}
|
|
1056
|
+
const results = {
|
|
1057
|
+
configPath,
|
|
1058
|
+
rootDir: normalizePath(cwd),
|
|
1059
|
+
diagnostics: [],
|
|
1060
|
+
};
|
|
954
1061
|
const stat = await sys.stat(configPath);
|
|
955
1062
|
if (stat.error) {
|
|
956
1063
|
const diagnostic = buildError(results.diagnostics);
|
|
@@ -983,12 +1090,33 @@ const loadCoreCompiler = async (sys) => {
|
|
|
983
1090
|
return globalThis.stencil;
|
|
984
1091
|
};
|
|
985
1092
|
|
|
1093
|
+
/**
|
|
1094
|
+
* Log the name of this package (`@stencil/core`) to an output stream
|
|
1095
|
+
*
|
|
1096
|
+
* The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
|
|
1097
|
+
*
|
|
1098
|
+
* The name of the package may not be logged, by design, for certain `task` types and logging levels
|
|
1099
|
+
*
|
|
1100
|
+
* @param logger the logging entity to use to output the name of the package
|
|
1101
|
+
* @param task the current task
|
|
1102
|
+
*/
|
|
986
1103
|
const startupLog = (logger, task) => {
|
|
987
1104
|
if (task === 'info' || task === 'serve' || task === 'version') {
|
|
988
1105
|
return;
|
|
989
1106
|
}
|
|
990
1107
|
logger.info(logger.cyan(`@stencil/core`));
|
|
991
1108
|
};
|
|
1109
|
+
/**
|
|
1110
|
+
* Log this package's version to an output stream
|
|
1111
|
+
*
|
|
1112
|
+
* The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
|
|
1113
|
+
*
|
|
1114
|
+
* The package version may not be logged, by design, for certain `task` types and logging levels
|
|
1115
|
+
*
|
|
1116
|
+
* @param logger the logging entity to use for output
|
|
1117
|
+
* @param task the current task
|
|
1118
|
+
* @param coreCompiler the compiler instance to derive version information from
|
|
1119
|
+
*/
|
|
992
1120
|
const startupLogVersion = (logger, task, coreCompiler) => {
|
|
993
1121
|
if (task === 'info' || task === 'serve' || task === 'version') {
|
|
994
1122
|
return;
|
|
@@ -1004,11 +1132,25 @@ const startupLogVersion = (logger, task, coreCompiler) => {
|
|
|
1004
1132
|
startupMsg += logger.emoji(' ' + coreCompiler.vermoji);
|
|
1005
1133
|
logger.info(startupMsg);
|
|
1006
1134
|
};
|
|
1135
|
+
/**
|
|
1136
|
+
* Log details from a {@link CompilerSystem} used by Stencil to an output stream
|
|
1137
|
+
*
|
|
1138
|
+
* The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
|
|
1139
|
+
*
|
|
1140
|
+
* @param sys the `CompilerSystem` to report details on
|
|
1141
|
+
* @param logger the logging entity to use for output
|
|
1142
|
+
* @param flags user set flags for the current invocation of Stencil
|
|
1143
|
+
* @param coreCompiler the compiler instance being used for this invocation of Stencil
|
|
1144
|
+
*/
|
|
1007
1145
|
const loadedCompilerLog = (sys, logger, flags, coreCompiler) => {
|
|
1008
1146
|
const sysDetails = sys.details;
|
|
1009
1147
|
const runtimeInfo = `${sys.name} ${sys.version}`;
|
|
1010
|
-
const platformInfo =
|
|
1011
|
-
|
|
1148
|
+
const platformInfo = sysDetails
|
|
1149
|
+
? `${sysDetails.platform}, ${sysDetails.cpuModel}`
|
|
1150
|
+
: `Unknown Platform, Unknown CPU Model`;
|
|
1151
|
+
const statsInfo = sysDetails
|
|
1152
|
+
? `cpus: ${sys.hardwareConcurrency}, freemem: ${Math.round(sysDetails.freemem() / 1000000)}MB, totalmem: ${Math.round(sysDetails.totalmem / 1000000)}MB`
|
|
1153
|
+
: 'Unknown CPU Core Count, Unknown Memory';
|
|
1012
1154
|
if (logger.getLevel() === 'debug') {
|
|
1013
1155
|
logger.debug(runtimeInfo);
|
|
1014
1156
|
logger.debug(platformInfo);
|
|
@@ -1022,6 +1164,14 @@ const loadedCompilerLog = (sys, logger, flags, coreCompiler) => {
|
|
|
1022
1164
|
logger.info(statsInfo);
|
|
1023
1165
|
}
|
|
1024
1166
|
};
|
|
1167
|
+
/**
|
|
1168
|
+
* Log various warnings to an output stream
|
|
1169
|
+
*
|
|
1170
|
+
* The output stream is determined by the {@link Logger} instance attached to the `config` argument to this function
|
|
1171
|
+
*
|
|
1172
|
+
* @param coreCompiler the compiler instance being used for this invocation of Stencil
|
|
1173
|
+
* @param config a validated configuration object to be used for this run of Stencil
|
|
1174
|
+
*/
|
|
1025
1175
|
const startupCompilerLog = (coreCompiler, config) => {
|
|
1026
1176
|
if (config.suppressLogs === true) {
|
|
1027
1177
|
return;
|
|
@@ -1043,6 +1193,21 @@ const startupCompilerLog = (coreCompiler, config) => {
|
|
|
1043
1193
|
}
|
|
1044
1194
|
};
|
|
1045
1195
|
|
|
1196
|
+
const startCheckVersion = async (config, currentVersion) => {
|
|
1197
|
+
if (config.devMode && !config.flags.ci && !currentVersion.includes('-dev.') && isFunction(config.sys.checkVersion)) {
|
|
1198
|
+
return config.sys.checkVersion(config.logger, currentVersion);
|
|
1199
|
+
}
|
|
1200
|
+
return null;
|
|
1201
|
+
};
|
|
1202
|
+
const printCheckVersionResults = async (versionChecker) => {
|
|
1203
|
+
if (versionChecker) {
|
|
1204
|
+
const checkVersionResults = await versionChecker;
|
|
1205
|
+
if (isFunction(checkVersionResults)) {
|
|
1206
|
+
checkVersionResults();
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1046
1211
|
const taskPrerender = async (coreCompiler, config) => {
|
|
1047
1212
|
startupCompilerLog(coreCompiler, config);
|
|
1048
1213
|
const hydrateAppFilePath = config.flags.unknownArgs[0];
|
|
@@ -1074,21 +1239,6 @@ const runPrerenderTask = async (coreCompiler, config, hydrateAppFilePath, compon
|
|
|
1074
1239
|
return diagnostics;
|
|
1075
1240
|
};
|
|
1076
1241
|
|
|
1077
|
-
const startCheckVersion = async (config, currentVersion) => {
|
|
1078
|
-
if (config.devMode && !config.flags.ci && !currentVersion.includes('-dev.') && isFunction(config.sys.checkVersion)) {
|
|
1079
|
-
return config.sys.checkVersion(config.logger, currentVersion);
|
|
1080
|
-
}
|
|
1081
|
-
return null;
|
|
1082
|
-
};
|
|
1083
|
-
const printCheckVersionResults = async (versionChecker) => {
|
|
1084
|
-
if (versionChecker) {
|
|
1085
|
-
const checkVersionResults = await versionChecker;
|
|
1086
|
-
if (isFunction(checkVersionResults)) {
|
|
1087
|
-
checkVersionResults();
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
1242
|
const taskWatch = async (coreCompiler, config) => {
|
|
1093
1243
|
let devServer = null;
|
|
1094
1244
|
let exitCode = 0;
|
|
@@ -1135,6 +1285,15 @@ const taskWatch = async (coreCompiler, config) => {
|
|
|
1135
1285
|
}
|
|
1136
1286
|
};
|
|
1137
1287
|
|
|
1288
|
+
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
1289
|
+
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
1290
|
+
const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
|
|
1291
|
+
const DOCS_CUSTOM = 'docs-custom';
|
|
1292
|
+
const DOCS_JSON = 'docs-json';
|
|
1293
|
+
const DOCS_README = 'docs-readme';
|
|
1294
|
+
const DOCS_VSCODE = 'docs-vscode';
|
|
1295
|
+
const WWW = 'www';
|
|
1296
|
+
|
|
1138
1297
|
const tryFn = async (fn, ...args) => {
|
|
1139
1298
|
try {
|
|
1140
1299
|
return await fn(...args);
|
|
@@ -1148,7 +1307,7 @@ const isInteractive = (sys, flags, object) => {
|
|
|
1148
1307
|
const terminalInfo = object ||
|
|
1149
1308
|
Object.freeze({
|
|
1150
1309
|
tty: sys.isTTY() ? true : false,
|
|
1151
|
-
ci: ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN'].filter((v) => !!sys.getEnvironmentVar(v)).length > 0 || !!flags.ci,
|
|
1310
|
+
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,
|
|
1152
1311
|
});
|
|
1153
1312
|
return terminalInfo.tty && !terminalInfo.ci;
|
|
1154
1313
|
};
|
|
@@ -1177,7 +1336,7 @@ async function readJson(sys, path) {
|
|
|
1177
1336
|
* @returns true if --debug has been passed, otherwise false
|
|
1178
1337
|
*/
|
|
1179
1338
|
function hasDebug(flags) {
|
|
1180
|
-
return flags.debug;
|
|
1339
|
+
return !!flags.debug;
|
|
1181
1340
|
}
|
|
1182
1341
|
/**
|
|
1183
1342
|
* Does the command have the verbose and debug flags?
|
|
@@ -1185,18 +1344,7 @@ function hasDebug(flags) {
|
|
|
1185
1344
|
* @returns true if both --debug and --verbose have been passed, otherwise false
|
|
1186
1345
|
*/
|
|
1187
1346
|
function hasVerbose(flags) {
|
|
1188
|
-
return flags.verbose && hasDebug(flags);
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* Used to determine if tracking should occur.
|
|
1193
|
-
* @param config The config passed into the Stencil command
|
|
1194
|
-
* @param sys The system where the command is invoked
|
|
1195
|
-
* @param ci whether or not the process is running in a Continuous Integration (CI) environment
|
|
1196
|
-
* @returns true if telemetry should be sent, false otherwise
|
|
1197
|
-
*/
|
|
1198
|
-
async function shouldTrack(config, sys, ci) {
|
|
1199
|
-
return !ci && isInteractive(sys, config.flags) && (await checkTelemetry(sys));
|
|
1347
|
+
return !!flags.verbose && hasDebug(flags);
|
|
1200
1348
|
}
|
|
1201
1349
|
|
|
1202
1350
|
const isTest$1 = () => process.env.JEST_WORKER_ID !== undefined;
|
|
@@ -1217,7 +1365,7 @@ async function readConfig(sys) {
|
|
|
1217
1365
|
};
|
|
1218
1366
|
await writeConfig(sys, config);
|
|
1219
1367
|
}
|
|
1220
|
-
else if (!UUID_REGEX.test(config['tokens.telemetry'])) {
|
|
1368
|
+
else if (!config['tokens.telemetry'] || !UUID_REGEX.test(config['tokens.telemetry'])) {
|
|
1221
1369
|
const newUuid = uuidv4();
|
|
1222
1370
|
await writeConfig(sys, { ...config, 'tokens.telemetry': newUuid });
|
|
1223
1371
|
config['tokens.telemetry'] = newUuid;
|
|
@@ -1253,14 +1401,16 @@ async function updateConfig(sys, newOptions) {
|
|
|
1253
1401
|
return await writeConfig(sys, Object.assign(config, newOptions));
|
|
1254
1402
|
}
|
|
1255
1403
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1404
|
+
/**
|
|
1405
|
+
* Used to determine if tracking should occur.
|
|
1406
|
+
* @param config The config passed into the Stencil command
|
|
1407
|
+
* @param sys The system where the command is invoked
|
|
1408
|
+
* @param ci whether or not the process is running in a Continuous Integration (CI) environment
|
|
1409
|
+
* @returns true if telemetry should be sent, false otherwise
|
|
1410
|
+
*/
|
|
1411
|
+
async function shouldTrack(config, sys, ci) {
|
|
1412
|
+
return !ci && isInteractive(sys, config.flags) && (await checkTelemetry(sys));
|
|
1413
|
+
}
|
|
1264
1414
|
|
|
1265
1415
|
/**
|
|
1266
1416
|
* Used to within taskBuild to provide the component_count property.
|
|
@@ -1271,11 +1421,11 @@ const WWW = 'www';
|
|
|
1271
1421
|
* @param result The results of a compiler build.
|
|
1272
1422
|
*/
|
|
1273
1423
|
async function telemetryBuildFinishedAction(sys, config, coreCompiler, result) {
|
|
1274
|
-
const tracking = await shouldTrack(config, sys, config.flags.ci);
|
|
1424
|
+
const tracking = await shouldTrack(config, sys, !!config.flags.ci);
|
|
1275
1425
|
if (!tracking) {
|
|
1276
1426
|
return;
|
|
1277
1427
|
}
|
|
1278
|
-
const component_count = Object.keys(result.componentGraph).length;
|
|
1428
|
+
const component_count = result.componentGraph ? Object.keys(result.componentGraph).length : undefined;
|
|
1279
1429
|
const data = await prepareData(coreCompiler, config, sys, result.duration, component_count);
|
|
1280
1430
|
await sendMetric(sys, config, 'stencil_cli_command', data);
|
|
1281
1431
|
config.logger.debug(`${config.logger.blue('Telemetry')}: ${config.logger.gray(JSON.stringify(data))}`);
|
|
@@ -1354,38 +1504,41 @@ function getActiveTargets(config) {
|
|
|
1354
1504
|
* @returns a Promise wrapping data for the telemetry endpoint
|
|
1355
1505
|
*/
|
|
1356
1506
|
const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
|
|
1507
|
+
var _a, _b, _c;
|
|
1357
1508
|
const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
|
|
1358
1509
|
const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
|
|
1359
1510
|
const targets = getActiveTargets(config);
|
|
1360
1511
|
const yarn = isUsingYarn(sys);
|
|
1361
1512
|
const stencil = coreCompiler.version || 'unknown';
|
|
1362
1513
|
const system = `${sys.name} ${sys.version}`;
|
|
1363
|
-
const os_name = sys.details.platform;
|
|
1364
|
-
const os_version = sys.details.release;
|
|
1365
|
-
const cpu_model = sys.details.cpuModel;
|
|
1514
|
+
const os_name = (_a = sys.details) === null || _a === void 0 ? void 0 : _a.platform;
|
|
1515
|
+
const os_version = (_b = sys.details) === null || _b === void 0 ? void 0 : _b.release;
|
|
1516
|
+
const cpu_model = (_c = sys.details) === null || _c === void 0 ? void 0 : _c.cpuModel;
|
|
1366
1517
|
const build = coreCompiler.buildId || 'unknown';
|
|
1367
1518
|
const has_app_pwa_config = hasAppTarget(config);
|
|
1368
1519
|
const anonymizedConfig = anonymizeConfigForTelemetry(config);
|
|
1520
|
+
const is_browser_env = IS_BROWSER_ENV;
|
|
1369
1521
|
return {
|
|
1370
|
-
|
|
1371
|
-
|
|
1522
|
+
arguments: config.flags.args,
|
|
1523
|
+
build,
|
|
1372
1524
|
component_count,
|
|
1373
|
-
|
|
1525
|
+
config: anonymizedConfig,
|
|
1526
|
+
cpu_model,
|
|
1527
|
+
duration_ms,
|
|
1528
|
+
has_app_pwa_config,
|
|
1529
|
+
is_browser_env,
|
|
1530
|
+
os_name,
|
|
1531
|
+
os_version,
|
|
1374
1532
|
packages,
|
|
1375
1533
|
packages_no_versions: packagesNoVersions,
|
|
1376
|
-
|
|
1377
|
-
task: config.flags.task,
|
|
1534
|
+
rollup,
|
|
1378
1535
|
stencil,
|
|
1379
1536
|
system,
|
|
1380
1537
|
system_major: getMajorVersion(system),
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
cpu_model,
|
|
1384
|
-
build,
|
|
1538
|
+
targets,
|
|
1539
|
+
task: config.flags.task,
|
|
1385
1540
|
typescript,
|
|
1386
|
-
|
|
1387
|
-
has_app_pwa_config,
|
|
1388
|
-
config: anonymizedConfig,
|
|
1541
|
+
yarn,
|
|
1389
1542
|
};
|
|
1390
1543
|
};
|
|
1391
1544
|
// props in output targets for which we retain their original values when
|
|
@@ -1692,13 +1845,6 @@ const taskDocs = async (coreCompiler, config) => {
|
|
|
1692
1845
|
await compiler.destroy();
|
|
1693
1846
|
};
|
|
1694
1847
|
|
|
1695
|
-
const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
1696
|
-
typeof require === 'function' &&
|
|
1697
|
-
!!global.process &&
|
|
1698
|
-
typeof __filename === 'string' &&
|
|
1699
|
-
(!global.origin || typeof global.origin !== 'string');
|
|
1700
|
-
const IS_BROWSER_ENV = typeof location !== 'undefined' && typeof navigator !== 'undefined' && typeof XMLHttpRequest !== 'undefined';
|
|
1701
|
-
|
|
1702
1848
|
/**
|
|
1703
1849
|
* Task to generate component boilerplate and write it to disk. This task can
|
|
1704
1850
|
* cause the program to exit with an error under various circumstances, such as
|
|
@@ -1959,7 +2105,7 @@ const taskTelemetry = async (flags, sys, logger) => {
|
|
|
1959
2105
|
const prompt = logger.dim(sys.details.platform === 'windows' ? '>' : '$');
|
|
1960
2106
|
const isEnabling = flags.args.includes('on');
|
|
1961
2107
|
const isDisabling = flags.args.includes('off');
|
|
1962
|
-
const INFORMATION = `Opt in or
|
|
2108
|
+
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')}`;
|
|
1963
2109
|
const THANK_YOU = `Thank you for helping to make Stencil better! 💖`;
|
|
1964
2110
|
const ENABLED_MESSAGE = `${logger.green('Enabled')}. ${THANK_YOU}\n\n`;
|
|
1965
2111
|
const DISABLED_MESSAGE = `${logger.red('Disabled')}\n\n`;
|
|
@@ -2090,32 +2236,32 @@ const taskTest = async (config) => {
|
|
|
2090
2236
|
config.logger.error(`"test" command is currently only implemented for a NodeJS environment`);
|
|
2091
2237
|
return config.sys.exit(1);
|
|
2092
2238
|
}
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
if
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
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.`));
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
// ensure we've got the required modules installed
|
|
2114
|
-
const diagnostics = await config.sys.lazyRequire.ensure(config.rootDir, ensureModuleIds);
|
|
2115
|
-
if (diagnostics.length > 0) {
|
|
2116
|
-
config.logger.printDiagnostics(diagnostics);
|
|
2117
|
-
return config.sys.exit(1);
|
|
2239
|
+
config.buildDocs = false;
|
|
2240
|
+
const testingRunOpts = {
|
|
2241
|
+
e2e: !!config.flags.e2e,
|
|
2242
|
+
screenshot: !!config.flags.screenshot,
|
|
2243
|
+
spec: !!config.flags.spec,
|
|
2244
|
+
updateScreenshot: !!config.flags.updateScreenshot,
|
|
2245
|
+
};
|
|
2246
|
+
// always ensure we have jest modules installed
|
|
2247
|
+
const ensureModuleIds = ['@types/jest', 'jest', 'jest-cli'];
|
|
2248
|
+
if (testingRunOpts.e2e) {
|
|
2249
|
+
// if it's an e2e test, also make sure we're got
|
|
2250
|
+
// puppeteer modules installed and if browserExecutablePath is provided don't download Chromium use only puppeteer-core instead
|
|
2251
|
+
const puppeteer = config.testing.browserExecutablePath ? 'puppeteer-core' : 'puppeteer';
|
|
2252
|
+
ensureModuleIds.push(puppeteer);
|
|
2253
|
+
if (testingRunOpts.screenshot) {
|
|
2254
|
+
// ensure we've got pixelmatch for screenshots
|
|
2255
|
+
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.`));
|
|
2118
2256
|
}
|
|
2257
|
+
}
|
|
2258
|
+
// ensure we've got the required modules installed
|
|
2259
|
+
const diagnostics = await config.sys.lazyRequire.ensure(config.rootDir, ensureModuleIds);
|
|
2260
|
+
if (diagnostics.length > 0) {
|
|
2261
|
+
config.logger.printDiagnostics(diagnostics);
|
|
2262
|
+
return config.sys.exit(1);
|
|
2263
|
+
}
|
|
2264
|
+
try {
|
|
2119
2265
|
// let's test!
|
|
2120
2266
|
const { createTesting } = await import('../testing/index.js');
|
|
2121
2267
|
const testing = await createTesting(config);
|
|
@@ -2131,95 +2277,6 @@ const taskTest = async (config) => {
|
|
|
2131
2277
|
}
|
|
2132
2278
|
};
|
|
2133
2279
|
|
|
2134
|
-
/**
|
|
2135
|
-
* Creates an instance of a logger
|
|
2136
|
-
* @returns the new logger instance
|
|
2137
|
-
*/
|
|
2138
|
-
const createLogger = () => {
|
|
2139
|
-
let useColors = IS_BROWSER_ENV;
|
|
2140
|
-
let level = 'info';
|
|
2141
|
-
return {
|
|
2142
|
-
enableColors: (uc) => (useColors = uc),
|
|
2143
|
-
getLevel: () => level,
|
|
2144
|
-
setLevel: (l) => (level = l),
|
|
2145
|
-
emoji: (e) => e,
|
|
2146
|
-
info: console.log.bind(console),
|
|
2147
|
-
warn: console.warn.bind(console),
|
|
2148
|
-
error: console.error.bind(console),
|
|
2149
|
-
debug: console.debug.bind(console),
|
|
2150
|
-
red: (msg) => msg,
|
|
2151
|
-
green: (msg) => msg,
|
|
2152
|
-
yellow: (msg) => msg,
|
|
2153
|
-
blue: (msg) => msg,
|
|
2154
|
-
magenta: (msg) => msg,
|
|
2155
|
-
cyan: (msg) => msg,
|
|
2156
|
-
gray: (msg) => msg,
|
|
2157
|
-
bold: (msg) => msg,
|
|
2158
|
-
dim: (msg) => msg,
|
|
2159
|
-
bgRed: (msg) => msg,
|
|
2160
|
-
createTimeSpan: (_startMsg, _debug = false) => ({
|
|
2161
|
-
duration: () => 0,
|
|
2162
|
-
finish: () => 0,
|
|
2163
|
-
}),
|
|
2164
|
-
printDiagnostics(diagnostics) {
|
|
2165
|
-
diagnostics.forEach((diagnostic) => logDiagnostic(diagnostic, useColors));
|
|
2166
|
-
},
|
|
2167
|
-
};
|
|
2168
|
-
};
|
|
2169
|
-
const logDiagnostic = (diagnostic, useColors) => {
|
|
2170
|
-
let color = BLUE;
|
|
2171
|
-
let prefix = 'Build';
|
|
2172
|
-
let msg = '';
|
|
2173
|
-
if (diagnostic.level === 'error') {
|
|
2174
|
-
color = RED;
|
|
2175
|
-
prefix = 'Error';
|
|
2176
|
-
}
|
|
2177
|
-
else if (diagnostic.level === 'warn') {
|
|
2178
|
-
color = YELLOW;
|
|
2179
|
-
prefix = 'Warning';
|
|
2180
|
-
}
|
|
2181
|
-
if (diagnostic.header) {
|
|
2182
|
-
prefix = diagnostic.header;
|
|
2183
|
-
}
|
|
2184
|
-
const filePath = diagnostic.relFilePath || diagnostic.absFilePath;
|
|
2185
|
-
if (filePath) {
|
|
2186
|
-
msg += filePath;
|
|
2187
|
-
if (typeof diagnostic.lineNumber === 'number' && diagnostic.lineNumber > 0) {
|
|
2188
|
-
msg += ', line ' + diagnostic.lineNumber;
|
|
2189
|
-
if (typeof diagnostic.columnNumber === 'number' && diagnostic.columnNumber > 0) {
|
|
2190
|
-
msg += ', column ' + diagnostic.columnNumber;
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
msg += '\n';
|
|
2194
|
-
}
|
|
2195
|
-
msg += diagnostic.messageText;
|
|
2196
|
-
if (diagnostic.lines && diagnostic.lines.length > 0) {
|
|
2197
|
-
diagnostic.lines.forEach((l) => {
|
|
2198
|
-
msg += '\n' + l.lineNumber + ': ' + l.text;
|
|
2199
|
-
});
|
|
2200
|
-
msg += '\n';
|
|
2201
|
-
}
|
|
2202
|
-
if (useColors) {
|
|
2203
|
-
const styledPrefix = [
|
|
2204
|
-
'%c' + prefix,
|
|
2205
|
-
`background: ${color}; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;`,
|
|
2206
|
-
];
|
|
2207
|
-
console.log(...styledPrefix, msg);
|
|
2208
|
-
}
|
|
2209
|
-
else if (diagnostic.level === 'error') {
|
|
2210
|
-
console.error(msg);
|
|
2211
|
-
}
|
|
2212
|
-
else if (diagnostic.level === 'warn') {
|
|
2213
|
-
console.warn(msg);
|
|
2214
|
-
}
|
|
2215
|
-
else {
|
|
2216
|
-
console.log(msg);
|
|
2217
|
-
}
|
|
2218
|
-
};
|
|
2219
|
-
const YELLOW = `#f39c12`;
|
|
2220
|
-
const RED = `#c0392b`;
|
|
2221
|
-
const BLUE = `#3498db`;
|
|
2222
|
-
|
|
2223
2280
|
const run = async (init) => {
|
|
2224
2281
|
const { args, logger, sys } = init;
|
|
2225
2282
|
try {
|
|
@@ -2234,7 +2291,7 @@ const run = async (init) => {
|
|
|
2234
2291
|
if (isFunction(sys.applyGlobalPatch)) {
|
|
2235
2292
|
sys.applyGlobalPatch(sys.getCurrentDirectory());
|
|
2236
2293
|
}
|
|
2237
|
-
if (task === 'help' || flags.help) {
|
|
2294
|
+
if (!task || task === 'help' || flags.help) {
|
|
2238
2295
|
await taskHelp(createConfigFlags({ task: 'help', args }), logger, sys);
|
|
2239
2296
|
return;
|
|
2240
2297
|
}
|