piral-cli 1.3.1-beta.6128 → 1.3.1-beta.6135

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.
@@ -29,5 +29,5 @@ var LogLevels;
29
29
  * timestamps.
30
30
  */
31
31
  LogLevels[LogLevels["debug"] = 5] = "debug";
32
- })(LogLevels = exports.LogLevels || (exports.LogLevels = {}));
32
+ })(LogLevels || (exports.LogLevels = LogLevels = {}));
33
33
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;AAoDA,IAAY,SA2BX;AA3BD,WAAY,SAAS;IACnB;;OAEG;IACH,iDAAY,CAAA;IACZ;;OAEG;IACH,2CAAS,CAAA;IACT;;OAEG;IACH,+CAAW,CAAA;IACX;;OAEG;IACH,yCAAQ,CAAA;IACR;;;OAGG;IACH,+CAAW,CAAA;IACX;;;OAGG;IACH,2CAAS,CAAA;AACX,CAAC,EA3BW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QA2BpB"}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;AAoDA,IAAY,SA2BX;AA3BD,WAAY,SAAS;IACnB;;OAEG;IACH,iDAAY,CAAA;IACZ;;OAEG;IACH,2CAAS,CAAA;IACT;;OAEG;IACH,+CAAW,CAAA;IACX;;OAEG;IACH,yCAAQ,CAAA;IACR;;;OAGG;IACH,+CAAW,CAAA;IACX;;;OAGG;IACH,2CAAS,CAAA;AACX,CAAC,EA3BW,SAAS,yBAAT,SAAS,QA2BpB"}
@@ -192,6 +192,7 @@ export interface BundlerDefinition {
192
192
  buildPilet: BuildPiletBundlerDefinition;
193
193
  }
194
194
  export type ImportmapVersions = 'all' | 'match-major' | 'any-patch' | 'exact';
195
+ export type ImportmapMode = 'host' | 'remote';
195
196
  export type PiletSchemaVersion = 'none' | 'v0' | 'v1' | 'v2' | 'v3';
196
197
  export type SourceLanguage = 'js' | 'ts';
197
198
  export type PiletPublishScheme = 'none' | 'digest' | 'bearer' | 'basic';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli",
3
- "version": "1.3.1-beta.6128",
3
+ "version": "1.3.1-beta.6135",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -81,5 +81,5 @@
81
81
  "typescript": "^5.0.0",
82
82
  "yargs": "^15.0.0"
83
83
  },
84
- "gitHead": "0a7041321aa3b3c86371377f74094df506ec3bae"
84
+ "gitHead": "553fea569c05719bdd52e2d0f4e141f165721243"
85
85
  }
@@ -4,7 +4,7 @@ import { satisfies, validate } from './version';
4
4
  import { computeHash } from './hash';
5
5
  import { getHash, readJson, findFile, checkExists, checkIsDirectory } from './io';
6
6
  import { tryResolvePackage } from './npm';
7
- import { SharedDependency, Importmap, ImportmapVersions } from '../types';
7
+ import { SharedDependency, Importmap, ImportmapVersions, ImportmapMode } from '../types';
8
8
 
9
9
  const shorthandsUrls = ['', '.', '...'];
10
10
 
