piral-cli 0.15.1-beta.4903 → 0.15.1-beta.4908
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/debug-pilet.js +15 -8
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +3 -1
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/remove-piral-instance-pilet.d.ts +6 -1
- package/lib/apps/remove-piral-instance-pilet.js +4 -13
- package/lib/apps/remove-piral-instance-pilet.js.map +1 -1
- package/lib/build/bundler-calls.js +5 -1
- package/lib/build/bundler-calls.js.map +1 -1
- package/lib/commands.js +6 -2
- package/lib/commands.js.map +1 -1
- package/lib/common/clients/lerna.d.ts +1 -0
- package/lib/common/clients/lerna.js +24 -2
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +1 -0
- package/lib/common/clients/npm.js +10 -1
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnp.d.ts +1 -0
- package/lib/common/clients/pnp.js +11 -2
- package/lib/common/clients/pnp.js.map +1 -1
- package/lib/common/clients/pnpm.d.ts +1 -0
- package/lib/common/clients/pnpm.js +11 -2
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +1 -0
- package/lib/common/clients/rush.js +11 -2
- package/lib/common/clients/rush.js.map +1 -1
- package/lib/common/clients/yarn.d.ts +1 -0
- package/lib/common/clients/yarn.js +11 -2
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/injectors.d.ts +1 -2
- package/lib/common/injectors.js +1 -2
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/io.js +6 -2
- package/lib/common/io.js.map +1 -1
- package/lib/common/npm.d.ts +3 -2
- package/lib/common/npm.js +17 -4
- package/lib/common/npm.js.map +1 -1
- package/lib/common/package.js +4 -0
- package/lib/common/package.js.map +1 -1
- package/lib/common/parallel.d.ts +1 -1
- package/lib/common/parallel.js +1 -1
- package/lib/common/parallel.js.map +1 -1
- package/lib/common/shell.js +1 -1
- package/lib/common/shell.js.map +1 -1
- package/lib/external/index.js +51 -51
- package/lib/types/common.d.ts +2 -0
- package/lib/types/common.js.map +1 -1
- package/lib/types/internal.d.ts +1 -0
- package/package.json +4 -4
- package/src/apps/debug-pilet.ts +20 -16
- package/src/apps/debug-piral.ts +4 -3
- package/src/apps/remove-piral-instance-pilet.ts +13 -18
- package/src/build/bundler-calls.ts +8 -4
- package/src/commands.ts +6 -2
- package/src/common/clients/lerna.ts +26 -2
- package/src/common/clients/npm.ts +7 -0
- package/src/common/clients/pnp.ts +8 -1
- package/src/common/clients/pnpm.ts +8 -1
- package/src/common/clients/rush.ts +8 -1
- package/src/common/clients/yarn.ts +8 -1
- package/src/common/injectors.ts +1 -3
- package/src/common/io.ts +5 -2
- package/src/common/npm.ts +21 -3
- package/src/common/package.ts +3 -0
- package/src/common/parallel.ts +2 -2
- package/src/common/shell.ts +1 -1
- package/src/external/resolve.ts +1 -1
- package/src/types/common.ts +2 -0
- package/src/types/internal.ts +1 -0
package/src/apps/debug-piral.ts
CHANGED
|
@@ -159,12 +159,12 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
159
159
|
hooks.afterBuild?.({ ...args, root, publicUrl, externals, entryFiles, piralInstances, bundler, ...dest });
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
+
bundler.start();
|
|
163
|
+
|
|
162
164
|
const krasBaseConfig = resolve(fullBase, krasrc);
|
|
163
165
|
const krasRootConfig = resolve(root, krasrc);
|
|
164
166
|
const mocks = join(targetDir, 'mocks');
|
|
165
167
|
const baseMocks = resolve(fullBase, 'mocks');
|
|
166
|
-
|
|
167
|
-
|
|
168
168
|
const mocksExist = await checkExistingDirectory(mocks);
|
|
169
169
|
const sources = [mocksExist ? mocks : undefined].filter(Boolean);
|
|
170
170
|
const initial = createInitialKrasConfig(baseMocks, sources);
|
|
@@ -187,8 +187,9 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
187
187
|
log('generalVerbose_0004', `Using kras with configuration: ${JSON.stringify(krasConfig, undefined, 2)}`);
|
|
188
188
|
|
|
189
189
|
const krasServer = buildKrasWithCli(krasConfig);
|
|
190
|
+
krasServer.setMaxListeners(16);
|
|
190
191
|
krasServer.removeAllListeners('open');
|
|
191
|
-
krasServer.on('open', notifyServerOnline(
|
|
192
|
+
krasServer.on('open', notifyServerOnline(publicUrl, krasConfig.api));
|
|
192
193
|
|
|
193
194
|
await hooks.beforeOnline?.({ krasServer, krasConfig, open, port, publicUrl });
|
|
194
195
|
await krasServer.start();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, resolve } from 'path';
|
|
2
|
-
import { setLogLevel, progress, log, matchAnyPilet, findFile, readJson, writeJson, logDone, findPiletRoot } from '../common';
|
|
3
|
-
import { LogLevels } from '../types';
|
|
2
|
+
import { setLogLevel, progress, log, matchAnyPilet, findFile, readJson, writeJson, logDone, findPiletRoot, determineNpmClient, uninstallNpmPackage } from '../common';
|
|
3
|
+
import { LogLevels, NpmClientType } from '../types';
|
|
4
4
|
|
|
5
5
|
export interface RemovePiralInstancePiletOptions {
|
|
6
6
|
/**
|
|
@@ -17,16 +17,24 @@ export interface RemovePiralInstancePiletOptions {
|
|
|
17
17
|
* Sets the source directory for adding the Piral instance.
|
|
18
18
|
*/
|
|
19
19
|
source?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The npm client to be used when scaffolding.
|
|
23
|
+
* @example 'yarn'
|
|
24
|
+
*/
|
|
25
|
+
npmClient?: NpmClientType;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
export const removePiralInstancePiletDefaults: RemovePiralInstancePiletOptions = {
|
|
23
29
|
logLevel: LogLevels.info,
|
|
24
30
|
app: undefined,
|
|
25
31
|
source: '.',
|
|
32
|
+
npmClient: undefined,
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
export async function removePiralInstancePilet(baseDir = process.cwd(), options: RemovePiralInstancePiletOptions = {}) {
|
|
29
36
|
const {
|
|
37
|
+
npmClient: defaultNpmClient = removePiralInstancePiletDefaults.npmClient,
|
|
30
38
|
logLevel = removePiralInstancePiletDefaults.logLevel,
|
|
31
39
|
source = removePiralInstancePiletDefaults.source,
|
|
32
40
|
app = removePiralInstancePiletDefaults.app,
|
|
@@ -35,33 +43,18 @@ export async function removePiralInstancePilet(baseDir = process.cwd(), options:
|
|
|
35
43
|
setLogLevel(logLevel);
|
|
36
44
|
progress('Reading configuration ...');
|
|
37
45
|
|
|
46
|
+
const npmClient = await determineNpmClient(fullBase, defaultNpmClient);
|
|
38
47
|
const allEntries = await matchAnyPilet(fullBase, [source]);
|
|
39
48
|
|
|
40
49
|
const tasks = allEntries.map(async (entryModule) => {
|
|
41
50
|
const targetDir = dirname(entryModule);
|
|
42
51
|
const piletJson = 'pilet.json';
|
|
43
|
-
const packageJson = 'package.json';
|
|
44
52
|
const piletJsonPath = await findFile(targetDir, piletJson);
|
|
45
53
|
|
|
46
54
|
if (piletJsonPath) {
|
|
47
55
|
const piletJsonDir = dirname(piletJsonPath);
|
|
48
56
|
const oldContent = await readJson(piletJsonDir, piletJson);
|
|
49
57
|
const root = await findPiletRoot(piletJsonDir);
|
|
50
|
-
const packageData = await readJson(root, packageJson);
|
|
51
|
-
|
|
52
|
-
if ('dependencies' in packageData && app in packageData.dependencies) {
|
|
53
|
-
packageData.dependencies[app] = undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if ('devDependencies' in packageData && app in packageData.devDependencies) {
|
|
57
|
-
packageData.devDependencies[app] = undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if ('peerDependencies' in packageData && app in packageData.peerDependencies) {
|
|
61
|
-
packageData.peerDependencies[app] = undefined;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
await writeJson(root, packageJson, packageData, true);
|
|
65
58
|
|
|
66
59
|
if ('piralInstances' in oldContent && app in oldContent.piralInstances) {
|
|
67
60
|
const newContent = {
|
|
@@ -74,6 +67,8 @@ export async function removePiralInstancePilet(baseDir = process.cwd(), options:
|
|
|
74
67
|
|
|
75
68
|
await writeJson(piletJsonDir, piletJson, newContent, true);
|
|
76
69
|
}
|
|
70
|
+
|
|
71
|
+
await uninstallNpmPackage(npmClient, app, root);
|
|
77
72
|
} else {
|
|
78
73
|
log('piletJsonNotAvailable_0180', targetDir);
|
|
79
74
|
}
|
|
@@ -10,6 +10,7 @@ type BundleListener = (args: any) => void;
|
|
|
10
10
|
|
|
11
11
|
function createBundler(cwd: string, ps: ChildProcess, args: any) {
|
|
12
12
|
let promise = Promise.resolve();
|
|
13
|
+
let started = false;
|
|
13
14
|
const listeners: Array<BundleListener> = [];
|
|
14
15
|
const bundle: BundleDetails = {
|
|
15
16
|
dir: cwd,
|
|
@@ -28,10 +29,13 @@ function createBundler(cwd: string, ps: ChildProcess, args: any) {
|
|
|
28
29
|
const bundler = {
|
|
29
30
|
bundle,
|
|
30
31
|
start() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (!started) {
|
|
33
|
+
started = true;
|
|
34
|
+
ps.send({
|
|
35
|
+
type: 'bundle',
|
|
36
|
+
...args,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
35
39
|
},
|
|
36
40
|
on(cb: BundleListener) {
|
|
37
41
|
listeners.push(cb);
|
package/src/commands.ts
CHANGED
|
@@ -811,7 +811,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
811
811
|
name: 'add-piral-instance-pilet',
|
|
812
812
|
alias: ['add-shell-pilet', 'install-shell-pilet', 'add-app-pilet', 'with-app-pilet'],
|
|
813
813
|
description: 'Adds another Piral instance to the available apps hosting the current pilet.',
|
|
814
|
-
arguments: ['[source]'],
|
|
814
|
+
arguments: ['<app> [source]'],
|
|
815
815
|
flags(argv) {
|
|
816
816
|
return argv
|
|
817
817
|
.positional('app', {
|
|
@@ -851,7 +851,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
851
851
|
name: 'remove-piral-instance-pilet',
|
|
852
852
|
alias: ['remove-shell-pilet', 'uninstall-shell-pilet', 'remove-app-pilet', 'without-app-pilet'],
|
|
853
853
|
description: 'Removes an existing Piral instance from the available apps hosting the current pilet.',
|
|
854
|
-
arguments: ['[source]'],
|
|
854
|
+
arguments: ['<app> [source]'],
|
|
855
855
|
flags(argv) {
|
|
856
856
|
return argv
|
|
857
857
|
.positional('app', {
|
|
@@ -867,6 +867,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
867
867
|
.number('log-level')
|
|
868
868
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
869
869
|
.default('log-level', apps.removePiralInstancePiletDefaults.logLevel)
|
|
870
|
+
.choices('npm-client', clientTypeKeys)
|
|
871
|
+
.describe('npm-client', 'Sets the npm client to be used for removing the Piral instance.')
|
|
872
|
+
.default('npm-client', apps.removePiralInstancePiletDefaults.npmClient)
|
|
870
873
|
.string('base')
|
|
871
874
|
.default('base', process.cwd())
|
|
872
875
|
.describe('base', 'Sets the base directory. By default the current directory is used.');
|
|
@@ -876,6 +879,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
876
879
|
logLevel: args['log-level'] as LogLevels,
|
|
877
880
|
app: args.app as string,
|
|
878
881
|
source: args.source as string,
|
|
882
|
+
npmClient: args['npm-client'] as NpmClientType,
|
|
879
883
|
});
|
|
880
884
|
},
|
|
881
885
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { log } from '../log';
|
|
3
|
-
import { findFile } from '../io';
|
|
3
|
+
import { findFile, readJson, writeJson } from '../io';
|
|
4
4
|
import { runCommand } from '../scripts';
|
|
5
5
|
import { MemoryStream } from '../MemoryStream';
|
|
6
6
|
|
|
@@ -37,10 +37,34 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
37
37
|
return ms.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export async function uninstallPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
|
+
const ms = new MemoryStream();
|
|
42
|
+
// at the moment not supported by Lerna directly
|
|
43
|
+
// workaround is to manipulate the package.json directly and bootstrap again...
|
|
44
|
+
const packageData = await readJson(target, 'package.json');
|
|
45
|
+
|
|
46
|
+
if (packageData.dependencies && packageRef in packageData.dependencies) {
|
|
47
|
+
packageData.dependencies[packageRef] = undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (packageData.devDependencies && packageRef in packageData.devDependencies) {
|
|
51
|
+
packageData.devDependencies[packageRef] = undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (packageData.peerDependencies && packageRef in packageData.peerDependencies) {
|
|
55
|
+
packageData.peerDependencies[packageRef] = undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
await writeJson(target, 'package.json', packageData, true);
|
|
59
|
+
await runLernaProcess(['bootstrap'], target, ms);
|
|
60
|
+
log('generalDebug_0003', `Lerna bootstrap (after remove) package result: ${ms.value}`);
|
|
61
|
+
return ms.value;
|
|
62
|
+
}
|
|
63
|
+
|
|
40
64
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
65
|
const ms = new MemoryStream();
|
|
42
66
|
await runLernaProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
43
|
-
log('generalDebug_0003', `Lerna
|
|
67
|
+
log('generalDebug_0003', `Lerna add package result: ${ms.value}`);
|
|
44
68
|
return ms.value;
|
|
45
69
|
}
|
|
46
70
|
|
|
@@ -21,6 +21,13 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
21
21
|
return ms.value;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export async function uninstallPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
25
|
+
const ms = new MemoryStream();
|
|
26
|
+
await runNpmProcess(['uninstall', packageRef, ...flags], target, ms);
|
|
27
|
+
log('generalDebug_0003', `npm uninstall package result: ${ms.value}`);
|
|
28
|
+
return ms.value;
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
25
32
|
const ms = new MemoryStream();
|
|
26
33
|
await runNpmProcess(['install', packageRef, '--legacy-peer-deps', ...flags], target, ms);
|
|
@@ -37,10 +37,17 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
37
37
|
return ms.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export async function uninstallPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
|
+
const ms = new MemoryStream();
|
|
42
|
+
await runYarnProcess(['remove', packageRef, ...convert(flags)], target, ms);
|
|
43
|
+
log('generalDebug_0003', `Yarn PnP remove package result: ${ms.value}`);
|
|
44
|
+
return ms.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
48
|
const ms = new MemoryStream();
|
|
42
49
|
await runYarnProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
43
|
-
log('generalDebug_0003', `Yarn PnP
|
|
50
|
+
log('generalDebug_0003', `Yarn PnP add package result: ${ms.value}`);
|
|
44
51
|
return ms.value;
|
|
45
52
|
}
|
|
46
53
|
|
|
@@ -33,10 +33,17 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
33
33
|
return ms.value;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export async function uninstallPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
37
|
+
const ms = new MemoryStream();
|
|
38
|
+
await runPnpmProcess(['remove', packageRef, ...convert(flags)], target, ms);
|
|
39
|
+
log('generalDebug_0003', `Pnpm remove package result: ${ms.value}`);
|
|
40
|
+
return ms.value;
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
37
44
|
const ms = new MemoryStream();
|
|
38
45
|
await runPnpmProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
39
|
-
log('generalDebug_0003', `Pnpm
|
|
46
|
+
log('generalDebug_0003', `Pnpm add package result: ${ms.value}`);
|
|
40
47
|
return ms.value;
|
|
41
48
|
}
|
|
42
49
|
|
|
@@ -40,10 +40,17 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
40
40
|
return ms.value;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
export async function uninstallPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
44
|
+
const ms = new MemoryStream();
|
|
45
|
+
await runRushProcess(['remove', packageRef, ...convert(flags)], target, ms);
|
|
46
|
+
log('generalDebug_0003', `Rush remove package result: ${ms.value}`);
|
|
47
|
+
return ms.value;
|
|
48
|
+
}
|
|
49
|
+
|
|
43
50
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
44
51
|
const ms = new MemoryStream();
|
|
45
52
|
await runRushProcess(['add', '--package', packageRef, ...convert(flags)], target, ms);
|
|
46
|
-
log('generalDebug_0003', `Rush
|
|
53
|
+
log('generalDebug_0003', `Rush add package result: ${ms.value}`);
|
|
47
54
|
return ms.value;
|
|
48
55
|
}
|
|
49
56
|
|
|
@@ -37,10 +37,17 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
37
37
|
return ms.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export async function uninstallPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
|
+
const ms = new MemoryStream();
|
|
42
|
+
await runYarnProcess(['remove', packageRef, ...convert(flags)], target, ms);
|
|
43
|
+
log('generalDebug_0003', `Yarn Classic remove package result: ${ms.value}`);
|
|
44
|
+
return ms.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
48
|
const ms = new MemoryStream();
|
|
42
49
|
await runYarnProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
43
|
-
log('generalDebug_0003', `Yarn Classic
|
|
50
|
+
log('generalDebug_0003', `Yarn Classic add package result: ${ms.value}`);
|
|
44
51
|
return ms.value;
|
|
45
52
|
}
|
|
46
53
|
|
package/src/common/injectors.ts
CHANGED
|
@@ -2,16 +2,14 @@ import { resolve } from 'path';
|
|
|
2
2
|
import { liveIcon, settingsIcon } from './emoji';
|
|
3
3
|
import { logInfo, log, logReset } from './log';
|
|
4
4
|
import { chalk } from '../external';
|
|
5
|
-
import { Bundler } from '../types';
|
|
6
5
|
|
|
7
|
-
export function notifyServerOnline(
|
|
6
|
+
export function notifyServerOnline(path: string, api: string | false) {
|
|
8
7
|
return (svc: any) => {
|
|
9
8
|
log('generalDebug_0003', `The kras server for debugging is online!`);
|
|
10
9
|
const address = `${svc.protocol}://localhost:${chalk.green(svc.port)}`;
|
|
11
10
|
logInfo(`${liveIcon} Running at ${chalk.bold(address + path)}`);
|
|
12
11
|
logInfo(`${settingsIcon} Manage via ${chalk.bold(address + api)}`);
|
|
13
12
|
logReset();
|
|
14
|
-
bundlers.forEach((bundler) => bundler.start());
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
15
|
|
package/src/common/io.ts
CHANGED
|
@@ -209,14 +209,17 @@ export async function matchAnyPilet(baseDir: string, patterns: Array<string>) {
|
|
|
209
209
|
matches.push(path);
|
|
210
210
|
};
|
|
211
211
|
const nameOfPackageJson = 'package.json';
|
|
212
|
+
const nameOfPiletJson = 'pilet.json';
|
|
212
213
|
const exts = preferences.map((s) => s.substring(1)).join(',');
|
|
213
214
|
const allPatterns = patterns.reduce<Array<AnyPattern>>((agg, curr) => {
|
|
214
215
|
const patterns = [];
|
|
215
216
|
|
|
216
217
|
if (/[a-zA-Z0-9\-\*]$/.test(curr) && !preferences.find((ext) => curr.endsWith(ext))) {
|
|
217
|
-
patterns.push(curr, `${curr}.{${exts}}`, `${curr}/${nameOfPackageJson}`);
|
|
218
|
+
patterns.push(curr, `${curr}.{${exts}}`, `${curr}/${nameOfPackageJson}`, `${curr}/${nameOfPiletJson}`);
|
|
218
219
|
} else if (curr.endsWith('/')) {
|
|
219
|
-
patterns.push(`${curr}index.{${exts}}`, `${curr}${nameOfPackageJson}`);
|
|
220
|
+
patterns.push(`${curr}index.{${exts}}`, `${curr}${nameOfPackageJson}`, `${curr}${nameOfPiletJson}`);
|
|
221
|
+
} else if (curr === '.' || curr === '..') {
|
|
222
|
+
patterns.push(`${curr}/index.{${exts}}`, `${curr}/${nameOfPackageJson}`, `${curr}/${nameOfPiletJson}`);
|
|
220
223
|
} else {
|
|
221
224
|
patterns.push(curr);
|
|
222
225
|
}
|
package/src/common/npm.ts
CHANGED
|
@@ -146,6 +146,24 @@ export async function installNpmPackageFromOptionalRegistry(
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
export async function uninstallNpmPackage(
|
|
150
|
+
client: NpmClientType,
|
|
151
|
+
packageRef: string,
|
|
152
|
+
target = '.',
|
|
153
|
+
...flags: Array<string>
|
|
154
|
+
): Promise<string> {
|
|
155
|
+
try {
|
|
156
|
+
const { uninstallPackage } = clients[client];
|
|
157
|
+
return await uninstallPackage(packageRef, target, ...flags);
|
|
158
|
+
} catch (ex) {
|
|
159
|
+
log(
|
|
160
|
+
'generalError_0002',
|
|
161
|
+
`Could not uninstall the package "${packageRef}" using ${client}. Make sure ${client} is correctly installed and accessible: ${ex}`,
|
|
162
|
+
);
|
|
163
|
+
throw ex;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
149
167
|
export async function installNpmPackage(
|
|
150
168
|
client: NpmClientType,
|
|
151
169
|
packageRef: string,
|
|
@@ -372,13 +390,13 @@ export function tryResolvePackage(name: string, baseDir: string = undefined) {
|
|
|
372
390
|
return path;
|
|
373
391
|
}
|
|
374
392
|
|
|
375
|
-
export function findPackageRoot(pck: string, baseDir: string
|
|
393
|
+
export function findPackageRoot(pck: string, baseDir: string) {
|
|
376
394
|
return tryResolvePackage(`${pck}/package.json`, baseDir);
|
|
377
395
|
}
|
|
378
396
|
|
|
379
|
-
export function isLinkedPackage(name: string, type: PackageType, hadVersion: boolean) {
|
|
397
|
+
export function isLinkedPackage(name: string, type: PackageType, hadVersion: boolean, target: string) {
|
|
380
398
|
if (type === 'registry' && !hadVersion) {
|
|
381
|
-
const root = findPackageRoot(name);
|
|
399
|
+
const root = findPackageRoot(name, target);
|
|
382
400
|
return typeof root === 'string';
|
|
383
401
|
}
|
|
384
402
|
|
package/src/common/package.ts
CHANGED
|
@@ -196,6 +196,7 @@ function findPiralInstances(
|
|
|
196
196
|
const relPath = appPackage && appPackage.app;
|
|
197
197
|
appPackage.app = relPath && resolve(root, relPath);
|
|
198
198
|
appPackage.root = root;
|
|
199
|
+
appPackage.port = piletDefinition?.piralInstances?.[proposedApp]?.port ?? 0;
|
|
199
200
|
return appPackage;
|
|
200
201
|
}
|
|
201
202
|
|
|
@@ -763,6 +764,7 @@ export async function retrievePiletData(target: string, app?: string) {
|
|
|
763
764
|
for (const appPackage of appPackages) {
|
|
764
765
|
const appFile: string = appPackage?.app;
|
|
765
766
|
const appRoot: string = appPackage?.root;
|
|
767
|
+
const appPort = appPackage?.port;
|
|
766
768
|
|
|
767
769
|
if (!appFile || !appRoot) {
|
|
768
770
|
fail('appInstanceInvalid_0011');
|
|
@@ -774,6 +776,7 @@ export async function retrievePiletData(target: string, app?: string) {
|
|
|
774
776
|
appFile,
|
|
775
777
|
appRoot,
|
|
776
778
|
emulator,
|
|
779
|
+
appPort,
|
|
777
780
|
});
|
|
778
781
|
}
|
|
779
782
|
|
package/src/common/parallel.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function concurrentWorkers<T, R>(
|
|
2
2
|
items: Array<T>,
|
|
3
3
|
concurrency: number,
|
|
4
|
-
worker: (item: T) => Promise<R>,
|
|
4
|
+
worker: (item: T, index: number) => Promise<R>,
|
|
5
5
|
): Promise<Array<R>> {
|
|
6
6
|
const maxItems = items.length;
|
|
7
7
|
const results: Array<R> = new Array(maxItems);
|
|
@@ -12,7 +12,7 @@ export async function concurrentWorkers<T, R>(
|
|
|
12
12
|
while (offset < maxItems) {
|
|
13
13
|
const i = offset++;
|
|
14
14
|
const item = items[i];
|
|
15
|
-
results[i] = await worker(item);
|
|
15
|
+
results[i] = await worker(item, i);
|
|
16
16
|
}
|
|
17
17
|
}),
|
|
18
18
|
);
|
package/src/common/shell.ts
CHANGED
|
@@ -16,7 +16,7 @@ export async function installPiralInstance(
|
|
|
16
16
|
npmClient: NpmClientType,
|
|
17
17
|
): Promise<[name: string, version: string]> {
|
|
18
18
|
const [sourceName, sourceVersion, hadVersion, type] = await dissectPackageName(baseDir, usedSource);
|
|
19
|
-
const isLocal = isLinkedPackage(sourceName, type, hadVersion);
|
|
19
|
+
const isLocal = isLinkedPackage(sourceName, type, hadVersion, rootDir);
|
|
20
20
|
|
|
21
21
|
if (!isLocal) {
|
|
22
22
|
const packageRef = combinePackageRef(sourceName, sourceVersion, type);
|
package/src/external/resolve.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'graceful-fs';
|
|
2
2
|
import { ResolverFactory, CachedInputFileSystem } from 'enhanced-resolve';
|
|
3
3
|
|
|
4
|
-
const nodeFileSystem = new CachedInputFileSystem(fs,
|
|
4
|
+
const nodeFileSystem = new CachedInputFileSystem(fs, 100);
|
|
5
5
|
|
|
6
6
|
const nodeContext = {
|
|
7
7
|
environments: ['node+es3+es5+process+native'],
|
package/src/types/common.ts
CHANGED
|
@@ -38,12 +38,14 @@ export interface PiralPackageData extends PackageData {
|
|
|
38
38
|
export interface PiralInstancePackageData extends PiralPackageData {
|
|
39
39
|
root: string;
|
|
40
40
|
app: string;
|
|
41
|
+
port: number;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export interface AppDefinition {
|
|
44
45
|
appPackage: PiralInstancePackageData;
|
|
45
46
|
appFile: string;
|
|
46
47
|
appRoot: string;
|
|
48
|
+
appPort: number;
|
|
47
49
|
emulator: boolean;
|
|
48
50
|
}
|
|
49
51
|
|