piral-cli 0.15.0-alpha.3589 → 0.15.0-alpha.3711

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 (52) hide show
  1. package/lib/apps/debug-pilet.js +17 -11
  2. package/lib/apps/debug-pilet.js.map +1 -1
  3. package/lib/apps/debug-piral.js +16 -7
  4. package/lib/apps/debug-piral.js.map +1 -1
  5. package/lib/apps/new-pilet.js +1 -1
  6. package/lib/apps/new-pilet.js.map +1 -1
  7. package/lib/apps/new-piral.js +3 -4
  8. package/lib/apps/new-piral.js.map +1 -1
  9. package/lib/bundler.js +1 -1
  10. package/lib/bundler.js.map +1 -1
  11. package/lib/commands.js +1 -2
  12. package/lib/commands.js.map +1 -1
  13. package/lib/common/clients/yarn.js +2 -0
  14. package/lib/common/clients/yarn.js.map +1 -1
  15. package/lib/common/constants.d.ts +2 -1
  16. package/lib/common/constants.js +11 -1
  17. package/lib/common/constants.js.map +1 -1
  18. package/lib/common/importmap.js +1 -1
  19. package/lib/common/importmap.js.map +1 -1
  20. package/lib/common/npm.js +2 -2
  21. package/lib/common/npm.js.map +1 -1
  22. package/lib/common/package.js +21 -7
  23. package/lib/common/package.js.map +1 -1
  24. package/lib/common/spec.js +1 -0
  25. package/lib/common/spec.js.map +1 -1
  26. package/lib/external/index.js +26221 -24858
  27. package/lib/helpers.js +3 -2
  28. package/lib/helpers.js.map +1 -1
  29. package/lib/injectors/pilet.d.ts +1 -0
  30. package/lib/injectors/pilet.js +7 -4
  31. package/lib/injectors/pilet.js.map +1 -1
  32. package/lib/messages.d.ts +54 -0
  33. package/lib/messages.js +62 -1
  34. package/lib/messages.js.map +1 -1
  35. package/package.json +3 -2
  36. package/src/apps/build-piral.test.ts +2 -2
  37. package/src/apps/debug-pilet.ts +9 -2
  38. package/src/apps/debug-piral.ts +6 -1
  39. package/src/apps/new-pilet.ts +1 -1
  40. package/src/apps/new-piral.ts +9 -5
  41. package/src/bundler.ts +1 -1
  42. package/src/commands.ts +1 -1
  43. package/src/common/clients/yarn.ts +2 -0
  44. package/src/common/constants.ts +11 -1
  45. package/src/common/importmap.ts +1 -1
  46. package/src/common/npm.ts +2 -2
  47. package/src/common/package.test.ts +5 -5
  48. package/src/common/package.ts +22 -10
  49. package/src/common/spec.ts +1 -0
  50. package/src/helpers.ts +3 -2
  51. package/src/injectors/pilet.ts +10 -4
  52. package/src/messages.ts +61 -0
@@ -46,6 +46,7 @@ export function getPiletSpecMeta(target: string, basePath: string) {
46
46
  dependencies: getDependencies(plainDependencies, basePath),
47
47
  };
48
48
  } else {
49
+ // uses no arguments
49
50
  return {
50
51
  spec: 'v0',
51
52
  hash: computeHash(content),
package/src/helpers.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ForceOverwrite, SourceLanguage } from './common/enums';
2
+ import { bundlerNames, frameworkLibs } from './common/constants';
2
3
  import {
3
4
  Framework,
4
5
  NpmClientType,
@@ -13,10 +14,10 @@ export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
13
14
  export const piralBuildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
14
15
  export const piletBuildTypeKeys: Array<PiletBuildType> = ['default', 'standalone', 'manifest'];
15
16
  export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn'];
16
- export const bundlerKeys: Array<string> = ['none', 'parcel', 'webpack', 'webpack5', 'esbuild', 'xbuild'];
17
+ export const bundlerKeys: Array<string> = ['none', ...bundlerNames];
17
18
  export const availableBundlers: Array<string> = [];
18
19
  export const availableReleaseProviders: Array<string> = [];
19
- export const frameworkKeys: Array<Framework> = ['piral', 'piral-core', 'piral-base'];
20
+ export const frameworkKeys: Array<Framework> = [...frameworkLibs];
20
21
  export const forceOverwriteKeys = Object.keys(ForceOverwrite).filter((m) => typeof ForceOverwrite[m] === 'number');
21
22
 
22
23
  export function valueOfForceOverwrite(key: string): ForceOverwrite {
@@ -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 def = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
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
@@ -1882,6 +1882,67 @@ export function entryFileMissing_0077(): QuickMessage {
1882
1882
  return [LogLevels.error, '0077', 'No valid entry file for the pilet found.'];
1883
1883
  }
1884
1884
 
1885
+ /**
1886
+ * @kind Warning
1887
+ *
1888
+ * @summary
1889
+ * The Piral instance is not referencing any framework package.
1890
+ *
1891
+ * @abstract
1892
+ * A Piral instance has to reference either `piral-base`, `piral-core`
1893
+ * or the whole `piral` framework package. If none of these dependencies
1894
+ * is found then no framework dependencies can be shared automatically.
1895
+ * Framework dependencies include react and react-router.
1896
+ *
1897
+ * @example
1898
+ * You might use a monorepo where most / all dependencies are declared in
1899
+ * a top-level package.json. Therefore, the package.json of the actual
1900
+ * Piral instance could look like this:
1901
+ *
1902
+ * ```json
1903
+ * {
1904
+ * "name": "my-piral-instance",
1905
+ * "version": "1.0.0",
1906
+ * "app": "./src/index.html",
1907
+ * "pilets": {}
1908
+ * }
1909
+ * ```
1910
+ *
1911
+ * While perfectly valid, this one lacks `dependencies` and `devDependencies`.
1912
+ * Surely, those are not really needed in the described case, but under
1913
+ * those conditions we cannot know what dependencies you may want to share. It
1914
+ * could be that you only reference `piral-base` and therefore don't want to
1915
+ * share anything except `tslib`. Or you use `piral-core` and also share things
1916
+ * like `react` or `react-router-dom`.
1917
+ *
1918
+ * Either way, in order to recognize that you'll need to include the correct
1919
+ * reference:
1920
+ *
1921
+ * ```json
1922
+ * {
1923
+ * "name": "my-piral-instance",
1924
+ * "version": "1.0.0",
1925
+ * "app": "./src/index.html",
1926
+ * "pilets": {},
1927
+ * "dependencies": {
1928
+ * "piral": "latest"
1929
+ * }
1930
+ * }
1931
+ * ```
1932
+ *
1933
+ * If you only want to use `piral-base` or `piral-core` then replace `piral` in
1934
+ * the example above. Also use the version that you'll like to use - `latest`
1935
+ * is just one example.
1936
+ *
1937
+ */
1938
+ export function frameworkLibMissing_0078(frameworkLibs: Array<string>): QuickMessage {
1939
+ return [
1940
+ LogLevels.warning,
1941
+ '0078',
1942
+ `Did not find any reference to either ${frameworkLibs.join(', ')}. No framework dependencies are shared.`,
1943
+ ];
1944
+ }
1945
+
1885
1946
  /**
1886
1947
  * @kind Error
1887
1948
  *