@@ -105,13 +105,14 @@ async function getInheritedDependencies(
105
105
  inheritedImport: string,
106
106
  dir: string,
107
107
  excludedDependencies: Array<string>,
108
+ inheritanceBehavior: ImportmapMode,
108
109
  ): Promise<Array<SharedDependency>> {
109
110
  const packageJson = tryResolvePackage(`${inheritedImport}/package.json`, dir);
110
111
 
111
112
  if (packageJson) {
112
113
  const packageDir = dirname(packageJson);
113
114
  const packageDetails = await readJson(packageDir, 'package.json');
114
- return await consumeImportmap(packageDir, packageDetails, true, 'exact', excludedDependencies);
115
+ return await consumeImportmap(packageDir, packageDetails, true, 'exact', inheritanceBehavior, excludedDependencies);
115
116
  } else {
116
117
  const directImportmap = tryResolvePackage(inheritedImport, dir);
117
118
 
@@ -120,6 +121,7 @@ async function getInheritedDependencies(
120
121
  const content = await readJson(baseDir, basename(directImportmap));
121
122
  return await resolveImportmap(baseDir, content, {
122
123
  availableSpecs: {},
124
+ inheritanceBehavior,
123
125
  excludedDependencies,
124
126
  ignoreFailure: true,
125
127
  versionBehavior: 'exact',
@@ -134,6 +136,7 @@ interface ImportmapResolutionOptions {
134
136
  availableSpecs: Record<string, string>;
135
137
  excludedDependencies: Array<string>;
136
138
  versionBehavior: ImportmapVersions;
139
+ inheritanceBehavior: ImportmapMode;
137
140
  ignoreFailure: boolean;
138
141
  }
139
142
 
@@ -147,11 +150,12 @@ async function resolveImportmap(
147
150
  const inheritedImports = importmap?.inherit;
148
151
  const excludedImports = importmap?.exclude;
149
152
 
150
- const onUnresolved = (entry: string) => {
153
+ const onUnresolved = (name: string, version: string) => {
151
154
  if (options.ignoreFailure) {
152
- log('skipUnresolvedDependency_0054', entry);
155
+ const id = version ? `${name}@${version}` : name;
156
+ log('skipUnresolvedDependency_0054', id);
153
157
  } else {
154
- fail('importMapReferenceNotFound_0027', dir, entry);
158
+ fail('importMapReferenceNotFound_0027', dir, name);
155
159
  }
156
160
  };
157
161
 
@@ -199,7 +203,7 @@ async function resolveImportmap(
199
203
  isAsync,
200
204
  );
201
205
  } else {
202
- onUnresolved(identifier);
206
+ onUnresolved(identifier, versionSpec);
203
207
  }
204
208
  } else if (!url.startsWith('.') && !isAbsolute(url)) {
205
209
  const entry = tryResolvePackage(url, dir);
@@ -224,7 +228,7 @@ async function resolveImportmap(
224
228
  isAsync,
225
229
  );
226
230
  } else {
227
- onUnresolved(url);
231
+ onUnresolved(url, versionSpec);
228
232
  }
229
233
  } else {
230
234
  const entry = resolve(dir, url);
@@ -256,7 +260,7 @@ async function resolveImportmap(
256
260
  isAsync,
257
261
  );
258
262
  } else if (isDirectory) {
259
- onUnresolved(entry);
263
+ onUnresolved(entry, versionSpec);
260
264
  } else {
261
265
  const hash = await getHash(entry);
262
266
 
@@ -271,19 +275,23 @@ async function resolveImportmap(
271
275
  });
272
276
  }
273
277
  } else {
274
- onUnresolved(url);
278
+ onUnresolved(url, versionSpec);
275
279
  }
276
280
  }
277
281
  }
278
282
  }
279
283
 
