piral-cli 0.15.0-alpha.3549 → 0.15.0-alpha.3592
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/lib/apps/debug-pilet.js +16 -11
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +15 -7
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/common/http.d.ts +0 -1
- package/lib/common/http.js +1 -14
- package/lib/common/http.js.map +1 -1
- package/lib/common/importmap.d.ts +2 -0
- package/lib/common/importmap.js +147 -0
- package/lib/common/importmap.js.map +1 -0
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/io.d.ts +1 -1
- package/lib/common/io.js +10 -2
- package/lib/common/io.js.map +1 -1
- package/lib/common/package.d.ts +2 -3
- package/lib/common/package.js +3 -95
- package/lib/common/package.js.map +1 -1
- package/lib/common/scripts.js +1 -1
- package/lib/common/scripts.js.map +1 -1
- package/lib/common/spec.js +1 -0
- package/lib/common/spec.js.map +1 -1
- package/lib/common/version.d.ts +2 -0
- package/lib/common/version.js +130 -0
- package/lib/common/version.js.map +1 -0
- package/lib/injectors/pilet.d.ts +1 -0
- package/lib/injectors/pilet.js +7 -4
- package/lib/injectors/pilet.js.map +1 -1
- package/lib/messages.d.ts +187 -0
- package/lib/messages.js +201 -2
- package/lib/messages.js.map +1 -1
- package/lib/types/common.d.ts +1 -0
- package/package.json +2 -2
- package/src/apps/debug-pilet.ts +6 -2
- package/src/apps/debug-piral.ts +3 -1
- package/src/common/http.ts +0 -13
- package/src/common/importmap.ts +153 -0
- package/src/common/index.ts +1 -0
- package/src/common/io.ts +11 -2
- package/src/common/package.ts +2 -104
- package/src/common/scripts.ts +1 -1
- package/src/common/spec.ts +1 -0
- package/src/common/version.test.ts +233 -0
- package/src/common/version.ts +142 -0
- package/src/injectors/pilet.ts +10 -4
- package/src/messages.ts +199 -0
- package/src/types/common.ts +1 -0
package/src/injectors/pilet.ts
CHANGED
|
@@ -19,6 +19,7 @@ interface Pilet {
|
|
|
19
19
|
|
|
20
20
|
export interface PiletInjectorConfig extends KrasInjectorConfig {
|
|
21
21
|
pilets: Array<Pilet>;
|
|
22
|
+
meta: string;
|
|
22
23
|
api: string;
|
|
23
24
|
app: string;
|
|
24
25
|
feed?: string;
|
|
@@ -29,17 +30,22 @@ interface PiletMetadata {
|
|
|
29
30
|
[key: string]: unknown;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
function fillPiletMeta(pilet: Pilet, basePath: string) {
|
|
33
|
+
function fillPiletMeta(pilet: Pilet, basePath: string, metaFile: string) {
|
|
33
34
|
const { root, bundler } = pilet;
|
|
34
|
-
const
|
|
35
|
+
const metaPath = join(root, metaFile);
|
|
36
|
+
const packagePath = join(root, 'package.json');
|
|
37
|
+
const def = JSON.parse(readFileSync(packagePath, 'utf8'));
|
|
38
|
+
const metaOverride = existsSync(metaPath) ? JSON.parse(readFileSync(metaPath, 'utf8')) : undefined;
|
|
35
39
|
const file = bundler.bundle.name.replace(/^[\/\\]/, '');
|
|
36
40
|
const target = join(bundler.bundle.dir, file);
|
|
37
41
|
const url = new URL(file, basePath);
|
|
38
42
|
const meta = {
|
|
43
|
+
custom: def.custom,
|
|
44
|
+
config: def.piletConfig,
|
|
45
|
+
...metaOverride,
|
|
39
46
|
name: def.name,
|
|
40
47
|
version: def.version,
|
|
41
48
|
link: `${url.href}?updated=${Date.now()}`,
|
|
42
|
-
custom: def.custom,
|
|
43
49
|
...getPiletSpecMeta(target, basePath),
|
|
44
50
|
};
|
|
45
51
|
|
|
@@ -92,7 +98,7 @@ export default class PiletInjector implements KrasInjector {
|
|
|
92
98
|
pilets.forEach((p, i) =>
|
|
93
99
|
p.bundler.on(() => {
|
|
94
100
|
const basePath = `${this.piletApi}/${i}/`;
|
|
95
|
-
const meta = fillPiletMeta(p, basePath);
|
|
101
|
+
const meta = fillPiletMeta(p, basePath, options.meta);
|
|
96
102
|
|
|
97
103
|
for (const id of Object.keys(cbs)) {
|
|
98
104
|
cbs[id](meta);
|
package/src/messages.ts
CHANGED
|
@@ -392,6 +392,205 @@ export function packageVersionInvalid_0024(version: string): QuickMessage {
|
|
|
392
392
|
return [LogLevels.error, '0024', `The given package version "${version}" is invalid.`];
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
/**
|
|
396
|
+
* @kind Error
|
|
397
|
+
*
|
|
398
|
+
* @summary
|
|
399
|
+
* Cannot add the shared dependency since its version constraint is not satisfied.
|
|
400
|
+
*
|
|
401
|
+
* @abstract
|
|
402
|
+
* The importmap definition allows you to define a version specifier separated with
|
|
403
|
+
* the '@' character. If you write down a version specifier then it has to be
|
|
404
|
+
* fulfilled already from the local version, otherwise the packaged version can
|
|
405
|
+
* potentially not be resolved at runtime. This would resolve in a pilet that fails
|
|
406
|
+
* when running in isolation and most likely fails when running with other pilets.
|
|
407
|
+
*
|
|
408
|
+
* @see
|
|
409
|
+
* - [import-maps specification](https://github.com/WICG/import-maps)
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* Check the contents of the available package.json:
|
|
413
|
+
*
|
|
414
|
+
* ```sh
|
|
415
|
+
* cat package.json
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* The displayed content should look similar to (i.e., contain an importmap such as):
|
|
419
|
+
*
|
|
420
|
+
* ```json
|
|
421
|
+
* {
|
|
422
|
+
* "importmap": {
|
|
423
|
+
* "imports": {
|
|
424
|
+
* "foo@^3.2.1": "foo"
|
|
425
|
+
* }
|
|
426
|
+
* }
|
|
427
|
+
* }
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* For the error to occur the specifier (^3.2.1) potentially does not match the version (e.g., if
|
|
431
|
+
* the version of the dependency is 3.1.2).
|
|
432
|
+
*
|
|
433
|
+
* One strategy is to remove the specifier, which will automatically use the exact current version
|
|
434
|
+
* as specifier:
|
|
435
|
+
*
|
|
436
|
+
* ```json
|
|
437
|
+
* {
|
|
438
|
+
* "importmap": {
|
|
439
|
+
* "imports": {
|
|
440
|
+
* "foo": "foo"
|
|
441
|
+
* }
|
|
442
|
+
* }
|
|
443
|
+
* }
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* The best way, however, is to look at the used version and adjust the specifier to be correct again.
|
|
447
|
+
* Alternatively, change the used version to satisfy the constraint again.
|
|
448
|
+
*/
|
|
449
|
+
export function importMapVersionSpecNotSatisfied_0025(depName: string, version: string): QuickMessage {
|
|
450
|
+
return [LogLevels.error, '0025', `The dependency "${depName}" in only available in version "${version}".`];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* @kind Error
|
|
455
|
+
*
|
|
456
|
+
* @summary
|
|
457
|
+
* The version spec part of the importmap identifer is invalid.
|
|
458
|
+
*
|
|
459
|
+
* @abstract
|
|
460
|
+
* The importmap definition allows you to define a version specifier separated with
|
|
461
|
+
* the '@' character. This part has to follow the semver convention and rules.
|
|
462
|
+
*
|
|
463
|
+
* Check your specifier via online tools such as "Semver check" to verify it is
|
|
464
|
+
* valid and follows the semver specification.
|
|
465
|
+
*
|
|
466
|
+
* @see
|
|
467
|
+
* - [Online Checker](https://jubianchi.github.io/semver-check/)
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* Check the contents of the available package.json:
|
|
471
|
+
*
|
|
472
|
+
* ```sh
|
|
473
|
+
* cat package.json
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
476
|
+
* The displayed content should look similar to (i.e., contain an importmap such as):
|
|
477
|
+
*
|
|
478
|
+
* ```json
|
|
479
|
+
* {
|
|
480
|
+
* "importmap": {
|
|
481
|
+
* "imports": {
|
|
482
|
+
* "foo@bar": "foo"
|
|
483
|
+
* }
|
|
484
|
+
* }
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*
|
|
488
|
+
* For the error to occur the specifier (bar) is not following the semver specification.
|
|
489
|
+
*
|
|
490
|
+
* One way is to remove the version spec, which will resolve to an exact version specifier
|
|
491
|
+
* and therefore always works:
|
|
492
|
+
*
|
|
493
|
+
* ```json
|
|
494
|
+
* {
|
|
495
|
+
* "importmap": {
|
|
496
|
+
* "imports": {
|
|
497
|
+
* "foo": "foo"
|
|
498
|
+
* }
|
|
499
|
+
* }
|
|
500
|
+
* }
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* The best way, however, is to look at the used version and adjust the specifier to be correct again,
|
|
504
|
+
* such as "^1.2.3" or "1.x" or "3" etc.
|
|
505
|
+
*/
|
|
506
|
+
export function importMapVersionSpecInvalid_0026(depName: string): QuickMessage {
|
|
507
|
+
return [LogLevels.error, '0026', `The dependency "${depName}" has an invalid version spec.`];
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @kind Error
|
|
512
|
+
*
|
|
513
|
+
* @summary
|
|
514
|
+
* The provided importmap reference could not be resolved.
|
|
515
|
+
*
|
|
516
|
+
* @abstract
|
|
517
|
+
* The importmap consists of keys and values. The keys represent the packages names and optional
|
|
518
|
+
* version specifiers to demand at runtime. The values represent the entry point or URL to use
|
|
519
|
+
* when the dependency is not yet loaded.
|
|
520
|
+
*
|
|
521
|
+
* In case of a non-URL value the reference has either to be a valid package name or a file path
|
|
522
|
+
* that leads to either a package or valid JS module. Either way, it needs to exist. If the path
|
|
523
|
+
* is invalid an error will be emitted.
|
|
524
|
+
*
|
|
525
|
+
* @see
|
|
526
|
+
* - [npm Install](https://docs.npmjs.com/cli/install)
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* Check the contents of the available package.json:
|
|
530
|
+
*
|
|
531
|
+
* ```sh
|
|
532
|
+
* cat package.json
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* The displayed content should look similar to (i.e., contain an importmap such as):
|
|
536
|
+
*
|
|
537
|
+
* ```json
|
|
538
|
+
* {
|
|
539
|
+
* "importmap": {
|
|
540
|
+
* "imports": {
|
|
541
|
+
* "foo@bar": "./node_modules/prect"
|
|
542
|
+
* }
|
|
543
|
+
* }
|
|
544
|
+
* }
|
|
545
|
+
* ```
|
|
546
|
+
*
|
|
547
|
+
* Note the potential misspelling. It maybe should have been "./node_modules/preact". In such
|
|
548
|
+
* cases the reference may not be resolved locally. If everything was written correctly the
|
|
549
|
+
* node modules are most likely not installed (correctly).
|
|
550
|
+
*/
|
|
551
|
+
export function importMapReferenceNotFound_0027(dir: string, reference: string): QuickMessage {
|
|
552
|
+
return [LogLevels.error, '0027', `The reference to "${reference}" could not be resolved from "${dir}". Are you sure the file or package exists?`];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* @kind Error
|
|
557
|
+
*
|
|
558
|
+
* @summary
|
|
559
|
+
* The provided importmap file could not be found.
|
|
560
|
+
*
|
|
561
|
+
* @abstract
|
|
562
|
+
* The importmap can be referenced in a file from the package.json. If the named
|
|
563
|
+
* file cannot be found the build process has to be stopped. Make sure that the
|
|
564
|
+
* file has been specified relative to the package.json where it was referenced
|
|
565
|
+
* from.
|
|
566
|
+
*
|
|
567
|
+
* @see
|
|
568
|
+
* - [import-maps specification](https://github.com/WICG/import-maps)
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* Check the contents of the available package.json:
|
|
572
|
+
*
|
|
573
|
+
* ```sh
|
|
574
|
+
* cat package.json
|
|
575
|
+
* ```
|
|
576
|
+
*
|
|
577
|
+
* The displayed content should look similar to (i.e., contain an importmap such as):
|
|
578
|
+
*
|
|
579
|
+
* ```json
|
|
580
|
+
* {
|
|
581
|
+
* "importmap": "./import-map.json"
|
|
582
|
+
* }
|
|
583
|
+
* ```
|
|
584
|
+
*
|
|
585
|
+
* If the importmap has instead been (re)named "importmap.json" then this will not work.
|
|
586
|
+
* Likewise, with the reference above the file is expected to be in the same directory
|
|
587
|
+
* as the package.json. If it is, e.g., in the "src" subfolder you'd should reference it
|
|
588
|
+
* as "./src/import-map.json" instead.
|
|
589
|
+
*/
|
|
590
|
+
export function importMapFileNotFound_0028(dir: string, file: string): QuickMessage {
|
|
591
|
+
return [LogLevels.error, '0028', `The importmap "${file}" could not be found at "${dir}".`];
|
|
592
|
+
}
|
|
593
|
+
|
|
395
594
|
/**
|
|
396
595
|
* @kind Error
|
|
397
596
|
*
|