piral-cli 0.14.24-beta.4161 → 0.14.24-beta.4163
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/new-pilet.js +1 -7
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +1 -7
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/common/clients/index.d.ts +19 -0
- package/lib/common/clients/index.js +40 -0
- package/lib/common/clients/index.js.map +1 -0
- package/lib/common/clients/lerna.d.ts +3 -1
- package/lib/common/clients/lerna.js +36 -3
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +2 -1
- package/lib/common/clients/npm.js +20 -16
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.d.ts +1 -0
- package/lib/common/clients/pnpm.js +14 -11
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +3 -0
- package/lib/common/clients/rush.js +64 -0
- package/lib/common/clients/rush.js.map +1 -0
- package/lib/common/clients/yarn.d.ts +1 -0
- package/lib/common/clients/yarn.js +16 -13
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/npm.d.ts +0 -9
- package/lib/common/npm.js +58 -121
- package/lib/common/npm.js.map +1 -1
- package/lib/common/scaffold.js +2 -2
- package/lib/common/scaffold.js.map +1 -1
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/types/public.d.ts +1 -1
- package/package.json +2 -2
- package/src/apps/new-pilet.ts +1 -9
- package/src/apps/upgrade-pilet.ts +1 -9
- package/src/common/clients/index.ts +33 -0
- package/src/common/clients/lerna.ts +33 -1
- package/src/common/clients/npm.ts +18 -15
- package/src/common/clients/pnpm.ts +13 -12
- package/src/common/clients/rush.ts +49 -0
- package/src/common/clients/yarn.ts +15 -14
- package/src/common/npm.test.ts +25 -38
- package/src/common/npm.ts +72 -123
- package/src/common/scaffold.ts +2 -2
- package/src/helpers.ts +1 -1
- package/src/types/public.ts +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { log } from '../log';
|
|
3
|
+
import { findFile } from '../io';
|
|
4
|
+
import { runCommand } from '../scripts';
|
|
5
|
+
import { MemoryStream } from '../MemoryStream';
|
|
6
|
+
|
|
7
|
+
// Helpers:
|
|
8
|
+
|
|
9
|
+
function runRushProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
|
|
10
|
+
log('generalDebug_0003', 'Starting the Rush process ...');
|
|
11
|
+
const cwd = resolve(process.cwd(), target);
|
|
12
|
+
return runCommand('rush', args, cwd, output);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function convert(flags: Array<string>) {
|
|
16
|
+
return flags.map((flag) => {
|
|
17
|
+
switch (flag) {
|
|
18
|
+
case '--save-exact':
|
|
19
|
+
return '--exact';
|
|
20
|
+
case '--save-dev':
|
|
21
|
+
return '--dev';
|
|
22
|
+
case '--no-save':
|
|
23
|
+
// unfortunately no
|
|
24
|
+
return '';
|
|
25
|
+
default:
|
|
26
|
+
return flag;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Client interface functions:
|
|
32
|
+
|
|
33
|
+
export async function installDependencies(target = '.', ...flags: Array<string>) {
|
|
34
|
+
const ms = new MemoryStream();
|
|
35
|
+
await runRushProcess(['update', ...convert(flags)], target, ms);
|
|
36
|
+
log('generalDebug_0003', `Rush install dependencies result: ${ms.value}`);
|
|
37
|
+
return ms.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
|
+
const ms = new MemoryStream();
|
|
42
|
+
await runRushProcess(['add', '--package', packageRef, ...convert(flags)], target, ms);
|
|
43
|
+
log('generalDebug_0003', `Rush install package result: ${ms.value}`);
|
|
44
|
+
return ms.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function detectClient(root: string) {
|
|
48
|
+
return !!(await findFile(root, 'rush.json'));
|
|
49
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { log } from '../log';
|
|
3
|
+
import { findFile } from '../io';
|
|
3
4
|
import { runCommand } from '../scripts';
|
|
4
5
|
import { MemoryStream } from '../MemoryStream';
|
|
5
6
|
|
|
7
|
+
// Helpers:
|
|
8
|
+
|
|
6
9
|
function runYarnProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
|
|
7
|
-
log('generalDebug_0003', 'Starting the Yarn process ...');
|
|
10
|
+
log('generalDebug_0003', 'Starting the Yarn@1 process ...');
|
|
8
11
|
const cwd = resolve(process.cwd(), target);
|
|
9
12
|
return runCommand('yarn', args, cwd, output);
|
|
10
13
|
}
|
|
@@ -25,24 +28,22 @@ function convert(flags: Array<string>) {
|
|
|
25
28
|
});
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
// Client interface functions:
|
|
32
|
+
|
|
28
33
|
export async function installDependencies(target = '.', ...flags: Array<string>) {
|
|
29
34
|
const ms = new MemoryStream();
|
|
30
35
|
await runYarnProcess(['install', ...convert(flags)], target, ms);
|
|
31
|
-
log('generalDebug_0003', `Yarn install dependencies result: ${ms.value}`);
|
|
36
|
+
log('generalDebug_0003', `Yarn@1 install dependencies result: ${ms.value}`);
|
|
32
37
|
return ms.value;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`Could not install the package "${packageRef}" using Yarn. Make sure Yarn@1 is correctly installed and accessible: ${ex}`,
|
|
45
|
-
);
|
|
46
|
-
throw ex;
|
|
47
|
-
}
|
|
41
|
+
const ms = new MemoryStream();
|
|
42
|
+
await runYarnProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
43
|
+
log('generalDebug_0003', `Yarn@1 install package result: ${ms.value}`);
|
|
44
|
+
return ms.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function detectClient(root: string) {
|
|
48
|
+
return !!(await findFile(root, 'yarn.lock'));
|
|
48
49
|
}
|
package/src/common/npm.test.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
|
+
import { clients } from './clients';
|
|
2
3
|
import {
|
|
3
4
|
dissectPackageName,
|
|
4
5
|
installPackage,
|
|
5
|
-
detectNpm,
|
|
6
|
-
detectPnpm,
|
|
7
|
-
detectYarn,
|
|
8
6
|
isMonorepoPackageRef,
|
|
9
|
-
detectMonorepo,
|
|
10
|
-
bootstrapMonorepo,
|
|
11
7
|
installDependencies,
|
|
12
8
|
createPackage,
|
|
13
9
|
findTarball,
|
|
@@ -42,6 +38,7 @@ jest.mock('../external', () => ({
|
|
|
42
38
|
}));
|
|
43
39
|
|
|
44
40
|
let specialCase = false;
|
|
41
|
+
let shouldFind = true;
|
|
45
42
|
let wrongCase = false;
|
|
46
43
|
const jsonValueString = JSON.stringify({ dependencies: { npm: { extraneous: true } } });
|
|
47
44
|
const jsonValueStringWrong = JSON.stringify({ dependencies: {} });
|
|
@@ -56,14 +53,15 @@ jest.mock('./scripts', () => ({
|
|
|
56
53
|
}));
|
|
57
54
|
|
|
58
55
|
jest.mock('fs', () => ({
|
|
59
|
-
constants: {
|
|
60
|
-
F_OK: 1,
|
|
61
|
-
},
|
|
62
56
|
createReadStream() {
|
|
63
57
|
return undefined;
|
|
64
58
|
},
|
|
65
59
|
exists: (file: string, cb: (status: boolean) => void) =>
|
|
66
|
-
cb(
|
|
60
|
+
cb(
|
|
61
|
+
shouldFind &&
|
|
62
|
+
!file.endsWith('package.json') &&
|
|
63
|
+
!(specialCase && (file.endsWith('lerna.json') || file.endsWith('yarn.lock'))),
|
|
64
|
+
),
|
|
67
65
|
existsSync: (file: string) => {
|
|
68
66
|
return true;
|
|
69
67
|
},
|
|
@@ -72,13 +70,6 @@ jest.mock('fs', () => ({
|
|
|
72
70
|
},
|
|
73
71
|
realpathSync: () => ({}),
|
|
74
72
|
readFileSync: () => '',
|
|
75
|
-
access: (path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void) => {
|
|
76
|
-
if (path.includes('test')) {
|
|
77
|
-
return callback(undefined);
|
|
78
|
-
} else {
|
|
79
|
-
return callback(new Error('bla'));
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
73
|
}));
|
|
83
74
|
|
|
84
75
|
describe('npm Module', () => {
|
|
@@ -210,19 +201,28 @@ describe('npm Module', () => {
|
|
|
210
201
|
});
|
|
211
202
|
|
|
212
203
|
it('detectNpm finds package-lock.json', async () => {
|
|
213
|
-
|
|
214
|
-
await
|
|
204
|
+
shouldFind = true;
|
|
205
|
+
await clients.npm.detectClient('test').then((result) => expect(result).toBeTruthy());
|
|
206
|
+
shouldFind = false;
|
|
207
|
+
await clients.npm.detectClient('toast').then((result) => expect(result).toBeFalsy());
|
|
208
|
+
shouldFind = true;
|
|
215
209
|
});
|
|
216
210
|
|
|
217
|
-
it('detectPnpm finds
|
|
218
|
-
|
|
219
|
-
await
|
|
211
|
+
it('detectPnpm finds pnpm-lock.yaml', async () => {
|
|
212
|
+
shouldFind = true;
|
|
213
|
+
await clients.pnpm.detectClient('test').then((result) => expect(result).toBeTruthy());
|
|
214
|
+
shouldFind = false;
|
|
215
|
+
await clients.pnpm.detectClient('toast').then((result) => expect(result).toBeFalsy());
|
|
216
|
+
shouldFind = true;
|
|
220
217
|
});
|
|
221
218
|
|
|
222
219
|
it('detectYarn finds yarn.lock', async () => {
|
|
223
|
-
|
|
220
|
+
shouldFind = true;
|
|
221
|
+
await clients.yarn.detectClient('test').then((result) => expect(result).toBeTruthy());
|
|
222
|
+
shouldFind = false;
|
|
224
223
|
specialCase = true;
|
|
225
|
-
await
|
|
224
|
+
await clients.yarn.detectClient('toast').then((result) => expect(result).toBeFalsy());
|
|
225
|
+
shouldFind = true;
|
|
226
226
|
specialCase = false;
|
|
227
227
|
});
|
|
228
228
|
|
|
@@ -233,24 +233,11 @@ describe('npm Module', () => {
|
|
|
233
233
|
await isMonorepoPackageRef('npm', './').then((result) => expect(result).toBeFalsy());
|
|
234
234
|
});
|
|
235
235
|
|
|
236
|
-
it('verifies whether lerna config path is valid', async () => {
|
|
237
|
-
wrongCase = false;
|
|
238
|
-
await detectMonorepo('./').then((result) => {
|
|
239
|
-
expect(result).toBe('lerna');
|
|
240
|
-
});
|
|
241
|
-
wrongCase = true;
|
|
242
|
-
specialCase = true;
|
|
243
|
-
await detectMonorepo('./').then((result) => {
|
|
244
|
-
expect(result).toBe('none');
|
|
245
|
-
});
|
|
246
|
-
specialCase = false;
|
|
247
|
-
});
|
|
248
|
-
|
|
249
236
|
it('verifies whether lerna bootstrap ran', async () => {
|
|
250
237
|
wrongCase = false;
|
|
251
|
-
await
|
|
238
|
+
await clients.lerna.installDependencies().then((result) => expect(result).toEqual(jsonValueString));
|
|
252
239
|
wrongCase = true;
|
|
253
|
-
await
|
|
240
|
+
await clients.lerna.installDependencies().then((result) => expect(result).not.toEqual(jsonValueString));
|
|
254
241
|
});
|
|
255
242
|
|
|
256
243
|
it('install dependencies with npm client', async () => {
|
package/src/common/npm.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve, relative, dirname } from 'path';
|
|
2
|
-
import { createReadStream, existsSync
|
|
2
|
+
import { createReadStream, existsSync } from 'fs';
|
|
3
3
|
import { log, fail } from './log';
|
|
4
|
+
import { clients, detectClients, isWrapperClient } from './clients';
|
|
4
5
|
import { config } from './config';
|
|
5
6
|
import { legacyCoreExternals, frameworkLibs } from './constants';
|
|
6
7
|
import { inspectPackage } from './inspect';
|
|
@@ -23,48 +24,28 @@ function resolveAbsPath(basePath: string, fullName: string) {
|
|
|
23
24
|
return resolve(basePath, relPath);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
access(resolve(root, 'pnpm-lock.yaml'), constants.F_OK, (noPnpmLock) => {
|
|
29
|
-
res(!noPnpmLock);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function detectNpm(root: string) {
|
|
35
|
-
return new Promise((res) => {
|
|
36
|
-
access(resolve(root, 'package-lock.json'), constants.F_OK, (noPackageLock) => {
|
|
37
|
-
res(!noPackageLock);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function detectYarn(root: string) {
|
|
43
|
-
return !!(await findFile(root, 'yarn.lock'));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function getLernaConfigPath(root: string) {
|
|
47
|
-
log('generalDebug_0003', 'Trying to get the configuration file for Lerna ...');
|
|
48
|
-
const file = await findFile(root, 'lerna.json');
|
|
27
|
+
async function detectMonorepoRoot(root: string): Promise<string> {
|
|
28
|
+
let previous = root;
|
|
49
29
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
30
|
+
do {
|
|
31
|
+
const isMonorepo =
|
|
32
|
+
(await checkExists(resolve(root, 'lerna.json'))) ||
|
|
33
|
+
(await checkExists(resolve(root, 'rush.json'))) ||
|
|
34
|
+
(await checkExists(resolve(root, 'pnpm-workspace.yaml')));
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
if (isMonorepo) {
|
|
37
|
+
return root;
|
|
38
|
+
}
|
|
57
39
|
|
|
58
|
-
|
|
59
|
-
const file = await getLernaConfigPath(root);
|
|
40
|
+
const packageJson = await readJson(root, 'package.json');
|
|
60
41
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return require(file).npmClient;
|
|
64
|
-
} catch (err) {
|
|
65
|
-
log('generalError_0002', `Could not read lerna.json: ${err}.`);
|
|
42
|
+
if (Array.isArray(packageJson?.workspaces)) {
|
|
43
|
+
return root;
|
|
66
44
|
}
|
|
67
|
-
|
|
45
|
+
|
|
46
|
+
previous = root;
|
|
47
|
+
root = dirname(root);
|
|
48
|
+
} while (root !== previous);
|
|
68
49
|
|
|
69
50
|
return undefined;
|
|
70
51
|
}
|
|
@@ -76,36 +57,45 @@ export async function getLernaNpmClient(root: string): Promise<NpmClientType> {
|
|
|
76
57
|
*/
|
|
77
58
|
export async function determineNpmClient(root: string, selected?: NpmClientType): Promise<NpmClientType> {
|
|
78
59
|
if (!selected || !clientTypeKeys.includes(selected)) {
|
|
79
|
-
log('generalDebug_0003', 'No npm client selected. Checking for lock files ...');
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
60
|
+
log('generalDebug_0003', 'No npm client selected. Checking for lock or config files ...');
|
|
61
|
+
|
|
62
|
+
const searchedClients = await detectClients(root);
|
|
63
|
+
const foundClients = searchedClients.filter((m) => m.result);
|
|
64
|
+
|
|
65
|
+
log(
|
|
66
|
+
'generalDebug_0003',
|
|
67
|
+
`Results of the lock file check: ${searchedClients.map((m) => `${m.client}=${m.result}`).join(', ')}`,
|
|
68
|
+
);
|
|
69
|
+
|
|
83
70
|
const defaultClient = config.npmClient;
|
|
84
71
|
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
72
|
+
if (foundClients.length > 1) {
|
|
73
|
+
const wrapperClient = foundClients.find((m) => isWrapperClient(m.client));
|
|
87
74
|
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
if (wrapperClient) {
|
|
76
|
+
const { client } = wrapperClient;
|
|
77
|
+
log('generalDebug_0003', `Found valid wrapper client via lock or config file: "${client}".`);
|
|
91
78
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (foundClients.length > 0) {
|
|
82
|
+
const { client } = foundClients[0];
|
|
83
|
+
|
|
84
|
+
if (foundClients.length > 1) {
|
|
85
|
+
const clientStr = `"${foundClients.map((m) => m.client).join('", "')}"`;
|
|
86
|
+
log('generalWarning_0001', `Found multiple clients via their lock or config files: ${clientStr}.`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
log('generalDebug_0003', `Found valid direct client via lock or config file: "${client}".`);
|
|
90
|
+
return client;
|
|
101
91
|
}
|
|
102
92
|
|
|
103
93
|
if (clientTypeKeys.includes(defaultClient)) {
|
|
104
|
-
log('generalDebug_0003', `
|
|
94
|
+
log('generalDebug_0003', `Using the default client: "${defaultClient}".`);
|
|
105
95
|
return defaultClient;
|
|
106
96
|
}
|
|
107
97
|
|
|
108
|
-
log('generalDebug_0003', 'Using the default npm client.');
|
|
98
|
+
log('generalDebug_0003', 'Using the default "npm" client.');
|
|
109
99
|
return 'npm';
|
|
110
100
|
}
|
|
111
101
|
|
|
@@ -113,103 +103,62 @@ export async function determineNpmClient(root: string, selected?: NpmClientType)
|
|
|
113
103
|
}
|
|
114
104
|
|
|
115
105
|
export async function isMonorepoPackageRef(refName: string, root: string): Promise<boolean> {
|
|
116
|
-
const c = require(`./clients/npm`);
|
|
117
106
|
const newRoot = await detectMonorepoRoot(root);
|
|
118
107
|
|
|
119
108
|
if (newRoot) {
|
|
120
|
-
const
|
|
109
|
+
const { listPackage } = clients.npm;
|
|
110
|
+
const details = await listPackage(refName, newRoot);
|
|
121
111
|
return details?.dependencies?.[refName]?.extraneous ?? false;
|
|
122
112
|
}
|
|
123
113
|
|
|
124
114
|
return false;
|
|
125
115
|
}
|
|
126
116
|
|
|
127
|
-
export async function detectMonorepoRoot(root: string): Promise<string> {
|
|
128
|
-
const file = await getLernaConfigPath(root);
|
|
129
|
-
|
|
130
|
-
if (file !== undefined) {
|
|
131
|
-
return dirname(file);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
let previous = root;
|
|
135
|
-
|
|
136
|
-
do {
|
|
137
|
-
const packageJson = await readJson(root, 'package.json');
|
|
138
|
-
|
|
139
|
-
if (Array.isArray(packageJson?.workspaces)) {
|
|
140
|
-
return root;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
previous = root;
|
|
144
|
-
root = dirname(root);
|
|
145
|
-
} while (root !== previous);
|
|
146
|
-
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export type MonorepoKind = 'none' | 'lerna' | 'yarn';
|
|
151
|
-
|
|
152
|
-
export async function detectMonorepo(root: string): Promise<MonorepoKind> {
|
|
153
|
-
const newRoot = await detectMonorepoRoot(root);
|
|
154
|
-
|
|
155
|
-
if (newRoot) {
|
|
156
|
-
const file = await getLernaConfigPath(newRoot);
|
|
157
|
-
|
|
158
|
-
if (file !== undefined) {
|
|
159
|
-
return 'lerna';
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const packageJson = await readJson(newRoot, 'package.json');
|
|
163
|
-
|
|
164
|
-
if (Array.isArray(packageJson?.workspaces)) {
|
|
165
|
-
return 'yarn';
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return 'none';
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export function bootstrapMonorepo(target = '.') {
|
|
173
|
-
const c = require(`./clients/lerna`);
|
|
174
|
-
return c.bootstrap(target);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
117
|
export function installDependencies(client: NpmClientType, target = '.'): Promise<string> {
|
|
178
|
-
const
|
|
179
|
-
return
|
|
118
|
+
const { installDependencies } = clients[client];
|
|
119
|
+
return installDependencies(target);
|
|
180
120
|
}
|
|
181
121
|
|
|
182
|
-
export function installPackage(
|
|
122
|
+
export async function installPackage(
|
|
183
123
|
client: NpmClientType,
|
|
184
124
|
packageRef: string,
|
|
185
125
|
target = '.',
|
|
186
126
|
...flags: Array<string>
|
|
187
127
|
): Promise<string> {
|
|
188
|
-
|
|
189
|
-
|
|
128
|
+
try {
|
|
129
|
+
const { installPackage } = clients[client];
|
|
130
|
+
return await installPackage(packageRef, target, ...flags);
|
|
131
|
+
} catch (ex) {
|
|
132
|
+
log(
|
|
133
|
+
'generalError_0002',
|
|
134
|
+
`Could not install the package "${packageRef}" using ${client}. Make sure ${client} is correctly installed and accessible: ${ex}`,
|
|
135
|
+
);
|
|
136
|
+
throw ex;
|
|
137
|
+
}
|
|
190
138
|
}
|
|
191
139
|
|
|
192
140
|
export function publishPackage(target = '.', file = '*.tgz', flags: Array<string> = []): Promise<string> {
|
|
193
|
-
const
|
|
194
|
-
return
|
|
141
|
+
const { publishPackage } = clients.npm;
|
|
142
|
+
return publishPackage(target, file, ...flags);
|
|
195
143
|
}
|
|
196
144
|
|
|
197
145
|
export function createPackage(target = '.'): Promise<string> {
|
|
198
|
-
const
|
|
199
|
-
return
|
|
146
|
+
const { createPackage } = clients.npm;
|
|
147
|
+
return createPackage(target);
|
|
200
148
|
}
|
|
201
149
|
|
|
202
150
|
export function findTarball(packageRef: string): Promise<string> {
|
|
203
|
-
const
|
|
204
|
-
return
|
|
151
|
+
const { findTarball } = clients.npm;
|
|
152
|
+
return findTarball(packageRef);
|
|
205
153
|
}
|
|
206
154
|
|
|
207
155
|
export function findSpecificVersion(packageName: string, version: string): Promise<string> {
|
|
208
|
-
const
|
|
209
|
-
return
|
|
156
|
+
const { findSpecificVersion } = clients.npm;
|
|
157
|
+
return findSpecificVersion(packageName, version);
|
|
210
158
|
}
|
|
211
159
|
|
|
212
160
|
export function findLatestVersion(packageName: string) {
|
|
161
|
+
const { findSpecificVersion } = clients.npm;
|
|
213
162
|
return findSpecificVersion(packageName, 'latest');
|
|
214
163
|
}
|
|
215
164
|
|
package/src/common/scaffold.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join, dirname, resolve, basename, isAbsolute } from 'path';
|
|
2
|
-
import { installPackage } from './
|
|
2
|
+
import { installPackage } from './npm';
|
|
3
3
|
import { ForceOverwrite, SourceLanguage } from './enums';
|
|
4
4
|
import { createDirectory, createFileIfNotExists, updateExistingJson } from './io';
|
|
5
5
|
import { log, fail } from './log';
|
|
@@ -36,7 +36,7 @@ async function getTemplateFiles(
|
|
|
36
36
|
if (templatePackageName.startsWith('.')) {
|
|
37
37
|
templatePackageName = resolve(process.cwd(), templatePackageName);
|
|
38
38
|
} else {
|
|
39
|
-
await installPackage(templatePackageName, __dirname, '--registry', registry);
|
|
39
|
+
await installPackage('npm', templatePackageName, __dirname, '--registry', registry);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const templateRunner = getTemplatePackage(templatePackageName);
|
package/src/helpers.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const publishModeKeys: Array<PiletPublishScheme> = ['none', 'basic', 'bea
|
|
|
15
15
|
export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
|
|
16
16
|
export const piralBuildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
|
|
17
17
|
export const piletBuildTypeKeys: Array<PiletBuildType> = ['default', 'standalone', 'manifest'];
|
|
18
|
-
export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn'];
|
|
18
|
+
export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn', 'lerna', 'rush'];
|
|
19
19
|
export const bundlerKeys: Array<string> = ['none', ...bundlerNames];
|
|
20
20
|
export const availableBundlers: Array<string> = [];
|
|
21
21
|
export const availableReleaseProviders: Array<string> = [];
|
package/src/types/public.ts
CHANGED
|
@@ -226,7 +226,7 @@ export type PiletBuildType = 'default' | 'standalone' | 'manifest';
|
|
|
226
226
|
|
|
227
227
|
export type PackageType = 'registry' | 'file' | 'git';
|
|
228
228
|
|
|
229
|
-
export type NpmClientType = 'npm' | 'yarn' | 'pnpm';
|
|
229
|
+
export type NpmClientType = 'npm' | 'yarn' | 'pnpm' | 'lerna' | 'rush';
|
|
230
230
|
|
|
231
231
|
export type Framework = 'piral' | 'piral-core' | 'piral-base';
|
|
232
232
|
|