280
284
  if (Array.isArray(inheritedImports)) {
281
- const excluded = Array.isArray(excludedImports)
282
- ? [...options.excludedDependencies, ...excludedImports]
283
- : options.excludedDependencies;
285
+ const includedImports = [...options.excludedDependencies, ...dependencies.map((m) => m.name)];
286
+ const excluded = Array.isArray(excludedImports) ? [...includedImports, ...excludedImports] : includedImports;
284
287
 
285
288
  for (const inheritedImport of inheritedImports) {
286
- const otherDependencies = await getInheritedDependencies(inheritedImport, dir, excluded);
289
+ const otherDependencies = await getInheritedDependencies(
290
+ inheritedImport,
291
+ dir,
292
+ excluded,
293
+ options.inheritanceBehavior,
294
+ );
287
295
 
288
296
  for (const dependency of otherDependencies) {
289
297
  const entry = dependencies.find((dep) => dep.name === dependency.name);
@@ -307,10 +315,13 @@ async function consumeImportmap(
307
315
  packageDetails: any,
308
316
  inherited: boolean,
309
317
  versionBehavior: ImportmapVersions,
318
+ mode: ImportmapMode,
310
319
  excludedDependencies: Array<string>,
311
320
  ): Promise<Array<SharedDependency>> {
312
321
  const importmap = packageDetails.importmap;
313
- const availableSpecs = inherited ? packageDetails.devDependencies : {};
322
+ const appShell = inherited && mode === 'remote';
323
+ const availableSpecs = appShell ? packageDetails.devDependencies : {};
324
+ const inheritanceBehavior = appShell ? 'host' : mode;
314
325
 
315
326
  if (typeof importmap === 'string') {
316
327
  const notFound = {};
@@ -326,6 +337,7 @@ async function consumeImportmap(
326
337
  ignoreFailure: inherited,
327
338
  excludedDependencies,
328
339
  versionBehavior,
340
+ inheritanceBehavior,
329
341
  });
330
342
  } else if (typeof importmap === 'undefined' && inherited) {
331
343
  // Fall back to sharedDependencies or pilets.external if available
@@ -348,6 +360,7 @@ async function consumeImportmap(
348
360
  excludedDependencies,
349
361
  ignoreFailure: inherited,
350
362
  versionBehavior,
363
+ inheritanceBehavior,
351
364
  });
352
365
  }
353
366
 
@@ -355,6 +368,7 @@ export function readImportmap(
355
368
  dir: string,
356
369
  packageDetails: any,
357
370
  versionBehavior: ImportmapVersions = 'exact',
371
+ inheritanceBehavior: ImportmapMode = 'remote',
358
372
  ): Promise<Array<SharedDependency>> {
359
- return consumeImportmap(dir, packageDetails, false, versionBehavior, []);
373
+ return consumeImportmap(dir, packageDetails, false, versionBehavior, inheritanceBehavior, []);
360
374
  }
@@ -558,9 +558,9 @@ export function flattenExternals(dependencies: Array<SharedDependency>, disableA
558
558
  }
559
559
 
560
560
  export async function retrieveExternals(root: string, packageInfo: any): Promise<Array<SharedDependency>> {
561
- const sharedDependencies = await readImportmap(root, packageInfo);
561
+ const importmap = await readImportmap(root, packageInfo, 'exact', 'host');
562
562
 
563
- if (sharedDependencies.length === 0) {
563
+ if (importmap.length === 0) {
564
564
  const allDeps = {
565
565
  ...packageInfo.devDependencies,
566
566
  ...packageInfo.dependencies,
@@ -577,7 +577,7 @@ export async function retrieveExternals(root: string, packageInfo: any): Promise
577
577
  }));
578
578
  }
579
579
 
580
- return sharedDependencies;
580
+ return importmap;
581
581
  }
582
582
 
583
583
  export async function retrievePiletsInfo(entryFile: string) {
@@ -819,7 +819,7 @@ export async function retrievePiletData(target: string, app?: string) {
819
819
  });
820
820
  }
821
821
 
822
- const importmap = await readImportmap(root, piletPackage, piletDefinition?.importmapVersions);
822
+ const importmap = await readImportmap(root, piletPackage, piletDefinition?.importmapVersions, 'remote');
823
823
 
824
824
  return {
825
825
  dependencies: piletPackage.dependencies || {},
@@ -221,6 +221,8 @@ export interface BundlerDefinition {
221
221
 
222
222
  export type ImportmapVersions = 'all' | 'match-major' | 'any-patch' | 'exact';
223
223
 
224
+ export type ImportmapMode = 'host' | 'remote';
225
+
224
226
  export type PiletSchemaVersion = 'none' | 'v0' | 'v1' | 'v2' | 'v3';
225
227
 
226
228
  export type SourceLanguage = 'js' | 'ts';