piral-cli 0.15.0-alpha.4122 → 0.15.0-alpha.4231
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 +5 -9
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.js +5 -3
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/publish-pilet.d.ts +4 -0
- package/lib/apps/publish-pilet.js +4 -3
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.d.ts +4 -0
- package/lib/apps/publish-piral.js +9 -7
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +2 -8
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.js +1 -1
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/bundler.js +1 -1
- package/lib/bundler.js.map +1 -1
- package/lib/commands.js +8 -0
- package/lib/commands.js.map +1 -1
- package/lib/common/browser.d.ts +1 -0
- package/lib/common/browser.js +16 -10
- package/lib/common/browser.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 +6 -1
- package/lib/common/clients/lerna.js +67 -3
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +4 -1
- package/lib/common/clients/npm.js +37 -16
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.d.ts +4 -0
- package/lib/common/clients/pnpm.js +43 -9
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +6 -0
- package/lib/common/clients/rush.js +118 -0
- package/lib/common/clients/rush.js.map +1 -0
- package/lib/common/clients/yarn.d.ts +4 -0
- package/lib/common/clients/yarn.js +45 -11
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/declaration.js +12 -9
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/emulator.js +2 -2
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/http.d.ts +1 -1
- package/lib/common/http.js +12 -7
- package/lib/common/http.js.map +1 -1
- package/lib/common/info.d.ts +4 -0
- package/lib/common/info.js +6 -1
- package/lib/common/info.js.map +1 -1
- package/lib/common/inspect.js +2 -1
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/interactive.d.ts +9 -0
- package/lib/common/interactive.js +31 -1
- package/lib/common/interactive.js.map +1 -1
- package/lib/common/io.js +1 -1
- package/lib/common/io.js.map +1 -1
- package/lib/common/npm.d.ts +9 -16
- package/lib/common/npm.js +110 -152
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +1 -1
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +6 -6
- package/lib/common/package.js +13 -4
- package/lib/common/package.js.map +1 -1
- package/lib/common/scaffold.js +5 -2
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/version.js +4 -4
- package/lib/common/version.js.map +1 -1
- package/lib/external/index.js +1982 -92
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/injectors/pilet.js +2 -2
- package/lib/injectors/pilet.js.map +1 -1
- package/lib/messages.d.ts +1 -1
- package/lib/messages.js.map +1 -1
- package/lib/plugin.js +27 -2
- package/lib/plugin.js.map +1 -1
- package/lib/release.d.ts +1 -1
- package/lib/release.js +7 -2
- package/lib/release.js.map +1 -1
- package/lib/types/common.d.ts +1 -1
- package/lib/types/internal.d.ts +9 -1
- package/lib/types/public.d.ts +1 -1
- package/package.json +5 -3
- package/src/apps/new-pilet.ts +9 -14
- package/src/apps/new-piral.ts +9 -5
- package/src/apps/publish-pilet.ts +10 -3
- package/src/apps/publish-piral.ts +21 -6
- package/src/apps/upgrade-pilet.ts +4 -12
- package/src/apps/upgrade-piral.ts +2 -2
- package/src/bundler.test.ts +1 -1
- package/src/bundler.ts +2 -2
- package/src/commands.ts +8 -0
- package/src/common/browser.ts +12 -8
- package/src/common/clients/index.ts +33 -0
- package/src/common/clients/lerna.ts +61 -1
- package/src/common/clients/npm.ts +32 -15
- package/src/common/clients/pnpm.ts +39 -10
- package/src/common/clients/rush.ts +111 -0
- package/src/common/clients/yarn.ts +41 -12
- package/src/common/declaration.ts +15 -9
- package/src/common/emulator.ts +3 -3
- package/src/common/http.ts +20 -6
- package/src/common/info.ts +6 -1
- package/src/common/inspect.ts +2 -1
- package/src/common/interactive.test.ts +3 -0
- package/src/common/interactive.ts +48 -1
- package/src/common/io.ts +1 -1
- package/src/common/npm.test.ts +109 -76
- package/src/common/npm.ts +119 -146
- package/src/common/pack.test.ts +1 -1
- package/src/common/pack.ts +2 -2
- package/src/common/package.ts +19 -10
- package/src/common/scaffold.ts +6 -2
- package/src/common/version.ts +4 -4
- package/src/external/index.ts +2 -1
- package/src/helpers.ts +1 -1
- package/src/injectors/pilet.ts +3 -3
- package/src/messages.ts +1 -1
- package/src/plugin.ts +34 -5
- package/src/release.ts +10 -2
- package/src/types/common.ts +1 -1
- package/src/types/internal.ts +6 -1
- package/src/types/public.ts +1 -1
package/src/common/emulator.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { findDependencyVersion, copyScaffoldingFiles, isValidDependency } from '
|
|
|
3
3
|
import { createFileFromTemplateIfNotExists } from './template';
|
|
4
4
|
import { filesTar, filesOnceTar } from './constants';
|
|
5
5
|
import { cliVersion } from './info';
|
|
6
|
-
import {
|
|
6
|
+
import { createNpmPackage, makeExternals } from './npm';
|
|
7
7
|
import { createPiralDeclaration } from './declaration';
|
|
8
8
|
import { ForceOverwrite } from './enums';
|
|
9
9
|
import { createTarball } from './archive';
|
|
@@ -31,7 +31,7 @@ export async function createEmulatorSources(
|
|
|
31
31
|
...piralPkg.devDependencies,
|
|
32
32
|
...piralPkg.dependencies,
|
|
33
33
|
};
|
|
34
|
-
const allExternals = makeExternals(allDeps, piralPkg.pilets?.externals);
|
|
34
|
+
const allExternals = makeExternals(sourceDir, allDeps, piralPkg.pilets?.externals);
|
|
35
35
|
|
|
36
36
|
const externalPackages = await Promise.all(
|
|
37
37
|
allExternals.filter(isValidDependency).map(async (name) => ({
|
|
@@ -138,7 +138,7 @@ export async function createEmulatorSources(
|
|
|
138
138
|
|
|
139
139
|
export async function packageEmulator(rootDir: string) {
|
|
140
140
|
// finally package everything up
|
|
141
|
-
await
|
|
141
|
+
await createNpmPackage(rootDir);
|
|
142
142
|
|
|
143
143
|
// get all files
|
|
144
144
|
const names = await getFileNames(rootDir);
|
package/src/common/http.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
2
|
import { Agent } from 'https';
|
|
3
3
|
import { Stream } from 'stream';
|
|
4
|
-
import {
|
|
4
|
+
import { tmpdir } from 'os';
|
|
5
5
|
import { createWriteStream } from 'fs';
|
|
6
6
|
import { log } from './log';
|
|
7
|
+
import { standardHeaders } from './info';
|
|
8
|
+
import { getTokenInteractively } from './interactive';
|
|
7
9
|
import { axios, FormData } from '../external';
|
|
8
10
|
import { PiletPublishScheme } from '../types';
|
|
9
11
|
|
|
10
|
-
const os = platform();
|
|
11
|
-
const standardHeaders = {
|
|
12
|
-
'user-agent': `piral-cli/http.node-${os}`,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
12
|
function getMessage(body: string | { message?: string }) {
|
|
16
13
|
if (typeof body === 'string') {
|
|
17
14
|
try {
|
|
@@ -74,6 +71,7 @@ export function postFile(
|
|
|
74
71
|
customFields: Record<string, string> = {},
|
|
75
72
|
customHeaders: Record<string, string> = {},
|
|
76
73
|
ca?: Buffer,
|
|
74
|
+
interactive = false,
|
|
77
75
|
): Promise<PostFileResult> {
|
|
78
76
|
const form = new FormData();
|
|
79
77
|
const httpsAgent = ca ? new Agent({ ca }) : undefined;
|
|
@@ -124,6 +122,22 @@ export function postFile(
|
|
|
124
122
|
// The request was made and the server responded with a status code
|
|
125
123
|
// that falls out of the range of 2xx
|
|
126
124
|
const { data, statusText, status } = error.response;
|
|
125
|
+
|
|
126
|
+
if (interactive && 'interactiveAuth' in data) {
|
|
127
|
+
const { interactiveAuth } = data;
|
|
128
|
+
|
|
129
|
+
if (typeof interactiveAuth === 'string') {
|
|
130
|
+
log(
|
|
131
|
+
'generalDebug_0003',
|
|
132
|
+
`Received status "${status}" from HTTP - trying interactive log in to "${interactiveAuth}".`,
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return getTokenInteractively(interactiveAuth, httpsAgent).then(({ mode, token }) =>
|
|
136
|
+
postFile(target, mode, token, file, customFields, customHeaders, ca, false),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
127
141
|
const message = getMessage(data) || '';
|
|
128
142
|
log('unsuccessfulHttpPost_0066', statusText, status, message);
|
|
129
143
|
return {
|
package/src/common/info.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { cpus } from 'os';
|
|
1
|
+
import { cpus, platform } from 'os';
|
|
2
2
|
|
|
3
3
|
const info = require('../../package.json');
|
|
4
|
+
const os = platform();
|
|
4
5
|
|
|
5
6
|
export function findCompatVersion(version: string) {
|
|
6
7
|
// we only care about major and minor
|
|
@@ -15,9 +16,13 @@ export function findCompatVersion(version: string) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const nodeVersion = process.version.substring(1);
|
|
19
|
+
export const cliName = info.name;
|
|
18
20
|
export const cliVersion = info.version;
|
|
19
21
|
export const compatVersion = findCompatVersion(cliVersion);
|
|
20
22
|
export const repositoryUrl = info.repository.url;
|
|
21
23
|
export const isWindows = process.platform === 'win32';
|
|
22
24
|
export const pathSeparator = isWindows ? ';' : ':';
|
|
23
25
|
export const cpuCount = cpus().length;
|
|
26
|
+
export const standardHeaders = {
|
|
27
|
+
'user-agent': `piral-cli/http.node-${os}`,
|
|
28
|
+
};
|
package/src/common/inspect.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dirname, basename } from 'path';
|
|
2
2
|
import { unpackGzTar } from './archive';
|
|
3
|
+
import { jju } from '../external';
|
|
3
4
|
import { PackageData, PackageFiles } from '../types';
|
|
4
5
|
|
|
5
6
|
const packageRoot = 'package/';
|
|
@@ -8,7 +9,7 @@ function getPackageJson(files: PackageFiles): PackageData {
|
|
|
8
9
|
const fileName = `${packageRoot}package.json`;
|
|
9
10
|
const fileContent = files[fileName];
|
|
10
11
|
const content = fileContent.toString('utf8');
|
|
11
|
-
return
|
|
12
|
+
return jju.parse(content);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
function getPiletMainPath(data: PackageData, files: PackageFiles) {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Agent } from 'https';
|
|
2
|
+
import { openBrowserAt } from './browser';
|
|
3
|
+
import { standardHeaders } from './info';
|
|
4
|
+
import { axios, inquirer } from '../external';
|
|
5
|
+
import { PiletPublishScheme } from '../types';
|
|
2
6
|
|
|
3
7
|
export function promptSelect(message: string, values: Array<string>, defaultValue: string): Promise<string> {
|
|
4
8
|
const questions = [
|
|
@@ -24,3 +28,46 @@ export function promptConfirm(message: string, defaultValue: boolean): Promise<b
|
|
|
24
28
|
];
|
|
25
29
|
return inquirer.prompt(questions).then((answers: any) => answers.q);
|
|
26
30
|
}
|
|
31
|
+
|
|
32
|
+
type TokenResult = Promise<{ mode: PiletPublishScheme; token: string }>;
|
|
33
|
+
|
|
34
|
+
const tokenRetrievers: Record<string, TokenResult> = {};
|
|
35
|
+
|
|
36
|
+
export function getTokenInteractively(url: string, httpsAgent: Agent): TokenResult {
|
|
37
|
+
if (!(url in tokenRetrievers)) {
|
|
38
|
+
tokenRetrievers[url] = axios.default
|
|
39
|
+
.post(
|
|
40
|
+
url,
|
|
41
|
+
{
|
|
42
|
+
clientId: 'piral-cli',
|
|
43
|
+
clientName: 'Piral CLI',
|
|
44
|
+
description: 'Authorize the Piral CLI temporarily to perform actions in your name.',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
headers: {
|
|
48
|
+
...standardHeaders,
|
|
49
|
+
'content-type': 'application/json',
|
|
50
|
+
},
|
|
51
|
+
httpsAgent,
|
|
52
|
+
},
|
|
53
|
+
)
|
|
54
|
+
.then((res) => {
|
|
55
|
+
const { loginUrl, callbackUrl, expires } = res.data;
|
|
56
|
+
console.log(`Use the URL below to complete the login. The link expires at ${new Date(expires)}.`);
|
|
57
|
+
console.log('===');
|
|
58
|
+
console.log(loginUrl);
|
|
59
|
+
console.log('===');
|
|
60
|
+
|
|
61
|
+
openBrowserAt(loginUrl);
|
|
62
|
+
|
|
63
|
+
return axios.default.get(callbackUrl).then(({ data }) => {
|
|
64
|
+
console.log('Logged in successfully.');
|
|
65
|
+
return {
|
|
66
|
+
...data,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return tokenRetrievers[url];
|
|
73
|
+
}
|
package/src/common/io.ts
CHANGED
|
@@ -239,7 +239,7 @@ export async function matchAnyPilet(baseDir: string, patterns: Array<string>) {
|
|
|
239
239
|
const allPatterns = patterns.reduce<Array<AnyPattern>>((agg, curr) => {
|
|
240
240
|
const patterns = [];
|
|
241
241
|
|
|
242
|
-
if (/[a-zA-Z0-9\-\*]
|
|
242
|
+
if (/[a-zA-Z0-9\-\*]$/.test(curr) && !preferences.find((ext) => curr.endsWith(ext))) {
|
|
243
243
|
patterns.push(curr, `${curr}.{${exts}}`, `${curr}/${nameOfPackageJson}`);
|
|
244
244
|
} else if (curr.endsWith('/')) {
|
|
245
245
|
patterns.push(`${curr}index.{${exts}}`, `${curr}${nameOfPackageJson}`);
|
package/src/common/npm.test.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
|
+
import { clients } from './clients';
|
|
2
3
|
import {
|
|
3
4
|
dissectPackageName,
|
|
4
|
-
|
|
5
|
-
detectNpm,
|
|
6
|
-
detectPnpm,
|
|
7
|
-
detectYarn,
|
|
5
|
+
installNpmPackage,
|
|
8
6
|
isMonorepoPackageRef,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
createPackage,
|
|
13
|
-
findTarball,
|
|
7
|
+
installNpmDependencies,
|
|
8
|
+
createNpmPackage,
|
|
9
|
+
findNpmTarball,
|
|
14
10
|
findSpecificVersion,
|
|
15
11
|
findLatestVersion,
|
|
16
12
|
isLocalPackage,
|
|
@@ -43,9 +39,10 @@ jest.mock('../external', () => ({
|
|
|
43
39
|
}));
|
|
44
40
|
|
|
45
41
|
let specialCase = false;
|
|
42
|
+
let shouldFind = true;
|
|
46
43
|
let wrongCase = false;
|
|
47
|
-
const jsonValueString = JSON.stringify({
|
|
48
|
-
const jsonValueStringWrong = JSON.stringify(
|
|
44
|
+
const jsonValueString = JSON.stringify([{ name: 'npm' }]);
|
|
45
|
+
const jsonValueStringWrong = JSON.stringify([]);
|
|
49
46
|
|
|
50
47
|
jest.mock('./scripts', () => ({
|
|
51
48
|
runCommand: (exe: string, args: Array<string>, cwd: string, output?: NodeJS.WritableStream) => {
|
|
@@ -57,14 +54,15 @@ jest.mock('./scripts', () => ({
|
|
|
57
54
|
}));
|
|
58
55
|
|
|
59
56
|
jest.mock('fs', () => ({
|
|
60
|
-
constants: {
|
|
61
|
-
F_OK: 1,
|
|
62
|
-
},
|
|
63
57
|
createReadStream() {
|
|
64
58
|
return undefined;
|
|
65
59
|
},
|
|
66
60
|
exists: (file: string, cb: (status: boolean) => void) =>
|
|
67
|
-
cb(
|
|
61
|
+
cb(
|
|
62
|
+
shouldFind &&
|
|
63
|
+
!file.endsWith('package.json') &&
|
|
64
|
+
!(specialCase && (file.endsWith('lerna.json') || file.endsWith('yarn.lock'))),
|
|
65
|
+
),
|
|
68
66
|
existsSync: (file: string) => {
|
|
69
67
|
return true;
|
|
70
68
|
},
|
|
@@ -73,13 +71,6 @@ jest.mock('fs', () => ({
|
|
|
73
71
|
},
|
|
74
72
|
realpathSync: () => ({}),
|
|
75
73
|
readFileSync: () => '',
|
|
76
|
-
access: (path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void) => {
|
|
77
|
-
if (path.includes('test')) {
|
|
78
|
-
return callback(undefined);
|
|
79
|
-
} else {
|
|
80
|
-
return callback(new Error('bla'));
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
74
|
}));
|
|
84
75
|
|
|
85
76
|
describe('npm Module', () => {
|
|
@@ -187,55 +178,66 @@ describe('npm Module', () => {
|
|
|
187
178
|
|
|
188
179
|
it('installs a package using the npm command line tool without a target', async () => {
|
|
189
180
|
wrongCase = false;
|
|
190
|
-
await
|
|
181
|
+
await installNpmPackage('npm', 'foo', 'latest').then((result) => expect(result).toEqual(jsonValueString));
|
|
191
182
|
wrongCase = true;
|
|
192
|
-
await
|
|
183
|
+
await installNpmPackage('npm', 'foo', 'latest').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
193
184
|
});
|
|
194
185
|
|
|
195
186
|
it('installs a package using the npm command line tool without a version', async () => {
|
|
196
187
|
wrongCase = false;
|
|
197
|
-
await
|
|
188
|
+
await installNpmPackage('npm', 'foo').then((result) => expect(result).toEqual(jsonValueString));
|
|
198
189
|
wrongCase = true;
|
|
199
|
-
await
|
|
190
|
+
await installNpmPackage('npm', 'foo').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
200
191
|
});
|
|
201
192
|
|
|
202
193
|
it('installs a package using the Yarn command line tool without a version', async () => {
|
|
203
194
|
wrongCase = false;
|
|
204
|
-
await
|
|
195
|
+
await installNpmPackage('yarn', 'foo').then((result) => expect(result).toEqual(jsonValueString));
|
|
205
196
|
wrongCase = true;
|
|
206
|
-
await
|
|
197
|
+
await installNpmPackage('yarn', 'foo').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
207
198
|
});
|
|
208
199
|
|
|
209
200
|
it('installs a package using the Pnpm command line tool without a version', async () => {
|
|
210
201
|
wrongCase = false;
|
|
211
|
-
await
|
|
202
|
+
await installNpmPackage('pnpm', 'foo').then((result) => expect(result).toEqual(jsonValueString));
|
|
212
203
|
wrongCase = true;
|
|
213
|
-
await
|
|
204
|
+
await installNpmPackage('pnpm', 'foo').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
214
205
|
});
|
|
215
206
|
|
|
216
207
|
it('installs a package using the npm command line tool with some flag', async () => {
|
|
217
208
|
wrongCase = false;
|
|
218
|
-
await
|
|
209
|
+
await installNpmPackage('npm', 'foo', '1.3', '.', '--a=b').then((result) =>
|
|
210
|
+
expect(result).toEqual(jsonValueString),
|
|
211
|
+
);
|
|
219
212
|
wrongCase = true;
|
|
220
|
-
await
|
|
213
|
+
await installNpmPackage('npm', 'foo', '1.3', '.', '--a=b').then((result) =>
|
|
221
214
|
expect(result).not.toEqual(jsonValueString),
|
|
222
215
|
);
|
|
223
216
|
});
|
|
224
217
|
|
|
225
218
|
it('detectNpm finds package-lock.json', async () => {
|
|
226
|
-
|
|
227
|
-
await
|
|
219
|
+
shouldFind = true;
|
|
220
|
+
await clients.npm.detectClient('test').then((result) => expect(result).toBeTruthy());
|
|
221
|
+
shouldFind = false;
|
|
222
|
+
await clients.npm.detectClient('toast').then((result) => expect(result).toBeFalsy());
|
|
223
|
+
shouldFind = true;
|
|
228
224
|
});
|
|
229
225
|
|
|
230
|
-
it('detectPnpm finds
|
|
231
|
-
|
|
232
|
-
await
|
|
226
|
+
it('detectPnpm finds pnpm-lock.yaml', async () => {
|
|
227
|
+
shouldFind = true;
|
|
228
|
+
await clients.pnpm.detectClient('test').then((result) => expect(result).toBeTruthy());
|
|
229
|
+
shouldFind = false;
|
|
230
|
+
await clients.pnpm.detectClient('toast').then((result) => expect(result).toBeFalsy());
|
|
231
|
+
shouldFind = true;
|
|
233
232
|
});
|
|
234
233
|
|
|
235
234
|
it('detectYarn finds yarn.lock', async () => {
|
|
236
|
-
|
|
235
|
+
shouldFind = true;
|
|
236
|
+
await clients.yarn.detectClient('test').then((result) => expect(result).toBeTruthy());
|
|
237
|
+
shouldFind = false;
|
|
237
238
|
specialCase = true;
|
|
238
|
-
await
|
|
239
|
+
await clients.yarn.detectClient('toast').then((result) => expect(result).toBeFalsy());
|
|
240
|
+
shouldFind = true;
|
|
239
241
|
specialCase = false;
|
|
240
242
|
});
|
|
241
243
|
|
|
@@ -246,59 +248,46 @@ describe('npm Module', () => {
|
|
|
246
248
|
await isMonorepoPackageRef('npm', './').then((result) => expect(result).toBeFalsy());
|
|
247
249
|
});
|
|
248
250
|
|
|
249
|
-
it('verifies whether lerna config path is valid', async () => {
|
|
250
|
-
wrongCase = false;
|
|
251
|
-
await detectMonorepo('./').then((result) => {
|
|
252
|
-
expect(result).toBe('lerna');
|
|
253
|
-
});
|
|
254
|
-
wrongCase = true;
|
|
255
|
-
specialCase = true;
|
|
256
|
-
await detectMonorepo('./').then((result) => {
|
|
257
|
-
expect(result).toBe('none');
|
|
258
|
-
});
|
|
259
|
-
specialCase = false;
|
|
260
|
-
});
|
|
261
|
-
|
|
262
251
|
it('verifies whether lerna bootstrap ran', async () => {
|
|
263
252
|
wrongCase = false;
|
|
264
|
-
await
|
|
253
|
+
await clients.lerna.installDependencies().then((result) => expect(result).toEqual(jsonValueString));
|
|
265
254
|
wrongCase = true;
|
|
266
|
-
await
|
|
255
|
+
await clients.lerna.installDependencies().then((result) => expect(result).not.toEqual(jsonValueString));
|
|
267
256
|
});
|
|
268
257
|
|
|
269
258
|
it('install dependencies with npm client', async () => {
|
|
270
259
|
wrongCase = false;
|
|
271
|
-
await
|
|
260
|
+
await installNpmDependencies('npm').then((result) => expect(result).toEqual(jsonValueString));
|
|
272
261
|
wrongCase = true;
|
|
273
|
-
await
|
|
262
|
+
await installNpmDependencies('npm').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
274
263
|
});
|
|
275
264
|
|
|
276
265
|
it('install dependencies with pnpm client', async () => {
|
|
277
266
|
wrongCase = false;
|
|
278
|
-
await
|
|
267
|
+
await installNpmDependencies('pnpm').then((result) => expect(result).toEqual(jsonValueString));
|
|
279
268
|
wrongCase = true;
|
|
280
|
-
await
|
|
269
|
+
await installNpmDependencies('pnpm').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
281
270
|
});
|
|
282
271
|
|
|
283
272
|
it('install dependencies with yarn client', async () => {
|
|
284
273
|
wrongCase = false;
|
|
285
|
-
await
|
|
274
|
+
await installNpmDependencies('yarn').then((result) => expect(result).toEqual(jsonValueString));
|
|
286
275
|
wrongCase = true;
|
|
287
|
-
await
|
|
276
|
+
await installNpmDependencies('yarn').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
288
277
|
});
|
|
289
278
|
|
|
290
279
|
it('create npm package', async () => {
|
|
291
280
|
wrongCase = false;
|
|
292
|
-
await
|
|
281
|
+
await createNpmPackage().then((result) => expect(result).toEqual(jsonValueString));
|
|
293
282
|
wrongCase = true;
|
|
294
|
-
await
|
|
283
|
+
await createNpmPackage().then((result) => expect(result).not.toEqual(jsonValueString));
|
|
295
284
|
});
|
|
296
285
|
|
|
297
286
|
it('find npm tarball', async () => {
|
|
298
287
|
wrongCase = false;
|
|
299
|
-
await
|
|
288
|
+
await findNpmTarball('foo').then((result) => expect(result).toEqual(jsonValueString));
|
|
300
289
|
wrongCase = true;
|
|
301
|
-
await
|
|
290
|
+
await findNpmTarball('foo').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
302
291
|
});
|
|
303
292
|
|
|
304
293
|
it('find latest version', async () => {
|
|
@@ -315,17 +304,61 @@ describe('npm Module', () => {
|
|
|
315
304
|
await findSpecificVersion('foo', '1.0.0').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
316
305
|
});
|
|
317
306
|
|
|
318
|
-
it('check if package is local', () => {
|
|
319
|
-
|
|
307
|
+
it('check if package from full file is local', () => {
|
|
308
|
+
const result = isLocalPackage('./', 'file://foo.tgz');
|
|
320
309
|
expect(result).toBeTruthy();
|
|
321
|
-
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('check if package from current dir is local', () => {
|
|
313
|
+
const result = isLocalPackage('./', './');
|
|
322
314
|
expect(result).toBeTruthy();
|
|
323
|
-
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('check if package from file is local', () => {
|
|
318
|
+
const result = isLocalPackage('./', 'foo.tgz');
|
|
319
|
+
expect(result).toBeTruthy();
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('check if package from nothing is not local', () => {
|
|
323
|
+
const result = isLocalPackage('./', null);
|
|
324
|
+
expect(result).toBeFalsy();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('check if package from tilde version is not local', () => {
|
|
328
|
+
const result = isLocalPackage('./', '~12.2.2');
|
|
329
|
+
expect(result).toBeFalsy();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('check if package from caret version is not local', () => {
|
|
333
|
+
const result = isLocalPackage('./', '^12.2.2');
|
|
334
|
+
expect(result).toBeFalsy();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('check if package from star version is not local', () => {
|
|
338
|
+
const result = isLocalPackage('./', '*');
|
|
339
|
+
expect(result).toBeFalsy();
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('check if package from greater than is not local', () => {
|
|
343
|
+
const result = isLocalPackage('./', '>=1.0.0');
|
|
344
|
+
expect(result).toBeFalsy();
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('check if package from home dir is local', () => {
|
|
348
|
+
const result = isLocalPackage('./', '~/foo/bar');
|
|
324
349
|
expect(result).toBeTruthy();
|
|
325
|
-
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('check if package from zero is not local', () => {
|
|
353
|
+
const result = isLocalPackage('./', '.0');
|
|
326
354
|
expect(result).toBeFalsy();
|
|
327
355
|
});
|
|
328
356
|
|
|
357
|
+
it('check if package from absolute dir is local', () => {
|
|
358
|
+
const result = isLocalPackage('./', '/0');
|
|
359
|
+
expect(result).toBeTruthy();
|
|
360
|
+
});
|
|
361
|
+
|
|
329
362
|
it('check if package is coming from git', () => {
|
|
330
363
|
let result = isGitPackage('https://.foo.git');
|
|
331
364
|
expect(result).toBeTruthy();
|
|
@@ -420,7 +453,7 @@ describe('npm Module', () => {
|
|
|
420
453
|
});
|
|
421
454
|
|
|
422
455
|
it('makeExternals without externals returns coreExternals', () => {
|
|
423
|
-
const externals = makeExternals({ piral: '*' });
|
|
456
|
+
const externals = makeExternals(process.cwd(), { piral: '*' });
|
|
424
457
|
expect(externals).toEqual([
|
|
425
458
|
'react',
|
|
426
459
|
'react-dom',
|
|
@@ -435,7 +468,7 @@ describe('npm Module', () => {
|
|
|
435
468
|
});
|
|
436
469
|
|
|
437
470
|
it('makeExternals with no externals returns coreExternals', () => {
|
|
438
|
-
const externals = makeExternals({ piral: '*' }, []);
|
|
471
|
+
const externals = makeExternals(process.cwd(), { piral: '*' }, []);
|
|
439
472
|
expect(externals).toEqual([
|
|
440
473
|
'react',
|
|
441
474
|
'react-dom',
|
|
@@ -450,12 +483,12 @@ describe('npm Module', () => {
|
|
|
450
483
|
});
|
|
451
484
|
|
|
452
485
|
it('makeExternals with exclude coreExternals returns empty set', () => {
|
|
453
|
-
const externals = makeExternals({ piral: '*' }, ['!*']);
|
|
486
|
+
const externals = makeExternals(process.cwd(), { piral: '*' }, ['!*']);
|
|
454
487
|
expect(externals).toEqual([]);
|
|
455
488
|
});
|
|
456
489
|
|
|
457
490
|
it('makeExternals with externals concats coreExternals', () => {
|
|
458
|
-
const externals = makeExternals({ piral: '*' }, ['foo', 'bar']);
|
|
491
|
+
const externals = makeExternals(process.cwd(), { piral: '*' }, ['foo', 'bar']);
|
|
459
492
|
expect(externals).toEqual([
|
|
460
493
|
'foo',
|
|
461
494
|
'bar',
|
|
@@ -472,7 +505,7 @@ describe('npm Module', () => {
|
|
|
472
505
|
});
|
|
473
506
|
|
|
474
507
|
it('makeExternals with external duplicate only reflects coreExternals', () => {
|
|
475
|
-
const externals = makeExternals({ piral: '*' }, ['react', 'foo']);
|
|
508
|
+
const externals = makeExternals(process.cwd(), { piral: '*' }, ['react', 'foo']);
|
|
476
509
|
expect(externals).toEqual([
|
|
477
510
|
'react',
|
|
478
511
|
'foo',
|
|
@@ -488,7 +521,7 @@ describe('npm Module', () => {
|
|
|
488
521
|
});
|
|
489
522
|
|
|
490
523
|
it('makeExternals with explicit include and exclude', () => {
|
|
491
|
-
const externals = makeExternals({ piral: '*' }, ['react', 'react-calendar', '!history']);
|
|
524
|
+
const externals = makeExternals(process.cwd(), { piral: '*' }, ['react', 'react-calendar', '!history']);
|
|
492
525
|
expect(externals).toEqual([
|
|
493
526
|
'react',
|
|
494
527
|
'react-calendar',
|
|
@@ -503,7 +536,7 @@ describe('npm Module', () => {
|
|
|
503
536
|
});
|
|
504
537
|
|
|
505
538
|
it('makeExternals with all exclude and explicit include', () => {
|
|
506
|
-
const externals = makeExternals({ piral: '*' }, ['react', 'react-router-dom', '!*']);
|
|
539
|
+
const externals = makeExternals(process.cwd(), { piral: '*' }, ['react', 'react-router-dom', '!*']);
|
|
507
540
|
expect(externals).toEqual(['react', 'react-router-dom']);
|
|
508
541
|
});
|
|
509
542
|
});
|