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,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,11 +8,28 @@ function createTempDir() {
|
|
|
7
8
|
return mkdtempSync(join(tmpdir(), 'piral-tests-new-pilet-'));
|
|
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,
|
|
16
|
+
installDependencies: (...args) => {
|
|
17
|
+
const [dir] = args;
|
|
18
|
+
const npmrc = resolve(dir, '.npmrc');
|
|
19
|
+
|
|
20
|
+
if (existsSync(npmrc)) {
|
|
21
|
+
const content = readFileSync(npmrc, 'utf8');
|
|
22
|
+
|
|
23
|
+
if (content.startsWith('registry=https://someFakeRegistry.com')) {
|
|
24
|
+
// in case of an invalid entry we fail fast instead of the usual npm timeout
|
|
25
|
+
return new Promise((_, reject) => {
|
|
26
|
+
setTimeout(reject, 1000);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return original.installDependencies(...args);
|
|
32
|
+
},
|
|
15
33
|
installPackage: (...args) => {
|
|
16
34
|
return original.installPackage(
|
|
17
35
|
...args,
|
|
@@ -24,80 +42,106 @@ jest.mock('../common/clients/npm', () => {
|
|
|
24
42
|
};
|
|
25
43
|
});
|
|
26
44
|
|
|
27
|
-
|
|
45
|
+
const testOptions = {
|
|
46
|
+
timeout: 60000,
|
|
47
|
+
};
|
|
28
48
|
|
|
29
49
|
describe('New Pilet Command', () => {
|
|
30
|
-
it(
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
50
|
+
it(
|
|
51
|
+
'scaffolding in an empty directory works',
|
|
52
|
+
async () => {
|
|
53
|
+
const dir = createTempDir();
|
|
54
|
+
await newPilet(dir, {
|
|
55
|
+
install: false,
|
|
56
|
+
source: 'piral@latest',
|
|
57
|
+
registry: 'https://someFakeRegistry.com',
|
|
58
|
+
});
|
|
59
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
60
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
61
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
62
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
63
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeTruthy();
|
|
64
|
+
},
|
|
65
|
+
testOptions,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
it(
|
|
69
|
+
'command will fail when providing invalid registry',
|
|
70
|
+
async () => {
|
|
71
|
+
// Arrange
|
|
72
|
+
const dir = createTempDir();
|
|
73
|
+
const options = {
|
|
74
|
+
install: true,
|
|
75
|
+
source: 'piral@latest',
|
|
76
|
+
registry: 'https://someFakeRegistry.com',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
let error = false;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await newPilet(dir, options);
|
|
83
|
+
} catch {
|
|
84
|
+
error = true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
expect(error).toBeTruthy();
|
|
88
|
+
},
|
|
89
|
+
testOptions,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
it(
|
|
93
|
+
'should scaffold without creating npmrc file',
|
|
94
|
+
async () => {
|
|
95
|
+
const dir = createTempDir();
|
|
96
|
+
await newPilet(dir, {
|
|
97
|
+
install: false,
|
|
98
|
+
source: 'piral@latest',
|
|
99
|
+
});
|
|
100
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
101
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
102
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
103
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
104
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
105
|
+
},
|
|
106
|
+
testOptions,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
it(
|
|
110
|
+
'scaffolding with language JS works',
|
|
111
|
+
async () => {
|
|
112
|
+
const dir = createTempDir();
|
|
113
|
+
await newPilet(dir, {
|
|
114
|
+
language: 'js',
|
|
115
|
+
install: false,
|
|
116
|
+
source: 'piral@latest',
|
|
117
|
+
});
|
|
118
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
119
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
120
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeFalsy();
|
|
121
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeTruthy();
|
|
122
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
123
|
+
},
|
|
124
|
+
testOptions,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
it(
|
|
128
|
+
'should set pilet name if passed as argument',
|
|
129
|
+
async () => {
|
|
130
|
+
const dir = createTempDir();
|
|
131
|
+
await newPilet(dir, {
|
|
132
|
+
install: false,
|
|
133
|
+
source: 'piral@latest',
|
|
134
|
+
name: 'testpiralname',
|
|
135
|
+
});
|
|
136
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
137
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
138
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
139
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
140
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
141
|
+
|
|
142
|
+
const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
|
|
143
|
+
expect(packageContent.name).toBe('testpiralname');
|
|
144
|
+
},
|
|
145
|
+
testOptions,
|
|
146
|
+
);
|
|
103
147
|
});
|
|
@@ -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
|
},
|