piral-cli 1.11.0-beta.fef8836 → 1.11.1-beta.220bc90
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/common/emulator.js +2 -1
- package/lib/common/emulator.js.map +1 -1
- package/package.json +2 -2
- package/src/apps/build-piral.test.ts +141 -169
- package/src/apps/new-pilet.test.ts +77 -97
- package/src/apps/new-piral.test.ts +74 -94
- package/src/common/emulator.ts +30 -20
- package/src/common/package.test.ts +85 -121
package/lib/common/emulator.js
CHANGED
|
@@ -29,6 +29,7 @@ async function makeExternals(sourceDir, piralPkg, externals) {
|
|
|
29
29
|
const externalPackages = await Promise.all(externals
|
|
30
30
|
.filter((ext) => ext.type === 'local' && (0, package_1.isValidDependency)(ext.name))
|
|
31
31
|
.map(async (external) => ({
|
|
32
|
+
id: external.requireId,
|
|
32
33
|
name: external.name,
|
|
33
34
|
version: await (0, package_1.findDependencyVersion)(piralPkg, sourceDir, external),
|
|
34
35
|
optional: external.isAsync,
|
|
@@ -40,7 +41,7 @@ async function makeExternals(sourceDir, piralPkg, externals) {
|
|
|
40
41
|
return deps;
|
|
41
42
|
}, {});
|
|
42
43
|
const importmapEntries = externalPackages.reduce((deps, dep) => {
|
|
43
|
-
deps[dep.
|
|
44
|
+
deps[dep.id] = dep.name;
|
|
44
45
|
return deps;
|
|
45
46
|
}, {});
|
|
46
47
|
const optionalDependencies = externalPackages.reduce((deps, dep) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/common/emulator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/common/emulator.ts"],"names":[],"mappings":";;AAuGA,sDAqFC;AAED,sDAmEC;AAED,0CAcC;AAjRD,+BAAgE;AAChE,uCAA6G;AAC7G,yCAA6D;AAC7D,2CAA2F;AAC3F,iCAAoC;AACpC,+BAAyC;AACzC,+CAAuD;A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"1.11.1-beta.220bc90",
|
|
4
4
|
"description": "The standard CLI for creating and building a Piral instance or a Pilet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"open": "^10",
|
|
79
79
|
"typescript": "^5"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "220bc902cdf09a8debd69e4d0beda078315d6a76"
|
|
82
82
|
}
|
|
@@ -154,173 +154,145 @@ describe('Build Piral Command', () => {
|
|
|
154
154
|
expect(error).toBeTruthy();
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
-
it(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
it(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
it(
|
|
301
|
-
'can create all builds with files',
|
|
302
|
-
async () => {
|
|
303
|
-
const dir = scaffoldNewPiralInstance([
|
|
304
|
-
'foo.txt',
|
|
305
|
-
{
|
|
306
|
-
from: 'src/bar.txt',
|
|
307
|
-
to: 'bar.txt',
|
|
308
|
-
},
|
|
309
|
-
]);
|
|
310
|
-
writeFileSync(resolve(dir, 'foo.txt'), 'foo!', 'utf8');
|
|
311
|
-
writeFileSync(resolve(dir, 'src/bar.txt'), 'bar!', 'utf8');
|
|
312
|
-
let error = false;
|
|
313
|
-
|
|
314
|
-
try {
|
|
315
|
-
await buildPiral(dir);
|
|
316
|
-
} catch {
|
|
317
|
-
error = true;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
expect(error).toBeFalsy();
|
|
321
|
-
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeTruthy();
|
|
322
|
-
expect(existsSync(resolve(dir, 'dist/release'))).toBeTruthy();
|
|
323
|
-
},
|
|
324
|
-
testOptions,
|
|
325
|
-
);
|
|
157
|
+
it('can create an emulator build without files in default subdir', testOptions, async () => {
|
|
158
|
+
const dir = scaffoldNewPiralInstance();
|
|
159
|
+
let error = false;
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
await buildPiral(dir, {
|
|
163
|
+
type: 'emulator',
|
|
164
|
+
});
|
|
165
|
+
} catch (err) {
|
|
166
|
+
console.log(err);
|
|
167
|
+
error = true;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
expect(error).toBeFalsy();
|
|
171
|
+
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeTruthy();
|
|
172
|
+
expect(existsSync(resolve(dir, 'dist/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
173
|
+
expect(existsSync(resolve(dir, 'dist/release'))).toBeFalsy();
|
|
174
|
+
expect(existsSync(resolve(dir, 'dist/index.html'))).toBeFalsy();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('can create an emulator build without files in explicit subdir', testOptions, async () => {
|
|
178
|
+
const dir = scaffoldNewPiralInstance();
|
|
179
|
+
let error = false;
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
await buildPiral(dir, {
|
|
183
|
+
type: 'emulator',
|
|
184
|
+
subdir: true,
|
|
185
|
+
});
|
|
186
|
+
} catch {
|
|
187
|
+
error = true;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
expect(error).toBeFalsy();
|
|
191
|
+
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeTruthy();
|
|
192
|
+
expect(existsSync(resolve(dir, 'dist/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
193
|
+
expect(existsSync(resolve(dir, 'dist/release'))).toBeFalsy();
|
|
194
|
+
expect(existsSync(resolve(dir, 'dist/index.html'))).toBeFalsy();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('can create an emulator build without files in no subdir', testOptions, async () => {
|
|
198
|
+
const dir = scaffoldNewPiralInstance();
|
|
199
|
+
let error = false;
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
await buildPiral(dir, {
|
|
203
|
+
type: 'emulator',
|
|
204
|
+
subdir: false,
|
|
205
|
+
});
|
|
206
|
+
} catch {
|
|
207
|
+
error = true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
expect(error).toBeFalsy();
|
|
211
|
+
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
212
|
+
expect(existsSync(resolve(dir, 'dist/piral-local-test-1.0.0.tgz'))).toBeTruthy();
|
|
213
|
+
expect(existsSync(resolve(dir, 'dist/release'))).toBeFalsy();
|
|
214
|
+
expect(existsSync(resolve(dir, 'dist/index.html'))).toBeFalsy();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('can create a release build in implicit subdir', testOptions, async () => {
|
|
218
|
+
const dir = scaffoldNewPiralInstance();
|
|
219
|
+
let error = false;
|
|
220
|
+
|
|
221
|
+
try {
|
|
222
|
+
await buildPiral(dir, {
|
|
223
|
+
type: 'release',
|
|
224
|
+
});
|
|
225
|
+
} catch {
|
|
226
|
+
error = true;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
expect(error).toBeFalsy();
|
|
230
|
+
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
231
|
+
expect(existsSync(resolve(dir, 'dist/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
232
|
+
expect(existsSync(resolve(dir, 'dist/release/index.html'))).toBeTruthy();
|
|
233
|
+
expect(existsSync(resolve(dir, 'dist/index.html'))).toBeFalsy();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('can create a release build in explicit subdir', testOptions, async () => {
|
|
237
|
+
const dir = scaffoldNewPiralInstance();
|
|
238
|
+
let error = false;
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
await buildPiral(dir, {
|
|
242
|
+
type: 'release',
|
|
243
|
+
subdir: true,
|
|
244
|
+
});
|
|
245
|
+
} catch {
|
|
246
|
+
error = true;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
expect(error).toBeFalsy();
|
|
250
|
+
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
251
|
+
expect(existsSync(resolve(dir, 'dist/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
252
|
+
expect(existsSync(resolve(dir, 'dist/release/index.html'))).toBeTruthy();
|
|
253
|
+
expect(existsSync(resolve(dir, 'dist/index.html'))).toBeFalsy();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('can create a release build in no subdir', testOptions, async () => {
|
|
257
|
+
const dir = scaffoldNewPiralInstance();
|
|
258
|
+
let error = false;
|
|
259
|
+
|
|
260
|
+
try {
|
|
261
|
+
await buildPiral(dir, {
|
|
262
|
+
type: 'release',
|
|
263
|
+
subdir: false,
|
|
264
|
+
});
|
|
265
|
+
} catch {
|
|
266
|
+
error = true;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
expect(error).toBeFalsy();
|
|
270
|
+
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
271
|
+
expect(existsSync(resolve(dir, 'dist/piral-local-test-1.0.0.tgz'))).toBeFalsy();
|
|
272
|
+
expect(existsSync(resolve(dir, 'dist/release/index.html'))).toBeFalsy();
|
|
273
|
+
expect(existsSync(resolve(dir, 'dist/index.html'))).toBeTruthy();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('can create all builds with files', testOptions, async () => {
|
|
277
|
+
const dir = scaffoldNewPiralInstance([
|
|
278
|
+
'foo.txt',
|
|
279
|
+
{
|
|
280
|
+
from: 'src/bar.txt',
|
|
281
|
+
to: 'bar.txt',
|
|
282
|
+
},
|
|
283
|
+
]);
|
|
284
|
+
writeFileSync(resolve(dir, 'foo.txt'), 'foo!', 'utf8');
|
|
285
|
+
writeFileSync(resolve(dir, 'src/bar.txt'), 'bar!', 'utf8');
|
|
286
|
+
let error = false;
|
|
287
|
+
|
|
288
|
+
try {
|
|
289
|
+
await buildPiral(dir);
|
|
290
|
+
} catch {
|
|
291
|
+
error = true;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
expect(error).toBeFalsy();
|
|
295
|
+
expect(existsSync(resolve(dir, 'dist/emulator/piral-local-test-1.0.0.tgz'))).toBeTruthy();
|
|
296
|
+
expect(existsSync(resolve(dir, 'dist/release'))).toBeTruthy();
|
|
297
|
+
});
|
|
326
298
|
});
|
|
@@ -47,101 +47,81 @@ const testOptions = {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
describe('New Pilet Command', () => {
|
|
50
|
-
it(
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
);
|
|
50
|
+
it('scaffolding in an empty directory works', testOptions, async () => {
|
|
51
|
+
const dir = createTempDir();
|
|
52
|
+
await newPilet(dir, {
|
|
53
|
+
install: false,
|
|
54
|
+
source: 'piral@latest',
|
|
55
|
+
registry: 'https://someFakeRegistry.com',
|
|
56
|
+
});
|
|
57
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
58
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
59
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
60
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
61
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeTruthy();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('command will fail when providing invalid registry', testOptions, async () => {
|
|
65
|
+
// Arrange
|
|
66
|
+
const dir = createTempDir();
|
|
67
|
+
const options = {
|
|
68
|
+
install: true,
|
|
69
|
+
source: 'piral@latest',
|
|
70
|
+
registry: 'https://someFakeRegistry.com',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
let error = false;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
await newPilet(dir, options);
|
|
77
|
+
} catch {
|
|
78
|
+
error = true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
expect(error).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should scaffold without creating npmrc file', testOptions, async () => {
|
|
85
|
+
const dir = createTempDir();
|
|
86
|
+
await newPilet(dir, {
|
|
87
|
+
install: false,
|
|
88
|
+
source: 'piral@latest',
|
|
89
|
+
});
|
|
90
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
91
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
92
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
93
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
94
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('scaffolding with language JS works', testOptions, async () => {
|
|
98
|
+
const dir = createTempDir();
|
|
99
|
+
await newPilet(dir, {
|
|
100
|
+
language: 'js',
|
|
101
|
+
install: false,
|
|
102
|
+
source: 'piral@latest',
|
|
103
|
+
});
|
|
104
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
105
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
106
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeFalsy();
|
|
107
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeTruthy();
|
|
108
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should set pilet name if passed as argument', testOptions, async () => {
|
|
112
|
+
const dir = createTempDir();
|
|
113
|
+
await newPilet(dir, {
|
|
114
|
+
install: false,
|
|
115
|
+
source: 'piral@latest',
|
|
116
|
+
name: 'testpiralname',
|
|
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'))).toBeTruthy();
|
|
121
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
122
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
123
|
+
|
|
124
|
+
const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
|
|
125
|
+
expect(packageContent.name).toBe('testpiralname');
|
|
126
|
+
});
|
|
147
127
|
});
|
|
@@ -24,104 +24,84 @@ const testOptions = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
describe('New Piral Command', () => {
|
|
27
|
-
it(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
39
|
-
},
|
|
40
|
-
testOptions,
|
|
41
|
-
);
|
|
27
|
+
it('scaffolding in an empty directory works', testOptions, async () => {
|
|
28
|
+
const dir = createTempDir();
|
|
29
|
+
await newPiral(dir, { install: false });
|
|
30
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
31
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
32
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
33
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
34
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
35
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
36
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
37
|
+
});
|
|
42
38
|
|
|
43
|
-
it(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
58
|
-
},
|
|
59
|
-
testOptions,
|
|
60
|
-
);
|
|
39
|
+
it('scaffolding with language JS works', testOptions, async () => {
|
|
40
|
+
const dir = createTempDir();
|
|
41
|
+
await newPiral(dir, {
|
|
42
|
+
language: 'js',
|
|
43
|
+
install: false,
|
|
44
|
+
});
|
|
45
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
46
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
47
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeFalsy();
|
|
48
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeTruthy();
|
|
49
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
50
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
51
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
52
|
+
});
|
|
61
53
|
|
|
62
|
-
it(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
install: false,
|
|
69
|
-
});
|
|
54
|
+
it('scaffolding with custom app name works', testOptions, async () => {
|
|
55
|
+
const dir = createTempDir();
|
|
56
|
+
await newPiral(dir, {
|
|
57
|
+
name: 'test-name',
|
|
58
|
+
install: false,
|
|
59
|
+
});
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
62
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
63
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
64
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
65
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
66
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
67
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
78
68
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
testOptions,
|
|
83
|
-
);
|
|
69
|
+
const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
|
|
70
|
+
expect(packageContent.name).toBe('test-name');
|
|
71
|
+
});
|
|
84
72
|
|
|
85
|
-
it(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
102
|
-
},
|
|
103
|
-
testOptions,
|
|
104
|
-
);
|
|
73
|
+
it('scaffolding for piral-core works', testOptions, async () => {
|
|
74
|
+
const dir = createTempDir();
|
|
75
|
+
await newPiral(dir, {
|
|
76
|
+
framework: 'piral-core',
|
|
77
|
+
install: false,
|
|
78
|
+
});
|
|
79
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeFalsy();
|
|
80
|
+
expect(existsSync(resolve(dir, 'node_modules/piral-core/package.json'))).toBeTruthy();
|
|
81
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
82
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
83
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeFalsy();
|
|
84
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
85
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
86
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
87
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
88
|
+
});
|
|
105
89
|
|
|
106
|
-
it(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
124
|
-
},
|
|
125
|
-
testOptions,
|
|
126
|
-
);
|
|
90
|
+
it('scaffolding for piral-base works', testOptions, async () => {
|
|
91
|
+
const dir = createTempDir();
|
|
92
|
+
await newPiral(dir, {
|
|
93
|
+
framework: 'piral-base',
|
|
94
|
+
install: false,
|
|
95
|
+
});
|
|
96
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeFalsy();
|
|
97
|
+
expect(existsSync(resolve(dir, 'node_modules/piral-core/package.json'))).toBeFalsy();
|
|
98
|
+
expect(existsSync(resolve(dir, 'node_modules/piral-base/package.json'))).toBeTruthy();
|
|
99
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
100
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
101
|
+
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeFalsy();
|
|
102
|
+
expect(existsSync(resolve(dir, 'src/index.ts'))).toBeTruthy();
|
|
103
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
104
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
105
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
106
|
+
});
|
|
127
107
|
});
|
package/src/common/emulator.ts
CHANGED
|
@@ -28,31 +28,41 @@ async function makeExternals(sourceDir: string, piralPkg: any, externals: Array<
|
|
|
28
28
|
externals
|
|
29
29
|
.filter((ext) => ext.type === 'local' && isValidDependency(ext.name))
|
|
30
30
|
.map(async (external) => ({
|
|
31
|
+
id: external.requireId,
|
|
31
32
|
name: external.name,
|
|
32
33
|
version: await findDependencyVersion(piralPkg, sourceDir, external),
|
|
33
34
|
optional: external.isAsync,
|
|
34
35
|
})),
|
|
35
36
|
);
|
|
36
|
-
const externalDependencies = externalPackages.reduce(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
const externalDependencies = externalPackages.reduce(
|
|
38
|
+
(deps, dep) => {
|
|
39
|
+
if (!dep.optional) {
|
|
40
|
+
deps[dep.name] = dep.version;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return deps;
|
|
44
|
+
},
|
|
45
|
+
{} as Record<string, string>,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const importmapEntries = externalPackages.reduce(
|
|
49
|
+
(deps, dep) => {
|
|
50
|
+
deps[dep.id] = dep.name;
|
|
51
|
+
return deps;
|
|
52
|
+
},
|
|
53
|
+
{} as Record<string, string>,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const optionalDependencies = externalPackages.reduce(
|
|
57
|
+
(deps, dep) => {
|
|
58
|
+
if (dep.optional) {
|
|
59
|
+
deps[dep.name] = dep.name;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return deps;
|
|
63
|
+
},
|
|
64
|
+
{} as Record<string, string>,
|
|
65
|
+
);
|
|
56
66
|
|
|
57
67
|
return [externalDependencies, importmapEntries, optionalDependencies] as const;
|
|
58
68
|
}
|
|
@@ -7,141 +7,105 @@ const testOptions = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
describe('CLI package module', () => {
|
|
10
|
-
it(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
expect(version).toBe(cliVersion);
|
|
15
|
-
},
|
|
16
|
-
testOptions,
|
|
17
|
-
);
|
|
10
|
+
it('findPackageVersion finds the current package version', testOptions, async () => {
|
|
11
|
+
const version = await findPackageVersion(process.cwd(), 'sample-piral');
|
|
12
|
+
expect(version).toBe(cliVersion);
|
|
13
|
+
});
|
|
18
14
|
|
|
19
|
-
it(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
expect(version).toBe('latest');
|
|
24
|
-
},
|
|
25
|
-
testOptions,
|
|
26
|
-
);
|
|
15
|
+
it('findPackageVersion falls back to latest', testOptions, async () => {
|
|
16
|
+
const version = await findPackageVersion(process.cwd(), 'foo-bar-not-exists');
|
|
17
|
+
expect(version).toBe('latest');
|
|
18
|
+
});
|
|
27
19
|
|
|
28
|
-
it(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
it('getPiletsInfo returns pilets information about provided piralInfo', testOptions, () => {
|
|
21
|
+
const emptyPiletsInfo = {
|
|
22
|
+
files: [],
|
|
23
|
+
template: 'default',
|
|
24
|
+
scripts: {},
|
|
25
|
+
validators: {},
|
|
26
|
+
devDependencies: {},
|
|
27
|
+
preScaffold: '',
|
|
28
|
+
postScaffold: '',
|
|
29
|
+
packageOverrides: {},
|
|
30
|
+
preUpgrade: '',
|
|
31
|
+
postUpgrade: '',
|
|
32
|
+
};
|
|
33
|
+
let result = getPiletsInfo({});
|
|
34
|
+
expect(result).toStrictEqual(emptyPiletsInfo);
|
|
35
|
+
|
|
36
|
+
const piralInfo = {
|
|
37
|
+
pilets: {
|
|
38
|
+
files: ['foo.tgz', 'foo2.tgz'],
|
|
33
39
|
template: 'default',
|
|
34
40
|
scripts: {},
|
|
35
41
|
validators: {},
|
|
36
42
|
devDependencies: {},
|
|
37
43
|
preScaffold: '',
|
|
38
|
-
postScaffold: '',
|
|
39
44
|
packageOverrides: {},
|
|
45
|
+
postScaffold: '',
|
|
40
46
|
preUpgrade: '',
|
|
41
47
|
postUpgrade: '',
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
pilets: {
|
|
48
|
-
files: ['foo.tgz', 'foo2.tgz'],
|
|
49
|
-
template: 'default',
|
|
50
|
-
scripts: {},
|
|
51
|
-
validators: {},
|
|
52
|
-
devDependencies: {},
|
|
53
|
-
preScaffold: '',
|
|
54
|
-
packageOverrides: {},
|
|
55
|
-
postScaffold: '',
|
|
56
|
-
preUpgrade: '',
|
|
57
|
-
postUpgrade: '',
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
result = getPiletsInfo(piralInfo);
|
|
61
|
-
expect(result).toStrictEqual(piralInfo.pilets);
|
|
62
|
-
},
|
|
63
|
-
testOptions,
|
|
64
|
-
);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
result = getPiletsInfo(piralInfo);
|
|
51
|
+
expect(result).toStrictEqual(piralInfo.pilets);
|
|
52
|
+
});
|
|
65
53
|
|
|
66
|
-
it(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
expect(result.devDependencies['piral-cli-webpack']).toEqual('latest');
|
|
76
|
-
},
|
|
77
|
-
testOptions,
|
|
78
|
-
);
|
|
54
|
+
it('getPiralPackage returns piral package with webpack in latest version', testOptions, async () => {
|
|
55
|
+
const result = await getPiralPackage(
|
|
56
|
+
'app',
|
|
57
|
+
{ language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
|
|
58
|
+
'10.0.0',
|
|
59
|
+
'webpack',
|
|
60
|
+
);
|
|
61
|
+
expect(result.devDependencies['piral-cli-webpack']).toEqual('latest');
|
|
62
|
+
});
|
|
79
63
|
|
|
80
|
-
it(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
expect(result.devDependencies['piral-cli-webpack']).toEqual('next');
|
|
90
|
-
},
|
|
91
|
-
testOptions,
|
|
92
|
-
);
|
|
64
|
+
it('getPiralPackage returns piral package with webpack in beta version', testOptions, async () => {
|
|
65
|
+
const result = await getPiralPackage(
|
|
66
|
+
'app',
|
|
67
|
+
{ language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
|
|
68
|
+
'0.15.0-beta.1',
|
|
69
|
+
'webpack',
|
|
70
|
+
);
|
|
71
|
+
expect(result.devDependencies['piral-cli-webpack']).toEqual('next');
|
|
72
|
+
});
|
|
93
73
|
|
|
94
|
-
it(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
expect(result.devDependencies['piral-cli-webpack']).toEqual('canary');
|
|
104
|
-
},
|
|
105
|
-
testOptions,
|
|
106
|
-
);
|
|
74
|
+
it('getPiralPackage returns piral package with webpack in alpha version', testOptions, async () => {
|
|
75
|
+
const result = await getPiralPackage(
|
|
76
|
+
'app',
|
|
77
|
+
{ language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
|
|
78
|
+
'0.15.0-alpha.1',
|
|
79
|
+
'webpack',
|
|
80
|
+
);
|
|
81
|
+
expect(result.devDependencies['piral-cli-webpack']).toEqual('canary');
|
|
82
|
+
});
|
|
107
83
|
|
|
108
|
-
it(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
expect(result.devDependencies['piral-cli-webpack']).toEqual('0.14.0');
|
|
118
|
-
},
|
|
119
|
-
testOptions,
|
|
120
|
-
);
|
|
84
|
+
it('getPiralPackage returns piral package with webpack in existing version', testOptions, async () => {
|
|
85
|
+
const result = await getPiralPackage(
|
|
86
|
+
'app',
|
|
87
|
+
{ language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
|
|
88
|
+
'0.14.0',
|
|
89
|
+
'webpack',
|
|
90
|
+
);
|
|
91
|
+
expect(result.devDependencies['piral-cli-webpack']).toEqual('0.14.0');
|
|
92
|
+
});
|
|
121
93
|
|
|
122
|
-
it(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
expect(result.devDependencies['piral-cli-webpack']).toBeUndefined();
|
|
131
|
-
},
|
|
132
|
-
testOptions,
|
|
133
|
-
);
|
|
94
|
+
it('getPiralPackage returns piral package without bundler', testOptions, async () => {
|
|
95
|
+
const result = await getPiralPackage(
|
|
96
|
+
'app',
|
|
97
|
+
{ language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
|
|
98
|
+
'1.0.0',
|
|
99
|
+
);
|
|
100
|
+
expect(result.devDependencies['piral-cli-webpack']).toBeUndefined();
|
|
101
|
+
});
|
|
134
102
|
|
|
135
|
-
it(
|
|
136
|
-
'
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
);
|
|
144
|
-
},
|
|
145
|
-
testOptions,
|
|
146
|
-
);
|
|
103
|
+
it('retrievePiletData error cases', testOptions, async () => {
|
|
104
|
+
await expect(retrievePiletData('foo', 'bar')).rejects.toThrow(
|
|
105
|
+
'[0010] The defined Piral instance ("bar") could not be found.',
|
|
106
|
+
);
|
|
107
|
+
await expect(retrievePiletData('/foo', 'sample-piral')).rejects.toThrow(
|
|
108
|
+
'[0075] Cannot find the "package.json". You need a valid package.json for your pilet.',
|
|
109
|
+
);
|
|
110
|
+
});
|
|
147
111
|
});
|