piral-cli 0.14.2 → 0.14.3-beta.3295

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 (47) hide show
  1. package/lib/apps/build-pilet.d.ts +6 -2
  2. package/lib/apps/build-pilet.js +86 -39
  3. package/lib/apps/build-pilet.js.map +1 -1
  4. package/lib/apps/debug-pilet.d.ts +2 -2
  5. package/lib/apps/publish-pilet.d.ts +1 -1
  6. package/lib/apps/publish-pilet.js +21 -14
  7. package/lib/apps/publish-pilet.js.map +1 -1
  8. package/lib/commands.js +7 -2
  9. package/lib/commands.js.map +1 -1
  10. package/lib/common/compatibility.js +4 -0
  11. package/lib/common/compatibility.js.map +1 -1
  12. package/lib/common/index.d.ts +1 -0
  13. package/lib/common/index.js +1 -0
  14. package/lib/common/index.js.map +1 -1
  15. package/lib/common/npm.d.ts +2 -1
  16. package/lib/common/npm.js +34 -8
  17. package/lib/common/npm.js.map +1 -1
  18. package/lib/common/spec.d.ts +29 -0
  19. package/lib/common/spec.js +57 -0
  20. package/lib/common/spec.js.map +1 -0
  21. package/lib/helpers.d.ts +3 -2
  22. package/lib/helpers.js +3 -2
  23. package/lib/helpers.js.map +1 -1
  24. package/lib/injectors/pilet.d.ts +2 -2
  25. package/lib/injectors/pilet.js +32 -74
  26. package/lib/injectors/pilet.js.map +1 -1
  27. package/lib/messages.d.ts +14 -1
  28. package/lib/messages.js +23 -3
  29. package/lib/messages.js.map +1 -1
  30. package/lib/rules/pilet-uses-latest-piral.js +17 -8
  31. package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
  32. package/lib/types/public.d.ts +1 -0
  33. package/package.json +2 -2
  34. package/src/apps/build-pilet.ts +135 -47
  35. package/src/apps/debug-pilet.ts +2 -2
  36. package/src/apps/publish-pilet.ts +22 -15
  37. package/src/commands.ts +9 -3
  38. package/src/common/compatibility.ts +6 -0
  39. package/src/common/index.ts +1 -0
  40. package/src/common/io.ts +2 -2
  41. package/src/common/npm.ts +44 -11
  42. package/src/common/spec.ts +58 -0
  43. package/src/helpers.ts +10 -2
  44. package/src/injectors/pilet.ts +31 -78
  45. package/src/messages.ts +22 -2
  46. package/src/rules/pilet-uses-latest-piral.ts +21 -11
  47. package/src/types/public.ts +2 -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,12 @@ import {
13
13
  matchAnyPilet,
14
14
  fail,
15
15
  config,
16
+ log,
17
+ createDirectory,
18
+ writeJson,
19
+ getPiletSpecMeta,
20
+ getFileNames,
21
+ copy,
16
22
  } from '../common';
17
23
 
