piral-cli 0.15.0-alpha.4098 → 0.15.0-alpha.4257
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/debug-pilet.js +26 -41
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +18 -33
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/new-pilet.js +5 -9
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.js +9 -3
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/publish-pilet.d.ts +4 -0
- package/lib/apps/publish-pilet.js +4 -3
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.d.ts +4 -0
- package/lib/apps/publish-piral.js +9 -7
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +2 -8
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.js +1 -1
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/bundler.js +1 -1
- package/lib/bundler.js.map +1 -1
- package/lib/commands.js +14 -6
- package/lib/commands.js.map +1 -1
- package/lib/common/browser.d.ts +1 -0
- package/lib/common/browser.js +16 -10
- package/lib/common/browser.js.map +1 -1
- package/lib/common/clients/index.d.ts +19 -0
- package/lib/common/clients/index.js +40 -0
- package/lib/common/clients/index.js.map +1 -0
- package/lib/common/clients/lerna.d.ts +6 -1
- package/lib/common/clients/lerna.js +67 -3
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +4 -1
- package/lib/common/clients/npm.js +37 -16
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.d.ts +4 -0
- package/lib/common/clients/pnpm.js +43 -9
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +6 -0
- package/lib/common/clients/rush.js +118 -0
- package/lib/common/clients/rush.js.map +1 -0
- package/lib/common/clients/yarn.d.ts +4 -0
- package/lib/common/clients/yarn.js +45 -11
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/constants.d.ts +1 -1
- package/lib/common/constants.js +1 -1
- package/lib/common/constants.js.map +1 -1
- package/lib/common/declaration.js +14 -10
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/emulator.js +2 -2
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/http.d.ts +1 -1
- package/lib/common/http.js +12 -7
- package/lib/common/http.js.map +1 -1
- package/lib/common/importmap.js +4 -14
- package/lib/common/importmap.js.map +1 -1
- package/lib/common/info.d.ts +4 -0
- package/lib/common/info.js +6 -1
- package/lib/common/info.js.map +1 -1
- package/lib/common/injectors.d.ts +36 -7
- package/lib/common/injectors.js +39 -11
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/inspect.js +2 -1
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/interactive.d.ts +9 -0
- package/lib/common/interactive.js +31 -1
- package/lib/common/interactive.js.map +1 -1
- package/lib/common/io.js +1 -1
- package/lib/common/io.js.map +1 -1
- package/lib/common/npm.d.ts +11 -16
- package/lib/common/npm.js +165 -158
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +1 -1
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +6 -7
- package/lib/common/package.js +26 -28
- package/lib/common/package.js.map +1 -1
- package/lib/common/scaffold.js +5 -2
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/version.js +4 -4
- package/lib/common/version.js.map +1 -1
- package/lib/external/index.js +1982 -92
- package/lib/helpers.d.ts +4 -4
- package/lib/helpers.js +10 -10
- package/lib/helpers.js.map +1 -1
- package/lib/injectors/{pilet.d.ts → pilet-injector.d.ts} +1 -0
- package/lib/injectors/{pilet.js → pilet-injector.js} +29 -31
- package/lib/injectors/pilet-injector.js.map +1 -0
- package/lib/injectors/{piral.d.ts → piral-injector.d.ts} +1 -0
- package/lib/injectors/{piral.js → piral-injector.js} +20 -22
- package/lib/injectors/piral-injector.js.map +1 -0
- package/lib/messages.d.ts +1 -1
- package/lib/messages.js +5 -1
- package/lib/messages.js.map +1 -1
- package/lib/plugin.js +27 -2
- package/lib/plugin.js.map +1 -1
- package/lib/release.d.ts +1 -1
- package/lib/release.js +7 -2
- package/lib/release.js.map +1 -1
- package/lib/types/common.d.ts +1 -1
- package/lib/types/internal.d.ts +9 -1
- package/lib/types/public.d.ts +2 -2
- package/package.json +6 -4
- package/src/apps/debug-pilet.ts +25 -47
- package/src/apps/debug-piral.ts +19 -36
- package/src/apps/new-pilet.ts +9 -14
- package/src/apps/new-piral.ts +16 -5
- package/src/apps/publish-pilet.ts +10 -3
- package/src/apps/publish-piral.ts +21 -6
- package/src/apps/upgrade-pilet.ts +4 -12
- package/src/apps/upgrade-piral.ts +2 -2
- package/src/bundler.test.ts +1 -1
- package/src/bundler.ts +2 -2
- package/src/commands.ts +17 -9
- package/src/common/browser.ts +12 -8
- package/src/common/clients/index.ts +33 -0
- package/src/common/clients/lerna.ts +61 -1
- package/src/common/clients/npm.ts +32 -15
- package/src/common/clients/pnpm.ts +39 -10
- package/src/common/clients/rush.ts +111 -0
- package/src/common/clients/yarn.ts +41 -12
- package/src/common/constants.ts +1 -1
- package/src/common/declaration.ts +17 -10
- package/src/common/emulator.ts +3 -3
- package/src/common/http.ts +20 -6
- package/src/common/importmap.ts +4 -14
- package/src/common/info.ts +6 -1
- package/src/common/injectors.ts +46 -17
- package/src/common/inspect.ts +2 -1
- package/src/common/interactive.test.ts +3 -0
- package/src/common/interactive.ts +48 -1
- package/src/common/io.ts +1 -1
- package/src/common/npm.test.ts +122 -76
- package/src/common/npm.ts +177 -152
- package/src/common/pack.test.ts +1 -1
- package/src/common/pack.ts +2 -2
- package/src/common/package.test.ts +1 -14
- package/src/common/package.ts +31 -29
- package/src/common/scaffold.ts +6 -2
- package/src/common/version.ts +4 -4
- package/src/external/index.ts +2 -1
- package/src/helpers.test.ts +5 -5
- package/src/helpers.ts +8 -8
- package/src/injectors/{pilet.test.ts → pilet-injector.test.ts} +10 -1
- package/src/injectors/{pilet.ts → pilet-injector.ts} +36 -28
- package/src/injectors/{piral.test.ts → piral-injector.test.ts} +5 -1
- package/src/injectors/{piral.ts → piral-injector.ts} +24 -17
- package/src/messages.ts +6 -2
- package/src/plugin.ts +34 -5
- package/src/release.ts +10 -2
- package/src/types/common.ts +1 -1
- package/src/types/internal.ts +6 -1
- package/src/types/public.ts +2 -2
- package/lib/injectors/pilet.js.map +0 -1
- package/lib/injectors/piral.js.map +0 -1
package/src/apps/debug-pilet.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
retrievePiletsInfo,
|
|
9
9
|
config,
|
|
10
10
|
openBrowser,
|
|
11
|
-
reorderInjectors,
|
|
12
11
|
notifyServerOnline,
|
|
13
12
|
setLogLevel,
|
|
14
13
|
progress,
|
|
@@ -19,6 +18,8 @@ import {
|
|
|
19
18
|
cpuCount,
|
|
20
19
|
concurrentWorkers,
|
|
21
20
|
normalizePublicUrl,
|
|
21
|
+
findFile,
|
|
22
|
+
createInitialKrasConfig,
|
|
22
23
|
} from '../common';
|
|
23
24
|
|
|
24
25
|
export interface DebugPiletOptions {
|
|
@@ -203,7 +204,6 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
203
204
|
|
|
204
205
|
await hooks.onBegin?.({ options, fullBase });
|
|
205
206
|
progress('Reading configuration ...');
|
|
206
|
-
const krasConfig = readKrasConfig({ port }, krasrc);
|
|
207
207
|
const api = `${publicUrl}${config.piletApi.replace(/^\/+/, '')}`;
|
|
208
208
|
const entryList = Array.isArray(entry) ? entry : [entry];
|
|
209
209
|
const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
|
|
@@ -213,10 +213,6 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
213
213
|
const maxListeners = Math.max(2 + allEntries.length * 2, 16);
|
|
214
214
|
log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
|
|
215
215
|
|
|
216
|
-
if (krasConfig.sources === undefined) {
|
|
217
|
-
krasConfig.sources = [];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
216
|
if (allEntries.length === 0) {
|
|
221
217
|
fail('entryFileMissing_0077');
|
|
222
218
|
}
|
|
@@ -234,15 +230,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
234
230
|
const dest = resolve(root, target);
|
|
235
231
|
const outDir = dirname(dest);
|
|
236
232
|
const outFile = basename(dest);
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
if (exists) {
|
|
240
|
-
if (krasConfig.directory === undefined) {
|
|
241
|
-
krasConfig.directory = mocks;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
krasConfig.sources.push(mocks);
|
|
245
|
-
}
|
|
233
|
+
const mocksExists = await checkExistingDirectory(mocks);
|
|
246
234
|
|
|
247
235
|
await hooks.beforeBuild?.({ root, publicUrl, importmap, entryModule, schemaVersion });
|
|
248
236
|
|
|
@@ -278,6 +266,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
278
266
|
externals,
|
|
279
267
|
piral: appPackage.name,
|
|
280
268
|
bundler,
|
|
269
|
+
mocks: mocksExists ? mocks : undefined,
|
|
281
270
|
root,
|
|
282
271
|
};
|
|
283
272
|
});
|
|
@@ -287,43 +276,32 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
287
276
|
|
|
288
277
|
await hooks.beforeApp?.({ appInstanceDir, pilets });
|
|
289
278
|
const appDir = appInstanceDir || (await getOrMakeAppDir(pilets[0], logLevel));
|
|
279
|
+
const appRoot = dirname(await findFile(appDir, 'package.json'));
|
|
290
280
|
await hooks.afterApp?.({ appInstanceDir, pilets });
|
|
291
281
|
|
|
292
282
|
Promise.all(pilets.map((p) => p.bundler.ready())).then(() => logDone(`Ready!`));
|
|
293
283
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
meta: 'debug-meta.json',
|
|
313
|
-
feed,
|
|
314
|
-
...piletInjector,
|
|
315
|
-
active: true,
|
|
316
|
-
pilets,
|
|
317
|
-
app: appDir,
|
|
318
|
-
publicUrl,
|
|
319
|
-
handle: ['/', api],
|
|
320
|
-
api,
|
|
284
|
+
const sources = pilets.map((m) => m.mocks).filter(Boolean);
|
|
285
|
+
const krasBaseConfig = resolve(fullBase, krasrc);
|
|
286
|
+
const krasRootConfig = resolve(appRoot, krasrc);
|
|
287
|
+
const initial = createInitialKrasConfig(sources[0] || resolve(fullBase, 'mocks'), { [api]: '' }, sources, feed);
|
|
288
|
+
const required = {
|
|
289
|
+
injectors: {
|
|
290
|
+
piral: {
|
|
291
|
+
active: false,
|
|
292
|
+
},
|
|
293
|
+
pilet: {
|
|
294
|
+
active: true,
|
|
295
|
+
pilets,
|
|
296
|
+
app: appDir,
|
|
297
|
+
publicUrl,
|
|
298
|
+
handle: ['/', api],
|
|
299
|
+
api,
|
|
300
|
+
},
|
|
301
|
+
},
|
|
321
302
|
};
|
|
322
|
-
|
|
323
|
-
krasConfig
|
|
324
|
-
krasConfig.map[api] = '';
|
|
325
|
-
|
|
326
|
-
krasConfig.injectors = reorderInjectors(injectorName, injectorConfig, otherInjectors);
|
|
303
|
+
const configs = [krasBaseConfig, ...pilets.map((p) => resolve(p.root, krasrc)), krasRootConfig];
|
|
304
|
+
const krasConfig = readKrasConfig({ port, initial, required }, ...configs);
|
|
327
305
|
|
|
328
306
|
log('generalVerbose_0004', `Using kras with configuration: ${JSON.stringify(krasConfig, undefined, 2)}`);
|
|
329
307
|
|
package/src/apps/debug-piral.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, join, resolve } from 'path';
|
|
2
|
-
import { readKrasConfig, krasrc, buildKrasWithCli
|
|
2
|
+
import { readKrasConfig, krasrc, buildKrasWithCli } from 'kras';
|
|
3
3
|
import { callPiralDebug } from '../bundler';
|
|
4
4
|
import { LogLevels } from '../types';
|
|
5
5
|
import {
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
retrievePiralRoot,
|
|
8
8
|
openBrowser,
|
|
9
9
|
checkCliCompatibility,
|
|
10
|
-
reorderInjectors,
|
|
11
10
|
notifyServerOnline,
|
|
12
11
|
setLogLevel,
|
|
13
12
|
progress,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
normalizePublicUrl,
|
|
17
16
|
logDone,
|
|
18
17
|
getDestination,
|
|
18
|
+
createInitialKrasConfig,
|
|
19
19
|
} from '../common';
|
|
20
20
|
|
|
21
21
|
export interface DebugPiralOptions {
|
|
@@ -99,8 +99,6 @@ export const debugPiralDefaults: DebugPiralOptions = {
|
|
|
99
99
|
optimizeModules: false,
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const injectorName = resolve(__dirname, '../injectors/piral.js');
|
|
103
|
-
|
|
104
102
|
export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOptions = {}) {
|
|
105
103
|
const {
|
|
106
104
|
entry = debugPiralDefaults.entry,
|
|
@@ -125,30 +123,9 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
125
123
|
const entryFiles = await retrievePiralRoot(fullBase, entry);
|
|
126
124
|
const { externals, name, root, ignored } = await retrievePiletsInfo(entryFiles);
|
|
127
125
|
const dest = getDestination(entryFiles, resolve(fullBase, target));
|
|
128
|
-
const krasConfig = readKrasConfig({ port }, krasrc);
|
|
129
126
|
|
|
130
127
|
await checkCliCompatibility(root);
|
|
131
128
|
|
|
132
|
-
if (krasConfig.directory === undefined) {
|
|
133
|
-
krasConfig.directory = join(dirname(entryFiles), 'mocks');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (krasConfig.ssl === undefined) {
|
|
137
|
-
krasConfig.ssl = undefined;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (krasConfig.map === undefined) {
|
|
141
|
-
krasConfig.map = {};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (krasConfig.api === undefined) {
|
|
145
|
-
krasConfig.api = '/manage-mock-server';
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (krasConfig.injectors === undefined) {
|
|
149
|
-
krasConfig.injectors = defaultConfig.injectors;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
129
|
await hooks.beforeBuild?.({ root, publicUrl, externals, entryFiles, name });
|
|
153
130
|
|
|
154
131
|
const bundler = await callPiralDebug(
|
|
@@ -174,18 +151,24 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
174
151
|
hooks.afterBuild?.({ ...args, root, publicUrl, externals, entryFiles, name, bundler, ...dest });
|
|
175
152
|
});
|
|
176
153
|
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
154
|
+
const krasBaseConfig = resolve(fullBase, krasrc);
|
|
155
|
+
const krasRootConfig = resolve(root, krasrc);
|
|
156
|
+
const initial = createInitialKrasConfig(join(dirname(entryFiles), 'mocks'));
|
|
157
|
+
const required = {
|
|
158
|
+
injectors: {
|
|
159
|
+
piral: {
|
|
160
|
+
active: true,
|
|
161
|
+
handle: ['/'],
|
|
162
|
+
feed,
|
|
163
|
+
publicUrl,
|
|
164
|
+
bundler,
|
|
165
|
+
},
|
|
166
|
+
pilet: {
|
|
167
|
+
active: false,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
185
170
|
};
|
|
186
|
-
|
|
187
|
-
krasConfig.map['/'] = '';
|
|
188
|
-
krasConfig.injectors = reorderInjectors(injectorName, injectorConfig, otherInjectors);
|
|
171
|
+
const krasConfig = readKrasConfig({ port, initial, required }, krasBaseConfig, krasRootConfig);
|
|
189
172
|
|
|
190
173
|
log('generalVerbose_0004', `Using kras with configuration: ${JSON.stringify(krasConfig, undefined, 2)}`);
|
|
191
174
|
|
package/src/apps/new-pilet.ts
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
SourceLanguage,
|
|
6
6
|
createDirectory,
|
|
7
7
|
createFileIfNotExists,
|
|
8
|
-
|
|
8
|
+
installNpmPackage,
|
|
9
9
|
dissectPackageName,
|
|
10
10
|
copyPiralFiles,
|
|
11
11
|
patchPiletPackage,
|
|
12
12
|
scaffoldPiletSourceFiles,
|
|
13
|
-
|
|
13
|
+
installNpmDependencies,
|
|
14
14
|
combinePackageRef,
|
|
15
15
|
getPackageName,
|
|
16
16
|
getPackageVersion,
|
|
@@ -27,10 +27,9 @@ import {
|
|
|
27
27
|
isLinkedPackage,
|
|
28
28
|
copyScaffoldingFiles,
|
|
29
29
|
getPiralPath,
|
|
30
|
-
detectMonorepo,
|
|
31
|
-
bootstrapMonorepo,
|
|
32
30
|
getPiletScaffoldData,
|
|
33
31
|
config,
|
|
32
|
+
initNpmProject,
|
|
34
33
|
} from '../common';
|
|
35
34
|
|
|
36
35
|
export interface NewPiletOptions {
|
|
@@ -130,6 +129,7 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
|
|
|
130
129
|
|
|
131
130
|
if (success) {
|
|
132
131
|
const npmClient = await determineNpmClient(root, options.npmClient);
|
|
132
|
+
const projectName = basename(root);
|
|
133
133
|
|
|
134
134
|
progress(`Scaffolding new pilet in %s ...`, root);
|
|
135
135
|
|
|
@@ -138,7 +138,7 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
|
|
|
138
138
|
'package.json',
|
|
139
139
|
JSON.stringify(
|
|
140
140
|
{
|
|
141
|
-
name:
|
|
141
|
+
name: projectName,
|
|
142
142
|
version: '1.0.0',
|
|
143
143
|
description: '',
|
|
144
144
|
keywords: ['pilet'],
|
|
@@ -154,6 +154,8 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
|
|
|
154
154
|
),
|
|
155
155
|
);
|
|
156
156
|
|
|
157
|
+
await initNpmProject(npmClient, projectName, root);
|
|
158
|
+
|
|
157
159
|
if (registry !== newPiletDefaults.registry) {
|
|
158
160
|
progress(`Setting up npm registry (%s) ...`, registry);
|
|
159
161
|
|
|
@@ -172,8 +174,7 @@ always-auth=true`,
|
|
|
172
174
|
const packageRef = combinePackageRef(sourceName, sourceVersion, type);
|
|
173
175
|
|
|
174
176
|
progress(`Installing npm package %s ...`, packageRef);
|
|
175
|
-
|
|
176
|
-
await installPackage(npmClient, packageRef, root, '--save-dev', '--save-exact');
|
|
177
|
+
await installNpmPackage(npmClient, packageRef, root, '--save-dev', '--save-exact');
|
|
177
178
|
} else {
|
|
178
179
|
progress(`Using locally available npm package %s ...`, sourceName);
|
|
179
180
|
}
|
|
@@ -215,13 +216,7 @@ always-auth=true`,
|
|
|
215
216
|
|
|
216
217
|
if (install) {
|
|
217
218
|
progress(`Installing dependencies ...`);
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (monorepoKind === 'lerna') {
|
|
221
|
-
await bootstrapMonorepo(root);
|
|
222
|
-
} else {
|
|
223
|
-
await installDependencies(npmClient, root);
|
|
224
|
-
}
|
|
219
|
+
await installNpmDependencies(npmClient, root);
|
|
225
220
|
}
|
|
226
221
|
|
|
227
222
|
if (postScaffold) {
|
package/src/apps/new-piral.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { resolve, basename } from 'path';
|
|
2
|
+
import { frameworkKeys } from '../helpers';
|
|
2
3
|
import { LogLevels, Framework, NpmClientType } from '../types';
|
|
3
4
|
import {
|
|
4
5
|
ForceOverwrite,
|
|
5
6
|
SourceLanguage,
|
|
6
|
-
|
|
7
|
+
installNpmPackage,
|
|
7
8
|
updateExistingJson,
|
|
8
9
|
getPiralPackage,
|
|
9
10
|
scaffoldPiralSourceFiles,
|
|
10
11
|
createDirectory,
|
|
11
12
|
createFileIfNotExists,
|
|
12
13
|
logDone,
|
|
13
|
-
|
|
14
|
+
installNpmDependencies,
|
|
14
15
|
combinePackageRef,
|
|
15
16
|
setLogLevel,
|
|
16
17
|
fail,
|
|
@@ -19,7 +20,9 @@ import {
|
|
|
19
20
|
cliVersion,
|
|
20
21
|
getPiralScaffoldData,
|
|
21
22
|
config,
|
|
23
|
+
initNpmProject,
|
|
22
24
|
} from '../common';
|
|
25
|
+
import { sourceLanguageKeys } from '..';
|
|
23
26
|
|
|
24
27
|
export interface NewPiralOptions {
|
|
25
28
|
/**
|
|
@@ -121,6 +124,11 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
|
|
|
121
124
|
} = options;
|
|
122
125
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
123
126
|
const root = resolve(fullBase, target);
|
|
127
|
+
|
|
128
|
+
if (!frameworkKeys.includes(framework)) {
|
|
129
|
+
fail('generalError_0002', `The "framework" value must be one of: ${frameworkKeys.join(', ')}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
124
132
|
setLogLevel(logLevel);
|
|
125
133
|
progress('Preparing source and target ...');
|
|
126
134
|
const success = await createDirectory(root);
|
|
@@ -128,6 +136,7 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
|
|
|
128
136
|
if (success) {
|
|
129
137
|
const npmClient = await determineNpmClient(root, options.npmClient);
|
|
130
138
|
const packageRef = combinePackageRef(framework, version, 'registry');
|
|
139
|
+
const projectName = basename(root);
|
|
131
140
|
|
|
132
141
|
progress(`Creating a new Piral instance in %s ...`, root);
|
|
133
142
|
|
|
@@ -136,7 +145,7 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
|
|
|
136
145
|
'package.json',
|
|
137
146
|
JSON.stringify(
|
|
138
147
|
{
|
|
139
|
-
name:
|
|
148
|
+
name: projectName,
|
|
140
149
|
version: '1.0.0',
|
|
141
150
|
description: '',
|
|
142
151
|
keywords: ['piral'],
|
|
@@ -148,6 +157,8 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
|
|
|
148
157
|
),
|
|
149
158
|
);
|
|
150
159
|
|
|
160
|
+
await initNpmProject(npmClient, projectName, root);
|
|
161
|
+
|
|
151
162
|
if (registry !== newPiralDefaults.registry) {
|
|
152
163
|
progress(`Setting up npm registry (%s) ...`, registry);
|
|
153
164
|
|
|
@@ -162,7 +173,7 @@ always-auth=true`,
|
|
|
162
173
|
|
|
163
174
|
progress(`Installing npm package ${packageRef} ...`);
|
|
164
175
|
|
|
165
|
-
await
|
|
176
|
+
await installNpmPackage(npmClient, packageRef, root, '--save-exact');
|
|
166
177
|
|
|
167
178
|
progress(`Taking care of templating ...`);
|
|
168
179
|
|
|
@@ -177,7 +188,7 @@ always-auth=true`,
|
|
|
177
188
|
|
|
178
189
|
if (install) {
|
|
179
190
|
progress(`Installing dependencies ...`);
|
|
180
|
-
await
|
|
191
|
+
await installNpmDependencies(npmClient, root);
|
|
181
192
|
}
|
|
182
193
|
|
|
183
194
|
logDone(`Piral instance scaffolded successfully!`);
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
log,
|
|
14
14
|
config,
|
|
15
15
|
checkExists,
|
|
16
|
-
|
|
16
|
+
findNpmTarball,
|
|
17
17
|
downloadFile,
|
|
18
18
|
matchAnyPilet,
|
|
19
19
|
retrievePiletData,
|
|
@@ -77,6 +77,11 @@ export interface PublishPiletOptions {
|
|
|
77
77
|
*/
|
|
78
78
|
headers?: Record<string, string>;
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Defines if authorization tokens can be retrieved interactively.
|
|
82
|
+
*/
|
|
83
|
+
interactive?: boolean;
|
|
84
|
+
|
|
80
85
|
/**
|
|
81
86
|
* Sets the bundler to use for building, if any specific.
|
|
82
87
|
*/
|
|
@@ -104,6 +109,7 @@ export const publishPiletDefaults: PublishPiletOptions = {
|
|
|
104
109
|
from: 'local',
|
|
105
110
|
fields: {},
|
|
106
111
|
headers: {},
|
|
112
|
+
interactive: false,
|
|
107
113
|
};
|
|
108
114
|
|
|
109
115
|
async function getFiles(
|
|
@@ -192,7 +198,7 @@ async function getFiles(
|
|
|
192
198
|
}
|
|
193
199
|
case 'npm': {
|
|
194
200
|
log('generalDebug_0003', `View npm package "${sources.join('", "')}".`);
|
|
195
|
-
const allUrls = await Promise.all(sources.map((s) =>
|
|
201
|
+
const allUrls = await Promise.all(sources.map((s) => findNpmTarball(s)));
|
|
196
202
|
log('generalDebug_0003', `Download file from "${allUrls.join('", "')}".`);
|
|
197
203
|
const allFiles = await Promise.all(allUrls.map((url) => downloadFile(url, ca)));
|
|
198
204
|
return allFiles.reduce((result, files) => [...result, ...files], []);
|
|
@@ -214,6 +220,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
|
|
|
214
220
|
fields = publishPiletDefaults.fields,
|
|
215
221
|
headers = publishPiletDefaults.headers,
|
|
216
222
|
mode = publishPiletDefaults.mode,
|
|
223
|
+
interactive = publishPiletDefaults.interactive,
|
|
217
224
|
_ = {},
|
|
218
225
|
bundlerName,
|
|
219
226
|
} = options;
|
|
@@ -254,7 +261,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
|
|
|
254
261
|
|
|
255
262
|
if (content) {
|
|
256
263
|
progress(`Publishing "%s" ...`, file, url);
|
|
257
|
-
const result = await postFile(url, mode, apiKey, content, fields, headers, ca);
|
|
264
|
+
const result = await postFile(url, mode, apiKey, content, fields, headers, ca, interactive);
|
|
258
265
|
|
|
259
266
|
if (result.success) {
|
|
260
267
|
successfulUploads.push(file);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { publishArtifacts } from '../release';
|
|
3
3
|
import { LogLevels, PiralBuildType } from '../types';
|
|
4
|
-
import { setLogLevel, progress, checkExists, fail, logDone, logReset,
|
|
4
|
+
import { setLogLevel, progress, checkExists, fail, logDone, logReset, publishNpmPackage, matchFiles } from '../common';
|
|
5
5
|
|
|
6
6
|
export interface PublishPiralOptions {
|
|
7
7
|
/**
|
|
@@ -19,6 +19,11 @@ export interface PublishPiralOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
fields?: Record<string, string>;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Defines if authorization tokens can be retrieved interactively.
|
|
24
|
+
*/
|
|
25
|
+
interactive?: boolean;
|
|
26
|
+
|
|
22
27
|
/**
|
|
23
28
|
* The provider to use for publishing the release artifacts.
|
|
24
29
|
*/
|
|
@@ -36,9 +41,15 @@ export const publishPiralDefaults: PublishPiralOptions = {
|
|
|
36
41
|
type: 'all',
|
|
37
42
|
provider: 'none',
|
|
38
43
|
fields: {},
|
|
44
|
+
interactive: false,
|
|
39
45
|
};
|
|
40
46
|
|
|
41
|
-
async function publishEmulator(
|
|
47
|
+
async function publishEmulator(
|
|
48
|
+
baseDir: string,
|
|
49
|
+
source: string,
|
|
50
|
+
args: Record<string, string> = {},
|
|
51
|
+
interactive = false,
|
|
52
|
+
) {
|
|
42
53
|
const type = 'emulator';
|
|
43
54
|
const directory = resolve(baseDir, source, type);
|
|
44
55
|
const exists = await checkExists(directory);
|
|
@@ -58,7 +69,9 @@ async function publishEmulator(baseDir: string, source: string, args: Record<str
|
|
|
58
69
|
p.push(`--${c}`, args[c]);
|
|
59
70
|
return p;
|
|
60
71
|
}, [] as Array<string>);
|
|
61
|
-
|
|
72
|
+
|
|
73
|
+
//TODO support interactive here, too?
|
|
74
|
+
await publishNpmPackage(directory, file, flags);
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
async function publishRelease(
|
|
@@ -66,6 +79,7 @@ async function publishRelease(
|
|
|
66
79
|
source: string,
|
|
67
80
|
providerName: string,
|
|
68
81
|
args: Record<string, string> = {},
|
|
82
|
+
interactive = false,
|
|
69
83
|
) {
|
|
70
84
|
const type = 'release';
|
|
71
85
|
const directory = resolve(baseDir, source, type);
|
|
@@ -76,7 +90,7 @@ async function publishRelease(
|
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
const files = await matchFiles(directory, '**/*');
|
|
79
|
-
await publishArtifacts(providerName, files, args);
|
|
93
|
+
await publishArtifacts(providerName, files, args, interactive);
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
export async function publishPiral(baseDir = process.cwd(), options: PublishPiralOptions = {}) {
|
|
@@ -86,6 +100,7 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
|
|
|
86
100
|
logLevel = publishPiralDefaults.logLevel,
|
|
87
101
|
fields = publishPiralDefaults.fields,
|
|
88
102
|
provider = publishPiralDefaults.provider,
|
|
103
|
+
interactive = publishPiralDefaults.interactive,
|
|
89
104
|
} = options;
|
|
90
105
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
91
106
|
setLogLevel(logLevel);
|
|
@@ -98,14 +113,14 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
|
|
|
98
113
|
|
|
99
114
|
if (type !== 'release') {
|
|
100
115
|
progress('Publishing emulator package ...');
|
|
101
|
-
await publishEmulator(fullBase, source, fields);
|
|
116
|
+
await publishEmulator(fullBase, source, fields, interactive);
|
|
102
117
|
logDone(`Successfully published emulator.`);
|
|
103
118
|
logReset();
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
if (type !== 'emulator') {
|
|
107
122
|
progress('Publishing release files ...');
|
|
108
|
-
await publishRelease(fullBase, source, provider, fields);
|
|
123
|
+
await publishRelease(fullBase, source, provider, fields, interactive);
|
|
109
124
|
logDone(`Successfully published release.`);
|
|
110
125
|
logReset();
|
|
111
126
|
}
|
|
@@ -2,7 +2,7 @@ import { resolve } from 'path';
|
|
|
2
2
|
import { LogLevels, NpmClientType } from '../types';
|
|
3
3
|
import {
|
|
4
4
|
readJson,
|
|
5
|
-
|
|
5
|
+
installNpmPackage,
|
|
6
6
|
checkExistingDirectory,
|
|
7
7
|
patchPiletPackage,
|
|
8
8
|
copyPiralFiles,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
readPiralPackage,
|
|
11
11
|
getPiletsInfo,
|
|
12
12
|
runScript,
|
|
13
|
-
|
|
13
|
+
installNpmDependencies,
|
|
14
14
|
getCurrentPackageDetails,
|
|
15
15
|
checkAppShellPackage,
|
|
16
16
|
setLogLevel,
|
|
@@ -22,8 +22,6 @@ import {
|
|
|
22
22
|
ForceOverwrite,
|
|
23
23
|
copyScaffoldingFiles,
|
|
24
24
|
getPiralPath,
|
|
25
|
-
detectMonorepo,
|
|
26
|
-
bootstrapMonorepo,
|
|
27
25
|
isMonorepoPackageRef,
|
|
28
26
|
getPiletScaffoldData,
|
|
29
27
|
SourceLanguage,
|
|
@@ -131,7 +129,7 @@ export async function upgradePilet(baseDir = process.cwd(), options: UpgradePile
|
|
|
131
129
|
if (!monorepoRef) {
|
|
132
130
|
// only install the latest if the shell does come from remote
|
|
133
131
|
progress(`Updating npm package to %s ...`, packageRef);
|
|
134
|
-
await
|
|
132
|
+
await installNpmPackage(npmClient, packageRef, root, '--no-save');
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
const piralInfo = await readPiralPackage(root, sourceName);
|
|
@@ -164,13 +162,7 @@ export async function upgradePilet(baseDir = process.cwd(), options: UpgradePile
|
|
|
164
162
|
|
|
165
163
|
if (install) {
|
|
166
164
|
progress(`Updating dependencies ...`);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (monorepoKind === 'lerna') {
|
|
170
|
-
await bootstrapMonorepo(root);
|
|
171
|
-
} else {
|
|
172
|
-
await installDependencies(npmClient, root);
|
|
173
|
-
}
|
|
165
|
+
await installNpmDependencies(npmClient, root);
|
|
174
166
|
}
|
|
175
167
|
|
|
176
168
|
if (postUpgrade) {
|
|
@@ -3,7 +3,7 @@ import { LogLevels, NpmClientType } from '../types';
|
|
|
3
3
|
import {
|
|
4
4
|
readJson,
|
|
5
5
|
checkExistingDirectory,
|
|
6
|
-
|
|
6
|
+
installNpmDependencies,
|
|
7
7
|
setLogLevel,
|
|
8
8
|
progress,
|
|
9
9
|
fail,
|
|
@@ -113,7 +113,7 @@ export async function upgradePiral(baseDir = process.cwd(), options: UpgradePira
|
|
|
113
113
|
|
|
114
114
|
if (install) {
|
|
115
115
|
progress(`Updating the npm packages to %s ...`, version);
|
|
116
|
-
await
|
|
116
|
+
await installNpmDependencies(npmClient, root);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
logDone('Piral instance upgraded successfully!');
|
package/src/bundler.test.ts
CHANGED
package/src/bundler.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { callDynamic, callStatic } from './build/bundler-calls';
|
|
2
2
|
import { availableBundlers } from './helpers';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
installNpmPackage,
|
|
5
5
|
cliVersion,
|
|
6
6
|
fail,
|
|
7
7
|
progress,
|
|
@@ -39,7 +39,7 @@ async function installDefaultBundler(root: string) {
|
|
|
39
39
|
const client = await determineNpmClient(root);
|
|
40
40
|
log('generalDebug_0003', `Prepare to install ${selectedPackage}@${cliVersion} using "${client}" into "${root}".`);
|
|
41
41
|
progress(`Installing ${selectedPackage} ...`);
|
|
42
|
-
await
|
|
42
|
+
await installNpmPackage(client, `${selectedPackage}@${cliVersion}`, root, '--save-dev', '--save-exact');
|
|
43
43
|
log('generalDebug_0003', `Installed bundler from "${selectedPackage}".`);
|
|
44
44
|
|
|
45
45
|
require('./inject').inject(selectedPackage);
|