piral-cli 0.15.0-alpha.4409 → 0.15.0-beta.4411
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 +4 -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 +4 -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 +12 -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 +6 -1
- package/src/common/io.ts +4 -5
- package/src/common/package.ts +46 -10
- package/src/types/common.ts +1 -0
|
@@ -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
|
@@ -140,7 +140,12 @@ async function resolveImportmap(dir: string, importmap: Importmap) {
|
|
|
140
140
|
const entry = dependencies.find((dep) => dep.name === dependency.name);
|
|
141
141
|
|
|
142
142
|
if (!entry) {
|
|
143
|
-
dependencies.push(
|
|
143
|
+
dependencies.push({
|
|
144
|
+
...dependency,
|
|
145
|
+
parents: [inheritedImport],
|
|
146
|
+
});
|
|
147
|
+
} else if (Array.isArray(entry.parents)) {
|
|
148
|
+
entry.parents.push(inheritedImport);
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
}
|
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/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
|
|