piral-cli 0.14.2 → 0.14.3-beta.3299

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 (55) hide show
  1. package/lib/apps/build-pilet.d.ts +6 -2
  2. package/lib/apps/build-pilet.js +110 -37
  3. package/lib/apps/build-pilet.js.map +1 -1
  4. package/lib/apps/build-piral.js +2 -0
  5. package/lib/apps/build-piral.js.map +1 -1
  6. package/lib/apps/debug-pilet.d.ts +2 -2
  7. package/lib/apps/publish-pilet.d.ts +9 -1
  8. package/lib/apps/publish-pilet.js +64 -28
  9. package/lib/apps/publish-pilet.js.map +1 -1
  10. package/lib/build/run-build-piral.js +3 -3
  11. package/lib/build/run-build-piral.js.map +1 -1
  12. package/lib/commands.js +12 -2
  13. package/lib/commands.js.map +1 -1
  14. package/lib/common/compatibility.js +4 -0
  15. package/lib/common/compatibility.js.map +1 -1
  16. package/lib/common/index.d.ts +1 -0
  17. package/lib/common/index.js +1 -0
  18. package/lib/common/index.js.map +1 -1
  19. package/lib/common/io.js +12 -4
  20. package/lib/common/io.js.map +1 -1
  21. package/lib/common/npm.d.ts +2 -1
  22. package/lib/common/npm.js +34 -8
  23. package/lib/common/npm.js.map +1 -1
  24. package/lib/common/spec.d.ts +29 -0
  25. package/lib/common/spec.js +57 -0
  26. package/lib/common/spec.js.map +1 -0
  27. package/lib/helpers.d.ts +3 -2
  28. package/lib/helpers.js +3 -2
  29. package/lib/helpers.js.map +1 -1
  30. package/lib/injectors/pilet.d.ts +2 -2
  31. package/lib/injectors/pilet.js +32 -74
  32. package/lib/injectors/pilet.js.map +1 -1
  33. package/lib/messages.d.ts +14 -1
  34. package/lib/messages.js +23 -3
  35. package/lib/messages.js.map +1 -1
  36. package/lib/rules/pilet-uses-latest-piral.js +17 -8
  37. package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
  38. package/lib/types/public.d.ts +2 -0
  39. package/package.json +2 -2
  40. package/src/apps/build-pilet.ts +180 -46
  41. package/src/apps/build-piral.ts +6 -4
  42. package/src/apps/debug-pilet.ts +2 -2
  43. package/src/apps/publish-pilet.ts +99 -29
  44. package/src/build/run-build-piral.ts +3 -1
  45. package/src/commands.ts +14 -3
  46. package/src/common/compatibility.ts +6 -0
  47. package/src/common/index.ts +1 -0
  48. package/src/common/io.ts +16 -6
  49. package/src/common/npm.ts +44 -11
  50. package/src/common/spec.ts +58 -0
  51. package/src/helpers.ts +10 -2
  52. package/src/injectors/pilet.ts +31 -78
  53. package/src/messages.ts +22 -2
  54. package/src/rules/pilet-uses-latest-piral.ts +21 -11
  55. package/src/types/public.ts +3 -0
@@ -1,6 +1,6 @@
1
1
  import { dirname, basename, resolve, relative } from 'path';
