@rindo/core 3.1.0 → 3.2.1
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 +97 -41
- package/cli/index.js +97 -41
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +814 -747
- package/compiler/rindo.min.js +2 -2
- 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 +5795 -268
- 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 +47 -2
- package/internal/rindo-public-compiler.d.ts +54 -10
- package/internal/testing/index.js +5 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +7 -2
- package/mock-doc/index.d.ts +6 -1
- package/mock-doc/index.js +7 -2
- package/mock-doc/package.json +1 -1
- package/package.json +3 -3
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +47 -41
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +5 -4
- package/testing/jest-preset.js +1 -1
- package/testing/package.json +1 -1
package/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo CLI (CommonJS) v3.1
|
|
2
|
+
Rindo CLI (CommonJS) v3.2.1 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -25,6 +25,34 @@ function _interopNamespace(e) {
|
|
|
25
25
|
return Object.freeze(n);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Default style mode id
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Constant for the 'dist-hydrate-script' output target
|
|
33
|
+
*/
|
|
34
|
+
const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
|
|
35
|
+
/**
|
|
36
|
+
* Constant for the 'docs-custom' output target
|
|
37
|
+
*/
|
|
38
|
+
const DOCS_CUSTOM = 'docs-custom';
|
|
39
|
+
/**
|
|
40
|
+
* Constant for the 'docs-json' output target
|
|
41
|
+
*/
|
|
42
|
+
const DOCS_JSON = 'docs-json';
|
|
43
|
+
/**
|
|
44
|
+
* Constant for the 'docs-readme' output target
|
|
45
|
+
*/
|
|
46
|
+
const DOCS_README = 'docs-readme';
|
|
47
|
+
/**
|
|
48
|
+
* Constant for the 'docs-vscode' output target
|
|
49
|
+
*/
|
|
50
|
+
const DOCS_VSCODE = 'docs-vscode';
|
|
51
|
+
/**
|
|
52
|
+
* Constant for the 'www' output target
|
|
53
|
+
*/
|
|
54
|
+
const WWW = 'www';
|
|
55
|
+
|
|
28
56
|
/**
|
|
29
57
|
* Convert a string from dash-case / kebab-case to PascalCase (or CamelCase,
|
|
30
58
|
* or whatever you call it!)
|
|
@@ -272,6 +300,9 @@ const pathComponents = (path, rootLength) => {
|
|
|
272
300
|
return [root, ...rest];
|
|
273
301
|
};
|
|
274
302
|
|
|
303
|
+
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
304
|
+
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
305
|
+
|
|
275
306
|
/**
|
|
276
307
|
* Check whether a string is a member of a ReadonlyArray<string>
|
|
277
308
|
*
|
|
@@ -536,12 +567,23 @@ const CLI_FLAG_ALIASES = {
|
|
|
536
567
|
h: 'help',
|
|
537
568
|
p: 'port',
|
|
538
569
|
v: 'version',
|
|
570
|
+
// JEST SPECIFIC CLI FLAGS
|
|
571
|
+
// these are defined in
|
|
572
|
+
// https://github.com/facebook/jest/blob/4156f86/packages/jest-cli/src/args.ts
|
|
573
|
+
b: 'bail',
|
|
574
|
+
e: 'expand',
|
|
575
|
+
f: 'onlyFailures',
|
|
576
|
+
i: 'runInBand',
|
|
577
|
+
o: 'onlyChanged',
|
|
578
|
+
t: 'testNamePattern',
|
|
579
|
+
u: 'updateSnapshot',
|
|
580
|
+
w: 'maxWorkers',
|
|
539
581
|
};
|
|
540
582
|
/**
|
|
541
583
|
* A regular expression which can be used to match a CLI flag for one of our
|
|
542
584
|
* short aliases.
|
|
543
585
|
*/
|
|
544
|
-
const CLI_FLAG_REGEX = new RegExp(`^-[
|
|
586
|
+
const CLI_FLAG_REGEX = new RegExp(`^-[chpvbewofitu]{1}$`);
|
|
545
587
|
/**
|
|
546
588
|
* Helper function for initializing a `ConfigFlags` object. Provide any overrides
|
|
547
589
|
* for default values and off you go!
|
|
@@ -586,13 +628,6 @@ const parseFlags = (args) => {
|
|
|
586
628
|
flags.args.splice(i, 1);
|
|
587
629
|
}
|
|
588
630
|
}
|
|
589
|
-
// to find unknown / unrecognized arguments we filter `args`, including only
|
|
590
|
-
// arguments whose normalized form is not found in `knownArgs`. `knownArgs`
|
|
591
|
-
// is populated during the call to `parseArgs` above. For arguments like
|
|
592
|
-
// `--foobar` the string `"--foobar"` will be added, while for more
|
|
593
|
-
// complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
|
|
594
|
-
// string `"--bizBoz"` will be added.
|
|
595
|
-
flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
|
|
596
631
|
return flags;
|
|
597
632
|
};
|
|
598
633
|
/**
|
|
@@ -670,12 +705,12 @@ const parseCLITerm = (flags, args) => {
|
|
|
670
705
|
else if (arg.startsWith('-') && arg.includes('=')) {
|
|
671
706
|
// we're dealing with an AliasEqualsArg, we have a special helper for that
|
|
672
707
|
const [originalArg, value] = parseEqualsArg(arg);
|
|
673
|
-
setCLIArg(flags,
|
|
708
|
+
setCLIArg(flags, desugarRawAlias(originalArg), normalizeFlagName(originalArg), value);
|
|
674
709
|
}
|
|
675
710
|
// AliasArg → "-" AliasName ( " " CLIValue )? ;
|
|
676
711
|
else if (CLI_FLAG_REGEX.test(arg)) {
|
|
677
712
|
// this is a short alias, like `-c` for Config
|
|
678
|
-
setCLIArg(flags, arg, normalizeFlagName(arg), parseCLIValue(args));
|
|
713
|
+
setCLIArg(flags, desugarRawAlias(arg), normalizeFlagName(arg), parseCLIValue(args));
|
|
679
714
|
}
|
|
680
715
|
// NegativeDashArg → "--no-" ArgName ;
|
|
681
716
|
else if (arg.startsWith('--no-') && arg.length > '--no-'.length) {
|
|
@@ -698,11 +733,14 @@ const parseCLITerm = (flags, args) => {
|
|
|
698
733
|
else if (arg.startsWith('--') && arg.length > '--'.length) {
|
|
699
734
|
setCLIArg(flags, arg, normalizeFlagName(arg), parseCLIValue(args));
|
|
700
735
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
736
|
+
else {
|
|
737
|
+
// if we get here then `arg` is not an argument in our list of supported
|
|
738
|
+
// arguments. This doesn't necessarily mean we want to report an error or
|
|
739
|
+
// anything though! Instead, with unknown / unrecognized arguments we want
|
|
740
|
+
// to stick them into the `unknownArgs` array, which is used when we pass
|
|
741
|
+
// CLI args to Jest, for instance.
|
|
742
|
+
flags.unknownArgs.push(arg);
|
|
743
|
+
}
|
|
706
744
|
};
|
|
707
745
|
/**
|
|
708
746
|
* Normalize a 'negative' flag name, just to do a little pre-processing before
|
|
@@ -748,7 +786,7 @@ const normalizeFlagName = (flagName) => {
|
|
|
748
786
|
* @param value the raw value to be set onto the config flags object
|
|
749
787
|
*/
|
|
750
788
|
const setCLIArg = (flags, rawArg, normalizedArg, value) => {
|
|
751
|
-
normalizedArg =
|
|
789
|
+
normalizedArg = desugarAlias(normalizedArg);
|
|
752
790
|
// We're setting a boolean!
|
|
753
791
|
if (readOnlyArrayHasStringMember(BOOLEAN_CLI_FLAGS, normalizedArg)) {
|
|
754
792
|
flags[normalizedArg] =
|
|
@@ -850,6 +888,14 @@ const setCLIArg = (flags, rawArg, normalizedArg, value) => {
|
|
|
850
888
|
throwCLIParsingError(rawArg, 'expected to receive a valid log level but received nothing');
|
|
851
889
|
}
|
|
852
890
|
}
|
|
891
|
+
else {
|
|
892
|
+
// we haven't found this flag in any of our lists of arguments, so we
|
|
893
|
+
// should put it in our list of unknown arguments
|
|
894
|
+
flags.unknownArgs.push(rawArg);
|
|
895
|
+
if (typeof value === 'string') {
|
|
896
|
+
flags.unknownArgs.push(value);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
853
899
|
};
|
|
854
900
|
/**
|
|
855
901
|
* We use this regular expression to detect CLI parameters which
|
|
@@ -874,9 +920,10 @@ const Empty = Symbol('Empty');
|
|
|
874
920
|
* A little helper which tries to parse a CLI value (as opposed to a flag) off
|
|
875
921
|
* of the argument array.
|
|
876
922
|
*
|
|
877
|
-
* We support a variety of different argument formats
|
|
878
|
-
* with `-`, so we can check the first character
|
|
879
|
-
* in our array of CLI arguments is a flag name
|
|
923
|
+
* We support a variety of different argument formats for flags (as opposed to
|
|
924
|
+
* values), but all of them start with `-`, so we can check the first character
|
|
925
|
+
* to test whether the next token in our array of CLI arguments is a flag name
|
|
926
|
+
* or a value.
|
|
880
927
|
*
|
|
881
928
|
* @param args an array of CLI args
|
|
882
929
|
* @returns either a string result or an Empty sentinel
|
|
@@ -965,24 +1012,36 @@ const throwNumberParsingError = (flag, value) => {
|
|
|
965
1012
|
throwCLIParsingError(flag, `expected a number but received "${value}"`);
|
|
966
1013
|
};
|
|
967
1014
|
/**
|
|
968
|
-
* A little helper to '
|
|
969
|
-
*
|
|
970
|
-
* pointer to 'config', so here we're doing something like `*c`. Of course, this
|
|
971
|
-
* being JS, this is just a metaphor!
|
|
1015
|
+
* A little helper to 'desugar' a flag alias, meaning expand it to its full
|
|
1016
|
+
* name. For instance, the alias `"c"` will desugar to `"config"`.
|
|
972
1017
|
*
|
|
973
|
-
* If no
|
|
974
|
-
*
|
|
1018
|
+
* If no expansion is found for the possible alias we just return the passed
|
|
1019
|
+
* string unmodified.
|
|
975
1020
|
*
|
|
976
1021
|
* @param maybeAlias a string which _could_ be an alias to a full flag name
|
|
977
1022
|
* @returns the full aliased flag name, if found, or the passed string if not
|
|
978
1023
|
*/
|
|
979
|
-
const
|
|
980
|
-
const
|
|
981
|
-
if (typeof
|
|
982
|
-
return
|
|
1024
|
+
const desugarAlias = (maybeAlias) => {
|
|
1025
|
+
const possiblyDesugared = CLI_FLAG_ALIASES[maybeAlias];
|
|
1026
|
+
if (typeof possiblyDesugared === 'string') {
|
|
1027
|
+
return possiblyDesugared;
|
|
983
1028
|
}
|
|
984
1029
|
return maybeAlias;
|
|
985
1030
|
};
|
|
1031
|
+
/**
|
|
1032
|
+
* Desugar a 'raw' alias (with a leading dash) and return an equivalent,
|
|
1033
|
+
* desugared argument.
|
|
1034
|
+
*
|
|
1035
|
+
* For instance, passing `"-c` will return `"--config"`.
|
|
1036
|
+
*
|
|
1037
|
+
* The reason we'd like to do this is not so much for our own code, but so that
|
|
1038
|
+
* we can transform an alias like `"-u"` to `"--updateSnapshot"` in order to
|
|
1039
|
+
* pass it along to Jest.
|
|
1040
|
+
*
|
|
1041
|
+
* @param rawAlias a CLI flag alias as found on the command line (like `"-c"`)
|
|
1042
|
+
* @returns an equivalent full command (like `"--config"`)
|
|
1043
|
+
*/
|
|
1044
|
+
const desugarRawAlias = (rawAlias) => '--' + desugarAlias(normalizeFlagName(rawAlias));
|
|
986
1045
|
|
|
987
1046
|
const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
988
1047
|
typeof require === 'function' &&
|
|
@@ -1176,7 +1235,7 @@ const startupLogVersion = (logger, task, coreCompiler) => {
|
|
|
1176
1235
|
const isDevBuild = coreCompiler.version.includes('-dev.');
|
|
1177
1236
|
let startupMsg;
|
|
1178
1237
|
if (isDevBuild) {
|
|
1179
|
-
startupMsg = logger.yellow(
|
|
1238
|
+
startupMsg = logger.yellow(`[LOCAL DEV] v${coreCompiler.version}`);
|
|
1180
1239
|
}
|
|
1181
1240
|
else {
|
|
1182
1241
|
startupMsg = logger.cyan(`v${coreCompiler.version}`);
|
|
@@ -1337,15 +1396,6 @@ const taskWatch = async (coreCompiler, config) => {
|
|
|
1337
1396
|
}
|
|
1338
1397
|
};
|
|
1339
1398
|
|
|
1340
|
-
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
1341
|
-
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
1342
|
-
const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
|
|
1343
|
-
const DOCS_CUSTOM = 'docs-custom';
|
|
1344
|
-
const DOCS_JSON = 'docs-json';
|
|
1345
|
-
const DOCS_README = 'docs-readme';
|
|
1346
|
-
const DOCS_VSCODE = 'docs-vscode';
|
|
1347
|
-
const WWW = 'www';
|
|
1348
|
-
|
|
1349
1399
|
const tryFn = async (fn, ...args) => {
|
|
1350
1400
|
try {
|
|
1351
1401
|
return await fn(...args);
|
|
@@ -2254,12 +2304,18 @@ const taskHelp = async (flags, logger, sys) => {
|
|
|
2254
2304
|
`);
|
|
2255
2305
|
};
|
|
2256
2306
|
|
|
2307
|
+
/**
|
|
2308
|
+
* Generate the output for Rindos 'info' task, and log that output - `npx rindo info`
|
|
2309
|
+
* @param coreCompiler the compiler instance to derive certain version information from
|
|
2310
|
+
* @param sys the compiler system instance that provides details about the system Rindo is running on
|
|
2311
|
+
* @param logger the logger instance to use to log information out to
|
|
2312
|
+
*/
|
|
2257
2313
|
const taskInfo = (coreCompiler, sys, logger) => {
|
|
2258
2314
|
const details = sys.details;
|
|
2259
2315
|
const versions = coreCompiler.versions;
|
|
2260
2316
|
console.log(``);
|
|
2261
2317
|
console.log(`${logger.cyan(' System:')} ${sys.name} ${sys.version}`);
|
|
2262
|
-
console.log(`${logger.cyan('
|
|
2318
|
+
console.log(`${logger.cyan(' Platform:')} ${details.platform} (${details.release})`);
|
|
2263
2319
|
console.log(`${logger.cyan(' CPU Model:')} ${details.cpuModel} (${sys.hardwareConcurrency} cpu${sys.hardwareConcurrency !== 1 ? 's' : ''})`);
|
|
2264
2320
|
console.log(`${logger.cyan(' Compiler:')} ${sys.getCompilerExecutingPath()}`);
|
|
2265
2321
|
console.log(`${logger.cyan(' Build:')} ${coreCompiler.buildId}`);
|
package/cli/index.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo CLI v3.1
|
|
2
|
+
Rindo CLI v3.2.1 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default style mode id
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Constant for the 'dist-hydrate-script' output target
|
|
9
|
+
*/
|
|
10
|
+
const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
|
|
11
|
+
/**
|
|
12
|
+
* Constant for the 'docs-custom' output target
|
|
13
|
+
*/
|
|
14
|
+
const DOCS_CUSTOM = 'docs-custom';
|
|
15
|
+
/**
|
|
16
|
+
* Constant for the 'docs-json' output target
|
|
17
|
+
*/
|
|
18
|
+
const DOCS_JSON = 'docs-json';
|
|
19
|
+
/**
|
|
20
|
+
* Constant for the 'docs-readme' output target
|
|
21
|
+
*/
|
|
22
|
+
const DOCS_README = 'docs-readme';
|
|
23
|
+
/**
|
|
24
|
+
* Constant for the 'docs-vscode' output target
|
|
25
|
+
*/
|
|
26
|
+
const DOCS_VSCODE = 'docs-vscode';
|
|
27
|
+
/**
|
|
28
|
+
* Constant for the 'www' output target
|
|
29
|
+
*/
|
|
30
|
+
const WWW = 'www';
|
|
31
|
+
|
|
4
32
|
/**
|
|
5
33
|
* Convert a string from dash-case / kebab-case to PascalCase (or CamelCase,
|
|
6
34
|
* or whatever you call it!)
|
|
@@ -248,6 +276,9 @@ const pathComponents = (path, rootLength) => {
|
|
|
248
276
|
return [root, ...rest];
|
|
249
277
|
};
|
|
250
278
|
|
|
279
|
+
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
280
|
+
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
281
|
+
|
|
251
282
|
/**
|
|
252
283
|
* Check whether a string is a member of a ReadonlyArray<string>
|
|
253
284
|
*
|
|
@@ -512,12 +543,23 @@ const CLI_FLAG_ALIASES = {
|
|
|
512
543
|
h: 'help',
|
|
513
544
|
p: 'port',
|
|
514
545
|
v: 'version',
|
|
546
|
+
// JEST SPECIFIC CLI FLAGS
|
|
547
|
+
// these are defined in
|
|
548
|
+
// https://github.com/facebook/jest/blob/4156f86/packages/jest-cli/src/args.ts
|
|
549
|
+
b: 'bail',
|
|
550
|
+
e: 'expand',
|
|
551
|
+
f: 'onlyFailures',
|
|
552
|
+
i: 'runInBand',
|
|
553
|
+
o: 'onlyChanged',
|
|
554
|
+
t: 'testNamePattern',
|
|
555
|
+
u: 'updateSnapshot',
|
|
556
|
+
w: 'maxWorkers',
|
|
515
557
|
};
|
|
516
558
|
/**
|
|
517
559
|
* A regular expression which can be used to match a CLI flag for one of our
|
|
518
560
|
* short aliases.
|
|
519
561
|
*/
|
|
520
|
-
const CLI_FLAG_REGEX = new RegExp(`^-[
|
|
562
|
+
const CLI_FLAG_REGEX = new RegExp(`^-[chpvbewofitu]{1}$`);
|
|
521
563
|
/**
|
|
522
564
|
* Helper function for initializing a `ConfigFlags` object. Provide any overrides
|
|
523
565
|
* for default values and off you go!
|
|
@@ -562,13 +604,6 @@ const parseFlags = (args) => {
|
|
|
562
604
|
flags.args.splice(i, 1);
|
|
563
605
|
}
|
|
564
606
|
}
|
|
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]));
|
|
572
607
|
return flags;
|
|
573
608
|
};
|
|
574
609
|
/**
|
|
@@ -646,12 +681,12 @@ const parseCLITerm = (flags, args) => {
|
|
|
646
681
|
else if (arg.startsWith('-') && arg.includes('=')) {
|
|
647
682
|
// we're dealing with an AliasEqualsArg, we have a special helper for that
|
|
648
683
|
const [originalArg, value] = parseEqualsArg(arg);
|
|
649
|
-
setCLIArg(flags,
|
|
684
|
+
setCLIArg(flags, desugarRawAlias(originalArg), normalizeFlagName(originalArg), value);
|
|
650
685
|
}
|
|
651
686
|
// AliasArg → "-" AliasName ( " " CLIValue )? ;
|
|
652
687
|
else if (CLI_FLAG_REGEX.test(arg)) {
|
|
653
688
|
// this is a short alias, like `-c` for Config
|
|
654
|
-
setCLIArg(flags, arg, normalizeFlagName(arg), parseCLIValue(args));
|
|
689
|
+
setCLIArg(flags, desugarRawAlias(arg), normalizeFlagName(arg), parseCLIValue(args));
|
|
655
690
|
}
|
|
656
691
|
// NegativeDashArg → "--no-" ArgName ;
|
|
657
692
|
else if (arg.startsWith('--no-') && arg.length > '--no-'.length) {
|
|
@@ -674,11 +709,14 @@ const parseCLITerm = (flags, args) => {
|
|
|
674
709
|
else if (arg.startsWith('--') && arg.length > '--'.length) {
|
|
675
710
|
setCLIArg(flags, arg, normalizeFlagName(arg), parseCLIValue(args));
|
|
676
711
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
712
|
+
else {
|
|
713
|
+
// if we get here then `arg` is not an argument in our list of supported
|
|
714
|
+
// arguments. This doesn't necessarily mean we want to report an error or
|
|
715
|
+
// anything though! Instead, with unknown / unrecognized arguments we want
|
|
716
|
+
// to stick them into the `unknownArgs` array, which is used when we pass
|
|
717
|
+
// CLI args to Jest, for instance.
|
|
718
|
+
flags.unknownArgs.push(arg);
|
|
719
|
+
}
|
|
682
720
|
};
|
|
683
721
|
/**
|
|
684
722
|
* Normalize a 'negative' flag name, just to do a little pre-processing before
|
|
@@ -724,7 +762,7 @@ const normalizeFlagName = (flagName) => {
|
|
|
724
762
|
* @param value the raw value to be set onto the config flags object
|
|
725
763
|
*/
|
|
726
764
|
const setCLIArg = (flags, rawArg, normalizedArg, value) => {
|
|
727
|
-
normalizedArg =
|
|
765
|
+
normalizedArg = desugarAlias(normalizedArg);
|
|
728
766
|
// We're setting a boolean!
|
|
729
767
|
if (readOnlyArrayHasStringMember(BOOLEAN_CLI_FLAGS, normalizedArg)) {
|
|
730
768
|
flags[normalizedArg] =
|
|
@@ -826,6 +864,14 @@ const setCLIArg = (flags, rawArg, normalizedArg, value) => {
|
|
|
826
864
|
throwCLIParsingError(rawArg, 'expected to receive a valid log level but received nothing');
|
|
827
865
|
}
|
|
828
866
|
}
|
|
867
|
+
else {
|
|
868
|
+
// we haven't found this flag in any of our lists of arguments, so we
|
|
869
|
+
// should put it in our list of unknown arguments
|
|
870
|
+
flags.unknownArgs.push(rawArg);
|
|
871
|
+
if (typeof value === 'string') {
|
|
872
|
+
flags.unknownArgs.push(value);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
829
875
|
};
|
|
830
876
|
/**
|
|
831
877
|
* We use this regular expression to detect CLI parameters which
|
|
@@ -850,9 +896,10 @@ const Empty = Symbol('Empty');
|
|
|
850
896
|
* A little helper which tries to parse a CLI value (as opposed to a flag) off
|
|
851
897
|
* of the argument array.
|
|
852
898
|
*
|
|
853
|
-
* We support a variety of different argument formats
|
|
854
|
-
* with `-`, so we can check the first character
|
|
855
|
-
* in our array of CLI arguments is a flag name
|
|
899
|
+
* We support a variety of different argument formats for flags (as opposed to
|
|
900
|
+
* values), but all of them start with `-`, so we can check the first character
|
|
901
|
+
* to test whether the next token in our array of CLI arguments is a flag name
|
|
902
|
+
* or a value.
|
|
856
903
|
*
|
|
857
904
|
* @param args an array of CLI args
|
|
858
905
|
* @returns either a string result or an Empty sentinel
|
|
@@ -941,24 +988,36 @@ const throwNumberParsingError = (flag, value) => {
|
|
|
941
988
|
throwCLIParsingError(flag, `expected a number but received "${value}"`);
|
|
942
989
|
};
|
|
943
990
|
/**
|
|
944
|
-
* A little helper to '
|
|
945
|
-
*
|
|
946
|
-
* pointer to 'config', so here we're doing something like `*c`. Of course, this
|
|
947
|
-
* being JS, this is just a metaphor!
|
|
991
|
+
* A little helper to 'desugar' a flag alias, meaning expand it to its full
|
|
992
|
+
* name. For instance, the alias `"c"` will desugar to `"config"`.
|
|
948
993
|
*
|
|
949
|
-
* If no
|
|
950
|
-
*
|
|
994
|
+
* If no expansion is found for the possible alias we just return the passed
|
|
995
|
+
* string unmodified.
|
|
951
996
|
*
|
|
952
997
|
* @param maybeAlias a string which _could_ be an alias to a full flag name
|
|
953
998
|
* @returns the full aliased flag name, if found, or the passed string if not
|
|
954
999
|
*/
|
|
955
|
-
const
|
|
956
|
-
const
|
|
957
|
-
if (typeof
|
|
958
|
-
return
|
|
1000
|
+
const desugarAlias = (maybeAlias) => {
|
|
1001
|
+
const possiblyDesugared = CLI_FLAG_ALIASES[maybeAlias];
|
|
1002
|
+
if (typeof possiblyDesugared === 'string') {
|
|
1003
|
+
return possiblyDesugared;
|
|
959
1004
|
}
|
|
960
1005
|
return maybeAlias;
|
|
961
1006
|
};
|
|
1007
|
+
/**
|
|
1008
|
+
* Desugar a 'raw' alias (with a leading dash) and return an equivalent,
|
|
1009
|
+
* desugared argument.
|
|
1010
|
+
*
|
|
1011
|
+
* For instance, passing `"-c` will return `"--config"`.
|
|
1012
|
+
*
|
|
1013
|
+
* The reason we'd like to do this is not so much for our own code, but so that
|
|
1014
|
+
* we can transform an alias like `"-u"` to `"--updateSnapshot"` in order to
|
|
1015
|
+
* pass it along to Jest.
|
|
1016
|
+
*
|
|
1017
|
+
* @param rawAlias a CLI flag alias as found on the command line (like `"-c"`)
|
|
1018
|
+
* @returns an equivalent full command (like `"--config"`)
|
|
1019
|
+
*/
|
|
1020
|
+
const desugarRawAlias = (rawAlias) => '--' + desugarAlias(normalizeFlagName(rawAlias));
|
|
962
1021
|
|
|
963
1022
|
const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
964
1023
|
typeof require === 'function' &&
|
|
@@ -1152,7 +1211,7 @@ const startupLogVersion = (logger, task, coreCompiler) => {
|
|
|
1152
1211
|
const isDevBuild = coreCompiler.version.includes('-dev.');
|
|
1153
1212
|
let startupMsg;
|
|
1154
1213
|
if (isDevBuild) {
|
|
1155
|
-
startupMsg = logger.yellow(
|
|
1214
|
+
startupMsg = logger.yellow(`[LOCAL DEV] v${coreCompiler.version}`);
|
|
1156
1215
|
}
|
|
1157
1216
|
else {
|
|
1158
1217
|
startupMsg = logger.cyan(`v${coreCompiler.version}`);
|
|
@@ -1313,15 +1372,6 @@ const taskWatch = async (coreCompiler, config) => {
|
|
|
1313
1372
|
}
|
|
1314
1373
|
};
|
|
1315
1374
|
|
|
1316
|
-
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
1317
|
-
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
|
|
1318
|
-
const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
|
|
1319
|
-
const DOCS_CUSTOM = 'docs-custom';
|
|
1320
|
-
const DOCS_JSON = 'docs-json';
|
|
1321
|
-
const DOCS_README = 'docs-readme';
|
|
1322
|
-
const DOCS_VSCODE = 'docs-vscode';
|
|
1323
|
-
const WWW = 'www';
|
|
1324
|
-
|
|
1325
1375
|
const tryFn = async (fn, ...args) => {
|
|
1326
1376
|
try {
|
|
1327
1377
|
return await fn(...args);
|
|
@@ -2230,12 +2280,18 @@ const taskHelp = async (flags, logger, sys) => {
|
|
|
2230
2280
|
`);
|
|
2231
2281
|
};
|
|
2232
2282
|
|
|
2283
|
+
/**
|
|
2284
|
+
* Generate the output for Rindos 'info' task, and log that output - `npx rindo info`
|
|
2285
|
+
* @param coreCompiler the compiler instance to derive certain version information from
|
|
2286
|
+
* @param sys the compiler system instance that provides details about the system Rindo is running on
|
|
2287
|
+
* @param logger the logger instance to use to log information out to
|
|
2288
|
+
*/
|
|
2233
2289
|
const taskInfo = (coreCompiler, sys, logger) => {
|
|
2234
2290
|
const details = sys.details;
|
|
2235
2291
|
const versions = coreCompiler.versions;
|
|
2236
2292
|
console.log(``);
|
|
2237
2293
|
console.log(`${logger.cyan(' System:')} ${sys.name} ${sys.version}`);
|
|
2238
|
-
console.log(`${logger.cyan('
|
|
2294
|
+
console.log(`${logger.cyan(' Platform:')} ${details.platform} (${details.release})`);
|
|
2239
2295
|
console.log(`${logger.cyan(' CPU Model:')} ${details.cpuModel} (${sys.hardwareConcurrency} cpu${sys.hardwareConcurrency !== 1 ? 's' : ''})`);
|
|
2240
2296
|
console.log(`${logger.cyan(' Compiler:')} ${sys.getCompilerExecutingPath()}`);
|
|
2241
2297
|
console.log(`${logger.cyan(' Build:')} ${coreCompiler.buildId}`);
|
package/cli/package.json
CHANGED