piral-cli 0.15.0-beta.4820 → 0.15.0-beta.4830

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.
Files changed (46) hide show
  1. package/lib/apps/build-pilet.js +1 -1
  2. package/lib/apps/build-pilet.js.map +1 -1
  3. package/lib/apps/build-piral.js +2 -2
  4. package/lib/apps/build-piral.js.map +1 -1
  5. package/lib/apps/debug-pilet.js +1 -1
  6. package/lib/apps/debug-pilet.js.map +1 -1
  7. package/lib/apps/debug-piral.js +1 -3
  8. package/lib/apps/debug-piral.js.map +1 -1
  9. package/lib/apps/validate-piral.js +2 -1
  10. package/lib/apps/validate-piral.js.map +1 -1
  11. package/lib/common/declaration.js +1 -1
  12. package/lib/common/declaration.js.map +1 -1
  13. package/lib/common/emulator.d.ts +2 -2
  14. package/lib/common/emulator.js +6 -4
  15. package/lib/common/emulator.js.map +1 -1
  16. package/lib/common/importmap.js +1 -1
  17. package/lib/common/importmap.js.map +1 -1
  18. package/lib/common/language.d.ts +4 -0
  19. package/lib/common/language.js +6 -2
  20. package/lib/common/language.js.map +1 -1
  21. package/lib/common/npm.d.ts +2 -2
  22. package/lib/common/npm.js +3 -3
  23. package/lib/common/npm.js.map +1 -1
  24. package/lib/common/package.d.ts +5 -4
  25. package/lib/common/package.js +24 -7
  26. package/lib/common/package.js.map +1 -1
  27. package/lib/rules/pilet-has-externals-as-peers.js +4 -4
  28. package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
  29. package/lib/rules/piral-has-valid-externals.js +10 -24
  30. package/lib/rules/piral-has-valid-externals.js.map +1 -1
  31. package/lib/types/common.d.ts +1 -1
  32. package/package.json +2 -2
  33. package/src/apps/build-pilet.ts +1 -1
  34. package/src/apps/build-piral.ts +2 -2
  35. package/src/apps/debug-pilet.ts +1 -1
  36. package/src/apps/debug-piral.ts +1 -1
  37. package/src/apps/validate-piral.ts +2 -1
  38. package/src/common/declaration.ts +1 -1
  39. package/src/common/emulator.ts +9 -7
  40. package/src/common/importmap.ts +1 -1
  41. package/src/common/language.ts +9 -1
  42. package/src/common/npm.ts +4 -5
  43. package/src/common/package.ts +34 -7
  44. package/src/rules/pilet-has-externals-as-peers.ts +4 -4
  45. package/src/rules/piral-has-valid-externals.ts +11 -29
  46. package/src/types/common.ts +1 -1
@@ -1,3 +1,4 @@
1
+ import { findDependencyVersion } from '../common';
1
2
  import { PiralRuleContext } from '../types';
2
3
 
3
4
  export type Options = void;
@@ -6,38 +7,19 @@ export type Options = void;
6
7
  * Checks that the externals to be used in pilets are valid.
7
8
  */
8
9
  export default function (context: PiralRuleContext, options: Options = undefined) {
9
- const { externals } = context.info;
10
+ const { externals } = context;
11
+ const invalidDepRefs = externals
12
+ .filter((ext) => !ext.parents || ext.parents.length === 0)
13
+ .map((ext) => ext.name)
14
+ .filter((name) => context.dependencies[name] === undefined && context.devDependencies[name] === undefined);
10
15
 
11
- if (!Array.isArray(externals)) {
12
- context.error(
16
+ for (const invalidDepRef of invalidDepRefs) {
17
+ context.warning(
13
18
  `
14
- The shared dependencies in pilets.external are invalid.
15
- Expected: <Array>.
16
- Received: <${typeof externals}>.
19
+ The shared dependency "${invalidDepRef}" is not listed in the "dependencies" and "devDependencies".
20
+ Expected: "${invalidDepRef}" in dependencies.
21
+ Received: <none>.
17
22
  `,
18
23
  );
19
- } else {
20
- const invalidDepTypes = externals.filter((ext) => typeof ext !== 'string');
21
- const invalidDepRefs = externals.filter((ext) => typeof ext === 'string' && !context.dependencies[ext]);
22
-
23
- if (invalidDepTypes.length > 0) {
24
- context.error(
25
- `
26
- The shared dependencies in pilets.external are invalid.
27
- Expected: Only names (<string>) in the array.
28
- Received: Found ${invalidDepTypes.length} non-<string> entries.
29
- `,
30
- );
31
- }
32
-
33
- for (const invalidDepRef of invalidDepRefs) {
34
- context.warning(
35
- `
36
- The shared dependency "${invalidDepRef}" is listed in pilets.external, but not in dependencies.
37
- Expected: "${invalidDepRef}" in dependencies.
38
- Received: <none>.
39
- `,
40
- );
41
- }
42
24
  }
43
25
  }
@@ -104,7 +104,6 @@ export interface TemplateFileLocation {
104
104
  export interface PiletsInfo {
105
105
  files: Array<string | TemplateFileLocation>;
106
106
  template: string;
107
- externals?: Array<string>;
108
107
  devDependencies: Record<string, string | true>;
109
108
  scripts: Record<string, string>;
110
109
  validators: Record<string, any>;
@@ -147,6 +146,7 @@ export interface Rule<T extends RuleContext> {
147
146
 
148
147
  export interface PiralRuleContext extends RuleContext {
149
148
  info: PiletsInfo;
149
+ externals: Array<SharedDependency>;
150
150
  }
151
151
 
152
152
  export interface PiletRuleContext extends RuleContext {