@rindo/core 2.17.2-0 → 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/index.cjs +95 -68
- package/cli/index.d.ts +1 -1
- package/cli/index.js +95 -68
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +292 -54
- 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 +16 -1
- package/mock-doc/index.d.ts +5 -0
- package/mock-doc/index.js +16 -1
- 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 +28 -21
- package/testing/mocks.d.ts +7 -6
- package/testing/package.json +1 -1
package/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo CLI (CommonJS) v2.17.2
|
|
2
|
+
Rindo CLI (CommonJS) v2.17.2 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -543,11 +543,12 @@ const createConfigFlags = (init = {}) => {
|
|
|
543
543
|
/**
|
|
544
544
|
* Parse command line arguments into a structured `ConfigFlags` object
|
|
545
545
|
*
|
|
546
|
-
* @param args an array of
|
|
547
|
-
* @param
|
|
546
|
+
* @param args an array of CLI flags
|
|
547
|
+
* @param _sys an optional compiler system
|
|
548
548
|
* @returns a structured ConfigFlags object
|
|
549
549
|
*/
|
|
550
|
-
const parseFlags = (args,
|
|
550
|
+
const parseFlags = (args, _sys) => {
|
|
551
|
+
// TODO: remove the _sys parameter here ^^ (for v3)
|
|
551
552
|
const flags = createConfigFlags();
|
|
552
553
|
// cmd line has more priority over npm scripts cmd
|
|
553
554
|
flags.args = Array.isArray(args) ? args.slice() : [];
|
|
@@ -555,24 +556,19 @@ const parseFlags = (args, sys) => {
|
|
|
555
556
|
flags.task = flags.args[0];
|
|
556
557
|
}
|
|
557
558
|
parseArgs(flags, flags.args);
|
|
558
|
-
if (sys && sys.name === 'node') {
|
|
559
|
-
const envArgs = getNpmConfigEnvArgs(sys);
|
|
560
|
-
parseArgs(flags, envArgs);
|
|
561
|
-
envArgs.forEach((envArg) => {
|
|
562
|
-
if (!flags.args.includes(envArg)) {
|
|
563
|
-
flags.args.push(envArg);
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
559
|
if (flags.task != null) {
|
|
568
560
|
const i = flags.args.indexOf(flags.task);
|
|
569
561
|
if (i > -1) {
|
|
570
562
|
flags.args.splice(i, 1);
|
|
571
563
|
}
|
|
572
564
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
565
|
+
// to find unknown / unrecognized arguments we filter `args`, including only
|
|
566
|
+
// arguments whose normalized form is not found in `knownArgs`. `knownArgs`
|
|
567
|
+
// is populated during the call to `parseArgs` above. For arguments like
|
|
568
|
+
// `--foobar` the string `"--foobar"` will be added, while for more
|
|
569
|
+
// complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
|
|
570
|
+
// string `"--bizBoz"` will be added.
|
|
571
|
+
flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
|
|
576
572
|
return flags;
|
|
577
573
|
};
|
|
578
574
|
/**
|
|
@@ -758,17 +754,17 @@ const getValue = (args, configCaseName) => {
|
|
|
758
754
|
let matchingArg;
|
|
759
755
|
args.forEach((arg, i) => {
|
|
760
756
|
if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
|
|
761
|
-
|
|
762
|
-
matchingArg = arg;
|
|
757
|
+
// our argument was passed at the command-line in the format --argName=arg-value
|
|
758
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
763
759
|
}
|
|
764
760
|
else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
|
|
761
|
+
// the next value in the array is assumed to be a value for this argument
|
|
765
762
|
value = args[i + 1];
|
|
766
763
|
matchingArg = arg;
|
|
767
764
|
}
|
|
768
765
|
else if (alias) {
|
|
769
766
|
if (arg.startsWith(`-${alias}=`)) {
|
|
770
|
-
value =
|
|
771
|
-
matchingArg = arg;
|
|
767
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
772
768
|
}
|
|
773
769
|
else if (arg === `-${alias}`) {
|
|
774
770
|
value = args[i + 1];
|
|
@@ -779,13 +775,42 @@ const getValue = (args, configCaseName) => {
|
|
|
779
775
|
return { value, matchingArg };
|
|
780
776
|
};
|
|
781
777
|
/**
|
|
782
|
-
*
|
|
783
|
-
* `--foobar
|
|
778
|
+
* Parse an 'equals' argument, which is a CLI argument-value pair in the
|
|
779
|
+
* format `--foobar=12` (as opposed to a space-separated format like
|
|
780
|
+
* `--foobar 12`).
|
|
781
|
+
*
|
|
782
|
+
* To parse this we split on the `=`, returning the first part as the argument
|
|
783
|
+
* name and the second part as the value. We join the value on `"="` in case
|
|
784
|
+
* there is another `"="` in the argument.
|
|
785
|
+
*
|
|
786
|
+
* This function is safe to call with any arg, and can therefore be used as
|
|
787
|
+
* an argument 'normalizer'. If CLI argument is not an 'equals' argument then
|
|
788
|
+
* the return value will be a tuple of the original argument and an empty
|
|
789
|
+
* string `""` for the value.
|
|
790
|
+
*
|
|
791
|
+
* In code terms, if you do:
|
|
792
|
+
*
|
|
793
|
+
* ```ts
|
|
794
|
+
* const [arg, value] = parseEqualsArg("--myArgument")
|
|
795
|
+
* ```
|
|
796
|
+
*
|
|
797
|
+
* Then `arg` will be `"--myArgument"` and `value` will be `""`, whereas if
|
|
798
|
+
* you do:
|
|
799
|
+
*
|
|
800
|
+
*
|
|
801
|
+
* ```ts
|
|
802
|
+
* const [arg, value] = parseEqualsArg("--myArgument=myValue")
|
|
803
|
+
* ```
|
|
804
|
+
*
|
|
805
|
+
* Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
|
|
784
806
|
*
|
|
785
|
-
* @param
|
|
786
|
-
* @returns the
|
|
807
|
+
* @param arg the arg in question
|
|
808
|
+
* @returns a tuple containing the arg name and the value (if present)
|
|
787
809
|
*/
|
|
788
|
-
const
|
|
810
|
+
const parseEqualsArg = (arg) => {
|
|
811
|
+
const [originalArg, ...value] = arg.split('=');
|
|
812
|
+
return [originalArg, value.join('=')];
|
|
813
|
+
};
|
|
789
814
|
/**
|
|
790
815
|
* Small helper for getting type-system-level assurance that a `string` can be
|
|
791
816
|
* narrowed to a `LogLevel`
|
|
@@ -799,28 +824,12 @@ const isLogLevel = (maybeLogLevel) =>
|
|
|
799
824
|
// `ReadonlyArray` 😢 thus we `as any`
|
|
800
825
|
//
|
|
801
826
|
// see microsoft/TypeScript#31018 for some discussion of this
|
|
802
|
-
LOG_LEVELS.includes(maybeLogLevel);
|
|
803
|
-
const getNpmConfigEnvArgs = (sys) => {
|
|
804
|
-
// process.env.npm_config_argv
|
|
805
|
-
// {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
|
|
806
|
-
let args = [];
|
|
807
|
-
try {
|
|
808
|
-
const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
|
|
809
|
-
if (npmConfigArgs) {
|
|
810
|
-
args = JSON.parse(npmConfigArgs).original;
|
|
811
|
-
if (args[0] === 'run') {
|
|
812
|
-
args = args.slice(2);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
catch (e) { }
|
|
817
|
-
return args;
|
|
818
|
-
};
|
|
827
|
+
LOG_LEVELS.includes(maybeLogLevel);
|
|
819
828
|
|
|
820
829
|
const dependencies = [
|
|
821
830
|
{
|
|
822
831
|
name: "@rindo/core",
|
|
823
|
-
version: "2.17.2
|
|
832
|
+
version: "2.17.2",
|
|
824
833
|
main: "compiler/rindo.js",
|
|
825
834
|
resources: [
|
|
826
835
|
"package.json",
|
|
@@ -1316,6 +1325,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
|
|
|
1316
1325
|
throw error;
|
|
1317
1326
|
}
|
|
1318
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Helper function to determine if a Rindo configuration builds an application.
|
|
1330
|
+
*
|
|
1331
|
+
* This function is a rough approximation whether an application is generated as a part of a Rindo build, based on
|
|
1332
|
+
* contents of the project's `rindo.config.ts` file.
|
|
1333
|
+
*
|
|
1334
|
+
* @param config the configuration used by the Rindo project
|
|
1335
|
+
* @returns true if we believe the project generates an application, false otherwise
|
|
1336
|
+
*/
|
|
1319
1337
|
function hasAppTarget(config) {
|
|
1320
1338
|
return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
|
|
1321
1339
|
}
|
|
@@ -1323,7 +1341,15 @@ function isUsingYarn(sys) {
|
|
|
1323
1341
|
var _a;
|
|
1324
1342
|
return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
|
|
1325
1343
|
}
|
|
1326
|
-
|
|
1344
|
+
/**
|
|
1345
|
+
* Build a list of the different types of output targets used in a Rindo configuration.
|
|
1346
|
+
*
|
|
1347
|
+
* Duplicate entries will not be returned from the list
|
|
1348
|
+
*
|
|
1349
|
+
* @param config the configuration used by the Rindo project
|
|
1350
|
+
* @returns a unique list of output target types found in the Rindo configuration
|
|
1351
|
+
*/
|
|
1352
|
+
function getActiveTargets(config) {
|
|
1327
1353
|
const result = config.outputTargets.map((t) => t.type);
|
|
1328
1354
|
return Array.from(new Set(result));
|
|
1329
1355
|
}
|
|
@@ -1340,7 +1366,7 @@ async function getActiveTargets(config) {
|
|
|
1340
1366
|
const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
|
|
1341
1367
|
const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
|
|
1342
1368
|
const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
|
|
1343
|
-
const targets =
|
|
1369
|
+
const targets = getActiveTargets(config);
|
|
1344
1370
|
const yarn = isUsingYarn(sys);
|
|
1345
1371
|
const rindo = coreCompiler.version || 'unknown';
|
|
1346
1372
|
const system = `${sys.name} ${sys.version}`;
|
|
@@ -1403,14 +1429,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
|
|
|
1403
1429
|
* @returns an anonymized copy of the same config
|
|
1404
1430
|
*/
|
|
1405
1431
|
const anonymizeConfigForTelemetry = (config) => {
|
|
1406
|
-
var _a;
|
|
1407
1432
|
const anonymizedConfig = { ...config };
|
|
1408
1433
|
for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
|
|
1409
1434
|
if (anonymizedConfig[prop] !== undefined) {
|
|
1410
1435
|
anonymizedConfig[prop] = 'omitted';
|
|
1411
1436
|
}
|
|
1412
1437
|
}
|
|
1413
|
-
anonymizedConfig.outputTargets =
|
|
1438
|
+
anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
|
|
1414
1439
|
// Anonymize the outputTargets on our configuration, taking advantage of the
|
|
1415
1440
|
// optional 2nd argument to `JSON.stringify`. If anything is not a string
|
|
1416
1441
|
// we retain it so that any nested properties are handled, else we check
|
|
@@ -1631,7 +1656,7 @@ function getMajorVersion(version) {
|
|
|
1631
1656
|
return parts[0];
|
|
1632
1657
|
}
|
|
1633
1658
|
|
|
1634
|
-
const taskBuild = async (coreCompiler, config
|
|
1659
|
+
const taskBuild = async (coreCompiler, config) => {
|
|
1635
1660
|
if (config.flags.watch) {
|
|
1636
1661
|
// watch build
|
|
1637
1662
|
await taskWatch(coreCompiler, config);
|
|
@@ -1644,10 +1669,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
|
|
|
1644
1669
|
const versionChecker = startCheckVersion(config, coreCompiler.version);
|
|
1645
1670
|
const compiler = await coreCompiler.createCompiler(config);
|
|
1646
1671
|
const results = await compiler.build();
|
|
1647
|
-
|
|
1648
|
-
if (sys) {
|
|
1649
|
-
await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
|
|
1650
|
-
}
|
|
1672
|
+
await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
|
|
1651
1673
|
await compiler.destroy();
|
|
1652
1674
|
if (results.hasError) {
|
|
1653
1675
|
exitCode = 1;
|
|
@@ -2011,10 +2033,7 @@ const taskHelp = async (flags, logger, sys) => {
|
|
|
2011
2033
|
${prompt} ${logger.green('rindo generate')} or ${logger.green('rindo g')}
|
|
2012
2034
|
|
|
2013
2035
|
`);
|
|
2014
|
-
|
|
2015
|
-
if (sys) {
|
|
2016
|
-
await taskTelemetry(flags, sys, logger);
|
|
2017
|
-
}
|
|
2036
|
+
await taskTelemetry(flags, sys, logger);
|
|
2018
2037
|
console.log(`
|
|
2019
2038
|
${logger.bold('Examples:')}
|
|
2020
2039
|
|
|
@@ -2162,7 +2181,7 @@ const BLUE = `#3498db`;
|
|
|
2162
2181
|
const run = async (init) => {
|
|
2163
2182
|
const { args, logger, sys } = init;
|
|
2164
2183
|
try {
|
|
2165
|
-
const flags = parseFlags(args
|
|
2184
|
+
const flags = parseFlags(args);
|
|
2166
2185
|
const task = flags.task;
|
|
2167
2186
|
if (flags.debug || flags.verbose) {
|
|
2168
2187
|
logger.setLevel('debug');
|
|
@@ -2200,9 +2219,7 @@ const run = async (init) => {
|
|
|
2200
2219
|
startupLogVersion(logger, task, coreCompiler);
|
|
2201
2220
|
loadedCompilerLog(sys, logger, flags, coreCompiler);
|
|
2202
2221
|
if (task === 'info') {
|
|
2203
|
-
|
|
2204
|
-
await taskInfo(coreCompiler, sys, logger);
|
|
2205
|
-
});
|
|
2222
|
+
taskInfo(coreCompiler, sys, logger);
|
|
2206
2223
|
return;
|
|
2207
2224
|
}
|
|
2208
2225
|
const validated = await coreCompiler.loadConfig({
|
|
@@ -2235,14 +2252,27 @@ const run = async (init) => {
|
|
|
2235
2252
|
}
|
|
2236
2253
|
}
|
|
2237
2254
|
};
|
|
2255
|
+
/**
|
|
2256
|
+
* Run a specified task
|
|
2257
|
+
* @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
|
|
2258
|
+
* @param config a configuration for the Rindo project to apply to the task run
|
|
2259
|
+
* @param task the task to run
|
|
2260
|
+
* @param sys the {@link CompilerSystem} for interacting with the operating system
|
|
2261
|
+
* @public
|
|
2262
|
+
*/
|
|
2238
2263
|
const runTask = async (coreCompiler, config, task, sys) => {
|
|
2239
|
-
var _a, _b;
|
|
2264
|
+
var _a, _b, _c;
|
|
2240
2265
|
const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
|
|
2241
|
-
const strictConfig = {
|
|
2242
|
-
|
|
2266
|
+
const strictConfig = {
|
|
2267
|
+
...config,
|
|
2268
|
+
flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
|
|
2269
|
+
logger,
|
|
2270
|
+
outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
|
|
2271
|
+
sys: sys !== null && sys !== void 0 ? sys : coreCompiler.createSystem({ logger }),
|
|
2272
|
+
};
|
|
2243
2273
|
switch (task) {
|
|
2244
2274
|
case 'build':
|
|
2245
|
-
await taskBuild(coreCompiler, strictConfig
|
|
2275
|
+
await taskBuild(coreCompiler, strictConfig);
|
|
2246
2276
|
break;
|
|
2247
2277
|
case 'docs':
|
|
2248
2278
|
await taskDocs(coreCompiler, strictConfig);
|
|
@@ -2261,10 +2291,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
|
|
|
2261
2291
|
await taskServe(strictConfig);
|
|
2262
2292
|
break;
|
|
2263
2293
|
case 'telemetry':
|
|
2264
|
-
|
|
2265
|
-
if (sys) {
|
|
2266
|
-
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2267
|
-
}
|
|
2294
|
+
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2268
2295
|
break;
|
|
2269
2296
|
case 'version':
|
|
2270
2297
|
console.log(coreCompiler.version);
|
package/cli/index.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export declare function run(init: CliInitOptions): Promise<void>;
|
|
|
12
12
|
* @param task The task command to run, such as `build`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function runTask(coreCompiler: any, config: Config, task: TaskCommand): Promise<void>;
|
|
15
|
-
export declare function parseFlags(args: string[],
|
|
15
|
+
export declare function parseFlags(args: string[], _sys?: CompilerSystem): ConfigFlags;
|
|
16
16
|
export { CompilerSystem, Config, ConfigFlags, Logger, TaskCommand };
|
package/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo CLI v2.17.2
|
|
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
|
|
@@ -519,11 +519,12 @@ const createConfigFlags = (init = {}) => {
|
|
|
519
519
|
/**
|
|
520
520
|
* Parse command line arguments into a structured `ConfigFlags` object
|
|
521
521
|
*
|
|
522
|
-
* @param args an array of
|
|
523
|
-
* @param
|
|
522
|
+
* @param args an array of CLI flags
|
|
523
|
+
* @param _sys an optional compiler system
|
|
524
524
|
* @returns a structured ConfigFlags object
|
|
525
525
|
*/
|
|
526
|
-
const parseFlags = (args,
|
|
526
|
+
const parseFlags = (args, _sys) => {
|
|
527
|
+
// TODO: remove the _sys parameter here ^^ (for v3)
|
|
527
528
|
const flags = createConfigFlags();
|
|
528
529
|
// cmd line has more priority over npm scripts cmd
|
|
529
530
|
flags.args = Array.isArray(args) ? args.slice() : [];
|
|
@@ -531,24 +532,19 @@ const parseFlags = (args, sys) => {
|
|
|
531
532
|
flags.task = flags.args[0];
|
|
532
533
|
}
|
|
533
534
|
parseArgs(flags, flags.args);
|
|
534
|
-
if (sys && sys.name === 'node') {
|
|
535
|
-
const envArgs = getNpmConfigEnvArgs(sys);
|
|
536
|
-
parseArgs(flags, envArgs);
|
|
537
|
-
envArgs.forEach((envArg) => {
|
|
538
|
-
if (!flags.args.includes(envArg)) {
|
|
539
|
-
flags.args.push(envArg);
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
535
|
if (flags.task != null) {
|
|
544
536
|
const i = flags.args.indexOf(flags.task);
|
|
545
537
|
if (i > -1) {
|
|
546
538
|
flags.args.splice(i, 1);
|
|
547
539
|
}
|
|
548
540
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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]));
|
|
552
548
|
return flags;
|
|
553
549
|
};
|
|
554
550
|
/**
|
|
@@ -734,17 +730,17 @@ const getValue = (args, configCaseName) => {
|
|
|
734
730
|
let matchingArg;
|
|
735
731
|
args.forEach((arg, i) => {
|
|
736
732
|
if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
|
|
737
|
-
|
|
738
|
-
matchingArg = arg;
|
|
733
|
+
// our argument was passed at the command-line in the format --argName=arg-value
|
|
734
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
739
735
|
}
|
|
740
736
|
else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
|
|
737
|
+
// the next value in the array is assumed to be a value for this argument
|
|
741
738
|
value = args[i + 1];
|
|
742
739
|
matchingArg = arg;
|
|
743
740
|
}
|
|
744
741
|
else if (alias) {
|
|
745
742
|
if (arg.startsWith(`-${alias}=`)) {
|
|
746
|
-
value =
|
|
747
|
-
matchingArg = arg;
|
|
743
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
748
744
|
}
|
|
749
745
|
else if (arg === `-${alias}`) {
|
|
750
746
|
value = args[i + 1];
|
|
@@ -755,13 +751,42 @@ const getValue = (args, configCaseName) => {
|
|
|
755
751
|
return { value, matchingArg };
|
|
756
752
|
};
|
|
757
753
|
/**
|
|
758
|
-
*
|
|
759
|
-
* `--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
|
+
*
|
|
776
|
+
*
|
|
777
|
+
* ```ts
|
|
778
|
+
* const [arg, value] = parseEqualsArg("--myArgument=myValue")
|
|
779
|
+
* ```
|
|
780
|
+
*
|
|
781
|
+
* Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
|
|
760
782
|
*
|
|
761
|
-
* @param
|
|
762
|
-
* @returns the
|
|
783
|
+
* @param arg the arg in question
|
|
784
|
+
* @returns a tuple containing the arg name and the value (if present)
|
|
763
785
|
*/
|
|
764
|
-
const
|
|
786
|
+
const parseEqualsArg = (arg) => {
|
|
787
|
+
const [originalArg, ...value] = arg.split('=');
|
|
788
|
+
return [originalArg, value.join('=')];
|
|
789
|
+
};
|
|
765
790
|
/**
|
|
766
791
|
* Small helper for getting type-system-level assurance that a `string` can be
|
|
767
792
|
* narrowed to a `LogLevel`
|
|
@@ -775,28 +800,12 @@ const isLogLevel = (maybeLogLevel) =>
|
|
|
775
800
|
// `ReadonlyArray` 😢 thus we `as any`
|
|
776
801
|
//
|
|
777
802
|
// see microsoft/TypeScript#31018 for some discussion of this
|
|
778
|
-
LOG_LEVELS.includes(maybeLogLevel);
|
|
779
|
-
const getNpmConfigEnvArgs = (sys) => {
|
|
780
|
-
// process.env.npm_config_argv
|
|
781
|
-
// {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
|
|
782
|
-
let args = [];
|
|
783
|
-
try {
|
|
784
|
-
const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
|
|
785
|
-
if (npmConfigArgs) {
|
|
786
|
-
args = JSON.parse(npmConfigArgs).original;
|
|
787
|
-
if (args[0] === 'run') {
|
|
788
|
-
args = args.slice(2);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
catch (e) { }
|
|
793
|
-
return args;
|
|
794
|
-
};
|
|
803
|
+
LOG_LEVELS.includes(maybeLogLevel);
|
|
795
804
|
|
|
796
805
|
const dependencies = [
|
|
797
806
|
{
|
|
798
807
|
name: "@rindo/core",
|
|
799
|
-
version: "2.17.2
|
|
808
|
+
version: "2.17.2",
|
|
800
809
|
main: "compiler/rindo.js",
|
|
801
810
|
resources: [
|
|
802
811
|
"package.json",
|
|
@@ -1292,6 +1301,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
|
|
|
1292
1301
|
throw error;
|
|
1293
1302
|
}
|
|
1294
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
|
+
*/
|
|
1295
1313
|
function hasAppTarget(config) {
|
|
1296
1314
|
return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
|
|
1297
1315
|
}
|
|
@@ -1299,7 +1317,15 @@ function isUsingYarn(sys) {
|
|
|
1299
1317
|
var _a;
|
|
1300
1318
|
return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
|
|
1301
1319
|
}
|
|
1302
|
-
|
|
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) {
|
|
1303
1329
|
const result = config.outputTargets.map((t) => t.type);
|
|
1304
1330
|
return Array.from(new Set(result));
|
|
1305
1331
|
}
|
|
@@ -1316,7 +1342,7 @@ async function getActiveTargets(config) {
|
|
|
1316
1342
|
const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
|
|
1317
1343
|
const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
|
|
1318
1344
|
const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
|
|
1319
|
-
const targets =
|
|
1345
|
+
const targets = getActiveTargets(config);
|
|
1320
1346
|
const yarn = isUsingYarn(sys);
|
|
1321
1347
|
const rindo = coreCompiler.version || 'unknown';
|
|
1322
1348
|
const system = `${sys.name} ${sys.version}`;
|
|
@@ -1379,14 +1405,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
|
|
|
1379
1405
|
* @returns an anonymized copy of the same config
|
|
1380
1406
|
*/
|
|
1381
1407
|
const anonymizeConfigForTelemetry = (config) => {
|
|
1382
|
-
var _a;
|
|
1383
1408
|
const anonymizedConfig = { ...config };
|
|
1384
1409
|
for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
|
|
1385
1410
|
if (anonymizedConfig[prop] !== undefined) {
|
|
1386
1411
|
anonymizedConfig[prop] = 'omitted';
|
|
1387
1412
|
}
|
|
1388
1413
|
}
|
|
1389
|
-
anonymizedConfig.outputTargets =
|
|
1414
|
+
anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
|
|
1390
1415
|
// Anonymize the outputTargets on our configuration, taking advantage of the
|
|
1391
1416
|
// optional 2nd argument to `JSON.stringify`. If anything is not a string
|
|
1392
1417
|
// we retain it so that any nested properties are handled, else we check
|
|
@@ -1607,7 +1632,7 @@ function getMajorVersion(version) {
|
|
|
1607
1632
|
return parts[0];
|
|
1608
1633
|
}
|
|
1609
1634
|
|
|
1610
|
-
const taskBuild = async (coreCompiler, config
|
|
1635
|
+
const taskBuild = async (coreCompiler, config) => {
|
|
1611
1636
|
if (config.flags.watch) {
|
|
1612
1637
|
// watch build
|
|
1613
1638
|
await taskWatch(coreCompiler, config);
|
|
@@ -1620,10 +1645,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
|
|
|
1620
1645
|
const versionChecker = startCheckVersion(config, coreCompiler.version);
|
|
1621
1646
|
const compiler = await coreCompiler.createCompiler(config);
|
|
1622
1647
|
const results = await compiler.build();
|
|
1623
|
-
|
|
1624
|
-
if (sys) {
|
|
1625
|
-
await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
|
|
1626
|
-
}
|
|
1648
|
+
await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
|
|
1627
1649
|
await compiler.destroy();
|
|
1628
1650
|
if (results.hasError) {
|
|
1629
1651
|
exitCode = 1;
|
|
@@ -1987,10 +2009,7 @@ const taskHelp = async (flags, logger, sys) => {
|
|
|
1987
2009
|
${prompt} ${logger.green('rindo generate')} or ${logger.green('rindo g')}
|
|
1988
2010
|
|
|
1989
2011
|
`);
|
|
1990
|
-
|
|
1991
|
-
if (sys) {
|
|
1992
|
-
await taskTelemetry(flags, sys, logger);
|
|
1993
|
-
}
|
|
2012
|
+
await taskTelemetry(flags, sys, logger);
|
|
1994
2013
|
console.log(`
|
|
1995
2014
|
${logger.bold('Examples:')}
|
|
1996
2015
|
|
|
@@ -2138,7 +2157,7 @@ const BLUE = `#3498db`;
|
|
|
2138
2157
|
const run = async (init) => {
|
|
2139
2158
|
const { args, logger, sys } = init;
|
|
2140
2159
|
try {
|
|
2141
|
-
const flags = parseFlags(args
|
|
2160
|
+
const flags = parseFlags(args);
|
|
2142
2161
|
const task = flags.task;
|
|
2143
2162
|
if (flags.debug || flags.verbose) {
|
|
2144
2163
|
logger.setLevel('debug');
|
|
@@ -2176,9 +2195,7 @@ const run = async (init) => {
|
|
|
2176
2195
|
startupLogVersion(logger, task, coreCompiler);
|
|
2177
2196
|
loadedCompilerLog(sys, logger, flags, coreCompiler);
|
|
2178
2197
|
if (task === 'info') {
|
|
2179
|
-
|
|
2180
|
-
await taskInfo(coreCompiler, sys, logger);
|
|
2181
|
-
});
|
|
2198
|
+
taskInfo(coreCompiler, sys, logger);
|
|
2182
2199
|
return;
|
|
2183
2200
|
}
|
|
2184
2201
|
const validated = await coreCompiler.loadConfig({
|
|
@@ -2211,14 +2228,27 @@ const run = async (init) => {
|
|
|
2211
2228
|
}
|
|
2212
2229
|
}
|
|
2213
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
|
+
*/
|
|
2214
2239
|
const runTask = async (coreCompiler, config, task, sys) => {
|
|
2215
|
-
var _a, _b;
|
|
2240
|
+
var _a, _b, _c;
|
|
2216
2241
|
const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
|
|
2217
|
-
const strictConfig = {
|
|
2218
|
-
|
|
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
|
+
};
|
|
2219
2249
|
switch (task) {
|
|
2220
2250
|
case 'build':
|
|
2221
|
-
await taskBuild(coreCompiler, strictConfig
|
|
2251
|
+
await taskBuild(coreCompiler, strictConfig);
|
|
2222
2252
|
break;
|
|
2223
2253
|
case 'docs':
|
|
2224
2254
|
await taskDocs(coreCompiler, strictConfig);
|
|
@@ -2237,10 +2267,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
|
|
|
2237
2267
|
await taskServe(strictConfig);
|
|
2238
2268
|
break;
|
|
2239
2269
|
case 'telemetry':
|
|
2240
|
-
|
|
2241
|
-
if (sys) {
|
|
2242
|
-
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2243
|
-
}
|
|
2270
|
+
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2244
2271
|
break;
|
|
2245
2272
|
case 'version':
|
|
2246
2273
|
console.log(coreCompiler.version);
|
package/cli/package.json
CHANGED