18
24
  export interface BuildPiletOptions {
@@ -25,7 +31,7 @@ export interface BuildPiletOptions {
25
31
  * The source index file (e.g. index.tsx) for collecting all the information
26
32
  * @example './src/index'
27
33
  */
28
- entry?: string;
34
+ entry?: string | Array<string>;
29
35
 
30
36
  /**
31
37
  * The target file of bundling.
@@ -68,6 +74,11 @@ export interface BuildPiletOptions {
68
74
  */
69
75
  contentHash?: boolean;
70
76
 
77
+ /**
78
+ * Selects the target type of the build (e.g. 'release'). "all" builds all target types.
79
+ */
80
+ type?: PiletBuildType;
81
+
71
82
  /**
72
83
  * States if the node modules should be included for target transpilation
73
84
  */
@@ -102,6 +113,7 @@ export const buildPiletDefaults: BuildPiletOptions = {
102
113
  target: './dist/index.js',
103
114
  minify: true,
104
115
  logLevel: LogLevels.info,
116
+ type: 'default',
105
117
  fresh: false,
106
118
  sourceMaps: true,
107
119
  contentHash: true,
@@ -122,70 +134,146 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
122
134
  optimizeModules = buildPiletDefaults.optimizeModules,
123
135
  schemaVersion = buildPiletDefaults.schemaVersion,
124
136
  declaration = buildPiletDefaults.declaration,
137
+ type = buildPiletDefaults.type,
125
138
  _ = {},
126
139
  hooks = {},
127
140
  bundlerName,
128
141
  app,
129
142
  } = options;
130
143
  const fullBase = resolve(process.cwd(), baseDir);
144
+ const entryList = Array.isArray(entry) ? entry : [entry];
131
145
  setLogLevel(logLevel);
132
146
 
133
147
  await hooks.onBegin?.({ options, fullBase });
134
148
  progress('Reading configuration ...');
135
- const allEntries = await matchAnyPilet(fullBase, [entry]);
149
+ const allEntries = await matchAnyPilet(fullBase, entryList);
150
+ log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
136
151
 
137
152
  if (allEntries.length === 0) {
138
153
  fail('entryFileMissing_0077');
139
154
  }
140
155
 
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,
146
- );
147
- const externals = [...Object.keys(peerDependencies), ...peerModules];
148
- const outDir = dirname(resolve(fullBase, target));
156
+ const pilets = await Promise.all(
157
+ allEntries.map(async (entryModule) => {
158
+ const targetDir = dirname(entryModule);
159
+ const { peerDependencies, peerModules, root, appPackage, appFile, piletPackage, ignored, importmap } =
160
+ await retrievePiletData(targetDir, app);
161
+ const externals = [...Object.keys(peerDependencies), ...peerModules];
162
+ const dest = resolve(root, target);
163
+ const outDir = dirname(dest);
164
+ const outFile = basename(dest);
149
165
 
150
- if (fresh) {
151
- progress('Removing output directory ...');
152
- await removeDirectory(outDir);
153
- }
166
+ if (fresh) {
167
+ progress('Removing output directory ...');
168
+ await removeDirectory(outDir);
169
+ }
154
170
 
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,
171
+ logInfo('Bundle pilet ...');
172
+
173
+ await hooks.beforeBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
174
+
175
+ await callPiletBuild(
176
+ {
177
+ root,
178
+ piral: appPackage.name,
179
+ optimizeModules,
180
+ sourceMaps,
181
+ contentHash,
182
+ minify,
183
+ externals,
184
+ targetDir,
185
+ importmap,
186
+ outFile,
187
+ outDir,
188
+ entryModule: `./${relative(root, entryModule)}`,
189
+ logLevel,
190
+ version: schemaVersion,
191
+ ignored,
192
+ _,
193
+ },
194
+ bundlerName,
195
+ );
196
+
197
+ await hooks.afterBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
198
+
199
+ if (declaration) {
200
+ await hooks.beforeDeclaration?.({ root, outDir, entryModule, piletPackage });
201
+ await createPiletDeclaration(
202
+ piletPackage.name,
203
+ root,
204
+ entryModule,
205
+ externals,
206
+ outDir,
207
+ ForceOverwrite.yes,
208
+ logLevel,
209
+ );
210
+ await hooks.afterDeclaration?.({ root, outDir, entryModule, piletPackage });
211
+ }
212
+
213
+ logDone(`Pilet "${piletPackage.name}" built successfully!`);
214
+
215
+ return {
216
+ id: piletPackage.name.replace(/[^a-zA-Z0-9\-]/gi, ''),
217
+ root,
218
+ appFile,
219
+ appPackage,
220
+ outDir,
221
+ outFile,
222
+ path: dest,
223
+ package: piletPackage,
224
+ };
225
+ }),
179
226
  );
180
227
 
181
- await hooks.afterBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
228
+ if (type === 'standalone') {
229
+ const outDir = resolve(fullBase, target, 'standalone');
230
+ const { appFile, appPackage, root } = pilets[0];
231
+ await createDirectory(outDir);
232
+
233
+ Promise.all(
234
+ pilets.map(async (p) => {
235
+ const files = await getFileNames(p.outDir);
236
+
237
+ for (const file of files) {
238
+ await copy(resolve(p.outDir, file), resolve(outDir, p.id, file), ForceOverwrite.yes);
239
+ }
240
+ }),
241
+ );
242
+
243
+ await callPiralBuild(
244
+ {
245
+ root,
246
+ piral: appPackage.name,
247
+ emulator: false,
248
+ optimizeModules: false,
249
+ sourceMaps,
250
+ contentHash,
251
+ minify,
252
+ externals: [],
253
+ publicUrl: '/',
254
+ outFile: 'index.html',
255
+ outDir,
256
+ entryFiles: appFile,
257
+ logLevel,
258
+ ignored: [],
259
+ _,
260
+ },
261
+ bundlerName,
262
+ );
263
+
264
+ await writeJson(
265
+ outDir,
266
+ '$pilet-api',
267
+ pilets.map((p) => ({
268
+ name: p.package.name,
269
+ version: p.package.version,
270
+ link: `./${p.id}/${p.outFile}`,
271
+ ...getPiletSpecMeta(p.path, p.outDir),
272
+ })),
273
+ );
182
274
 
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 });
275
+ logDone(`Standalone app available at "${outDir}"!`);
187
276
  }
