piral-cli 0.15.0-alpha.4409 → 0.15.0-beta.4466
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.
- package/lib/apps/build-pilet.js +3 -2
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/debug-pilet.js +3 -2
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/new-pilet.js +3 -0
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.js +2 -0
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/publish-pilet.js +3 -2
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/cli.js +4 -2
- package/lib/cli.js.map +1 -1
- package/lib/common/clients/index.js +13 -7
- package/lib/common/clients/index.js.map +1 -1
- package/lib/common/clients/lerna.d.ts +1 -1
- package/lib/common/clients/lerna.js +2 -2
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +1 -1
- package/lib/common/clients/npm.js +2 -2
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnp.d.ts +1 -1
- package/lib/common/clients/pnp.js +2 -2
- package/lib/common/clients/pnp.js.map +1 -1
- package/lib/common/clients/pnpm.d.ts +1 -1
- package/lib/common/clients/pnpm.js +2 -2
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +1 -1
- package/lib/common/clients/rush.js +2 -2
- package/lib/common/clients/rush.js.map +1 -1
- package/lib/common/clients/yarn.d.ts +1 -1
- package/lib/common/clients/yarn.js +2 -2
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/emoji.js +8 -8
- package/lib/common/emoji.js.map +1 -1
- package/lib/common/importmap.js +22 -1
- package/lib/common/importmap.js.map +1 -1
- package/lib/common/io.d.ts +1 -1
- package/lib/common/io.js +4 -4
- package/lib/common/io.js.map +1 -1
- package/lib/common/package.d.ts +3 -3
- package/lib/common/package.js +29 -10
- package/lib/common/package.js.map +1 -1
- package/lib/types/common.d.ts +1 -0
- package/package.json +2 -2
- package/src/apps/build-pilet.ts +4 -2
- package/src/apps/debug-pilet.ts +4 -2
- package/src/apps/new-pilet.ts +8 -0
- package/src/apps/new-piral.ts +10 -0
- package/src/apps/publish-pilet.ts +4 -2
- package/src/cli.ts +6 -3
- package/src/common/clients/index.ts +9 -3
- package/src/common/clients/lerna.ts +2 -2
- package/src/common/clients/npm.ts +2 -2
- package/src/common/clients/pnp.ts +2 -2
- package/src/common/clients/pnpm.ts +2 -2
- package/src/common/clients/rush.ts +2 -2
- package/src/common/clients/yarn.ts +2 -2
- package/src/common/emoji.ts +8 -8
- package/src/common/importmap.ts +25 -2
- package/src/common/io.ts +4 -5
- package/src/common/npm.test.ts +5 -6
- package/src/common/package.ts +46 -10
- package/src/types/common.ts +1 -0
|
@@ -44,8 +44,8 @@ export async function installPackage(packageRef: string, target = '.', ...flags:
|
|
|
44
44
|
return ms.value;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export async function detectClient(root: string) {
|
|
48
|
-
return !!(await findFile(root, '.pnp.cjs'));
|
|
47
|
+
export async function detectClient(root: string, stopDir = resolve(root, '/')) {
|
|
48
|
+
return !!(await findFile(root, '.pnp.cjs', stopDir));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export async function initProject(projectName: string, target: string) {}
|
|
@@ -40,8 +40,8 @@ export async function installPackage(packageRef: string, target = '.', ...flags:
|
|
|
40
40
|
return ms.value;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export async function detectClient(root: string) {
|
|
44
|
-
return !!(await findFile(root, 'pnpm-lock.yaml'));
|
|
43
|
+
export async function detectClient(root: string, stopDir = resolve(root, '/')) {
|
|
44
|
+
return !!(await findFile(root, 'pnpm-lock.yaml', stopDir));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export async function initProject(projectName: string, target: string) {}
|
|
@@ -47,8 +47,8 @@ export async function installPackage(packageRef: string, target = '.', ...flags:
|
|
|
47
47
|
return ms.value;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export async function detectClient(root: string) {
|
|
51
|
-
return !!(await findFile(root, rushJson));
|
|
50
|
+
export async function detectClient(root: string, stopDir = resolve(root, '/')) {
|
|
51
|
+
return !!(await findFile(root, rushJson, stopDir));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export async function initProject(packageName: string, target: string) {
|
|
@@ -44,8 +44,8 @@ export async function installPackage(packageRef: string, target = '.', ...flags:
|
|
|
44
44
|
return ms.value;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export async function detectClient(root: string) {
|
|
48
|
-
return !!(await findFile(root, 'yarn.lock'));
|
|
47
|
+
export async function detectClient(root: string, stopDir = resolve(root, '/')) {
|
|
48
|
+
return !!(await findFile(root, 'yarn.lock', stopDir));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export async function initProject(projectName: string, target: string) {}
|
package/src/common/emoji.ts
CHANGED
|
@@ -5,11 +5,11 @@ const supportsEmoji = !isWindows || process.env.TERM === 'xterm-256color';
|
|
|
5
5
|
// see https://unicode.org/emoji/charts/full-emoji-list.html
|
|
6
6
|
export const liveIcon = supportsEmoji ? '🚀 ' : '>';
|
|
7
7
|
export const settingsIcon = supportsEmoji ? '🔧 ' : '>';
|
|
8
|
-
export const cactusIcon = supportsEmoji ? '👻' : '>';
|
|
9
|
-
export const clapIcon = supportsEmoji ? '👏' : '^';
|
|
10
|
-
export const sparklesIcon = supportsEmoji ? '✨' : '>';
|
|
11
|
-
export const unicornIcon = supportsEmoji ? '🦄' : '>';
|
|
12
|
-
export const caterpillerIcon = supportsEmoji ? '🐛' : '+';
|
|
13
|
-
export const butterflyIcon = supportsEmoji ? '🦋' : '+';
|
|
14
|
-
export const zapIcon = supportsEmoji ? '⚡' : '>';
|
|
15
|
-
export const rainbowIcon = supportsEmoji ? '🌈' : '~';
|
|
8
|
+
export const cactusIcon = supportsEmoji ? '👻 ' : '>';
|
|
9
|
+
export const clapIcon = supportsEmoji ? '👏 ' : '^';
|
|
10
|
+
export const sparklesIcon = supportsEmoji ? '✨ ' : '>';
|
|
11
|
+
export const unicornIcon = supportsEmoji ? '🦄 ' : '>';
|
|
12
|
+
export const caterpillerIcon = supportsEmoji ? '🐛 ' : '+';
|
|
13
|
+
export const butterflyIcon = supportsEmoji ? '🦋 ' : '+';
|
|
14
|
+
export const zapIcon = supportsEmoji ? '⚡ ' : '>';
|
|
15
|
+
export const rainbowIcon = supportsEmoji ? '🌈 ' : '~';
|
package/src/common/importmap.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolve, dirname } from 'path';
|
|
1
|
+
import { resolve, dirname, isAbsolute } from 'path';
|
|
2
2
|
import { log, fail } from './log';
|
|
3
3
|
import { satisfies, validate } from './version';
|
|
4
4
|
import { computeHash } from './hash';
|
|
@@ -84,6 +84,24 @@ async function resolveImportmap(dir: string, importmap: Importmap) {
|
|
|
84
84
|
} else {
|
|
85
85
|
fail('importMapReferenceNotFound_0027', dir, identifier);
|
|
86
86
|
}
|
|
87
|
+
} else if (!url.startsWith('.') && !isAbsolute(url)) {
|
|
88
|
+
const entry = tryResolvePackage(url, dir);
|
|
89
|
+
|
|
90
|
+
if (entry) {
|
|
91
|
+
const packageJson = await findFile(dirname(entry), 'package.json');
|
|
92
|
+
const [version, requireVersion] = getLocalDependencyVersion(packageJson, depName, versionSpec);
|
|
93
|
+
|
|
94
|
+
dependencies.push({
|
|
95
|
+
id: `${identifier}@${version}`,
|
|
96
|
+
requireId: `${identifier}@${requireVersion}`,
|
|
97
|
+
entry,
|
|
98
|
+
name: identifier,
|
|
99
|
+
ref: `${assetName}.js`,
|
|
100
|
+
type: 'local',
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
fail('importMapReferenceNotFound_0027', dir, url);
|
|
104
|
+
}
|
|
87
105
|
} else {
|
|
88
106
|
const entry = resolve(dir, url);
|
|
89
107
|
const exists = await checkExists(entry);
|
|
@@ -140,7 +158,12 @@ async function resolveImportmap(dir: string, importmap: Importmap) {
|
|
|
140
158
|
const entry = dependencies.find((dep) => dep.name === dependency.name);
|
|
141
159
|
|
|
142
160
|
if (!entry) {
|
|
143
|
-
dependencies.push(
|
|
161
|
+
dependencies.push({
|
|
162
|
+
...dependency,
|
|
163
|
+
parents: [inheritedImport],
|
|
164
|
+
});
|
|
165
|
+
} else if (Array.isArray(entry.parents)) {
|
|
166
|
+
entry.parents.push(inheritedImport);
|
|
144
167
|
}
|
|
145
168
|
}
|
|
146
169
|
}
|
package/src/common/io.ts
CHANGED
|
@@ -187,15 +187,14 @@ export function getFileNames(target: string) {
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
export async function findFile(topDir: string, fileName: string): Promise<string> {
|
|
190
|
+
export async function findFile(topDir: string, fileName: string, stopDir = resolve(topDir, '/')): Promise<string> {
|
|
191
191
|
const path = join(topDir, fileName);
|
|
192
192
|
const exists = await checkExists(path);
|
|
193
193
|
|
|
194
194
|
if (!exists) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return await findFile(parentDir, fileName);
|
|
195
|
+
if (topDir !== stopDir) {
|
|
196
|
+
const parentDir = resolve(topDir, '..');
|
|
197
|
+
return await findFile(parentDir, fileName, stopDir);
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
return undefined;
|
package/src/common/npm.test.ts
CHANGED
|
@@ -454,12 +454,12 @@ describe('npm Module', () => {
|
|
|
454
454
|
|
|
455
455
|
it('makeExternals without externals returns coreExternals', () => {
|
|
456
456
|
const externals = makeExternals(process.cwd(), { piral: '*' });
|
|
457
|
-
expect(externals).toEqual(['react', 'react-dom', 'react-router', 'react-router-dom', '
|
|
457
|
+
expect(externals).toEqual(['react', 'react-dom', 'react-router', 'react-router-dom', 'tslib']);
|
|
458
458
|
});
|
|
459
459
|
|
|
460
460
|
it('makeExternals with no externals returns coreExternals', () => {
|
|
461
461
|
const externals = makeExternals(process.cwd(), { piral: '*' }, []);
|
|
462
|
-
expect(externals).toEqual(['react', 'react-dom', 'react-router', 'react-router-dom', '
|
|
462
|
+
expect(externals).toEqual(['react', 'react-dom', 'react-router', 'react-router-dom', 'tslib']);
|
|
463
463
|
});
|
|
464
464
|
|
|
465
465
|
it('makeExternals with exclude coreExternals returns empty set', () => {
|
|
@@ -476,19 +476,18 @@ describe('npm Module', () => {
|
|
|
476
476
|
'react-dom',
|
|
477
477
|
'react-router',
|
|
478
478
|
'react-router-dom',
|
|
479
|
-
'history',
|
|
480
479
|
'tslib',
|
|
481
480
|
]);
|
|
482
481
|
});
|
|
483
482
|
|
|
484
483
|
it('makeExternals with external duplicate only reflects coreExternals', () => {
|
|
485
484
|
const externals = makeExternals(process.cwd(), { piral: '*' }, ['react', 'foo']);
|
|
486
|
-
expect(externals).toEqual(['react', 'foo', 'react-dom', 'react-router', 'react-router-dom', '
|
|
485
|
+
expect(externals).toEqual(['react', 'foo', 'react-dom', 'react-router', 'react-router-dom', 'tslib']);
|
|
487
486
|
});
|
|
488
487
|
|
|
489
488
|
it('makeExternals with explicit include and exclude', () => {
|
|
490
|
-
const externals = makeExternals(process.cwd(), { piral: '*' }, ['react', 'react-calendar', '!
|
|
491
|
-
expect(externals).toEqual(['react', 'react-calendar', 'react-dom', 'react-router', 'react-router-dom'
|
|
489
|
+
const externals = makeExternals(process.cwd(), { piral: '*' }, ['react', 'react-calendar', '!tslib']);
|
|
490
|
+
expect(externals).toEqual(['react', 'react-calendar', 'react-dom', 'react-router', 'react-router-dom']);
|
|
492
491
|
});
|
|
493
492
|
|
|
494
493
|
it('makeExternals with all exclude and explicit include', () => {
|
package/src/common/package.ts
CHANGED
|
@@ -12,7 +12,15 @@ import { getHash, checkIsDirectory, matchFiles } from './io';
|
|
|
12
12
|
import { readJson, copy, updateExistingJson, findFile, checkExists } from './io';
|
|
13
13
|
import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath } from './npm';
|
|
14
14
|
import { makePiletExternals, makeExternals, findPackageRoot } from './npm';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
SourceLanguage,
|
|
17
|
+
Framework,
|
|
18
|
+
FileInfo,
|
|
19
|
+
PiletsInfo,
|
|
20
|
+
TemplateFileLocation,
|
|
21
|
+
PackageData,
|
|
22
|
+
SharedDependency,
|
|
23
|
+
} from '../types';
|
|
16
24
|
|
|
17
25
|
function appendBundler(devDependencies: Record<string, string>, bundler: string, version: string) {
|
|
18
26
|
if (bundler && bundler !== 'none') {
|
|
@@ -182,7 +190,6 @@ export function getPiralPackage(app: string, data: PiralPackageData, version: st
|
|
|
182
190
|
framework === 'piral-native' && 'piral-native', // this we also only take if we selected piral-native
|
|
183
191
|
].filter(Boolean),
|
|
184
192
|
},
|
|
185
|
-
pilets: getPiletsInfo({}),
|
|
186
193
|
dependencies,
|
|
187
194
|
devDependencies,
|
|
188
195
|
};
|
|
@@ -501,10 +508,6 @@ export async function patchPiletPackage(
|
|
|
501
508
|
) {
|
|
502
509
|
log('generalDebug_0003', `Patching the package.json in "${root}" ...`);
|
|
503
510
|
const { externals, packageOverrides, ...info } = getPiletsInfo(piralInfo);
|
|
504
|
-
const piral = {
|
|
505
|
-
comment: 'Keep this section to use the Piral CLI.',
|
|
506
|
-
name,
|
|
507
|
-
};
|
|
508
511
|
const piralDependencies = {
|
|
509
512
|
...piralInfo.devDependencies,
|
|
510
513
|
...piralInfo.dependencies,
|
|
@@ -548,8 +551,7 @@ export async function patchPiletPackage(
|
|
|
548
551
|
appendBundler(devDependencies, bundler, version);
|
|
549
552
|
}
|
|
550
553
|
|
|
551
|
-
|
|
552
|
-
piral,
|
|
554
|
+
await updateExistingJson(root, 'package.json', deepMerge(packageOverrides, {
|
|
553
555
|
importmap: {
|
|
554
556
|
imports: {},
|
|
555
557
|
inherit: [name],
|
|
@@ -559,10 +561,16 @@ export async function patchPiletPackage(
|
|
|
559
561
|
[name]: undefined,
|
|
560
562
|
},
|
|
561
563
|
scripts,
|
|
562
|
-
});
|
|
564
|
+
}));
|
|
563
565
|
|
|
564
|
-
await updateExistingJson(root, 'package.json', packageContent);
|
|
565
566
|
log('generalDebug_0003', `Succesfully patched the package.json.`);
|
|
567
|
+
|
|
568
|
+
await updateExistingJson(root, 'pilet.json', {
|
|
569
|
+
piralInstances: {
|
|
570
|
+
[name]: {},
|
|
571
|
+
},
|
|
572
|
+
});
|
|
573
|
+
log('generalDebug_0003', `Succesfully patched the pilet.json.`);
|
|
566
574
|
}
|
|
567
575
|
|
|
568
576
|
/**
|
|
@@ -580,6 +588,34 @@ export function checkAppShellPackage(appPackage: PackageData) {
|
|
|
580
588
|
return false;
|
|
581
589
|
}
|
|
582
590
|
|
|
591
|
+
export function combinePiletExternals(
|
|
592
|
+
appShells: Array<string>,
|
|
593
|
+
peerDependencies: Record<string, string>,
|
|
594
|
+
peerModules: Array<string>,
|
|
595
|
+
importmap: Array<SharedDependency>,
|
|
596
|
+
) {
|
|
597
|
+
const externals = [...Object.keys(peerDependencies), ...peerModules];
|
|
598
|
+
|
|
599
|
+
for (let i = importmap.length; i--; ) {
|
|
600
|
+
const entry = importmap[i];
|
|
601
|
+
|
|
602
|
+
// if the entry has no parents, i.e., it was explicitly mentioned in the importmap
|
|
603
|
+
// then keep it in the importmap (=> prefer the distributed approach, which will always work)
|
|
604
|
+
if (Array.isArray(entry.parents)) {
|
|
605
|
+
// only accept entry as a centrally shared dependency if the entry appears in all
|
|
606
|
+
// mentioned / referenced app shells
|
|
607
|
+
// in other cases (e.g., if one app shell does not share this) use the distributed
|
|
608
|
+
// mechanism to ensure that the dependency can also be resolved in this shell
|
|
609
|
+
if (appShells.every((app) => entry.parents.includes(app))) {
|
|
610
|
+
externals.push(entry.name);
|
|
611
|
+
importmap.splice(i, 1);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return externals;
|
|
617
|
+
}
|
|
618
|
+
|
|
583
619
|
export async function retrievePiletData(target: string, app?: string) {
|
|
584
620
|
const packageJson = await findFile(target, 'package.json');
|
|
585
621
|
|