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.
Files changed (99) hide show
  1. package/lib/apps/build-pilet.js +1 -1
  2. package/lib/apps/build-pilet.js.map +1 -1
  3. package/lib/bundler.js +25 -1
  4. package/lib/bundler.js.map +1 -1
  5. package/lib/cli.js +5 -2
  6. package/lib/cli.js.map +1 -1
  7. package/lib/commands.js +24 -1
  8. package/lib/commands.js.map +1 -1
  9. package/lib/common/declaration.d.ts +1 -1
  10. package/lib/common/declaration.js +43 -18
  11. package/lib/common/declaration.js.map +1 -1
  12. package/lib/common/io.js +5 -2
  13. package/lib/common/io.js.map +1 -1
  14. package/lib/common/log.js +24 -1
  15. package/lib/common/log.js.map +1 -1
  16. package/lib/common/npm.js +13 -13
  17. package/lib/common/npm.js.map +1 -1
  18. package/lib/external/index.js +426 -230
  19. package/lib/inject.js +24 -1
  20. package/lib/inject.js.map +1 -1
  21. package/lib/{common/clients → npm-clients}/bun.js +5 -5
  22. package/lib/npm-clients/bun.js.map +1 -0
  23. package/lib/{common/clients → npm-clients}/index.js +31 -8
  24. package/lib/npm-clients/index.js.map +1 -0
  25. package/lib/{common/clients → npm-clients}/lerna.js +4 -4
  26. package/lib/npm-clients/lerna.js.map +1 -0
  27. package/lib/{common/clients → npm-clients}/npm.js +4 -4
  28. package/lib/npm-clients/npm.js.map +1 -0
  29. package/lib/{common/clients → npm-clients}/pnp.js +4 -4
  30. package/lib/npm-clients/pnp.js.map +1 -0
  31. package/lib/{common/clients → npm-clients}/pnpm.js +4 -4
  32. package/lib/npm-clients/pnpm.js.map +1 -0
  33. package/lib/{common/clients → npm-clients}/rush.js +5 -5
  34. package/lib/npm-clients/rush.js.map +1 -0
  35. package/lib/{common/clients → npm-clients}/yarn.js +4 -4
  36. package/lib/npm-clients/yarn.js.map +1 -0
  37. package/package.json +3 -3
  38. package/src/apps/build-pilet.test.ts +1 -0
  39. package/src/apps/build-pilet.ts +1 -0
  40. package/src/apps/build-piral.test.ts +19 -12
  41. package/src/apps/new-pilet.test.ts +120 -76
  42. package/src/apps/new-piral.test.ts +100 -77
  43. package/src/apps/pack-pilet.test.ts +2 -3
  44. package/src/apps/upgrade-pilet.test.ts +1 -0
  45. package/src/bundler.test.ts +8 -7
  46. package/src/bundler.ts +2 -1
  47. package/src/cli.ts +1 -1
  48. package/src/common/archive.test.ts +10 -7
  49. package/src/common/browser.test.ts +2 -1
  50. package/src/common/compatibility.test.ts +1 -0
  51. package/src/common/declaration.ts +49 -20
  52. package/src/common/envs.test.ts +2 -1
  53. package/src/common/hash.test.ts +1 -0
  54. package/src/common/http.test.ts +73 -70
  55. package/src/common/importmap.test.ts +3 -2
  56. package/src/common/info.test.ts +1 -0
  57. package/src/common/interactive.test.ts +2 -1
  58. package/src/common/io.ts +1 -1
  59. package/src/common/merge.test.ts +1 -0
  60. package/src/common/npm.test.ts +35 -37
  61. package/src/common/npm.ts +1 -1
  62. package/src/common/pack.test.ts +11 -10
  63. package/src/common/package.test.ts +131 -92
  64. package/src/common/parallel.test.ts +1 -0
  65. package/src/common/patches.test.ts +1 -0
  66. package/src/common/port.test.ts +2 -1
  67. package/src/common/rules.test.ts +4 -3
  68. package/src/common/url.test.ts +1 -0
  69. package/src/common/utils.test.ts +1 -0
  70. package/src/common/version.test.ts +1 -0
  71. package/src/external/index.test.ts +1 -0
  72. package/src/helpers.test.ts +1 -0
  73. package/src/injectors/pilet-injector.test.ts +6 -5
  74. package/src/injectors/piral-injector.test.ts +7 -6
  75. package/src/{common/clients → npm-clients}/bun.ts +5 -5
  76. package/src/{common/clients → npm-clients}/index.ts +1 -1
  77. package/src/{common/clients → npm-clients}/lerna.ts +4 -4
  78. package/src/{common/clients → npm-clients}/npm.ts +4 -4
  79. package/src/{common/clients → npm-clients}/pnp.ts +4 -4
  80. package/src/{common/clients → npm-clients}/pnpm.ts +4 -4
  81. package/src/{common/clients → npm-clients}/rush.ts +5 -5
  82. package/src/{common/clients → npm-clients}/yarn.ts +4 -4
  83. package/src/rules/pilet-has-externals-as-peers.test.ts +4 -3
  84. package/lib/common/clients/bun.js.map +0 -1
  85. package/lib/common/clients/index.js.map +0 -1
  86. package/lib/common/clients/lerna.js.map +0 -1
  87. package/lib/common/clients/npm.js.map +0 -1
  88. package/lib/common/clients/pnp.js.map +0 -1
  89. package/lib/common/clients/pnpm.js.map +0 -1
  90. package/lib/common/clients/rush.js.map +0 -1
  91. package/lib/common/clients/yarn.js.map +0 -1
  92. /package/lib/{common/clients → npm-clients}/bun.d.ts +0 -0
  93. /package/lib/{common/clients → npm-clients}/index.d.ts +0 -0
  94. /package/lib/{common/clients → npm-clients}/lerna.d.ts +0 -0
  95. /package/lib/{common/clients → npm-clients}/npm.d.ts +0 -0
  96. /package/lib/{common/clients → npm-clients}/pnp.d.ts +0 -0
  97. /package/lib/{common/clients → npm-clients}/pnpm.d.ts +0 -0
  98. /package/lib/{common/clients → npm-clients}/rush.d.ts +0 -0
  99. /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
