piral-cli 1.3.3-beta.6187 → 1.3.3-beta.6201
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/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/importmap.js +3 -3
- package/lib/common/importmap.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 +2 -2
- package/src/apps/build-pilet.test.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/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/importmap.ts +1 -1
- 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,3 +1,4 @@
|
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
1
2
|
import { mkdtempSync, existsSync, readFileSync } from 'fs';
|
|
2
3
|
import { tmpdir } from 'os';
|
|
3
4
|
import { join, resolve } from 'path';
|
|
@@ -7,8 +8,8 @@ function createTempDir() {
|
|
|
7
8
|
return mkdtempSync(join(tmpdir(), 'piral-tests-new-piral-'));
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
const original =
|
|
11
|
+
vitest.mock('../npm-clients/npm', async () => {
|
|
12
|
+
const original: any = await vitest.importActual('../npm-clients/npm');
|
|
12
13
|
|
|
13
14
|
return {
|
|
14
15
|
...original,
|
|
@@ -18,87 +19,109 @@ jest.mock('../common/clients/npm', () => {
|
|
|
18
19
|
};
|
|
19
20
|
});
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
const testOptions = {
|
|
23
|
+
timeout: 60000,
|
|
24
|
+
};
|
|
22
25
|
|
|
23
26
|
describe('New Piral Command', () => {
|
|
24
|
-
it(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
it(
|
|
28
|
+
'scaffolding in an empty directory works',
|
|
29
|
+
async () => {
|
|
30
|
+
const dir = createTempDir();
|
|
31
|
+
await newPiral(dir, { install: false });
|
|
32
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
33
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
34
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
35
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
36
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
37
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
38
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
39
|
+
},
|
|
40
|
+
testOptions,
|
|
41
|
+
);
|
|
35
42
|
|
|
36
|
-
it(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
it(
|
|
44
|
+
'scaffolding with language JS works',
|
|
45
|
+
async () => {
|
|
46
|
+
const dir = createTempDir();
|
|
47
|
+
await newPiral(dir, {
|
|
48
|
+
language: 'js',
|
|
49
|
+
install: false,
|
|
50
|
+
});
|
|
51
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
52
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
53
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeFalsy();
|
|
54
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeTruthy();
|
|
55
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
56
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
57
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
58
|
+
},
|
|
59
|
+
testOptions,
|
|
60
|
+
);
|
|
50
61
|
|
|
51
|
-
it(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
it(
|
|
63
|
+
'scaffolding with custom app name works',
|
|
64
|
+
async () => {
|
|
65
|
+
const dir = createTempDir();
|
|
66
|
+
await newPiral(dir, {
|
|
67
|
+
name: 'test-name',
|
|
68
|
+
install: false,
|
|
69
|
+
});
|
|
57
70
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
72
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
73
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
74
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
75
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
76
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
77
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
65
78
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
|
|
80
|
+
expect(packageContent.name).toBe('test-name');
|
|
81
|
+
},
|
|
82
|
+
testOptions,
|
|
83
|
+
);
|
|
69
84
|
|
|
70
|
-
it(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
it(
|
|
86
|
+
'scaffolding for piral-core works',
|
|
87
|
+
async () => {
|
|
88
|
+
const dir = createTempDir();
|
|
89
|
+
await newPiral(dir, {
|
|
90
|
+
framework: 'piral-core',
|
|
91
|
+
install: false,
|
|
92
|
+
});
|
|
93
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeFalsy();
|
|
94
|
+
expect(existsSync(resolve(dir, 'node_modules/piral-core/package.json'))).toBeTruthy();
|
|
95
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
96
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
97
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeFalsy();
|
|
98
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
99
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
100
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
101
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
102
|
+
},
|
|
103
|
+
testOptions,
|
|
104
|
+
);
|
|
86
105
|
|
|
87
|
-
it(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
it(
|
|
107
|
+
'scaffolding for piral-base works',
|
|
108
|
+
async () => {
|
|
109
|
+
const dir = createTempDir();
|
|
110
|
+
await newPiral(dir, {
|
|
111
|
+
framework: 'piral-base',
|
|
112
|
+
install: false,
|
|
113
|
+
});
|
|
114
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeFalsy();
|
|
115
|
+
expect(existsSync(resolve(dir, 'node_modules/piral-core/package.json'))).toBeFalsy();
|
|
116
|
+
expect(existsSync(resolve(dir, 'node_modules/piral-base/package.json'))).toBeTruthy();
|
|
117
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
118
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
119
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeFalsy();
|
|
120
|
+
expect(existsSync(resolve(dir, 'src/index.ts'))).toBeTruthy();
|
|
121
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
122
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
123
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
124
|
+
},
|
|
125
|
+
testOptions,
|
|
126
|
+
);
|
|
104
127
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
1
2
|
import { mkdtempSync, existsSync, writeFileSync } from 'fs';
|
|
2
3
|
import { tmpdir } from 'os';
|
|
3
4
|
import { join, resolve } from 'path';
|
|
@@ -40,11 +41,9 @@ describe('Pack Pilet Command', () => {
|
|
|
40
41
|
}),
|
|
41
42
|
'utf8',
|
|
42
43
|
);
|
|
43
|
-
process.chdir(dir);
|
|
44
44
|
|
|
45
|
-
await packPilet();
|
|
45
|
+
await packPilet(dir);
|
|
46
46
|
|
|
47
|
-
process.chdir(originalDir);
|
|
48
47
|
expect(existsSync(resolve(dir, 'my-pilet-1.0.0.tgz'))).toBeTruthy();
|
|
49
48
|
});
|
|
50
49
|
|
package/src/bundler.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
1
2
|
import {
|
|
2
3
|
setBundler,
|
|
3
4
|
callPiletBuild,
|
|
@@ -13,20 +14,20 @@ const defaults = {
|
|
|
13
14
|
bundler: false,
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
callDynamic:
|
|
17
|
+
vitest.mock('./build/bundler-calls.ts', () => ({
|
|
18
|
+
callDynamic: vitest.fn(() =>
|
|
18
19
|
Promise.resolve({
|
|
19
20
|
bundle: {},
|
|
20
21
|
}),
|
|
21
22
|
),
|
|
22
|
-
callStatic:
|
|
23
|
+
callStatic: vitest.fn(() =>
|
|
23
24
|
Promise.resolve({
|
|
24
25
|
bundle: {},
|
|
25
26
|
}),
|
|
26
27
|
),
|
|
27
28
|
}));
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
vitest.mock('./inject', () => ({
|
|
30
31
|
inject() {
|
|
31
32
|
if (defaults.bundler) {
|
|
32
33
|
setBundler({
|
|
@@ -43,7 +44,7 @@ jest.mock('./inject', () => ({
|
|
|
43
44
|
},
|
|
44
45
|
}));
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
vitest.mock('./common', () => ({
|
|
47
48
|
config: {
|
|
48
49
|
bundler: 'parcel',
|
|
49
50
|
},
|
|
@@ -51,7 +52,7 @@ jest.mock('./common', () => ({
|
|
|
51
52
|
return Promise.resolve(defval);
|
|
52
53
|
},
|
|
53
54
|
compatVersion: '1',
|
|
54
|
-
installNpmPackage:
|
|
55
|
+
installNpmPackage: vitest.fn(),
|
|
55
56
|
fail(msg) {
|
|
56
57
|
throw new Error(msg);
|
|
57
58
|
},
|
|
@@ -60,7 +61,7 @@ jest.mock('./common', () => ({
|
|
|
60
61
|
determineNpmClient() {
|
|
61
62
|
return 'npm';
|
|
62
63
|
},
|
|
63
|
-
patchModules:
|
|
64
|
+
patchModules: vitest.fn(),
|
|
64
65
|
logReset() {},
|
|
65
66
|
}));
|
|
66
67
|
|
package/src/bundler.ts
CHANGED
|
@@ -57,7 +57,8 @@ async function installDefaultBundler(root: string) {
|
|
|
57
57
|
await installNpmPackage(client, packageId, root, '--save-dev', '--save-exact');
|
|
58
58
|
log('generalDebug_0003', `Installed bundler from "${selectedPackage}".`);
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const { inject } = await import('./inject');
|
|
61
|
+
inject(selectedPackage);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
function checkDefaultBundler(bundler: QualifiedBundler) {
|
package/src/cli.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
2
|
+
import { createTarball, unpackTarball } from './archive';
|
|
2
3
|
import { Stream, Readable } from 'stream';
|
|
3
4
|
|
|
4
5
|
class ReadableString extends Readable {
|
|
@@ -32,21 +33,23 @@ interface ExtractOptions {
|
|
|
32
33
|
keep: boolean;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
vitest.mock('path', async () => {
|
|
37
|
+
const original = await vitest.importActual('path') as any;
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
...original,
|
|
38
41
|
relative: (from: string, to: string) => {
|
|
39
42
|
return to;
|
|
40
43
|
},
|
|
41
44
|
resolve: (...pathSegments: string[]) => {
|
|
42
45
|
return pathSegments[1];
|
|
43
46
|
},
|
|
44
|
-
}
|
|
45
|
-
);
|
|
47
|
+
};
|
|
48
|
+
});
|
|
46
49
|
|
|
47
50
|
const fileNotFoundError = 'File not found!';
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
vitest.mock('../external', () => ({
|
|
50
53
|
ora() {
|
|
51
54
|
return {};
|
|
52
55
|
},
|
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/importmap.ts
CHANGED
|
@@ -320,7 +320,7 @@ async function consumeImportmap(
|
|
|
320
320
|
): Promise<Array<SharedDependency>> {
|
|
321
321
|
const importmap = packageDetails.importmap;
|
|
322
322
|
const appShell = inherited && mode === 'remote';
|
|
323
|
-
const availableSpecs = appShell ? packageDetails.devDependencies : {};
|
|
323
|
+
const availableSpecs = appShell ? packageDetails.devDependencies ?? {} : {};
|
|
324
324
|
const inheritanceBehavior = appShell ? 'host' : mode;
|
|
325
325
|
|
|
326
326
|
if (typeof importmap === 'string') {
|
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