piral-cli 0.15.1-beta.4903 → 0.15.1-beta.4906
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 +4 -3
- 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 +1 -0
- package/lib/common/npm.js +14 -1
- package/lib/common/npm.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/package.json +2 -2
- package/src/apps/debug-pilet.ts +6 -11
- 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 +18 -0
- package/src/common/parallel.ts +2 -2
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,
|
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
|
);
|