- jest.mock('../common/clients/npm', () => {
11
- const original = jest.requireActual('../common/clients/npm');
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
- jest.setTimeout(90000);
45
+ const testOptions = {
46
+ timeout: 60000,
47
+ };
28
48
 
29
49
  describe('New Pilet Command', () => {
30
- it('scaffolding in an empty directory works', async () => {
31
- const dir = createTempDir();
32
- await newPilet(dir, {
33
- install: false,
34
- source: 'piral@latest',
35
- registry: 'https://someFakeRegistry.com',
36
- });
37
- expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
38
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
39
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
40
- expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
41
- expect(existsSync(resolve(dir, '.npmrc'))).toBeTruthy();
42
- });
43
-
44
- it('command will fail when providing invalid registry', async () => {
45
- // Arrange
46
- const dir = createTempDir();
47
- const options = {
48
- install: true,
49
- source: 'piral@latest',
50
- registry: 'https://someFakeRegistry.com',
51
- };
52
-
53
- // Act
54
- const result = await newPilet(dir, options);
55
-
56
- // Assert
57
- expect(result).toBeUndefined();
58
- });
59
-
60
- it('should scaffold without creating npmrc file', async () => {
61
- const dir = createTempDir();
62
- await newPilet(dir, {
63
- install: false,
64
- source: 'piral@latest',
65
- });
66
- expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
67
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
68
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
69
- expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
70
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
71
- });
72
-
73
- it('scaffolding with language JS works', async () => {
74
- const dir = createTempDir();
75
- await newPilet(dir, {
76
- language: 'js',
77
- install: false,
78
- source: 'piral@latest',
79
- });
80
- expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
81
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
82
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeFalsy();
83
- expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeTruthy();
84
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
85
- });
86
-
87
- it('should set pilet name if passed as argument', async () => {
88
- const dir = createTempDir();
89
- await newPilet(dir, {
90
- install: false,
91
- source: 'piral@latest',
92
- name: 'testpiralname',
93
- });
94
- expect(existsSync(resolve(dir, 'node_modules/piral/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.tsx'))).toBeTruthy();
98
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
99
-
100
- const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
101
- expect(packageContent.name).toBe('testpiralname');
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
- jest.mock('../common/clients/npm', () => {
11
- const original = jest.requireActual('../common/clients/npm');
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
- jest.setTimeout(90000);
22
+ const testOptions = {
23
+ timeout: 60000,
24
+ };
22
25
 
23
26
  describe('New Piral Command', () => {
24
- it('scaffolding in an empty directory works', async () => {
25
- const dir = createTempDir();
26
- await newPiral(dir, { install: false });
27
- expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
28
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
29
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
30
- expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
31
- expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
32
- expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
33
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
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('scaffolding with language JS works', async () => {
37
- const dir = createTempDir();
38
- await newPiral(dir, {
39
- language: 'js',
40
- install: false,
41
- });
42
- expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
43
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
44
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeFalsy();
45
- expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeTruthy();
46
- expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
47
- expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
48
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
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('scaffolding with custom app name works', async () => {
52
- const dir = createTempDir();
53
- await newPiral(dir, {
54
- name: 'test-name',
55
- install: false,
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
- expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
59
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
60
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
61
- expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
62
- expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
63
- expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
64
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
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
- const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
67
- expect(packageContent.name).toBe('test-name');
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('scaffolding for piral-core works', async () => {
71
- const dir = createTempDir();
72
- await newPiral(dir, {
73
- framework: 'piral-core',
74
- install: false,
75
- });
76
- expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeFalsy();
77
- expect(existsSync(resolve(dir, 'node_modules/piral-core/package.json'))).toBeTruthy();
78
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
79
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
80
- expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeFalsy();
81
- expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
82
- expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
83
- expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
84
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
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('scaffolding for piral-base works', async () => {
88
- const dir = createTempDir();
89
- await newPiral(dir, {
90
- framework: 'piral-base',
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'))).toBeFalsy();
95
- expect(existsSync(resolve(dir, 'node_modules/piral-base/package.json'))).toBeTruthy();
96
- expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
97
- expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
98
- expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeFalsy();
99
- expect(existsSync(resolve(dir, 'src/index.ts'))).toBeTruthy();
100
- expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
101
- expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
102
- expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
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
 
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { mkdtempSync } from 'fs';
2
3
  import { tmpdir } from 'os';
3
4
  import { join } from 'path';
@@ -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
- jest.mock('./build/bundler-calls.ts', () => ({
17
- callDynamic: jest.fn(() =>
17
+ vitest.mock('./build/bundler-calls.ts', () => ({
18
+ callDynamic: vitest.fn(() =>
18
19
  Promise.resolve({
19
20
  bundle: {},
20
21
  }),
21
22
  ),
22
- callStatic: jest.fn(() =>
23
+ callStatic: vitest.fn(() =>
23
24
  Promise.resolve({
24
25
  bundle: {},
25
26
  }),
26
27
  ),
27
28
  }));
28
29
 
29
- jest.mock('./inject', () => ({
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
- jest.mock('./common', () => ({
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: jest.fn(),
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: jest.fn(),
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
- require('./inject').inject(selectedPackage);
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,4 @@
1
- import * as yargs from 'yargs';
1
+ import yargs from 'yargs';
2
2
  import { detailed } from 'yargs-parser';
3
3
  import { caterpillerIcon, zapIcon, butterflyIcon, cliName, cliVersion } from './common';
4
4
  import { runQuestionnaireFor } from './questionnaire';
@@ -1,4 +1,5 @@
1
- import { createTarball, unpackTarball, unpackGzTar } from './archive';
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
- jest.mock('path', () =>
36
- // extend the auto mock of path
37
- Object.assign(jest.genMockFromModule('path'), {
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
- jest.mock('../external', () => ({
52
+ vitest.mock('../external', () => ({
50
53
  ora() {
51
54
  return {};
52
55
  },
@@ -1,8 +1,9 @@
1
+ import { describe, it, expect, vitest } from 'vitest';
1
2
  import { openBrowser } from './browser';
2
3
 
3
4
  let error = false;
4
5
 
5
- jest.mock('../external', () => ({
6
+ vitest.mock('../external', () => ({
6
7
  rc(_, cfg) {
7
8
  return cfg;
8
9
  },
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { checkAppShellCompatibility } from './compatibility';
2
3
  import { cliVersion } from './info';
3
4