piral-cli 1.4.0-beta.6250 → 1.4.0-beta.6253

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 (163) hide show
  1. package/lib/api.js +8 -17
  2. package/lib/api.js.map +1 -1
  3. package/lib/apps/add-piral-instance-pilet.js +20 -31
  4. package/lib/apps/add-piral-instance-pilet.js.map +1 -1
  5. package/lib/apps/build-pilet.js +139 -147
  6. package/lib/apps/build-pilet.js.map +1 -1
  7. package/lib/apps/build-piral.js +130 -144
  8. package/lib/apps/build-piral.js.map +1 -1
  9. package/lib/apps/debug-pilet.js +107 -119
  10. package/lib/apps/debug-pilet.js.map +1 -1
  11. package/lib/apps/debug-piral.js +62 -70
  12. package/lib/apps/debug-piral.js.map +1 -1
  13. package/lib/apps/declaration-piral.js +6 -17
  14. package/lib/apps/declaration-piral.js.map +1 -1
  15. package/lib/apps/new-pilet.js +71 -82
  16. package/lib/apps/new-pilet.js.map +1 -1
  17. package/lib/apps/new-piral.js +42 -53
  18. package/lib/apps/new-piral.js.map +1 -1
  19. package/lib/apps/pack-pilet.js +7 -18
  20. package/lib/apps/pack-pilet.js.map +1 -1
  21. package/lib/apps/publish-pilet.js +127 -141
  22. package/lib/apps/publish-pilet.js.map +1 -1
  23. package/lib/apps/publish-piral.js +48 -63
  24. package/lib/apps/publish-piral.js.map +1 -1
  25. package/lib/apps/remove-piral-instance-pilet.js +30 -35
  26. package/lib/apps/remove-piral-instance-pilet.js.map +1 -1
  27. package/lib/apps/run-emulator-piral.js +49 -61
  28. package/lib/apps/run-emulator-piral.js.map +1 -1
  29. package/lib/apps/upgrade-pilet.js +64 -76
  30. package/lib/apps/upgrade-pilet.js.map +1 -1
  31. package/lib/apps/upgrade-piral.js +31 -43
  32. package/lib/apps/upgrade-piral.js.map +1 -1
  33. package/lib/apps/validate-pilet.js +34 -45
  34. package/lib/apps/validate-pilet.js.map +1 -1
  35. package/lib/apps/validate-piral.js +29 -51
  36. package/lib/apps/validate-piral.js.map +1 -1
  37. package/lib/build/bundler-calls.js +12 -3
  38. package/lib/build/bundler-calls.js.map +1 -1
  39. package/lib/build/run-build-pilet.js +5 -14
  40. package/lib/build/run-build-pilet.js.map +1 -1
  41. package/lib/build/run-build-piral.js +5 -14
  42. package/lib/build/run-build-piral.js.map +1 -1
  43. package/lib/build/run-debug-mono-piral.js +5 -14
  44. package/lib/build/run-debug-mono-piral.js.map +1 -1
  45. package/lib/build/run-debug-pilet.js +5 -14
  46. package/lib/build/run-debug-pilet.js.map +1 -1
  47. package/lib/build/run-debug-piral.js +5 -14
  48. package/lib/build/run-debug-piral.js.map +1 -1
  49. package/lib/bundler.js +100 -127
  50. package/lib/bundler.js.map +1 -1
  51. package/lib/commands.js +5 -1
  52. package/lib/commands.js.map +1 -1
  53. package/lib/common/browser.js +13 -26
  54. package/lib/common/browser.js.map +1 -1
  55. package/lib/common/compatibility.js +10 -21
  56. package/lib/common/compatibility.js.map +1 -1
  57. package/lib/common/declaration.js +80 -101
  58. package/lib/common/declaration.js.map +1 -1
  59. package/lib/common/emulator.js +186 -182
  60. package/lib/common/emulator.js.map +1 -1
  61. package/lib/common/http.js +7 -4
  62. package/lib/common/http.js.map +1 -1
  63. package/lib/common/importmap.js +172 -187
  64. package/lib/common/importmap.js.map +1 -1
  65. package/lib/common/injectors.js +4 -1
  66. package/lib/common/injectors.js.map +1 -1
  67. package/lib/common/inspect.js +5 -2
  68. package/lib/common/inspect.js.map +1 -1
  69. package/lib/common/interactive.js +9 -15
  70. package/lib/common/interactive.js.map +1 -1
  71. package/lib/common/io.js +256 -299
  72. package/lib/common/io.js.map +1 -1
  73. package/lib/common/language.js +21 -5
  74. package/lib/common/language.js.map +1 -1
  75. package/lib/common/npm.js +193 -228
  76. package/lib/common/npm.js.map +1 -1
  77. package/lib/common/pack.js +71 -86
  78. package/lib/common/pack.js.map +1 -1
  79. package/lib/common/package.js +428 -448
  80. package/lib/common/package.js.map +1 -1
  81. package/lib/common/parallel.js +12 -23
  82. package/lib/common/parallel.js.map +1 -1
  83. package/lib/common/patcher.js +54 -71
  84. package/lib/common/patcher.js.map +1 -1
  85. package/lib/common/platform.js +1 -12
  86. package/lib/common/platform.js.map +1 -1
  87. package/lib/common/port.js +11 -24
  88. package/lib/common/port.js.map +1 -1
  89. package/lib/common/rules.js +6 -17
  90. package/lib/common/rules.js.map +1 -1
  91. package/lib/common/scaffold.js +52 -59
  92. package/lib/common/scaffold.js.map +1 -1
  93. package/lib/common/shell.js +50 -58
  94. package/lib/common/shell.js.map +1 -1
  95. package/lib/common/spec.js +1 -1
  96. package/lib/common/spec.js.map +1 -1
  97. package/lib/common/template.js +3 -14
  98. package/lib/common/template.js.map +1 -1
  99. package/lib/common/watcher.js +7 -16
  100. package/lib/common/watcher.js.map +1 -1
  101. package/lib/common/website.d.ts +5 -1
  102. package/lib/common/website.js +71 -57
  103. package/lib/common/website.js.map +1 -1
  104. package/lib/injectors/pilet-injector.js +138 -145
  105. package/lib/injectors/pilet-injector.js.map +1 -1
  106. package/lib/injectors/piral-injector.js +55 -67
  107. package/lib/injectors/piral-injector.js.map +1 -1
  108. package/lib/messages.d.ts +81 -0
  109. package/lib/messages.js +94 -1
  110. package/lib/messages.js.map +1 -1
  111. package/lib/npm-clients/bun.js +36 -60
  112. package/lib/npm-clients/bun.js.map +1 -1
  113. package/lib/npm-clients/index.js +10 -21
  114. package/lib/npm-clients/index.js.map +1 -1
  115. package/lib/npm-clients/lerna.js +48 -72
  116. package/lib/npm-clients/lerna.js.map +1 -1
  117. package/lib/npm-clients/npm.js +69 -105
  118. package/lib/npm-clients/npm.js.map +1 -1
  119. package/lib/npm-clients/pnp.js +35 -59
  120. package/lib/npm-clients/pnp.js.map +1 -1
  121. package/lib/npm-clients/pnpm.js +35 -59
  122. package/lib/npm-clients/pnpm.js.map +1 -1
  123. package/lib/npm-clients/rush.js +53 -77
  124. package/lib/npm-clients/rush.js.map +1 -1
  125. package/lib/npm-clients/yarn.js +35 -59
  126. package/lib/npm-clients/yarn.js.map +1 -1
  127. package/lib/platforms/node.js +4 -17
  128. package/lib/platforms/node.js.map +1 -1
  129. package/lib/platforms/web.js +81 -96
  130. package/lib/platforms/web.js.map +1 -1
  131. package/lib/plugin.js +56 -75
  132. package/lib/plugin.js.map +1 -1
  133. package/lib/questionnaire.js +46 -12
  134. package/lib/questionnaire.js.map +1 -1
  135. package/lib/release.js +32 -47
  136. package/lib/release.js.map +1 -1
  137. package/lib/rules/index.js +10 -23
  138. package/lib/rules/index.js.map +1 -1
  139. package/lib/rules/pilet-has-externals-as-peers.js +34 -45
  140. package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
  141. package/lib/rules/pilet-has-no-self-reference.js +16 -27
  142. package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
  143. package/lib/rules/pilet-has-non-conflicting-css.js +27 -42
  144. package/lib/rules/pilet-has-non-conflicting-css.js.map +1 -1
  145. package/lib/rules/pilet-stays-small.js +20 -33
  146. package/lib/rules/pilet-stays-small.js.map +1 -1
  147. package/lib/rules/pilet-uses-latest-piral.js +17 -28
  148. package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
  149. package/lib/rules/piral-has-valid-devDependencies.js +4 -1
  150. package/lib/rules/piral-has-valid-devDependencies.js.map +1 -1
  151. package/lib/runner.js +3 -12
  152. package/lib/runner.js.map +1 -1
  153. package/lib/select.js +21 -32
  154. package/lib/select.js.map +1 -1
  155. package/lib/start.js +6 -17
  156. package/lib/start.js.map +1 -1
  157. package/package.json +2 -2
  158. package/src/apps/build-piral.test.ts +1 -1
  159. package/src/common/package.ts +23 -17
  160. package/src/common/shell.ts +2 -1
  161. package/src/common/website.ts +47 -16
  162. package/src/injectors/pilet-injector.ts +12 -2
  163. package/src/messages.ts +93 -0
