piral-cli 0.13.8 → 0.14.0-beta.3156

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 (202) hide show
  1. package/README.md +5 -2
  2. package/lib/api.js +23 -23
  3. package/lib/api.js.map +1 -1
  4. package/lib/apps/build-pilet.js +18 -16
  5. package/lib/apps/build-pilet.js.map +1 -1
  6. package/lib/apps/build-piral.js +35 -34
  7. package/lib/apps/build-piral.js.map +1 -1
  8. package/lib/apps/debug-pilet.js +28 -27
  9. package/lib/apps/debug-pilet.js.map +1 -1
  10. package/lib/apps/debug-piral.js +15 -14
  11. package/lib/apps/debug-piral.js.map +1 -1
  12. package/lib/apps/declaration-piral.js +5 -3
  13. package/lib/apps/declaration-piral.js.map +1 -1
  14. package/lib/apps/new-pilet.js +43 -39
  15. package/lib/apps/new-pilet.js.map +1 -1
  16. package/lib/apps/new-piral.js +21 -20
  17. package/lib/apps/new-piral.js.map +1 -1
  18. package/lib/apps/pack-pilet.js +6 -4
  19. package/lib/apps/pack-pilet.js.map +1 -1
  20. package/lib/apps/publish-pilet.js +48 -47
  21. package/lib/apps/publish-pilet.js.map +1 -1
  22. package/lib/apps/publish-piral.js +23 -22
  23. package/lib/apps/publish-piral.js.map +1 -1
  24. package/lib/apps/upgrade-pilet.js +34 -33
  25. package/lib/apps/upgrade-pilet.js.map +1 -1
  26. package/lib/apps/upgrade-piral.js +20 -19
  27. package/lib/apps/upgrade-piral.js.map +1 -1
  28. package/lib/apps/validate-pilet.js +13 -11
  29. package/lib/apps/validate-pilet.js.map +1 -1
  30. package/lib/apps/validate-piral.js +12 -10
  31. package/lib/apps/validate-piral.js.map +1 -1
  32. package/lib/build/bundler-calls.d.ts +3 -0
  33. package/lib/build/bundler-calls.js +107 -0
  34. package/lib/build/bundler-calls.js.map +1 -0
  35. package/lib/build/run-build-pilet.d.ts +1 -0
  36. package/lib/build/run-build-pilet.js +65 -0
  37. package/lib/build/run-build-pilet.js.map +1 -0
  38. package/lib/build/run-build-piral.d.ts +1 -0
  39. package/lib/build/run-build-piral.js +66 -0
  40. package/lib/build/run-build-piral.js.map +1 -0
  41. package/lib/build/run-debug-mono-piral.d.ts +1 -0
  42. package/lib/build/run-debug-mono-piral.js +71 -0
  43. package/lib/build/run-debug-mono-piral.js.map +1 -0
  44. package/lib/build/run-debug-pilet.d.ts +1 -0
  45. package/lib/build/run-debug-pilet.js +90 -0
  46. package/lib/build/run-debug-pilet.js.map +1 -0
  47. package/lib/build/run-debug-piral.d.ts +1 -0
  48. package/lib/build/run-debug-piral.js +86 -0
  49. package/lib/build/run-debug-piral.js.map +1 -0
  50. package/lib/bundler.js +62 -25
  51. package/lib/bundler.js.map +1 -1
  52. package/lib/cli.js +2 -2
  53. package/lib/cli.js.map +1 -1
  54. package/lib/commands.js +12 -12
  55. package/lib/commands.js.map +1 -1
  56. package/lib/common/archive.js +8 -8
  57. package/lib/common/archive.js.map +1 -1
  58. package/lib/common/browser.js +2 -2
  59. package/lib/common/browser.js.map +1 -1
  60. package/lib/common/clients/lerna.js +4 -4
  61. package/lib/common/clients/lerna.js.map +1 -1
  62. package/lib/common/clients/npm.js +12 -12
  63. package/lib/common/clients/npm.js.map +1 -1
  64. package/lib/common/clients/pnpm.js +5 -5
  65. package/lib/common/clients/pnpm.js.map +1 -1
  66. package/lib/common/clients/yarn.js +5 -5
  67. package/lib/common/clients/yarn.js.map +1 -1
  68. package/lib/common/compatibility.js +9 -9
  69. package/lib/common/compatibility.js.map +1 -1
  70. package/lib/common/config.d.ts +5 -1
  71. package/lib/common/config.js +2 -1
  72. package/lib/common/config.js.map +1 -1
  73. package/lib/common/constants.d.ts +1 -1
  74. package/lib/common/constants.js +2 -2
  75. package/lib/common/constants.js.map +1 -1
  76. package/lib/common/declaration.js +19 -19
  77. package/lib/common/declaration.js.map +1 -1
  78. package/lib/common/emulator.js +24 -23
  79. package/lib/common/emulator.js.map +1 -1
  80. package/lib/common/envs.js +3 -3
  81. package/lib/common/envs.js.map +1 -1
  82. package/lib/common/hash.d.ts +1 -0
  83. package/lib/common/hash.js +8 -3
  84. package/lib/common/hash.js.map +1 -1
  85. package/lib/common/http.d.ts +1 -0
  86. package/lib/common/http.js +28 -14
  87. package/lib/common/http.js.map +1 -1
  88. package/lib/common/injectors.js +4 -4
  89. package/lib/common/injectors.js.map +1 -1
  90. package/lib/common/inspect.js +4 -4
  91. package/lib/common/inspect.js.map +1 -1
  92. package/lib/common/io.js +77 -73
  93. package/lib/common/io.js.map +1 -1
  94. package/lib/common/language.js +2 -2
  95. package/lib/common/language.js.map +1 -1
  96. package/lib/common/log.js +8 -8
  97. package/lib/common/log.js.map +1 -1
  98. package/lib/common/npm.d.ts +3 -1
  99. package/lib/common/npm.js +68 -48
  100. package/lib/common/npm.js.map +1 -1
  101. package/lib/common/pack.js +18 -18
  102. package/lib/common/pack.js.map +1 -1
  103. package/lib/common/package.d.ts +4 -2
  104. package/lib/common/package.js +182 -81
  105. package/lib/common/package.js.map +1 -1
  106. package/lib/common/patcher.js +20 -20
  107. package/lib/common/patcher.js.map +1 -1
  108. package/lib/common/port.js +3 -3
  109. package/lib/common/port.js.map +1 -1
  110. package/lib/common/rules.js +4 -4
  111. package/lib/common/rules.js.map +1 -1
  112. package/lib/common/scaffold.js +15 -15
  113. package/lib/common/scaffold.js.map +1 -1
  114. package/lib/common/scripts.js +5 -5
  115. package/lib/common/scripts.js.map +1 -1
  116. package/lib/common/template.js +4 -4
  117. package/lib/common/template.js.map +1 -1
  118. package/lib/external/index.js +1369 -611
  119. package/lib/helpers.js +2 -2
  120. package/lib/helpers.js.map +1 -1
  121. package/lib/inject.js +2 -2
  122. package/lib/inject.js.map +1 -1
  123. package/lib/injectors/pilet.d.ts +1 -10
  124. package/lib/injectors/pilet.js +74 -27
  125. package/lib/injectors/pilet.js.map +1 -1
  126. package/lib/injectors/piral.d.ts +4 -2
  127. package/lib/injectors/piral.js +20 -5
  128. package/lib/injectors/piral.js.map +1 -1
  129. package/lib/messages.d.ts +11 -3
  130. package/lib/messages.js +11 -3
  131. package/lib/messages.js.map +1 -1
  132. package/lib/pb-cli.js +1 -1
  133. package/lib/pb-cli.js.map +1 -1
  134. package/lib/pilet-cli.js +1 -1
  135. package/lib/pilet-cli.js.map +1 -1
  136. package/lib/piral-cli.js +1 -1
  137. package/lib/piral-cli.js.map +1 -1
  138. package/lib/plugin.js +10 -10
  139. package/lib/plugin.js.map +1 -1
  140. package/lib/release.js +3 -3
  141. package/lib/release.js.map +1 -1
  142. package/lib/resolvers.js +13 -13
  143. package/lib/resolvers.js.map +1 -1
  144. package/lib/rules/index.js +7 -7
  145. package/lib/rules/index.js.map +1 -1
  146. package/lib/rules/pilet-has-externals-as-peers.js +3 -3
  147. package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
  148. package/lib/rules/pilet-has-no-self-reference.js +1 -1
  149. package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
  150. package/lib/rules/pilet-stays-small.js +3 -3
  151. package/lib/rules/pilet-stays-small.js.map +1 -1
  152. package/lib/rules/pilet-uses-latest-piral.js +1 -1
  153. package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
  154. package/lib/rules/piral-entry-ends-with-html.js +1 -1
  155. package/lib/rules/piral-entry-ends-with-html.js.map +1 -1
  156. package/lib/rules/piral-has-valid-files.js +5 -5
  157. package/lib/rules/piral-has-valid-files.js.map +1 -1
  158. package/lib/runner.js +1 -1
  159. package/lib/runner.js.map +1 -1
  160. package/lib/select.js +6 -6
  161. package/lib/select.js.map +1 -1
  162. package/lib/types/common.d.ts +8 -0
  163. package/lib/types/public.d.ts +66 -12
  164. package/package.json +3 -3
  165. package/src/apps/build-pilet.ts +7 -4
  166. package/src/apps/build-piral.ts +6 -5
  167. package/src/apps/debug-pilet.ts +3 -2
  168. package/src/apps/debug-piral.ts +2 -1
  169. package/src/apps/declaration-piral.ts +3 -1
  170. package/src/apps/new-pilet.ts +7 -3
  171. package/src/apps/new-piral.ts +2 -1
  172. package/src/apps/pack-pilet.ts +3 -1
  173. package/src/apps/publish-pilet.ts +6 -5
  174. package/src/apps/publish-piral.ts +3 -2
  175. package/src/apps/upgrade-pilet.ts +5 -4
  176. package/src/apps/upgrade-piral.ts +2 -1
  177. package/src/apps/validate-pilet.ts +5 -2
  178. package/src/apps/validate-piral.ts +3 -1
  179. package/src/build/bundler-calls.ts +121 -0
  180. package/src/build/run-build-pilet.ts +89 -0
  181. package/src/build/run-build-piral.ts +88 -0
  182. package/src/build/run-debug-mono-piral.ts +87 -0
  183. package/src/build/run-debug-pilet.ts +114 -0
  184. package/src/build/run-debug-piral.ts +106 -0
  185. package/src/bundler.test.ts +83 -68
  186. package/src/bundler.ts +52 -12
  187. package/src/common/config.ts +6 -1
  188. package/src/common/constants.ts +1 -1
  189. package/src/common/emulator.ts +1 -0
  190. package/src/common/hash.ts +5 -0
  191. package/src/common/http.ts +18 -4
  192. package/src/common/io.ts +4 -0
  193. package/src/common/npm.test.ts +14 -14
  194. package/src/common/npm.ts +21 -2
  195. package/src/common/package.ts +120 -9
  196. package/src/helpers.ts +2 -2
  197. package/src/injectors/pilet.ts +82 -22
  198. package/src/injectors/piral.test.ts +6 -5
  199. package/src/injectors/piral.ts +21 -2
  200. package/src/messages.ts +23 -15
  201. package/src/types/common.ts +9 -0
  202. package/src/types/public.ts +71 -20
