piral-cli 1.3.3-beta.6190 → 1.3.3-beta.6204
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 +1 -1
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/bundler.js +25 -1
- package/lib/bundler.js.map +1 -1
- package/lib/cli.js +5 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +24 -1
- package/lib/commands.js.map +1 -1
- package/lib/common/declaration.d.ts +1 -1
- package/lib/common/declaration.js +43 -18
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/io.js +5 -2
- package/lib/common/io.js.map +1 -1
- package/lib/common/log.js +24 -1
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.js +13 -13
- package/lib/common/npm.js.map +1 -1
- package/lib/external/index.js +426 -230
- package/lib/inject.js +24 -1
- package/lib/inject.js.map +1 -1
- package/lib/{common/clients → npm-clients}/bun.js +5 -5
- package/lib/npm-clients/bun.js.map +1 -0
- package/lib/{common/clients → npm-clients}/index.js +31 -8
- package/lib/npm-clients/index.js.map +1 -0
- package/lib/{common/clients → npm-clients}/lerna.js +4 -4
- package/lib/npm-clients/lerna.js.map +1 -0
- package/lib/{common/clients → npm-clients}/npm.js +4 -4
- package/lib/npm-clients/npm.js.map +1 -0
- package/lib/{common/clients → npm-clients}/pnp.js +4 -4
- package/lib/npm-clients/pnp.js.map +1 -0
- package/lib/{common/clients → npm-clients}/pnpm.js +4 -4
- package/lib/npm-clients/pnpm.js.map +1 -0
- package/lib/{common/clients → npm-clients}/rush.js +5 -5
- package/lib/npm-clients/rush.js.map +1 -0
- package/lib/{common/clients → npm-clients}/yarn.js +4 -4
- package/lib/npm-clients/yarn.js.map +1 -0
- package/package.json +3 -3
- package/src/apps/build-pilet.test.ts +1 -0
- package/src/apps/build-pilet.ts +1 -0
- package/src/apps/build-piral.test.ts +19 -12
- package/src/apps/new-pilet.test.ts +120 -76
- package/src/apps/new-piral.test.ts +100 -77
- package/src/apps/pack-pilet.test.ts +2 -3
- package/src/apps/upgrade-pilet.test.ts +1 -0
- package/src/bundler.test.ts +8 -7
- package/src/bundler.ts +2 -1
- package/src/cli.ts +1 -1
- package/src/common/archive.test.ts +10 -7
- package/src/common/browser.test.ts +2 -1
- package/src/common/compatibility.test.ts +1 -0
- package/src/common/declaration.ts +49 -20
- package/src/common/envs.test.ts +2 -1
- package/src/common/hash.test.ts +1 -0
- package/src/common/http.test.ts +73 -70
- package/src/common/importmap.test.ts +3 -2
- package/src/common/info.test.ts +1 -0
- package/src/common/interactive.test.ts +2 -1
- package/src/common/io.ts +1 -1
- package/src/common/merge.test.ts +1 -0
- package/src/common/npm.test.ts +35 -37
- package/src/common/npm.ts +1 -1
- package/src/common/pack.test.ts +11 -10
- package/src/common/package.test.ts +131 -92
- package/src/common/parallel.test.ts +1 -0
- package/src/common/patches.test.ts +1 -0
- package/src/common/port.test.ts +2 -1
- package/src/common/rules.test.ts +4 -3
- package/src/common/url.test.ts +1 -0
- package/src/common/utils.test.ts +1 -0
- package/src/common/version.test.ts +1 -0
- package/src/external/index.test.ts +1 -0
- package/src/helpers.test.ts +1 -0
- package/src/injectors/pilet-injector.test.ts +6 -5
- package/src/injectors/piral-injector.test.ts +7 -6
- package/src/{common/clients → npm-clients}/bun.ts +5 -5
- package/src/{common/clients → npm-clients}/index.ts +1 -1
- package/src/{common/clients → npm-clients}/lerna.ts +4 -4
- package/src/{common/clients → npm-clients}/npm.ts +4 -4
- package/src/{common/clients → npm-clients}/pnp.ts +4 -4
- package/src/{common/clients → npm-clients}/pnpm.ts +4 -4
- package/src/{common/clients → npm-clients}/rush.ts +5 -5
- package/src/{common/clients → npm-clients}/yarn.ts +4 -4
- package/src/rules/pilet-has-externals-as-peers.test.ts +4 -3
- package/lib/common/clients/bun.js.map +0 -1
- package/lib/common/clients/index.js.map +0 -1
- package/lib/common/clients/lerna.js.map +0 -1
- package/lib/common/clients/npm.js.map +0 -1
- package/lib/common/clients/pnp.js.map +0 -1
- package/lib/common/clients/pnpm.js.map +0 -1
- package/lib/common/clients/rush.js.map +0 -1
- package/lib/common/clients/yarn.js.map +0 -1
- /package/lib/{common/clients → npm-clients}/bun.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/index.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/lerna.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/npm.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/pnp.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/pnpm.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/rush.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/yarn.d.ts +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { DeclOptions, generateDeclaration,
|
|
1
|
+
import { DeclOptions, generateDeclaration, createDiffPlugin, Logger } from 'dets';
|
|
2
2
|
import { dirname, basename, resolve, extname } from 'path';
|
|
3
3
|
import { progress, log, logWarn, logVerbose, logInfo } from './log';
|
|
4
4
|
import { ForceOverwrite } from './enums';
|
|
5
5
|
import { retrievePiralRoot, retrievePiletsInfo, flattenExternals, validateSharedDependencies } from './package';
|
|
6
|
-
import { entryModuleExtensions, piralBaseRoot } from './constants';
|
|
7
|
-
import { readText, getEntryFiles, matchFiles, createFileIfNotExists } from './io';
|
|
6
|
+
import { entryModuleExtensions, piralBaseRoot, packageJson } from './constants';
|
|
7
|
+
import { readText, getEntryFiles, matchFiles, createFileIfNotExists, readJson } from './io';
|
|
8
8
|
import { getModulePath } from '../external';
|
|
9
9
|
import { LogLevels } from '../types';
|
|
10
10
|
|
|
11
|
+
const piletApiName = 'PiletApi';
|
|
12
|
+
|
|
11
13
|
function findPiralBaseRoot(root: string, framework: string) {
|
|
12
14
|
const piralJson = `${framework}/package.json`;
|
|
13
15
|
|
|
@@ -21,6 +23,26 @@ function findPiralBaseRoot(root: string, framework: string) {
|
|
|
21
23
|
return root;
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
async function findPiralInstanceApi(piralInstance: string) {
|
|
27
|
+
if (piralInstance) {
|
|
28
|
+
const path = require.resolve(`${piralInstance}/${packageJson}`);
|
|
29
|
+
const root = dirname(path);
|
|
30
|
+
const data = await readJson(root, packageJson);
|
|
31
|
+
const subpath = data.types || data.typings;
|
|
32
|
+
|
|
33
|
+
if (subpath) {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
file: resolve(root, subpath),
|
|
37
|
+
name: piletApiName,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
|
|
24
46
|
function findPiralBaseApi(root: string, framework: string) {
|
|
25
47
|
// for some package managers, e.g., pnpm we need to first go into
|
|
26
48
|
// some specifics before being able to retrieve "piral-base"
|
|
@@ -36,7 +58,7 @@ function findPiralBaseApi(root: string, framework: string) {
|
|
|
36
58
|
return [
|
|
37
59
|
{
|
|
38
60
|
file: resolve(projectDir, piletApiTypings),
|
|
39
|
-
name:
|
|
61
|
+
name: piletApiName,
|
|
40
62
|
},
|
|
41
63
|
];
|
|
42
64
|
} catch (err) {
|
|
@@ -113,7 +135,7 @@ async function createDeclarationFile(
|
|
|
113
135
|
progress('Bundling declaration file ...');
|
|
114
136
|
|
|
115
137
|
try {
|
|
116
|
-
const result = generateDeclaration(options);
|
|
138
|
+
const result = await generateDeclaration(options);
|
|
117
139
|
|
|
118
140
|
progress('Writing declaration file ...');
|
|
119
141
|
await createFileIfNotExists(target, 'index.d.ts', result, forceOverwrite);
|
|
@@ -124,6 +146,7 @@ async function createDeclarationFile(
|
|
|
124
146
|
|
|
125
147
|
export async function createPiletDeclaration(
|
|
126
148
|
name: string,
|
|
149
|
+
piralInstances: Array<string>,
|
|
127
150
|
root: string,
|
|
128
151
|
entry: string,
|
|
129
152
|
allowedImports: Array<string>,
|
|
@@ -131,21 +154,27 @@ export async function createPiletDeclaration(
|
|
|
131
154
|
forceOverwrite: ForceOverwrite,
|
|
132
155
|
logLevel: LogLevels,
|
|
133
156
|
) {
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
files
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
157
|
+
const piralInstance = piralInstances[0];
|
|
158
|
+
const apis = await findPiralInstanceApi(piralInstance);
|
|
159
|
+
const file = apis.map((m) => m.file)[0];
|
|
160
|
+
|
|
161
|
+
if (file) {
|
|
162
|
+
const files = await getAllFiles([entry]);
|
|
163
|
+
const types = findDeclaredTypings(root);
|
|
164
|
+
const options: DeclOptions = {
|
|
165
|
+
name: piralInstance,
|
|
166
|
+
root,
|
|
167
|
+
files,
|
|
168
|
+
types,
|
|
169
|
+
plugins: [createDiffPlugin(file)],
|
|
170
|
+
apis,
|
|
171
|
+
noModuleDeclaration: true,
|
|
172
|
+
imports: allowedImports,
|
|
173
|
+
logLevel,
|
|
174
|
+
logger: createLogger(),
|
|
175
|
+
};
|
|
176
|
+
return await createDeclarationFile(options, root, target, forceOverwrite);
|
|
177
|
+
}
|
|
149
178
|
}
|
|
150
179
|
|
|
151
180
|
export async function createPiralDeclaration(
|
package/src/common/envs.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describe, it, expect, vitest, beforeEach, afterEach } from 'vitest';
|
|
1
2
|
import { resolve } from 'path';
|
|
2
3
|
import { setStandardEnvs } from './envs';
|
|
3
4
|
|
|
@@ -7,7 +8,7 @@ describe('Environment Module', () => {
|
|
|
7
8
|
const oldEnv = process.env;
|
|
8
9
|
|
|
9
10
|
beforeEach(() => {
|
|
10
|
-
|
|
11
|
+
vitest.resetModules();
|
|
11
12
|
process.env = {};
|
|
12
13
|
});
|
|
13
14
|
|
package/src/common/hash.test.ts
CHANGED
package/src/common/http.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
1
2
|
import { postFile, downloadFile } from './http';
|
|
2
3
|
|
|
3
4
|
const apiUrl = 'http://sample.fooo.com/api/v1/pilet';
|
|
@@ -7,79 +8,81 @@ let errorOther = false;
|
|
|
7
8
|
let errorResponse = false;
|
|
8
9
|
let errorResponse2 = false;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
vitest.mock('../external', async () => {
|
|
12
|
+
return {
|
|
13
|
+
rc(_, cfg) {
|
|
14
|
+
return cfg;
|
|
15
|
+
},
|
|
16
|
+
ora() {
|
|
17
|
+
return {
|
|
18
|
+
warn() {},
|
|
19
|
+
fail() {},
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
axios: {
|
|
23
|
+
default: {
|
|
24
|
+
post(url, _, options) {
|
|
25
|
+
const found = url === apiUrl;
|
|
26
|
+
const auth = options.headers.authorization === 'Basic 123';
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
28
|
+
if (errorRequest) {
|
|
29
|
+
return Promise.reject({
|
|
30
|
+
request: {},
|
|
31
|
+
});
|
|
32
|
+
} else if (errorOther) {
|
|
33
|
+
return Promise.reject({
|
|
34
|
+
message: 'error',
|
|
35
|
+
});
|
|
36
|
+
} else if (errorResponse) {
|
|
37
|
+
return Promise.reject({
|
|
38
|
+
response: {
|
|
39
|
+
status: 410,
|
|
40
|
+
statusText: 'Not Gone',
|
|
41
|
+
data: '{ "message": "This component is not available anymore." }',
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
} else if (errorResponse2) {
|
|
45
|
+
return Promise.reject({
|
|
46
|
+
response: {
|
|
47
|
+
status: 410,
|
|
48
|
+
statusText: 'Not Gone',
|
|
49
|
+
data: { message: 'This component is not available anymore.' },
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
} else if (!found) {
|
|
53
|
+
return Promise.reject({
|
|
54
|
+
response: {
|
|
55
|
+
status: 404,
|
|
56
|
+
statusText: 'Not found',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
} else if (!auth) {
|
|
60
|
+
return Promise.reject({
|
|
61
|
+
response: {
|
|
62
|
+
status: 401,
|
|
63
|
+
statusText: 'Not authorized',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
return Promise.resolve({
|
|
68
|
+
status: 200,
|
|
69
|
+
statusText: 'OK',
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
get(url, options) {
|
|
74
|
+
if (errorOther) {
|
|
75
|
+
return Promise.reject({
|
|
76
|
+
message: 'error',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return Promise.resolve({ data: 'test' });
|
|
80
|
+
},
|
|
78
81
|
},
|
|
79
82
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
+
FormData: (await vitest.importActual('form-data') as any).default,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
83
86
|
|
|
84
87
|
describe('HTTP Module', () => {
|
|
85
88
|
it('postFile form posts a file successfully should be ok', async () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
1
2
|
import { readImportmap } from './importmap';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
vitest.mock('./npm', () => ({
|
|
4
5
|
tryResolvePackage(id, dir) {
|
|
5
6
|
if (id === 'qxz') {
|
|
6
7
|
return undefined;
|
|
@@ -45,7 +46,7 @@ const mockPackages = {
|
|
|
45
46
|
},
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
vitest.mock('./io', () => ({
|
|
49
50
|
checkIsDirectory() {},
|
|
50
51
|
getHash() {},
|
|
51
52
|
readJson(dir) {
|
package/src/common/info.test.ts
CHANGED
package/src/common/io.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import rimraf from 'rimraf';
|
|
2
2
|
import { transpileModule, ModuleKind, ModuleResolutionKind, ScriptTarget, JsxEmit } from 'typescript';
|
|
3
3
|
import { join, resolve, basename, dirname, extname } from 'path';
|
|
4
4
|
import { exists, lstat, unlink, statSync } from 'fs';
|
package/src/common/merge.test.ts
CHANGED
package/src/common/npm.test.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
1
2
|
import { resolve } from 'path';
|
|
2
|
-
import { clients } from '
|
|
3
|
+
import { clients } from '../npm-clients';
|
|
3
4
|
import {
|
|
4
5
|
dissectPackageName,
|
|
5
6
|
installNpmPackage,
|
|
@@ -24,10 +25,10 @@ import {
|
|
|
24
25
|
findPackageRoot,
|
|
25
26
|
} from './npm';
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
vitest.mock('child_process');
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
...
|
|
30
|
+
vitest.mock('../external', async () => ({
|
|
31
|
+
...((await vitest.importActual('../external')) as any),
|
|
31
32
|
rc() {},
|
|
32
33
|
ora() {
|
|
33
34
|
return {
|
|
@@ -58,7 +59,7 @@ let wrongCase = false;
|
|
|
58
59
|
const jsonValueString = JSON.stringify([{ name: 'npm' }]);
|
|
59
60
|
const jsonValueStringWrong = JSON.stringify([]);
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
vitest.mock('./scripts', () => ({
|
|
62
63
|
runCommand: (exe: string, args: Array<string>, cwd: string, output?: NodeJS.WritableStream) => {
|
|
63
64
|
return new Promise<void>((resolve) => {
|
|
64
65
|
output?.write(wrongCase ? jsonValueStringWrong : jsonValueString, () => {});
|
|
@@ -67,29 +68,34 @@ jest.mock('./scripts', () => ({
|
|
|
67
68
|
},
|
|
68
69
|
}));
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
71
|
+
vitest.mock('fs', async () => {
|
|
72
|
+
const fs = (await vitest.importActual('fs')) as any;
|
|
73
|
+
return {
|
|
74
|
+
...fs,
|
|
75
|
+
exists: (file: string, cb: (status: boolean) => void) =>
|
|
76
|
+
cb(
|
|
77
|
+
shouldFind &&
|
|
78
|
+
!file.endsWith('package.json') &&
|
|
79
|
+
!(specialCase && (file.endsWith('lerna.json') || file.endsWith('yarn.lock'))),
|
|
80
|
+
),
|
|
81
|
+
existsSync: (file: string) => {
|
|
82
|
+
return true;
|
|
83
|
+
},
|
|
84
|
+
readFile: (
|
|
85
|
+
file: string,
|
|
86
|
+
type: string,
|
|
87
|
+
callback: (err: NodeJS.ErrnoException | undefined, data: string) => void,
|
|
88
|
+
) => {
|
|
89
|
+
if (fs.existsSync(file)) {
|
|
90
|
+
return fs.readFile(file, type, callback);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return callback(undefined, '');
|
|
94
|
+
},
|
|
95
|
+
realpathSync: () => ({}),
|
|
96
|
+
readFileSync: () => '',
|
|
97
|
+
};
|
|
98
|
+
});
|
|
93
99
|
|
|
94
100
|
describe('npm Module', () => {
|
|
95
101
|
it('findPackageRoot correctly resolves the package root of parcel-bundler', () => {
|
|
@@ -488,15 +494,7 @@ describe('npm Module', () => {
|
|
|
488
494
|
|
|
489
495
|
it('makeExternals with externals concats coreExternals', async () => {
|
|
490
496
|
const externals = await makeExternals(process.cwd(), { piral: '*' }, ['foo', 'bar']);
|
|
491
|
-
expect(externals).toEqual([
|
|
492
|
-
'foo',
|
|
493
|
-
'bar',
|
|
494
|
-
'react',
|
|
495
|
-
'react-dom',
|
|
496
|
-
'react-router',
|
|
497
|
-
'react-router-dom',
|
|
498
|
-
'tslib',
|
|
499
|
-
]);
|
|
497
|
+
expect(externals).toEqual(['foo', 'bar', 'react', 'react-dom', 'react-router', 'react-router-dom', 'tslib']);
|
|
500
498
|
});
|
|
501
499
|
|
|
502
500
|
it('makeExternals with external duplicate only reflects coreExternals', async () => {
|
package/src/common/npm.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { resolve, relative, dirname } from 'path';
|
|
2
2
|
import { createReadStream, existsSync } from 'fs';
|
|
3
3
|
import { log, fail } from './log';
|
|
4
|
-
import { clients, detectClients, isWrapperClient } from './clients';
|
|
5
4
|
import { config } from './config';
|
|
6
5
|
import { legacyCoreExternals, frameworkLibs, defaultRegistry, packageJson } from './constants';
|
|
7
6
|
import { inspectPackage } from './inspect';
|
|
8
7
|
import { readJson, checkExists } from './io';
|
|
8
|
+
import { clients, detectClients, isWrapperClient } from '../npm-clients';
|
|
9
9
|
import { clientTypeKeys } from '../helpers';
|
|
10
10
|
import { getModulePath } from '../external';
|
|
11
11
|
import { PackageType, NpmClientType } from '../types';
|
package/src/common/pack.test.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
1
2
|
import { createPiletPackage } from './pack';
|
|
2
3
|
import { resolve } from 'path';
|
|
3
4
|
|
|
4
5
|
let json: any = {};
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
readJson:
|
|
8
|
-
removeDirectory:
|
|
9
|
-
checkIsDirectory:
|
|
10
|
-
makeTempDir:
|
|
11
|
-
copy:
|
|
12
|
-
checkExists:
|
|
13
|
-
createDirectory:
|
|
7
|
+
vitest.mock('./io', () => ({
|
|
8
|
+
readJson: vitest.fn(() => json),
|
|
9
|
+
removeDirectory: vitest.fn(() => Promise.resolve()),
|
|
10
|
+
checkIsDirectory: vitest.fn(() => false),
|
|
11
|
+
makeTempDir: vitest.fn(() => Promise.resolve('')),
|
|
12
|
+
copy: vitest.fn(() => Promise.resolve()),
|
|
13
|
+
checkExists: vitest.fn(() => Promise.resolve(true)),
|
|
14
|
+
createDirectory: vitest.fn(() => Promise.resolve()),
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
createTgz:
|
|
17
|
+
vitest.mock('./archive', () => ({
|
|
18
|
+
createTgz: vitest.fn(() => Promise.resolve()),
|
|
18
19
|
}));
|
|
19
20
|
|
|
20
21
|
describe('Pack Module', () => {
|