@@ -1,10 +1,10 @@
1
- import { join, resolve } from 'path';
1
+ import { join, relative, resolve } from 'path';
2
2
  import { createPiralStubIndexIfNotExists } from './template';
3
3
  import { packageJson } from './constants';
4
4
  import { ForceOverwrite } from './enums';
5
- import { createDirectory, writeBinary } from './io';
5
+ import { createDirectory, readJson, writeBinary } from './io';
6
6
  import { writeJson } from './io';
7
- import { progress } from './log';
7
+ import { progress, log } from './log';
8
8
  import { axios } from '../external';
9
9
  import { EmulatorWebsiteManifestFiles, EmulatorWebsiteManifest } from '../types';
10
10
 
@@ -21,16 +21,14 @@ async function downloadEmulatorFiles(manifestUrl: string, target: string, files:
21
21
  );
22
22
  }
23
23
 
24
- export async function scaffoldFromEmulatorWebsite(rootDir: string, manifestUrl: string) {
25
- progress(`Downloading emulator from %s ...`, manifestUrl);
26
- const response = await axios.default.get(manifestUrl);
27
- const emulatorJson: EmulatorWebsiteManifest = response.data;
28
-
29
- const targetDir = resolve(rootDir, 'node_modules', emulatorJson.name);
30
- const appDirName = 'app';
24
+ async function createEmulatorFiles(
25
+ targetDir: string,
26
+ appDir: string,
27
+ manifestUrl: string,
28
+ emulatorJson: EmulatorWebsiteManifest,
29
+ ) {
31
30
  const mainFile = 'index.js';
32
- const appDir = resolve(targetDir, appDirName);
33
- await createDirectory(appDir);
31
+ const appDirName = relative(targetDir, appDir);
34
32
 
35
33
  await writeJson(
36
34
  targetDir,
@@ -48,9 +46,9 @@ export async function scaffoldFromEmulatorWebsite(rootDir: string, manifestUrl:
48
46
  generated: true,
49
47
  },
50
48
  files: emulatorJson.files.assets,
51
- main: `./${join(appDirName, mainFile)}`,
52
- typings: `./${join(appDirName, emulatorJson.files.typings)}`,
53
- app: `./${join(appDirName, emulatorJson.files.app)}`,
49
+ main: join(appDirName, mainFile),
50
+ typings: join(appDirName, emulatorJson.files.typings),
51
+ app: join(appDirName, emulatorJson.files.app),
54
52
  peerDependencies: {},
55
53
  optionalDependencies: emulatorJson.dependencies.optional,
56
54
  devDependencies: emulatorJson.dependencies.included,
@@ -65,5 +63,38 @@ export async function scaffoldFromEmulatorWebsite(rootDir: string, manifestUrl:
65
63
  });
66
64
 
67
65
  await downloadEmulatorFiles(manifestUrl, appDir, emulatorJson.files);
68
- return emulatorJson.name;
66
+ }
67
+
68
+ export async function updateFromEmulatorWebsite(targetDir: string, manifestUrl: string) {
69
+ progress(`Updating emulator from %s ...`, manifestUrl);
70
+
71
+ try {
72
+ const response = await axios.default.get(manifestUrl);
73
+ const nextEmulator: EmulatorWebsiteManifest = response.data;
74
+ const currentEmulator = await readJson(targetDir, packageJson);
75
+
76
+ if (currentEmulator.name !== nextEmulator.name) {
77
+ log('remoteEmulatorNameChanged_0121', currentEmulator.name);
78
+ } else if (currentEmulator.piralCLI.timstamp !== nextEmulator.timestamp) {
79
+ log('generalDebug_0003', `The timestamp on "${currentEmulator.name}" is different (${nextEmulator.timestamp}).`);
80
+ const appDir = resolve(targetDir, 'app');
81
+ await createEmulatorFiles(targetDir, appDir, manifestUrl, nextEmulator);
82
+ } else {
83
+ log('generalDebug_0003', `Nothing to update for "${currentEmulator.name}".`);
84
+ }
85
+ } catch (ex) {
86
+ log('generalDebug_0003', `HTTP request for emulator update failed: ${ex}`);
87
+ log('skipEmulatorUpdate_0120', manifestUrl);
88
+ }
89
+ }
90
+
91
+ export async function scaffoldFromEmulatorWebsite(rootDir: string, manifestUrl: string) {
92
+ progress(`Downloading emulator from %s ...`, manifestUrl);
93
+ const response = await axios.default.get(manifestUrl);
94
+ const emulatorJson: EmulatorWebsiteManifest = response.data;
95
+ const targetDir = resolve(rootDir, 'node_modules', emulatorJson.name);
96
+ const appDir = resolve(targetDir, 'app');
97
+ await createDirectory(appDir);
98
+ await createEmulatorFiles(targetDir, appDir, manifestUrl, emulatorJson);
99
+ return { name: emulatorJson.name, path: targetDir };
69
100
  }
@@ -343,8 +343,18 @@ export default class PiletInjector implements KrasInjector {
343
343
 
344
344
  if (!fileInfo || fileInfo.mtime < this.proxyInfo.date) {
345
345
  const url = new URL(path, this.proxyInfo.source);
346
- const response = await axios.default.get(url.href, { responseType: 'arraybuffer' });
347
- await writeFile(target, response.data);
346
+
347
+ try {
348
+ const response = await axios.default.get(url.href, { responseType: 'arraybuffer' });
349
+ await writeFile(target, response.data);
350
+ } catch (ex) {
351
+ log('generalDebug_0003', `HTTP request for emulator asset retrieval failed: ${ex}`);
352
+ log(
353
+ fileInfo ? 'optionalEmulatorAssetUpdateSkipped_0122' : 'requiredEmulatorAssetDownloadSkipped_0123',
354
+ url.href,
355
+ );
356
+ return !!fileInfo;
357
+ }
348
358
  }
349
359
 
350
360
  return true;
package/src/messages.ts CHANGED
@@ -2492,6 +2492,99 @@ export function publishFeedMissingVersion_0116(): QuickMessage {
2492
2492
  ];
2493
2493
  }
2494
2494
 
2495
+ /**
2496
+ * @kind Info
2497
+ *
2498
+ * @summary
2499
+ * The remote emulator could not be updated using its given manifest URL.
2500
+ *
2501
+ * @abstract
2502
+ * The remote emulator could not be retrieved from its specified URL. This could be due to a problem with
2503
+ * the network or due to the emulator website not being available right now.
2504
+ *
2505
+ * This is just an informative message. In the current scenario the emulator has been downloaded previously
2506
+ * already. Therefore, only potential updates are blocked due to the error.
2507
+ *
2508
+ * If the error persists please try to access the emulator's URL in your browser. In case this works make
2509
+ * sure that the browser does not have different proxy settings compared ot the rest of your system.
2510
+ *
2511
+ * @see
2512
+ * - [Chrome proxy settings](https://oxylabs.io/resources/integrations/chrome)
2513
+ * - [Firefox proxy settings](https://support.mozilla.org/en-US/kb/connection-settings-firefox)
2514
+ */
2515
+ export function skipEmulatorUpdate_0120(manifestUrl: string): QuickMessage {
2516
+ return [LogLevels.info, '0120', `Failed to retrieve current emulator from "${manifestUrl}". Skipping update.`];
2517
+ }
2518
+
2519
+ /**
2520
+ * @kind Warning
2521
+ *
2522
+ * @summary
2523
+ * The remote emulator could not be updated as the given manifest URL returns a differently named emulator.
2524
+ *
2525
+ * @abstract
2526
+ * When a remote emulator is first installed it will be integrated using its specified name as shell name.
2527
+ * The remote emulator is always auto-updated whenever the Piral CLI is running pilet commands. However,
2528
+ * in case the current emulator manifest has a different name the update will be blocked. In this case a
2529
+ * reinstallation of the emulator is necessary.
2530
+ *
2531
+ * Use "pilet remove-piral-instance" and "pilet add-piral-instance" to remove the old instance (by its given
2532
+ * name) and add the new instance (by the manifest URL).
2533
+ *
2534
+ * @see
2535
+ * - [Chrome proxy settings](https://oxylabs.io/resources/integrations/chrome)
2536
+ * - [Firefox proxy settings](https://support.mozilla.org/en-US/kb/connection-settings-firefox)
2537
+ */
2538
+ export function remoteEmulatorNameChanged_0121(name: string): QuickMessage {
2539
+ return [LogLevels.warning, '0121', `The name of the emulator has changed. Skipping updates for "${name}".`];
2540
+ }
2541
+
2542
+ /**
2543
+ * @kind Info
2544
+ *
2545
+ * @summary
2546
+ * An asset of the remote emulator could not be updated.
2547
+ *
2548
+ * @abstract
2549
+ * The metadata of an remote emulator has been updated, however, one of the asset files could
2550
+ * not be updated. The previously downloaded version of this file will be used as a fallback.
2551
+ *
2552
+ * Using the previously downloaded version of a file might just work, however, for several
2553
+ * reasons this might also break. In any case, if you see this info then any kinds of issues
2554
+ * appearing could potentially be solved by just giving your machine network access again or
2555
+ * waiting for the remote sources to be accessible again.
2556
+ *
2557
+ * @see
2558
+ * - [Chrome proxy settings](https://oxylabs.io/resources/integrations/chrome)
2559
+ * - [Firefox proxy settings](https://support.mozilla.org/en-US/kb/connection-settings-firefox)
2560
+ */
2561
+ export function optionalEmulatorAssetUpdateSkipped_0122(url: string): QuickMessage {
2562
+ return [LogLevels.info, '0122', `Could not update asset file at "${url}".`];
2563
+ }
2564
+
2565
+ /**
2566
+ * @kind Warning
2567
+ *
2568
+ * @summary
2569
+ * An asset of the remote emulator could not be downloaded.
2570
+ *
2571
+ * @abstract
2572
+ * The metadata of an remote emulator has been downloaded, however, one of the asset files
2573
+ * could not be downloaded. Consequently, the fallback (index.html) will be used as
2574
+ * replacement in the dev server.
2575
+ *
2576
+ * If you see this warning then any kinds of issues appearing could potentially be solved by
2577
+ * just giving your machine network access again or waiting for the remote sources to be
2578
+ * accessible again.
2579
+ *
2580
+ * @see
2581
+ * - [Chrome proxy settings](https://oxylabs.io/resources/integrations/chrome)
2582
+ * - [Firefox proxy settings](https://support.mozilla.org/en-US/kb/connection-settings-firefox)
2583
+ */
2584
+ export function requiredEmulatorAssetDownloadSkipped_0123(url: string): QuickMessage {
2585
+ return [LogLevels.warning, '0123', `Could not download asset file at "${url}".`];
2586
+ }
2587
+
2495
2588
  /**
2496
2589
  * @kind Warning
2497
2590
  *