package/src/messages.ts CHANGED
@@ -161,7 +161,7 @@ export function appInstanceNotFound_0010(name: string): QuickMessage {
161
161
  * It should be an HTML file.
162
162
  *
163
163
  * @see
164
- * - [Parcel HTML Asset](https://parceljs.org/html.html)
164
+ * - [Parcel HTML Asset](https://parceljs.org/languages/html/)
165
165
  *
166
166
  * @example
167
167
  * Make sure the package.json of the Piral instance is valid (has an "app" field).
@@ -1277,10 +1277,10 @@ export function failedHttpGet_0068(error: string): QuickMessage {
1277
1277
  *
1278
1278
  * @abstract
1279
1279
  * While submitting the HTTP get request an error was reported.
1280
- *
1280
+ *
1281
1281
  * Potentially, the server returned some more indicative error message. In this
1282
1282
  * case read it carefully to know what version was already published.
1283
- *
1283
+ *
1284
1284
  * In any case only the documentation of the corresponding feed service can be
1285
1285
  * conclusive how this can be resolved. Presumably, some payment of some fee
1286
1286
  * is necessary to publish pilets.
@@ -1299,28 +1299,28 @@ export function failedToUploadPayment_0161(response: any): QuickMessage {
1299
1299
  *
1300
1300
  * @abstract
1301
1301
  * While submitting the HTTP get request an error was reported.
1302
- *
1302
+ *
1303
1303
  * Potentially, the server returned some more indicative error message. In this
1304
1304
  * case read it carefully to know what version was already published.
1305
- *
1305
+ *
1306
1306
  * In any case you need to change the version to continue. You can do that by
1307
1307
  * editing the "version" field in the pilet's package.json or using `npm version`.
1308
1308
  *
1309
1309
  * @example
1310
1310
  * If you already published the pilet, e.g., via
1311
- *
1311
+ *
1312
1312
  * ```sh
1313
1313
  * pilet publish --api-key ... --url ...
1314
1314
  * ```
1315
- *
1315
+ *
1316
1316
  * then doing this again without any change should result in this error.
1317
- *
1317
+ *
1318
1318
  * Now we can patch-upgrade the version of the pilet:
1319
- *
1319
+ *
1320
1320
  * ```sh
1321
1321
  * npm version patch
1322
1322
  * ```
1323
- *
1323
+ *
1324
1324
  * And try the `pilet publish` command again. This time it should just work.
1325
1325
  */
1326
1326
  export function failedToUploadVersion_0162(response: any): QuickMessage {
@@ -1337,10 +1337,10 @@ export function failedToUploadVersion_0162(response: any): QuickMessage {
1337
1337
  *
1338
1338
  * @abstract
1339
1339
  * While submitting the HTTP get request an error was reported.
1340
- *
1340
+ *
1341
1341
  * Potentially, the server returned some more indicative error message. In this
1342
1342
  * case read it carefully to know how much the limit was exceeded.
1343
- *
1343
+ *
1344
1344
  * In any case the pilet must be somehow trimmed down. Most often, the size is
1345
1345
  * dominantly determined by some external packages that are referened. Use a
1346
1346
  * page such as bundlephobia.com or some IDE tools to find out which packages
@@ -1960,7 +1960,7 @@ export function publishProviderMissing_0113(providerName: string, availableProvi
1960
1960
  * ```sh
1961
1961
  * piral publish --type release --provider xcopy --fields.target "/temp/dest"
1962
1962
  * ```
1963
- *
1963
+ *
1964
1964
  * The type is "release".
1965
1965
  */
1966
1966
  export function publishEmulatorSourcesInvalid_0114(): QuickMessage {
@@ -2010,14 +2010,19 @@ export function failedToOpenBrowser_0170(error: string): QuickMessage {
2010
2010
  * the interpretation of compatible feed services slightly and has an impact of the usage
2011
2011
  * of the pilet in the browser.
2012
2012
  *
2013
- * The selected schema version needs to be either "v0" or "v1".
2013
+ * The selected schema version needs to be either "v0", "v1", or "v2".
2014
2014
  *
2015
2015
  * - v0: will download and evaluate the pilet explicitly
2016
- * - v1: will use a script tag for integration of the pilet (default)
2016
+ * - v1: will use a script tag for integration of the pilet
2017
+ * - v2: will use SystemJS for integration of the pilet (default)
2017
2018
  *
2018
2019
  * The v1 version has better support for older browsers, but requires a polyfill to work
2019
2020
  * correctly. This polyfill is part of the standard Piral polyfills.
2020
2021
  *
2022
+ * The v2 version uses a SystemJS format for the pilet. It has the broadest browser support
2023
+ * but requires the custom format as output. Most bundlers support SystemJS directly or
2024
+ * indirectly, making it a quite broad choice.
2025
+ *
2021
2026
  * @see
2022
2027
  * - [GitHub currentScript-polyfill](https://github.com/amiller-gh/currentScript-polyfill)
2023
2028
  *
@@ -2053,6 +2058,7 @@ export function invalidSchemaVersion_0171(schemaVersion: string, schemas: Array<
2053
2058
  * @see
2054
2059
  * - [Webpack](https://webpack.js.org)
2055
2060
  * - [Parcel](https://parceljs.org)
2061
+ * - [esbuild](https://esbuild.github.io)
2056
2062
  * - [Pluggable bundlers](https://docs.piral.io/reference/documentation/bundlers)
2057
2063
  *
2058
2064
  * @example
@@ -2084,6 +2090,7 @@ export function bundlerMissing_0172(bundlerName: string, installed: Array<string
2084
2090
  * @see
2085
2091
  * - [Webpack](https://webpack.js.org)
2086
2092
  * - [Parcel](https://parceljs.org)
2093
+ * - [esbuild](https://esbuild.github.io)
2087
2094
  * - [Pluggable bundlers](https://docs.piral.io/reference/documentation/bundlers)
2088
2095
  *
2089
2096
  * @example
@@ -2115,6 +2122,7 @@ export function defaultBundlerMissing_0173(): QuickMessage {
2115
2122
  * @see
2116
2123
  * - [Webpack](https://webpack.js.org)
2117
2124
  * - [Parcel](https://parceljs.org)
2125
+ * - [esbuild](https://esbuild.github.io)
2118
2126
  * - [Pluggable bundlers](https://docs.piral.io/reference/documentation/bundlers)
2119
2127
  *
2120
2128
  * @example
@@ -76,6 +76,14 @@ export interface RuleContext {
76
76
  peerDependencies: Record<string, string>;
77
77
  }
78
78
 
79
+ export interface SharedDependency {
80
+ id: string;
81
+ name: string;
82
+ ref: string;
83
+ type: 'local' | 'remote';
84
+ entry: string;
85
+ }
86
+
79
87
  export interface RuleRunner<T extends RuleContext> {
80
88
  (context: T, options: any): void | Promise<void>;
81
89
  }
@@ -92,6 +100,7 @@ export interface PiralRuleContext extends RuleContext {
92
100
  export interface PiletRuleContext extends RuleContext {
93
101
  data: PiralData;
94
102
  peerModules: Array<string>;
103
+ importmap: Array<SharedDependency>;
95
104
  }
96
105
 
97
106
  export interface PiralData {
@@ -1,13 +1,5 @@
1
1
  import { Argv, Arguments } from 'yargs';
2
- import {
3
- RuleRunner,
4
- PiletRuleContext,
5
- PiralRuleContext,
6
- Bundler,
7
- BundleDetails,
8
- LogLevels,
9
- ReleaseProvider,
10
- } from './common';
2
+ import { RuleRunner, PiletRuleContext, PiralRuleContext, LogLevels, SharedDependency, ReleaseProvider } from './common';
11
3
 
12
4
  export interface ToolCommandRunner<U = {}> {
13
5
  (args: Arguments<U>): void | Promise<void>;
@@ -108,6 +100,7 @@ export interface DebugPiletParameters extends BaseBundleParameters {
108
100
  piral: string;
109
101
  hmr: boolean;
110
102
  externals: Array<string>;
103
+ importmap: Array<SharedDependency>;
111
104
  targetDir: string;
112
105
  entryModule: string;
113
106
  logLevel: LogLevels;
@@ -120,6 +113,7 @@ export interface BuildPiletParameters extends BaseBundleParameters {
120
113
  contentHash: boolean;
121
114
  minify: boolean;
122
115
  externals: Array<string>;
116
+ importmap: Array<SharedDependency>;
123
117
  targetDir: string;
124
118
  outFile: string;
125
119
  outDir: string;
@@ -128,28 +122,85 @@ export interface BuildPiletParameters extends BaseBundleParameters {
128
122
  version: PiletSchemaVersion;
129
123
  }
130
124
 
131
- export interface WatchPiralBundlerDefinition {
132
- run(args: WatchPiralParameters): Promise<Bundler>;
125
+ export interface BundlerPrepareArgs<T> {
126
+ (args: T): T | Promise<T>;
133
127
  }
134
128
 
135
- export interface DebugPiralBundlerDefinition {
129
+ export interface BaseBundlerDefinition<T> {
130
+ path: string;
131
+ prepare?: BundlerPrepareArgs<T>;
132
+ }
133
+
134
+ export interface WatchPiralBundlerDefinition extends BaseBundlerDefinition<WatchPiralParameters> {}
135
+
136
+ export interface DebugPiralBundlerDefinition extends BaseBundlerDefinition<DebugPiralParameters> {
136
137
  flags?: ToolCommandFlagsSetter;
137
- run(args: DebugPiralParameters): Promise<Bundler>;
138
138
  }
139
139
 
140
- export interface BuildPiralBundlerDefinition {
140
+ export interface BuildPiralBundlerDefinition extends BaseBundlerDefinition<BuildPiralParameters> {
141
141
  flags?: ToolCommandFlagsSetter;
142
- run(args: BuildPiralParameters): Promise<BundleDetails>;
143
142
  }
144
143
 
145
- export interface DebugPiletBundlerDefinition {
144
+ export interface DebugPiletBundlerDefinition extends BaseBundlerDefinition<DebugPiletParameters> {
146
145
  flags?: ToolCommandFlagsSetter;
147
- run(args: DebugPiletParameters): Promise<Bundler>;
148
146
  }
149
147
 
150
- export interface BuildPiletBundlerDefinition {
148
+ export interface BuildPiletBundlerDefinition extends BaseBundlerDefinition<BuildPiletParameters> {
151
149
  flags?: ToolCommandFlagsSetter;
152
- run(args: BuildPiletParameters): Promise<BundleDetails>;
150
+ }
151
+
152
+ export interface PiralBuildHandler {
153
+ create(config: {
154
+ root: string;
155
+ entryFiles: string;
156
+ outDir: string;
157
+ outFile: string;
158
+ externals: Array<string>;
159
+ emulator: boolean;
160
+ sourceMaps: boolean;
161
+ contentHash: boolean;
162
+ minify: boolean;
163
+ publicUrl: string;
164
+ hmr: boolean;
165
+ logLevel: LogLevels;
166
+ watch: boolean;
167
+ args: any;
168
+ }): Promise<BundleHandlerResponse>;
169
+ }
170
+
171
+ export interface PiletBuildHandler {
172
+ create(config: {
173
+ root: string;
174
+ piral: string;
175
+ entryModule: string;
176
+ targetDir: string;
177
+ outDir: string;
178
+ outFile: string;
179
+ externals: Array<string>;
180
+ importmap: Array<SharedDependency>;
181
+ version: PiletSchemaVersion;
182
+ develop: boolean;
183
+ sourceMaps: boolean;
184
+ contentHash: boolean;
185
+ minify: boolean;
186
+ logLevel: LogLevels;
187
+ watch: boolean;
188
+ args: any;
189
+ }): Promise<BundleHandlerResponse>;
190
+ }
191
+
192
+ export interface BundleResult {
193
+ outDir: string;
194
+ outFile: string;
195
+ hash?: string;
196
+ name?: string;
197
+ requireRef?: string;
198
+ }
199
+
200
+ export interface BundleHandlerResponse {
201
+ onStart(cb: () => void): void;
202
+ onEnd(cb: (result: BundleResult) => void): void;
203
+ bundle(): Promise<BundleResult>;
153
204
  }
154
205
 
155
206
  export interface BundlerDefinition {
@@ -160,7 +211,7 @@ export interface BundlerDefinition {
160
211
  buildPilet: BuildPiletBundlerDefinition;
161
212
  }
162
213
 
163
- export type PiletSchemaVersion = 'none' | 'v0' | 'v1';
214
+ export type PiletSchemaVersion = 'none' | 'v0' | 'v1' | 'v2';
164
215
 
165
216
  export type PiletPublishSource = 'local' | 'npm' | 'remote';
166
217