@rindo/core 2.17.1 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/config-flags.d.ts +12 -4
- package/cli/index.cjs +113 -73
- package/cli/index.d.ts +1 -1
- package/cli/index.js +113 -73
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +348 -61
- package/compiler/rindo.min.js +2 -2
- package/dependencies.json +1 -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 +1 -1
- 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 +1 -1
- package/internal/hydrate/package.json +1 -1
- package/internal/package.json +1 -1
- package/internal/rindo-private.d.ts +12 -2
- package/internal/rindo-public-compiler.d.ts +1 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +41 -3
- package/mock-doc/index.d.ts +15 -0
- package/mock-doc/index.js +41 -3
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +1 -1
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +37 -22
- package/testing/mocks.d.ts +7 -6
- package/testing/package.json +1 -1
package/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo CLI v2.17.
|
|
2
|
+
Rindo CLI v2.17.2 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* This sets the log level hierarchy for our terminal logger, ranging from
|
|
@@ -497,46 +497,54 @@ const CLI_ARG_ALIASES = {
|
|
|
497
497
|
help: 'h',
|
|
498
498
|
port: 'p',
|
|
499
499
|
version: 'v',
|
|
500
|
-
};
|
|
501
|
-
|
|
500
|
+
};
|
|
502
501
|
/**
|
|
503
|
-
*
|
|
502
|
+
* Helper function for initializing a `ConfigFlags` object. Provide any overrides
|
|
503
|
+
* for default values and off you go!
|
|
504
504
|
*
|
|
505
|
-
* @param
|
|
506
|
-
* @
|
|
507
|
-
* @returns a structured ConfigFlags object
|
|
505
|
+
* @param init an object with any overrides for default values
|
|
506
|
+
* @returns a complete CLI flag object
|
|
508
507
|
*/
|
|
509
|
-
const
|
|
508
|
+
const createConfigFlags = (init = {}) => {
|
|
510
509
|
const flags = {
|
|
511
510
|
task: null,
|
|
512
511
|
args: [],
|
|
513
512
|
knownArgs: [],
|
|
514
513
|
unknownArgs: [],
|
|
514
|
+
...init,
|
|
515
515
|
};
|
|
516
|
+
return flags;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Parse command line arguments into a structured `ConfigFlags` object
|
|
521
|
+
*
|
|
522
|
+
* @param args an array of CLI flags
|
|
523
|
+
* @param _sys an optional compiler system
|
|
524
|
+
* @returns a structured ConfigFlags object
|
|
525
|
+
*/
|
|
526
|
+
const parseFlags = (args, _sys) => {
|
|
527
|
+
// TODO: remove the _sys parameter here ^^ (for v3)
|
|
528
|
+
const flags = createConfigFlags();
|
|
516
529
|
// cmd line has more priority over npm scripts cmd
|
|
517
530
|
flags.args = Array.isArray(args) ? args.slice() : [];
|
|
518
531
|
if (flags.args.length > 0 && flags.args[0] && !flags.args[0].startsWith('-')) {
|
|
519
532
|
flags.task = flags.args[0];
|
|
520
533
|
}
|
|
521
534
|
parseArgs(flags, flags.args);
|
|
522
|
-
if (sys && sys.name === 'node') {
|
|
523
|
-
const envArgs = getNpmConfigEnvArgs(sys);
|
|
524
|
-
parseArgs(flags, envArgs);
|
|
525
|
-
envArgs.forEach((envArg) => {
|
|
526
|
-
if (!flags.args.includes(envArg)) {
|
|
527
|
-
flags.args.push(envArg);
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
535
|
if (flags.task != null) {
|
|
532
536
|
const i = flags.args.indexOf(flags.task);
|
|
533
537
|
if (i > -1) {
|
|
534
538
|
flags.args.splice(i, 1);
|
|
535
539
|
}
|
|
536
540
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
541
|
+
// to find unknown / unrecognized arguments we filter `args`, including only
|
|
542
|
+
// arguments whose normalized form is not found in `knownArgs`. `knownArgs`
|
|
543
|
+
// is populated during the call to `parseArgs` above. For arguments like
|
|
544
|
+
// `--foobar` the string `"--foobar"` will be added, while for more
|
|
545
|
+
// complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
|
|
546
|
+
// string `"--bizBoz"` will be added.
|
|
547
|
+
flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
|
|
540
548
|
return flags;
|
|
541
549
|
};
|
|
542
550
|
/**
|
|
@@ -722,17 +730,17 @@ const getValue = (args, configCaseName) => {
|
|
|
722
730
|
let matchingArg;
|
|
723
731
|
args.forEach((arg, i) => {
|
|
724
732
|
if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
|
|
725
|
-
|
|
726
|
-
matchingArg = arg;
|
|
733
|
+
// our argument was passed at the command-line in the format --argName=arg-value
|
|
734
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
727
735
|
}
|
|
728
736
|
else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
|
|
737
|
+
// the next value in the array is assumed to be a value for this argument
|
|
729
738
|
value = args[i + 1];
|
|
730
739
|
matchingArg = arg;
|
|
731
740
|
}
|
|
732
741
|
else if (alias) {
|
|
733
742
|
if (arg.startsWith(`-${alias}=`)) {
|
|
734
|
-
value =
|
|
735
|
-
matchingArg = arg;
|
|
743
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
736
744
|
}
|
|
737
745
|
else if (arg === `-${alias}`) {
|
|
738
746
|
value = args[i + 1];
|
|
@@ -743,13 +751,42 @@ const getValue = (args, configCaseName) => {
|
|
|
743
751
|
return { value, matchingArg };
|
|
744
752
|
};
|
|
745
753
|
/**
|
|
746
|
-
*
|
|
747
|
-
* `--foobar
|
|
754
|
+
* Parse an 'equals' argument, which is a CLI argument-value pair in the
|
|
755
|
+
* format `--foobar=12` (as opposed to a space-separated format like
|
|
756
|
+
* `--foobar 12`).
|
|
757
|
+
*
|
|
758
|
+
* To parse this we split on the `=`, returning the first part as the argument
|
|
759
|
+
* name and the second part as the value. We join the value on `"="` in case
|
|
760
|
+
* there is another `"="` in the argument.
|
|
761
|
+
*
|
|
762
|
+
* This function is safe to call with any arg, and can therefore be used as
|
|
763
|
+
* an argument 'normalizer'. If CLI argument is not an 'equals' argument then
|
|
764
|
+
* the return value will be a tuple of the original argument and an empty
|
|
765
|
+
* string `""` for the value.
|
|
766
|
+
*
|
|
767
|
+
* In code terms, if you do:
|
|
768
|
+
*
|
|
769
|
+
* ```ts
|
|
770
|
+
* const [arg, value] = parseEqualsArg("--myArgument")
|
|
771
|
+
* ```
|
|
772
|
+
*
|
|
773
|
+
* Then `arg` will be `"--myArgument"` and `value` will be `""`, whereas if
|
|
774
|
+
* you do:
|
|
775
|
+
*
|
|
748
776
|
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
777
|
+
* ```ts
|
|
778
|
+
* const [arg, value] = parseEqualsArg("--myArgument=myValue")
|
|
779
|
+
* ```
|
|
780
|
+
*
|
|
781
|
+
* Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
|
|
782
|
+
*
|
|
783
|
+
* @param arg the arg in question
|
|
784
|
+
* @returns a tuple containing the arg name and the value (if present)
|
|
751
785
|
*/
|
|
752
|
-
const
|
|
786
|
+
const parseEqualsArg = (arg) => {
|
|
787
|
+
const [originalArg, ...value] = arg.split('=');
|
|
788
|
+
return [originalArg, value.join('=')];
|
|
789
|
+
};
|
|
753
790
|
/**
|
|
754
791
|
* Small helper for getting type-system-level assurance that a `string` can be
|
|
755
792
|
* narrowed to a `LogLevel`
|
|
@@ -763,28 +800,12 @@ const isLogLevel = (maybeLogLevel) =>
|
|
|
763
800
|
// `ReadonlyArray` 😢 thus we `as any`
|
|
764
801
|
//
|
|
765
802
|
// see microsoft/TypeScript#31018 for some discussion of this
|
|
766
|
-
LOG_LEVELS.includes(maybeLogLevel);
|
|
767
|
-
const getNpmConfigEnvArgs = (sys) => {
|
|
768
|
-
// process.env.npm_config_argv
|
|
769
|
-
// {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
|
|
770
|
-
let args = [];
|
|
771
|
-
try {
|
|
772
|
-
const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
|
|
773
|
-
if (npmConfigArgs) {
|
|
774
|
-
args = JSON.parse(npmConfigArgs).original;
|
|
775
|
-
if (args[0] === 'run') {
|
|
776
|
-
args = args.slice(2);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
catch (e) { }
|
|
781
|
-
return args;
|
|
782
|
-
};
|
|
803
|
+
LOG_LEVELS.includes(maybeLogLevel);
|
|
783
804
|
|
|
784
805
|
const dependencies = [
|
|
785
806
|
{
|
|
786
807
|
name: "@rindo/core",
|
|
787
|
-
version: "2.17.
|
|
808
|
+
version: "2.17.2",
|
|
788
809
|
main: "compiler/rindo.js",
|
|
789
810
|
resources: [
|
|
790
811
|
"package.json",
|
|
@@ -1118,6 +1139,7 @@ const isInteractive = (sys, flags, object) => {
|
|
|
1118
1139
|
return terminalInfo.tty && !terminalInfo.ci;
|
|
1119
1140
|
};
|
|
1120
1141
|
const UUID_REGEX = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i);
|
|
1142
|
+
// Plucked from https://github.com/navify/jigra/blob/HEAD/cli/src/util/uuid.ts
|
|
1121
1143
|
function uuidv4() {
|
|
1122
1144
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
1123
1145
|
const r = (Math.random() * 16) | 0;
|
|
@@ -1279,6 +1301,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
|
|
|
1279
1301
|
throw error;
|
|
1280
1302
|
}
|
|
1281
1303
|
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Helper function to determine if a Rindo configuration builds an application.
|
|
1306
|
+
*
|
|
1307
|
+
* This function is a rough approximation whether an application is generated as a part of a Rindo build, based on
|
|
1308
|
+
* contents of the project's `rindo.config.ts` file.
|
|
1309
|
+
*
|
|
1310
|
+
* @param config the configuration used by the Rindo project
|
|
1311
|
+
* @returns true if we believe the project generates an application, false otherwise
|
|
1312
|
+
*/
|
|
1282
1313
|
function hasAppTarget(config) {
|
|
1283
1314
|
return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
|
|
1284
1315
|
}
|
|
@@ -1286,7 +1317,15 @@ function isUsingYarn(sys) {
|
|
|
1286
1317
|
var _a;
|
|
1287
1318
|
return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
|
|
1288
1319
|
}
|
|
1289
|
-
|
|
1320
|
+
/**
|
|
1321
|
+
* Build a list of the different types of output targets used in a Rindo configuration.
|
|
1322
|
+
*
|
|
1323
|
+
* Duplicate entries will not be returned from the list
|
|
1324
|
+
*
|
|
1325
|
+
* @param config the configuration used by the Rindo project
|
|
1326
|
+
* @returns a unique list of output target types found in the Rindo configuration
|
|
1327
|
+
*/
|
|
1328
|
+
function getActiveTargets(config) {
|
|
1290
1329
|
const result = config.outputTargets.map((t) => t.type);
|
|
1291
1330
|
return Array.from(new Set(result));
|
|
1292
1331
|
}
|
|
@@ -1303,7 +1342,7 @@ async function getActiveTargets(config) {
|
|
|
1303
1342
|
const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
|
|
1304
1343
|
const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
|
|
1305
1344
|
const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
|
|
1306
|
-
const targets =
|
|
1345
|
+
const targets = getActiveTargets(config);
|
|
1307
1346
|
const yarn = isUsingYarn(sys);
|
|
1308
1347
|
const rindo = coreCompiler.version || 'unknown';
|
|
1309
1348
|
const system = `${sys.name} ${sys.version}`;
|
|
@@ -1366,14 +1405,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
|
|
|
1366
1405
|
* @returns an anonymized copy of the same config
|
|
1367
1406
|
*/
|
|
1368
1407
|
const anonymizeConfigForTelemetry = (config) => {
|
|
1369
|
-
var _a;
|
|
1370
1408
|
const anonymizedConfig = { ...config };
|
|
1371
1409
|
for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
|
|
1372
1410
|
if (anonymizedConfig[prop] !== undefined) {
|
|
1373
1411
|
anonymizedConfig[prop] = 'omitted';
|
|
1374
1412
|
}
|
|
1375
1413
|
}
|
|
1376
|
-
anonymizedConfig.outputTargets =
|
|
1414
|
+
anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
|
|
1377
1415
|
// Anonymize the outputTargets on our configuration, taking advantage of the
|
|
1378
1416
|
// optional 2nd argument to `JSON.stringify`. If anything is not a string
|
|
1379
1417
|
// we retain it so that any nested properties are handled, else we check
|
|
@@ -1594,7 +1632,7 @@ function getMajorVersion(version) {
|
|
|
1594
1632
|
return parts[0];
|
|
1595
1633
|
}
|
|
1596
1634
|
|
|
1597
|
-
const taskBuild = async (coreCompiler, config
|
|
1635
|
+
const taskBuild = async (coreCompiler, config) => {
|
|
1598
1636
|
if (config.flags.watch) {
|
|
1599
1637
|
// watch build
|
|
1600
1638
|
await taskWatch(coreCompiler, config);
|
|
@@ -1607,10 +1645,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
|
|
|
1607
1645
|
const versionChecker = startCheckVersion(config, coreCompiler.version);
|
|
1608
1646
|
const compiler = await coreCompiler.createCompiler(config);
|
|
1609
1647
|
const results = await compiler.build();
|
|
1610
|
-
|
|
1611
|
-
if (sys) {
|
|
1612
|
-
await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
|
|
1613
|
-
}
|
|
1648
|
+
await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
|
|
1614
1649
|
await compiler.destroy();
|
|
1615
1650
|
if (results.hasError) {
|
|
1616
1651
|
exitCode = 1;
|
|
@@ -1974,10 +2009,7 @@ const taskHelp = async (flags, logger, sys) => {
|
|
|
1974
2009
|
${prompt} ${logger.green('rindo generate')} or ${logger.green('rindo g')}
|
|
1975
2010
|
|
|
1976
2011
|
`);
|
|
1977
|
-
|
|
1978
|
-
if (sys) {
|
|
1979
|
-
await taskTelemetry(flags, sys, logger);
|
|
1980
|
-
}
|
|
2012
|
+
await taskTelemetry(flags, sys, logger);
|
|
1981
2013
|
console.log(`
|
|
1982
2014
|
${logger.bold('Examples:')}
|
|
1983
2015
|
|
|
@@ -2125,7 +2157,7 @@ const BLUE = `#3498db`;
|
|
|
2125
2157
|
const run = async (init) => {
|
|
2126
2158
|
const { args, logger, sys } = init;
|
|
2127
2159
|
try {
|
|
2128
|
-
const flags = parseFlags(args
|
|
2160
|
+
const flags = parseFlags(args);
|
|
2129
2161
|
const task = flags.task;
|
|
2130
2162
|
if (flags.debug || flags.verbose) {
|
|
2131
2163
|
logger.setLevel('debug');
|
|
@@ -2137,7 +2169,7 @@ const run = async (init) => {
|
|
|
2137
2169
|
sys.applyGlobalPatch(sys.getCurrentDirectory());
|
|
2138
2170
|
}
|
|
2139
2171
|
if (task === 'help' || flags.help) {
|
|
2140
|
-
await taskHelp({ task: 'help', args }, logger, sys);
|
|
2172
|
+
await taskHelp(createConfigFlags({ task: 'help', args }), logger, sys);
|
|
2141
2173
|
return;
|
|
2142
2174
|
}
|
|
2143
2175
|
startupLog(logger, task);
|
|
@@ -2163,9 +2195,7 @@ const run = async (init) => {
|
|
|
2163
2195
|
startupLogVersion(logger, task, coreCompiler);
|
|
2164
2196
|
loadedCompilerLog(sys, logger, flags, coreCompiler);
|
|
2165
2197
|
if (task === 'info') {
|
|
2166
|
-
|
|
2167
|
-
await taskInfo(coreCompiler, sys, logger);
|
|
2168
|
-
});
|
|
2198
|
+
taskInfo(coreCompiler, sys, logger);
|
|
2169
2199
|
return;
|
|
2170
2200
|
}
|
|
2171
2201
|
const validated = await coreCompiler.loadConfig({
|
|
@@ -2198,14 +2228,27 @@ const run = async (init) => {
|
|
|
2198
2228
|
}
|
|
2199
2229
|
}
|
|
2200
2230
|
};
|
|
2231
|
+
/**
|
|
2232
|
+
* Run a specified task
|
|
2233
|
+
* @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
|
|
2234
|
+
* @param config a configuration for the Rindo project to apply to the task run
|
|
2235
|
+
* @param task the task to run
|
|
2236
|
+
* @param sys the {@link CompilerSystem} for interacting with the operating system
|
|
2237
|
+
* @public
|
|
2238
|
+
*/
|
|
2201
2239
|
const runTask = async (coreCompiler, config, task, sys) => {
|
|
2202
|
-
var _a, _b;
|
|
2240
|
+
var _a, _b, _c;
|
|
2203
2241
|
const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
|
|
2204
|
-
const strictConfig = {
|
|
2205
|
-
|
|
2242
|
+
const strictConfig = {
|
|
2243
|
+
...config,
|
|
2244
|
+
flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
|
|
2245
|
+
logger,
|
|
2246
|
+
outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
|
|
2247
|
+
sys: sys !== null && sys !== void 0 ? sys : coreCompiler.createSystem({ logger }),
|
|
2248
|
+
};
|
|
2206
2249
|
switch (task) {
|
|
2207
2250
|
case 'build':
|
|
2208
|
-
await taskBuild(coreCompiler, strictConfig
|
|
2251
|
+
await taskBuild(coreCompiler, strictConfig);
|
|
2209
2252
|
break;
|
|
2210
2253
|
case 'docs':
|
|
2211
2254
|
await taskDocs(coreCompiler, strictConfig);
|
|
@@ -2224,10 +2267,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
|
|
|
2224
2267
|
await taskServe(strictConfig);
|
|
2225
2268
|
break;
|
|
2226
2269
|
case 'telemetry':
|
|
2227
|
-
|
|
2228
|
-
if (sys) {
|
|
2229
|
-
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2230
|
-
}
|
|
2270
|
+
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2231
2271
|
break;
|
|
2232
2272
|
case 'version':
|
|
2233
2273
|
console.log(coreCompiler.version);
|
package/cli/package.json
CHANGED