188
277
 
189
- logDone('Pilet built successfully!');
190
- await hooks.onEnd?.({ root });
278
+ await hooks.onEnd?.({});
191
279
  }
@@ -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.
@@ -23,7 +23,7 @@ export interface PublishPiletOptions {
23
23
  * used with `--fresh`, otherwise expects source to be a path leading
24
24
  * to a `*.tgz` file.
25
25
  */
26
- source?: string;
26
+ source?: string | Array<string>;
27
27
 
28
28
  /**
29
29
  * Sets the URL of the feed service to deploy to.
@@ -83,7 +83,7 @@ export const publishPiletDefaults: PublishPiletOptions = {
83
83
 
84
84
  async function getFiles(
85
85
  baseDir: string,
86
- source: string,
86
+ sources: Array<string>,
87
87
  from: PiletPublishSource,
88
88
  fresh: boolean,
89
89
  schemaVersion: PiletSchemaVersion,
@@ -107,17 +107,23 @@ async function getFiles(
107
107
  log('generalDebug_0003', `Did not find fresh flag. Trying to match from "${from}".`);
108
108
 
109
109
  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);
110
+ case 'local': {
111
+ log('generalDebug_0003', `Matching files using "${sources.join('", "')}".`);
112
+ const allFiles = await Promise.all(sources.map((s) => matchFiles(baseDir, s)));
113
+ return allFiles.reduce((result, files) => [...result, ...files], []);
114
+ }
115
+ case 'remote': {
116
+ log('generalDebug_0003', `Download file from "${sources.join('", "')}".`);
117
+ const allFiles = await Promise.all(sources.map((s) => downloadFile(s, ca)));
118
+ return allFiles.reduce((result, files) => [...result, ...files], []);
119
+ }
120
+ case 'npm': {
121
+ log('generalDebug_0003', `View npm package "${sources.join('", "')}".`);
122
+ const allUrls = await Promise.all(sources.map((s) => findTarball(s)));
123
+ log('generalDebug_0003', `Download file from "${allUrls.join('", "')}".`);
124
+ const allFiles = await Promise.all(allUrls.map((url) => downloadFile(url, ca)));
125
+ return allFiles.reduce((result, files) => [...result, ...files], []);
126
+ }
121
127
  }
122
128
  }
123
129
  }
@@ -153,12 +159,13 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
153
159
  }
154
160
 
155
161
  log('generalDebug_0003', 'Getting the tgz files ...');
156
- const files = await getFiles(fullBase, source, from, fresh, schemaVersion, ca);
162
+ const sources = Array.isArray(source) ? source : [source];
163
+ const files = await getFiles(fullBase, sources, from, fresh, schemaVersion, ca);
157
164
  const successfulUploads: Array<string> = [];
158
165
  log('generalDebug_0003', 'Received available tgz files.');
159
166
 
160
167
  if (files.length === 0) {
161
- fail('missingPiletTarball_0061', source);
168
+ fail('missingPiletTarball_0061', sources);
162
169
  }
163
170
 
164
171
  log('generalInfo_0000', `Using feed service "${url}".`);
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,
@@ -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';
package/src/common/io.ts CHANGED
@@ -254,7 +254,7 @@ export async function matchAnyPilet(baseDir: string, patterns: Array<string>) {
254
254
  log('generalDebug_0003', `Found a "source" field with value "${source}".`);
255
255
  const target = resolve(targetDir, source);
256
256
  const exists = await checkExists(target);
257
-
257
+
258
258
  if (exists) {
259
259
  log('generalDebug_0003', `Taking existing target as "${target}".`);
260
260
  matched(name, target);
@@ -264,7 +264,7 @@ export async function matchAnyPilet(baseDir: string, patterns: Array<string>) {
264
264
  } else {
265
265
  log('generalDebug_0003', `No "source" field found. Trying combinations in "src".`);
266
266
  const files = await matchPattern(targetDir, `src/index.{${exts}}`);
267
-
267
+
268
268
  if (files.length > 0) {
269
269
  log('generalDebug_0003', `Found a result; taking "${files[0]}".`);
270
270
  matched(name, files[0]);
package/src/common/npm.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { resolve, relative } from 'path';
1
+ import { resolve, relative, dirname } from 'path';
2
2
  import { createReadStream, existsSync, access, constants } from 'fs';
3
3
  import { log, fail } from './log';
4
4
  import { config } from './config';
@@ -107,23 +107,56 @@ export async function determineNpmClient(root: string, selected?: NpmClientType)
107
107
 
108
108
  export async function isMonorepoPackageRef(refName: string, root: string): Promise<boolean> {
109
109
  const c = require(`./clients/npm`);
110
- const details = await c.listPackage(refName, root);
111
- return details?.dependencies?.[refName]?.extraneous ?? false;
112
- }
110
+ const newRoot = await detectMonorepoRoot(root);
113
111
 
114
- export type MonorepoKind = 'none' | 'lerna' | 'yarn';
112
+ if (newRoot) {
113
+ const details = await c.listPackage(refName, newRoot);
114
+ return details?.dependencies?.[refName]?.extraneous ?? false;
115
+ }
115
116
 
116
- export async function detectMonorepo(root: string): Promise<MonorepoKind> {
117
+ return false;
118
+ }
119
+
120
+ export async function detectMonorepoRoot(root: string): Promise<string> {
117
121
  const file = await getLernaConfigPath(root);
118
122
 
119
123
  if (file !== undefined) {
120
- return 'lerna';
124
+ return dirname(file);
121
125
  }
122
126
 
123
- const packageJson = await readJson(root, 'package.json');
127
+ let previous = root;
128
+
129
+ do {
130
+ const packageJson = await readJson(root, 'package.json');
131
+
132
+ if (Array.isArray(packageJson?.workspaces)) {
133
+ return root;
134
+ }
135
+
136
+ previous = root;
137
+ root = dirname(root);
138
+ } while (root !== previous);
139
+
140
+ return undefined;
141
+ }
142
+
143
+ export type MonorepoKind = 'none' | 'lerna' | 'yarn';
144
+
145
+ export async function detectMonorepo(root: string): Promise<MonorepoKind> {
146
+ const newRoot = await detectMonorepoRoot(root);
124
147
 
125
- if (Array.isArray(packageJson?.workspaces)) {
126
- return 'yarn';
148
+ if (newRoot) {
149
+ const file = await getLernaConfigPath(newRoot);
150
+
151
+ if (file !== undefined) {
152
+ return 'lerna';
153
+ }
154
+
155
+ const packageJson = await readJson(newRoot, 'package.json');
156
+
157
+ if (Array.isArray(packageJson?.workspaces)) {
158
+ return 'yarn';
159
+ }
127
160
  }
128
161
 
129
162
  return 'none';
@@ -159,7 +192,7 @@ export function createPackage(target = '.'): Promise<string> {
159
192
  return c.createPackage(target);
160
193
  }
161
194
 
162
- export function findTarball(packageRef: string) {
195
+ export function findTarball(packageRef: string): Promise<string> {
163
196
  const c = require(`./clients/npm`);
164
197
  return c.findTarball(packageRef);
165
198
  }
@@ -0,0 +1,58 @@
1
+ import { existsSync, readFileSync, statSync } from 'fs';
2
+ import { computeHash, computeIntegrity } from './hash';
3
+
4
+ const checkV1 = /^\/\/\s*@pilet\s+v:1\s*\(([A-Za-z0-9\_\:\-]+)\)/;
5
+ const checkV2 = /^\/\/\s*@pilet\s+v:2\s*(?:\(([A-Za-z0-9\_\:\-]+),\s*(.*)\))?/;
6
+
7
+ function getDependencies(deps: string, basePath: string) {
8
+ try {
9
+ const depMap = JSON.parse(deps);
10
+
11
+ if (depMap && typeof depMap === 'object') {
12
+ return Object.keys(depMap).reduce((obj, depName) => {
13
+ const depUrl = depMap[depName];
14
+
15
+ if (typeof depUrl === 'string') {
16
+ const url = new URL(depUrl, basePath);
17
+ obj[depName] = url.href;
18
+ }
19
+
20
+ return obj;
21
+ }, {});
22
+ }
23
+ } catch {}
24
+
25
+ return {};
26
+ }
27
+
28
+ export function getPiletSpecMeta(target: string, basePath: string) {
29
+ if (existsSync(target) && statSync(target).isFile()) {
30
+ const content = readFileSync(target, 'utf8');
31
+
32
+ if (checkV1.test(content)) {
33
+ // uses single argument; requireRef (required)
34
+ const [, requireRef] = checkV1.exec(content);
35
+ return {
36
+ spec: 'v1',
37
+ requireRef,
38
+ integrity: computeIntegrity(content),
39
+ };
40
+ } else if (checkV2.test(content)) {
41
+ // uses two arguments; requireRef and dependencies as JSON (required)
42
+ const [, requireRef, plainDependencies] = checkV2.exec(content);
43
+ return {
44
+ spec: 'v2',
45
+ requireRef,
46
+ dependencies: getDependencies(plainDependencies, basePath),
47
+ };
48
+ } else {
49
+ return {
50
+ spec: 'v0',
51
+ hash: computeHash(content),
52
+ noCache: true,
53
+ };
54
+ }
55
+ }
56
+
57
+ return {};
58
+ }
package/src/helpers.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  import { ForceOverwrite, SourceLanguage } from './common/enums';
2
- import { Framework, NpmClientType, PiletSchemaVersion, PiletPublishSource, PiralBuildType } from './types';
2
+ import {
3
+ Framework,
4
+ NpmClientType,
5
+ PiletSchemaVersion,
6
+ PiletPublishSource,
7
+ PiralBuildType,
8
+ PiletBuildType,
9
+ } from './types';
3
10
 
4
11
  export const schemaKeys: Array<PiletSchemaVersion> = ['v0', 'v1', 'v2', 'none'];
5
12
  export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
6
- export const buildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
13
+ export const piralBuildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
14
+ export const piletBuildTypeKeys: Array<PiletBuildType> = ['default', 'standalone'];
7
15
  export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn'];
8
16
  export const bundlerKeys: Array<string> = ['none', 'parcel', 'webpack', 'webpack5', 'esbuild'];
9
17
  export const availableBundlers: Array<string> = [];