2
- import { LogLevels, PiletSchemaVersion } from '../types';
3
- import { callPiletBuild } from '../bundler';
2
+ import { LogLevels, PiletBuildType, PiletSchemaVersion } from '../types';
3
+ import { callPiletBuild, callPiralBuild } from '../bundler';
4
4
  import {
5
5
  removeDirectory,
6
6
  retrievePiletData,
@@ -13,6 +13,13 @@ import {
13
13
  matchAnyPilet,
14
14
  fail,
15
15
  config,
16
+ log,
17
+ createDirectory,
18
+ writeJson,
19
+ getPiletSpecMeta,
20
+ getFileNames,
21
+ copy,
22
+ checkAppShellPackage,
16
23
  } from '../common';
17
24
 
18
25
  export interface BuildPiletOptions {
@@ -25,7 +32,7 @@ export interface BuildPiletOptions {
25
32
  * The source index file (e.g. index.tsx) for collecting all the information
26
33
  * @example './src/index'
27
34
  */
28
- entry?: string;
35
+ entry?: string | Array<string>;
29
36
 
30
37
  /**
31
38
  * The target file of bundling.
@@ -68,6 +75,11 @@ export interface BuildPiletOptions {
68
75
  */
69
76
  contentHash?: boolean;
70
77
 
78
+ /**
79
+ * Selects the target type of the build (e.g. 'release'). "all" builds all target types.
80
+ */
81
+ type?: PiletBuildType;
82
+
71
83
  /**
72
84
  * States if the node modules should be included for target transpilation
73
85
  */
@@ -97,11 +109,45 @@ export interface BuildPiletOptions {
97
109
  };
98
110
  }
99
111
 
112
+ interface PiletData {
113
+ id: string;
114
+ package: any;
115
+ path: string;
116
+ outFile: string;
117
+ outDir: string;
118
+ }
119
+
120
+ function createMetadata(outDir: string, outFile: string, pilets: Array<PiletData>) {
121
+ return writeJson(
122
+ outDir,
123
+ outFile,
124
+ pilets.map((p) => ({
125
+ name: p.package.name,
126
+ version: p.package.version,
127
+ link: `./${p.id}/${p.outFile}`,
128
+ ...getPiletSpecMeta(p.path, p.outDir),
129
+ })),
130
+ );
131
+ }
132
+
133
+ function copyPilets(outDir: string, pilets: Array<PiletData>) {
134
+ return Promise.all(
135
+ pilets.map(async (p) => {
136
+ const files = await getFileNames(p.outDir);
137
+
138
+ for (const file of files) {
139
+ await copy(resolve(p.outDir, file), resolve(outDir, p.id, file), ForceOverwrite.yes);
140
+ }
141
+ }),
142
+ );
143
+ }
144
+
100
145
  export const buildPiletDefaults: BuildPiletOptions = {
101
146
  entry: './src/index',
102
147
  target: './dist/index.js',
103
148
  minify: true,
104
149
  logLevel: LogLevels.info,
150
+ type: 'default',
105
151
  fresh: false,
106
152
  sourceMaps: true,
107
153
  contentHash: true,
@@ -122,70 +168,158 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
122
168
  optimizeModules = buildPiletDefaults.optimizeModules,
123
169
  schemaVersion = buildPiletDefaults.schemaVersion,
124
170
  declaration = buildPiletDefaults.declaration,
171
+ type = buildPiletDefaults.type,
125
172
  _ = {},
126
173
  hooks = {},
127
174
  bundlerName,
128
175
  app,
129
176
  } = options;
130
177
  const fullBase = resolve(process.cwd(), baseDir);
178
+ const entryList = Array.isArray(entry) ? entry : [entry];
131
179
  setLogLevel(logLevel);
132
180
 
133
181
  await hooks.onBegin?.({ options, fullBase });
134
182
  progress('Reading configuration ...');
135
- const allEntries = await matchAnyPilet(fullBase, [entry]);
183
+ const allEntries = await matchAnyPilet(fullBase, entryList);
184
+ log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
136
185
 
137
186
  if (allEntries.length === 0) {
138
187
  fail('entryFileMissing_0077');
139
188
  }
140
189
 
141
- const entryModule = allEntries.shift();
142
- const targetDir = dirname(entryModule);
143
- const { peerDependencies, peerModules, root, appPackage, piletPackage, ignored, importmap } = await retrievePiletData(
144
- targetDir,
145
- app,
190
+ const pilets = await Promise.all(
191
+ allEntries.map(async (entryModule) => {
192
+ const targetDir = dirname(entryModule);
193
+ const { peerDependencies, peerModules, root, appPackage, appFile, piletPackage, ignored, importmap } =
194
+ await retrievePiletData(targetDir, app);
195
+ const externals = [...Object.keys(peerDependencies), ...peerModules];
196
+ const dest = resolve(root, target);
197
+ const outDir = dirname(dest);
198
+ const outFile = basename(dest);
199
+
200
+ if (fresh) {
201
+ progress('Removing output directory ...');
202
+ await removeDirectory(outDir);
203
+ }
204
+
205
+ logInfo('Bundle pilet ...');
206
+
207
+ await hooks.beforeBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
208
+
209
+ await callPiletBuild(
210
+ {
211
+ root,
212
+ piral: appPackage.name,
213
+ optimizeModules,
214
+ sourceMaps,
215
+ contentHash,
216
+ minify,
217
+ externals,
218
+ targetDir,
219
+ importmap,
220
+ outFile,
221
+ outDir,
222
+ entryModule: `./${relative(root, entryModule)}`,
223
+ logLevel,
224
+ version: schemaVersion,
225
+ ignored,
226
+ _,
227
+ },
228
+ bundlerName,
229
+ );
230
+
231
+ await hooks.afterBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
232
+
233
+ if (declaration) {
234
+ await hooks.beforeDeclaration?.({ root, outDir, entryModule, piletPackage });
235
+ await createPiletDeclaration(
236
+ piletPackage.name,
237
+ root,
238
+ entryModule,
239
+ externals,
240
+ outDir,
241
+ ForceOverwrite.yes,
242
+ logLevel,
243
+ );
244
+ await hooks.afterDeclaration?.({ root, outDir, entryModule, piletPackage });
245
+ }
246
+
247
+ logDone(`Pilet "${piletPackage.name}" built successfully!`);
248
+
249
+ return {
250
+ id: piletPackage.name.replace(/[^a-zA-Z0-9\-]/gi, ''),
251
+ root,
252
+ appFile,
253
+ appPackage,
254
+ outDir,
255
+ outFile,
256
+ path: dest,
257
+ package: piletPackage,
258
+ };
259
+ }),
146
260
  );
147
- const externals = [...Object.keys(peerDependencies), ...peerModules];
148
- const outDir = dirname(resolve(fullBase, target));
149
261
 
150
- if (fresh) {
151
- progress('Removing output directory ...');
262
+ if (type === 'standalone') {
263
+ const distDir = dirname(resolve(fullBase, target));
264
+ const outDir = resolve(distDir, 'standalone');
265
+ const { appFile, appPackage, root } = pilets[0];
266
+ const isEmulator = checkAppShellPackage(appPackage);
267
+
268
+ logInfo('Building standalone solution ...');
269
+
152
270
  await removeDirectory(outDir);
153
- }
154
271
 
155
- logInfo('Bundle pilet ...');
156
-
157
- await hooks.beforeBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
158
-
159
- await callPiletBuild(
160
- {
161
- root,
162
- piral: appPackage.name,
163
- optimizeModules,
164
- sourceMaps,
165
- contentHash,
166
- minify,
167
- externals,
168
- targetDir,
169
- importmap,
170
- outFile: basename(target),
171
- outDir,
172
- entryModule: `./${relative(root, entryModule)}`,
173
- logLevel,
174
- version: schemaVersion,
175
- ignored,
176
- _,
177
- },
178
- bundlerName,
179
- );
272
+ progress('Copying files ...');
273
+
274
+ await copyPilets(outDir, pilets);
275
+
276
+ await createMetadata(outDir, '$pilet-api', pilets);
277
+
278
+ if (isEmulator) {
279
+ // in case of an emulator assets are not "seen" by the bundler, so we
280
+ // just copy overthing over - this should work in most cases.
281
+ await copy(dirname(appFile), outDir, ForceOverwrite.yes);
282
+ }
283
+
284
+ progress('Optimizing app shell ...');
285
+
286
+ await callPiralBuild(
287
+ {
288
+ root,
289
+ piral: appPackage.name,
290
+ emulator: false,
291
+ standalone: true,
292
+ optimizeModules: false,
293
+ sourceMaps,
294
+ contentHash,
295
+ minify,
296
+ externals: [],
297
+ publicUrl: '/',
298
+ outFile: 'index.html',
299
+ outDir,
300
+ entryFiles: appFile,
301
+ logLevel,
302
+ ignored: [],
303
+ _,
304
+ },
305
+ bundlerName,
306
+ );
307
+
308
+ logDone(`Standalone app available at "${outDir}"!`);
309
+ } else if (type === 'manifest') {
310
+ const manifest = 'pilets.json';
311
+ const outDir = dirname(resolve(fullBase, target));
312
+
313
+ logInfo('Building pilet manifest ...');
314
+
315
+ progress('Copying files ...');
316
+
317
+ await copyPilets(outDir, pilets);
180
318
 
181
- await hooks.afterBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
319
+ await createMetadata(outDir, manifest, pilets);
182
320
 
183
- if (declaration) {
184
- await hooks.beforeDeclaration?.({ root, outDir, entryModule, piletPackage });
185
- await createPiletDeclaration(piletPackage.name, root, entryModule, externals, outDir, ForceOverwrite.yes, logLevel);
186
- await hooks.afterDeclaration?.({ root, outDir, entryModule, piletPackage });
321
+ logDone(`Manifest available at "${outDir}/${manifest}"!`);
187
322
  }
188
323
 
189
- logDone('Pilet built successfully!');
190
- await hooks.onEnd?.({ root });
324
+ await hooks.onEnd?.({});
191
325
  }
@@ -199,6 +199,7 @@ export async function buildPiral(baseDir = process.cwd(), options: BuildPiralOpt
199
199
  root,
200
200
  piral: name,
201
201
  emulator: true,
202
+ standalone: false,
202
203
  optimizeModules,
203
204
  sourceMaps,
204
205
  contentHash,
@@ -219,11 +220,11 @@ export async function buildPiral(baseDir = process.cwd(), options: BuildPiralOpt
219
220
 
220
221
  await runLifecycle(root, scripts, 'piral:postbuild');
221
222
  await runLifecycle(root, scripts, `piral:postbuild-${emulatorName}`);
222
-
223
+
223
224
  await hooks.beforeEmulator?.({ root, externals, targetDir, outDir });
224
225
 
225
226
  const rootDir = await createEmulatorSources(root, outDir, outFile, logLevel);
226
-
227
+
227
228
  await hooks.afterEmulator?.({ root, externals, targetDir, outDir, rootDir });
228
229
 
229
230
  if (type !== emulatorSourcesName) {
@@ -247,7 +248,7 @@ export async function buildPiral(baseDir = process.cwd(), options: BuildPiralOpt
247
248
  await removeDirectory(targetDir);
248
249
 
249
250
  logInfo(`Bundle ${releaseName} ...`);
250
-
251
+
251
252
  await hooks.beforeBuild?.({ root, publicUrl, externals, entryFiles, targetDir, name });
252
253
 
253
254
  const { dir: outDir, name: outFile, hash } = await callPiralBuild(
@@ -255,6 +256,7 @@ export async function buildPiral(baseDir = process.cwd(), options: BuildPiralOpt
255
256
  root,
256
257
  piral: name,
257
258
  emulator: false,
259
+ standalone: false,
258
260
  optimizeModules,
259
261
  sourceMaps,
260
262
  contentHash,
@@ -270,7 +272,7 @@ export async function buildPiral(baseDir = process.cwd(), options: BuildPiralOpt
270
272
  },
271
273
  bundlerName,
272
274
  );
273
-
275
+
274
276
  await hooks.afterBuild?.({ root, publicUrl, externals, entryFiles, targetDir, name, outDir, outFile, hash });
275
277
 
276
278
  await runLifecycle(root, scripts, 'piral:postbuild');
@@ -65,9 +65,9 @@ export interface DebugPiletOptions {
65
65
  schemaVersion?: PiletSchemaVersion;
66
66
 
67
67
  /**
68
- * The URL of a pilet feed used to include locally missing pilets.
68
+ * The URL of a pilet feed(s) used to include locally missing pilets.
69
69
  */
70
- feed?: string;
70
+ feed?: string | Array<string>;
71
71
 
72
72
  /**
73
73
  * Additional arguments for a specific bundler.
@@ -1,5 +1,5 @@
1
- import { relative, join, dirname, basename, resolve } from 'path';
2
- import { buildPilet } from './build-pilet';
1
+ import { relative, dirname, basename, resolve } from 'path';
2
+ import { callPiletBuild } from '../bundler';
3
3
  import { LogLevels, PiletSchemaVersion, PiletPublishSource } from '../types';
4
4
  import {
5
5
  postFile,
@@ -15,6 +15,10 @@ import {
15
15
  checkExists,
16
16
  findTarball,
17
17
  downloadFile,
18
+ matchAnyPilet,
19
+ retrievePiletData,
20
+ removeDirectory,
21
+ logInfo,
18
22
  } from '../common';
19
23
 
20
24
  export interface PublishPiletOptions {
@@ -23,7 +27,7 @@ export interface PublishPiletOptions {
23
27
  * used with `--fresh`, otherwise expects source to be a path leading
24
28
  * to a `*.tgz` file.
25
29
  */
26
- source?: string;
30
+ source?: string | Array<string>;
27
31
 
28
32
  /**
29
33
  * Sets the URL of the feed service to deploy to.
@@ -67,6 +71,16 @@ export interface PublishPiletOptions {
67
71
  * Places additional fields that should be posted to the feed service.
68
72
  */
69
73
  fields?: Record<string, string>;
74
+
75
+ /**
76
+ * Sets the bundler to use for building, if any specific.
77
+ */
78
+ bundlerName?: string;
79
+
80
+ /**
81
+ * Additional arguments for a specific bundler.
82
+ */
83
+ _?: Record<string, any>;
70
84
  }
71
85
 
72
86
  export const publishPiletDefaults: PublishPiletOptions = {
@@ -83,41 +97,94 @@ export const publishPiletDefaults: PublishPiletOptions = {
83
97
 
84
98
  async function getFiles(
85
99
  baseDir: string,
86
- source: string,
100
+ sources: Array<string>,
87
101
  from: PiletPublishSource,
88
102
  fresh: boolean,
89
103
  schemaVersion: PiletSchemaVersion,
104
+ logLevel: LogLevels,
105
+ bundlerName: string,
106
+ _?: Record<string, any>,
90
107
  ca?: Buffer,
91
108
  ): Promise<Array<string>> {
92
109
  if (fresh) {
93
110
  log('generalDebug_0003', 'Detected "--fresh". Trying to resolve the package.json.');
94
- const details = require(join(baseDir, 'package.json'));
95
- progress('Triggering pilet build ...');
96
- await buildPilet(baseDir, {
97
- target: details.main,
98
- fresh,
99
- schemaVersion,
100
- });
101
- log('generalDebug_0003', 'Successfully built.');
102
- progress('Triggering pilet pack ...');
103
- const file = await createPiletPackage(baseDir, '.', '.');
104
- log('generalDebug_0003', 'Successfully packed.');
105
- return [file];
111
+ const allEntries = await matchAnyPilet(baseDir, sources);
112
+
113
+ if (allEntries.length === 0) {
114
+ fail('entryFileMissing_0077');
115
+ }
116
+
117
+ return await Promise.all(
118
+ allEntries.map(async (entryModule) => {
119
+ const targetDir = dirname(entryModule);
120
+ const { root, piletPackage, importmap, peerDependencies, peerModules, appPackage } = await retrievePiletData(
121
+ targetDir,
122
+ );
123
+ const dest = resolve(root, piletPackage.main);
124
+ const outDir = dirname(dest);
125
+ const outFile = basename(dest);
126
+ const externals = [...Object.keys(peerDependencies), ...peerModules];
127
+ progress('Triggering pilet build ...');
128
+
129
+ if (fresh) {
130
+ progress('Removing output directory ...');
131
+ await removeDirectory(outDir);
132
+ }
133
+
134
+ logInfo('Bundle pilet ...');
135
+
136
+ await callPiletBuild(
137
+ {
138
+ root,
139
+ piral: appPackage.name,
140
+ optimizeModules: false,
141
+ sourceMaps: true,
142
+ contentHash: true,
143
+ minify: true,
144
+ externals,
145
+ targetDir,
146
+ importmap,
147
+ outFile,
148
+ outDir,
149
+ entryModule: `./${relative(root, entryModule)}`,
150
+ logLevel,
151
+ version: schemaVersion,
152
+ ignored: [],
153
+ _,
154
+ },
155
+ bundlerName,
156
+ );
157
+
158
+ log('generalDebug_0003', `Pilet "${piletPackage.name}" built successfully!`);
159
+ progress('Triggering pilet pack ...');
160
+
161
+ const file = await createPiletPackage(root, '.', '.');
162
+ log('generalDebug_0003', `Pilet "${piletPackage.name}" packed successfully!`);
163
+
164
+ return file;
165
+ }),
166
+ );
106
167
  } else {
107
168
  log('generalDebug_0003', `Did not find fresh flag. Trying to match from "${from}".`);
108
169
 
109
170
  switch (from) {
110
- case 'local':
111
- log('generalDebug_0003', `Matching files using "${source}".`);
112
- return await matchFiles(baseDir, source);
113
- case 'remote':
114
- log('generalDebug_0003', `Download file from "${source}".`);
115
- return await downloadFile(source, ca);
116
- case 'npm':
117
- log('generalDebug_0003', `View npm package "${source}".`);
118
- const url = await findTarball(source);
119
- log('generalDebug_0003', `Download file from "${url}".`);
120
- return await downloadFile(url, ca);
171
+ case 'local': {
172
+ log('generalDebug_0003', `Matching files using "${sources.join('", "')}".`);
173
+ const allFiles = await Promise.all(sources.map((s) => matchFiles(baseDir, s)));
174
+ return allFiles.reduce((result, files) => [...result, ...files], []);
175
+ }
176
+ case 'remote': {
177
+ log('generalDebug_0003', `Download file from "${sources.join('", "')}".`);
178
+ const allFiles = await Promise.all(sources.map((s) => downloadFile(s, ca)));
179
+ return allFiles.reduce((result, files) => [...result, ...files], []);
180
+ }
181
+ case 'npm': {
182
+ log('generalDebug_0003', `View npm package "${sources.join('", "')}".`);
183
+ const allUrls = await Promise.all(sources.map((s) => findTarball(s)));
184
+ log('generalDebug_0003', `Download file from "${allUrls.join('", "')}".`);
185
+ const allFiles = await Promise.all(allUrls.map((url) => downloadFile(url, ca)));
186
+ return allFiles.reduce((result, files) => [...result, ...files], []);
187
+ }
121
188
  }
122
189
  }
123
190
  }
@@ -133,6 +200,8 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
133
200
  schemaVersion = publishPiletDefaults.schemaVersion,
134
201
  cert = config.cert ?? publishPiletDefaults.cert,
135
202
  fields = publishPiletDefaults.fields,
203
+ _ = {},
204
+ bundlerName,
136
205
  } = options;
137
206
  const fullBase = resolve(process.cwd(), baseDir);
138
207
  setLogLevel(logLevel);
@@ -153,12 +222,13 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
153
222
  }
154
223
 
155
224
  log('generalDebug_0003', 'Getting the tgz files ...');
156
- const files = await getFiles(fullBase, source, from, fresh, schemaVersion, ca);
225
+ const sources = Array.isArray(source) ? source : [source];
226
+ const files = await getFiles(fullBase, sources, from, fresh, schemaVersion, logLevel, bundlerName, _, ca);
157
227
  const successfulUploads: Array<string> = [];
158
228
  log('generalDebug_0003', 'Received available tgz files.');
159
229
 
160
230
  if (files.length === 0) {
161
- fail('missingPiletTarball_0061', source);
231
+ fail('missingPiletTarball_0061', sources);
162
232
  }
163
233
 
164
234
  log('generalInfo_0000', `Using feed service "${url}".`);
@@ -7,6 +7,7 @@ function run(
7
7
  root: string,
8
8
  piral: string,
9
9
  emulator: boolean,
10
+ standalone: boolean,
10
11
  sourceMaps: boolean,
11
12
  contentHash: boolean,
12
13
  minify: boolean,
@@ -22,7 +23,7 @@ function run(
22
23
  production: !emulator,
23
24
  root,
24
25
  debugPiral: emulator,
25
- debugPilet: emulator,
26
+ debugPilet: emulator || standalone,
26
27
  piral,
27
28
  dependencies: externals,
28
29
  });
@@ -56,6 +57,7 @@ process.on('message', async (msg) => {
56
57
  process.cwd(),
57
58
  msg.piral,
58
59
  msg.emulator,
60
+ msg.standalone,
59
61
  msg.sourceMaps,
60
62
  msg.contentHash,
61
63
  msg.minify,
package/src/commands.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { piletBuildTypeKeys } from '.';
1
2
  import * as apps from './apps';
2
3
  import {
3
4
  availableBundlers,
@@ -13,7 +14,7 @@ import {
13
14
  schemaKeys,
14
15
  fromKeys,
15
16
  bundlerKeys,
16
- buildTypeKeys,
17
+ piralBuildTypeKeys,
17
18
  } from './helpers';
18
19
  import {
19
20
  ToolCommand,
@@ -23,6 +24,7 @@ import {
23
24
  PiralBuildType,
24
25
  PiletPublishSource,
25
26
  PiletSchemaVersion,
27
+ PiletBuildType,
26
28
  } from './types';
27
29
 
28
30
  function specializeCommand(commands: Array<ToolCommand<any>>, command: ToolCommand<any>, suffix: string) {
@@ -143,7 +145,7 @@ const allCommands: Array<ToolCommand<any>> = [
143
145
  .boolean('optimize-modules')
144
146
  .describe('optimize-modules', 'Also includes the node modules for target transpilation.')
145
147
  .default('optimize-modules', apps.buildPiralDefaults.optimizeModules)
146
- .choices('type', buildTypeKeys)
148
+ .choices('type', piralBuildTypeKeys)
147
149
  .describe('type', 'Selects the target type of the build. "all" builds all target types.')
148
150
  .default('type', apps.buildPiralDefaults.type)
149
151
  .choices('bundler', availableBundlers)
@@ -186,7 +188,7 @@ const allCommands: Array<ToolCommand<any>> = [
186
188
  .number('log-level')
187
189
  .describe('log-level', 'Sets the log level to use (1-5).')
188
190
  .default('log-level', apps.publishPiralDefaults.logLevel)
189
- .choices('type', buildTypeKeys)
191
+ .choices('type', piralBuildTypeKeys)
190
192
  .describe('type', 'Selects the target type to publish. "all" publishes all target types.')
191
193
  .default('type', apps.publishPiralDefaults.type)
192
194
  .choices('provider', availableReleaseProviders)
@@ -482,6 +484,9 @@ const allCommands: Array<ToolCommand<any>> = [
482
484
  .choices('bundler', availableBundlers)
483
485
  .describe('bundler', 'Sets the bundler to use.')
484
486
  .default('bundler', availableBundlers[0])
487
+ .choices('type', piletBuildTypeKeys)
488
+ .describe('type', 'Selects the target type of the build.')
489
+ .default('type', apps.buildPiletDefaults.type)
485
490
  .string('app')
486
491
  .describe('app', 'Sets the name of the Piral instance.')
487
492
  .string('base')
@@ -498,6 +503,7 @@ const allCommands: Array<ToolCommand<any>> = [
498
503
  declaration: args.declaration as boolean,
499
504
  sourceMaps: args['source-maps'] as boolean,
500
505
  optimizeModules: args['optimize-modules'] as boolean,
506
+ type: args.type as PiletBuildType,
501
507
  fresh: args.fresh as boolean,
502
508
  logLevel: args['log-level'] as LogLevels,
503
509
  schemaVersion: args.schema as PiletSchemaVersion,
@@ -567,6 +573,9 @@ const allCommands: Array<ToolCommand<any>> = [
567
573
  .choices('schema', schemaKeys)
568
574
  .describe('schema', 'Sets the schema to be used when making a fresh build of the pilet.')
569
575
  .default('schema', apps.publishPiletDefaults.schemaVersion)
576
+ .choices('bundler', availableBundlers)
577
+ .describe('bundler', 'Sets the bundler to use.')
578
+ .default('bundler', availableBundlers[0])
570
579
  .choices('from', fromKeys)
571
580
  .describe('from', 'Sets the type of the source to use for publishing.')
572
581
  .default('from', apps.publishPiletDefaults.from)
@@ -584,10 +593,12 @@ const allCommands: Array<ToolCommand<any>> = [
584
593
  url: args.url as string,
585
594
  logLevel: args['log-level'] as LogLevels,
586
595
  cert: args['ca-cert'] as string,
596
+ bundlerName: args.bundler as string,
587
597
  fresh: args.fresh as boolean,
588
598
  from: args.from as PiletPublishSource,
589
599
  schemaVersion: args.schema as PiletSchemaVersion,
590
600
  fields: args.fields as Record<string, string>,
601
+ _: args,
591
602
  });
592
603
  },
593
604
  },
@@ -4,6 +4,12 @@ import { log } from './log';
4
4
 
5
5
  export function checkAppShellCompatibility(piralVersion: string) {
6
6
  log('generalDebug_0003', `Checking compatibility ...`);
7
+
8
+ if (!piralVersion) {
9
+ log('appShellMaybeIncompatible_0102', cliVersion);
10
+ return false;
11
+ }
12
+
7
13
  const compatible = findCompatVersion(piralVersion);
8
14
  log('generalDebug_0003', `Used versions: "${compatible}" and "${compatVersion}".`);
9
15
 
@@ -25,4 +25,5 @@ export * from './port';
25
25
  export * from './rules';
26
26
  export * from './scaffold';
27
27
  export * from './scripts';
28
+ export * from './spec';
28
29
  export * from './template';