piral-cli 0.14.19-beta.3927 → 0.14.19-beta.3968
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.d.ts +4 -0
- package/lib/apps/build-pilet.js +4 -3
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/debug-pilet.d.ts +4 -0
- package/lib/apps/debug-pilet.js +4 -3
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/publish-pilet.d.ts +9 -1
- package/lib/apps/publish-pilet.js +4 -2
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/commands.js +16 -0
- package/lib/commands.js.map +1 -1
- package/lib/common/http.d.ts +2 -1
- package/lib/common/http.js +18 -4
- package/lib/common/http.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/info.d.ts +1 -0
- package/lib/common/info.js +3 -1
- package/lib/common/info.js.map +1 -1
- package/lib/common/parallel.d.ts +1 -0
- package/lib/common/parallel.js +29 -0
- package/lib/common/parallel.js.map +1 -0
- package/lib/helpers.d.ts +2 -1
- package/lib/helpers.js +2 -1
- package/lib/helpers.js.map +1 -1
- package/lib/types/public.d.ts +1 -0
- package/package.json +2 -2
- package/src/apps/build-pilet.ts +105 -99
- package/src/apps/debug-pilet.ts +56 -49
- package/src/apps/publish-pilet.ts +16 -2
- package/src/commands.ts +18 -0
- package/src/common/http.test.ts +7 -7
- package/src/common/http.ts +21 -3
- package/src/common/index.ts +1 -0
- package/src/common/info.ts +3 -0
- package/src/common/parallel.test.ts +28 -0
- package/src/common/parallel.ts +21 -0
- package/src/helpers.ts +2 -0
- package/src/types/public.ts +2 -0
package/lib/helpers.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keyOfPiletLanguage = exports.valueOfPiletLanguage = exports.piletLanguageKeys = exports.keyOfForceOverwrite = exports.valueOfForceOverwrite = exports.forceOverwriteKeys = exports.frameworkKeys = exports.availableReleaseProviders = exports.availableBundlers = exports.bundlerKeys = exports.clientTypeKeys = exports.piletBuildTypeKeys = exports.piralBuildTypeKeys = exports.fromKeys = exports.schemaKeys = void 0;
|
|
3
|
+
exports.keyOfPiletLanguage = exports.valueOfPiletLanguage = exports.piletLanguageKeys = exports.keyOfForceOverwrite = exports.valueOfForceOverwrite = exports.forceOverwriteKeys = exports.frameworkKeys = exports.availableReleaseProviders = exports.availableBundlers = exports.bundlerKeys = exports.clientTypeKeys = exports.piletBuildTypeKeys = exports.piralBuildTypeKeys = exports.fromKeys = exports.publishModeKeys = exports.schemaKeys = void 0;
|
|
4
4
|
const enums_1 = require("./common/enums");
|
|
5
5
|
const constants_1 = require("./common/constants");
|
|
6
6
|
exports.schemaKeys = ['v0', 'v1', 'v2', 'none'];
|
|
7
|
+
exports.publishModeKeys = ['none', 'basic', 'bearer', 'digest'];
|
|
7
8
|
exports.fromKeys = ['local', 'remote', 'npm'];
|
|
8
9
|
exports.piralBuildTypeKeys = ['all', 'release', 'emulator', 'emulator-sources'];
|
|
9
10
|
exports.piletBuildTypeKeys = ['default', 'standalone', 'manifest'];
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,0CAAgE;AAChE,kDAAiE;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,0CAAgE;AAChE,kDAAiE;AAWpD,QAAA,UAAU,GAA8B,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACnE,QAAA,eAAe,GAA8B,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACnF,QAAA,QAAQ,GAA8B,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AACjE,QAAA,kBAAkB,GAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;AAC/F,QAAA,kBAAkB,GAA0B,CAAC,SAAS,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAClF,QAAA,cAAc,GAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/D,QAAA,WAAW,GAAkB,CAAC,MAAM,EAAE,GAAG,wBAAY,CAAC,CAAC;AACvD,QAAA,iBAAiB,GAAkB,EAAE,CAAC;AACtC,QAAA,yBAAyB,GAAkB,EAAE,CAAC;AAC9C,QAAA,aAAa,GAAqB,CAAC,GAAG,yBAAa,CAAC,CAAC;AACrD,QAAA,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,sBAAc,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;AAEnH,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,KAAK,MAAM,iBAAiB,IAAI,0BAAkB,EAAE;QAClD,IAAI,iBAAiB,KAAK,GAAG,EAAE;YAC7B,OAAO,sBAAc,CAAC,iBAAiB,CAAC,CAAC;SAC1C;KACF;IAED,OAAO,sBAAc,CAAC,EAAE,CAAC;AAC3B,CAAC;AARD,sDAQC;AAED,SAAgB,mBAAmB,CAAC,KAAqB;IACvD,KAAK,MAAM,iBAAiB,IAAI,0BAAkB,EAAE;QAClD,IAAI,sBAAc,CAAC,iBAAiB,CAAC,KAAK,KAAK,EAAE;YAC/C,OAAO,iBAAiB,CAAC;SAC1B;KACF;IAED,OAAO,0BAAkB,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC;AARD,kDAQC;AAEY,QAAA,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,sBAAc,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;AAElH,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,KAAK,MAAM,gBAAgB,IAAI,yBAAiB,EAAE;QAChD,IAAI,gBAAgB,KAAK,GAAG,EAAE;YAC5B,OAAO,sBAAc,CAAC,gBAAgB,CAAC,CAAC;SACzC;KACF;IAED,OAAO,sBAAc,CAAC,EAAE,CAAC;AAC3B,CAAC;AARD,oDAQC;AAED,SAAgB,kBAAkB,CAAC,KAAqB;IACtD,KAAK,MAAM,gBAAgB,IAAI,yBAAiB,EAAE;QAChD,IAAI,sBAAc,CAAC,gBAAgB,CAAC,KAAK,KAAK,EAAE;YAC9C,OAAO,gBAAgB,CAAC;SACzB;KACF;IAED,OAAO,yBAAiB,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AARD,gDAQC"}
|
package/lib/types/public.d.ts
CHANGED
|
@@ -185,6 +185,7 @@ export interface BundlerDefinition {
|
|
|
185
185
|
buildPilet: BuildPiletBundlerDefinition;
|
|
186
186
|
}
|
|
187
187
|
export declare type PiletSchemaVersion = 'none' | 'v0' | 'v1' | 'v2';
|
|
188
|
+
export declare type PiletPublishScheme = 'none' | 'digest' | 'bearer' | 'basic';
|
|
188
189
|
export declare type PiletPublishSource = 'local' | 'npm' | 'remote';
|
|
189
190
|
export declare type PiralBuildType = 'all' | 'release' | 'emulator' | 'emulator-sources';
|
|
190
191
|
export declare type PiletBuildType = 'default' | 'standalone' | 'manifest';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli",
|
|
3
|
-
"version": "0.14.19-beta.
|
|
3
|
+
"version": "0.14.19-beta.3968",
|
|
4
4
|
"description": "The standard CLI for creating and building a Piral instance or a Pilet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"typescript": "^4.0.2",
|
|
78
78
|
"yargs": "^15.4.1"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "3065473b4bbbb26675c8973e5a53669a458ca796"
|
|
81
81
|
}
|
package/src/apps/build-pilet.ts
CHANGED
|
@@ -14,14 +14,48 @@ import {
|
|
|
14
14
|
fail,
|
|
15
15
|
config,
|
|
16
16
|
log,
|
|
17
|
-
createDirectory,
|
|
18
17
|
writeJson,
|
|
19
18
|
getPiletSpecMeta,
|
|
20
19
|
getFileNames,
|
|
21
20
|
copy,
|
|
22
21
|
checkAppShellPackage,
|
|
22
|
+
cpuCount,
|
|
23
|
+
concurrentWorkers,
|
|
23
24
|
} from '../common';
|
|
24
25
|
|
|
26
|
+
interface PiletData {
|
|
27
|
+
id: string;
|
|
28
|
+
package: any;
|
|
29
|
+
path: string;
|
|
30
|
+
outFile: string;
|
|
31
|
+
outDir: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function createMetadata(outDir: string, outFile: string, pilets: Array<PiletData>) {
|
|
35
|
+
return writeJson(
|
|
36
|
+
outDir,
|
|
37
|
+
outFile,
|
|
38
|
+
pilets.map((p) => ({
|
|
39
|
+
name: p.package.name,
|
|
40
|
+
version: p.package.version,
|
|
41
|
+
link: `./${p.id}/${p.outFile}`,
|
|
42
|
+
...getPiletSpecMeta(p.path, p.outDir),
|
|
43
|
+
})),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function copyPilets(outDir: string, pilets: Array<PiletData>) {
|
|
48
|
+
return Promise.all(
|
|
49
|
+
pilets.map(async (p) => {
|
|
50
|
+
const files = await getFileNames(p.outDir);
|
|
51
|
+
|
|
52
|
+
for (const file of files) {
|
|
53
|
+
await copy(resolve(p.outDir, file), resolve(outDir, p.id, file), ForceOverwrite.yes);
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
25
59
|
export interface BuildPiletOptions {
|
|
26
60
|
/**
|
|
27
61
|
* Sets the name of the Piral instance.
|
|
@@ -50,6 +84,11 @@ export interface BuildPiletOptions {
|
|
|
50
84
|
*/
|
|
51
85
|
declaration?: boolean;
|
|
52
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Sets the maximum number of parallel build processes.
|
|
89
|
+
*/
|
|
90
|
+
concurrency?: number;
|
|
91
|
+
|
|
53
92
|
/**
|
|
54
93
|
* Sets the log level to use (1-5).
|
|
55
94
|
*/
|
|
@@ -109,39 +148,6 @@ export interface BuildPiletOptions {
|
|
|
109
148
|
};
|
|
110
149
|
}
|
|
111
150
|
|
|
112
|
-
interface PiletData {
|
|
113
|
-
id: string;
|
|
114
|
-
package: any;
|
|
115
|
-
path: string;
|
|
116
|
-
outFile: string;
|
|
117
|
-
outDir: string;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function createMetadata(outDir: string, outFile: string, pilets: Array<PiletData>) {
|
|
121
|
-
return writeJson(
|
|
122
|
-
outDir,
|
|
123
|
-
outFile,
|
|
124
|
-
pilets.map((p) => ({
|
|
125
|
-
name: p.package.name,
|
|
126
|
-
version: p.package.version,
|
|
127
|
-
link: `./${p.id}/${p.outFile}`,
|
|
128
|
-
...getPiletSpecMeta(p.path, p.outDir),
|
|
129
|
-
})),
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function copyPilets(outDir: string, pilets: Array<PiletData>) {
|
|
134
|
-
return Promise.all(
|
|
135
|
-
pilets.map(async (p) => {
|
|
136
|
-
const files = await getFileNames(p.outDir);
|
|
137
|
-
|
|
138
|
-
for (const file of files) {
|
|
139
|
-
await copy(resolve(p.outDir, file), resolve(outDir, p.id, file), ForceOverwrite.yes);
|
|
140
|
-
}
|
|
141
|
-
}),
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
151
|
export const buildPiletDefaults: BuildPiletOptions = {
|
|
146
152
|
entry: './src/index',
|
|
147
153
|
target: './dist/index.js',
|
|
@@ -153,6 +159,7 @@ export const buildPiletDefaults: BuildPiletOptions = {
|
|
|
153
159
|
contentHash: true,
|
|
154
160
|
optimizeModules: false,
|
|
155
161
|
schemaVersion: config.schemaVersion,
|
|
162
|
+
concurrency: cpuCount,
|
|
156
163
|
declaration: true,
|
|
157
164
|
};
|
|
158
165
|
|
|
@@ -165,6 +172,7 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
165
172
|
contentHash = buildPiletDefaults.contentHash,
|
|
166
173
|
logLevel = buildPiletDefaults.logLevel,
|
|
167
174
|
fresh = buildPiletDefaults.fresh,
|
|
175
|
+
concurrency = buildPiletDefaults.concurrency,
|
|
168
176
|
optimizeModules = buildPiletDefaults.optimizeModules,
|
|
169
177
|
schemaVersion = buildPiletDefaults.schemaVersion,
|
|
170
178
|
declaration = buildPiletDefaults.declaration,
|
|
@@ -187,77 +195,75 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
187
195
|
fail('entryFileMissing_0077');
|
|
188
196
|
}
|
|
189
197
|
|
|
190
|
-
const pilets = await
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
198
|
+
const pilets = await concurrentWorkers(allEntries, concurrency, async (entryModule) => {
|
|
199
|
+
const targetDir = dirname(entryModule);
|
|
200
|
+
const { peerDependencies, peerModules, root, appPackage, appFile, piletPackage, ignored, importmap } =
|
|
201
|
+
await retrievePiletData(targetDir, app);
|
|
202
|
+
const externals = [...Object.keys(peerDependencies), ...peerModules];
|
|
203
|
+
const dest = resolve(root, target);
|
|
204
|
+
const outDir = dirname(dest);
|
|
205
|
+
const outFile = basename(dest);
|
|
206
|
+
|
|
207
|
+
if (fresh) {
|
|
208
|
+
progress('Removing output directory ...');
|
|
209
|
+
await removeDirectory(outDir);
|
|
210
|
+
}
|
|
204
211
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
await hooks.beforeBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
|
|
208
|
-
|
|
209
|
-
await callPiletBuild(
|
|
210
|
-
{
|
|
211
|
-
root,
|
|
212
|
-
piral: appPackage.name,
|
|
213
|
-
optimizeModules,
|
|
214
|
-
sourceMaps,
|
|
215
|
-
contentHash,
|
|
216
|
-
minify,
|
|
217
|
-
externals,
|
|
218
|
-
targetDir,
|
|
219
|
-
importmap,
|
|
220
|
-
outFile,
|
|
221
|
-
outDir,
|
|
222
|
-
entryModule: `./${relative(root, entryModule)}`,
|
|
223
|
-
logLevel,
|
|
224
|
-
version: schemaVersion,
|
|
225
|
-
ignored,
|
|
226
|
-
_,
|
|
227
|
-
},
|
|
228
|
-
bundlerName,
|
|
229
|
-
);
|
|
212
|
+
logInfo('Bundle pilet ...');
|
|
230
213
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (declaration) {
|
|
234
|
-
await hooks.beforeDeclaration?.({ root, outDir, entryModule, piletPackage });
|
|
235
|
-
await createPiletDeclaration(
|
|
236
|
-
piletPackage.name,
|
|
237
|
-
root,
|
|
238
|
-
entryModule,
|
|
239
|
-
externals,
|
|
240
|
-
outDir,
|
|
241
|
-
ForceOverwrite.yes,
|
|
242
|
-
logLevel,
|
|
243
|
-
);
|
|
244
|
-
await hooks.afterDeclaration?.({ root, outDir, entryModule, piletPackage });
|
|
245
|
-
}
|
|
214
|
+
await hooks.beforeBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
|
|
246
215
|
|
|
247
|
-
|
|
216
|
+
await callPiletBuild(
|
|
217
|
+
{
|
|
218
|
+
root,
|
|
219
|
+
piral: appPackage.name,
|
|
220
|
+
optimizeModules,
|
|
221
|
+
sourceMaps,
|
|
222
|
+
contentHash,
|
|
223
|
+
minify,
|
|
224
|
+
externals,
|
|
225
|
+
targetDir,
|
|
226
|
+
importmap,
|
|
227
|
+
outFile,
|
|
228
|
+
outDir,
|
|
229
|
+
entryModule: `./${relative(root, entryModule)}`,
|
|
230
|
+
logLevel,
|
|
231
|
+
version: schemaVersion,
|
|
232
|
+
ignored,
|
|
233
|
+
_,
|
|
234
|
+
},
|
|
235
|
+
bundlerName,
|
|
236
|
+
);
|
|
248
237
|
|
|
249
|
-
|
|
250
|
-
|
|
238
|
+
await hooks.afterBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
|
|
239
|
+
|
|
240
|
+
if (declaration) {
|
|
241
|
+
await hooks.beforeDeclaration?.({ root, outDir, entryModule, piletPackage });
|
|
242
|
+
await createPiletDeclaration(
|
|
243
|
+
piletPackage.name,
|
|
251
244
|
root,
|
|
252
|
-
|
|
253
|
-
|
|
245
|
+
entryModule,
|
|
246
|
+
externals,
|
|
254
247
|
outDir,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
248
|
+
ForceOverwrite.yes,
|
|
249
|
+
logLevel,
|
|
250
|
+
);
|
|
251
|
+
await hooks.afterDeclaration?.({ root, outDir, entryModule, piletPackage });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
logDone(`Pilet "${piletPackage.name}" built successfully!`);
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
id: piletPackage.name.replace(/[^a-zA-Z0-9\-]/gi, ''),
|
|
258
|
+
root,
|
|
259
|
+
appFile,
|
|
260
|
+
appPackage,
|
|
261
|
+
outDir,
|
|
262
|
+
outFile,
|
|
263
|
+
path: dest,
|
|
264
|
+
package: piletPackage,
|
|
265
|
+
};
|
|
266
|
+
});
|
|
261
267
|
|
|
262
268
|
if (type === 'standalone') {
|
|
263
269
|
const distDir = dirname(resolve(fullBase, target));
|
package/src/apps/debug-pilet.ts
CHANGED
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
fail,
|
|
17
17
|
log,
|
|
18
18
|
logDone,
|
|
19
|
+
cpuCount,
|
|
20
|
+
concurrentWorkers,
|
|
19
21
|
} from '../common';
|
|
20
22
|
|
|
21
23
|
export interface DebugPiletOptions {
|
|
@@ -51,6 +53,11 @@ export interface DebugPiletOptions {
|
|
|
51
53
|
*/
|
|
52
54
|
port?: number;
|
|
53
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Sets the maximum number of parallel build processes.
|
|
58
|
+
*/
|
|
59
|
+
concurrency?: number;
|
|
60
|
+
|
|
54
61
|
/**
|
|
55
62
|
* Defines if hot module reloading (HMR) should be integrated for faster debugging.
|
|
56
63
|
*/
|
|
@@ -105,6 +112,7 @@ export const debugPiletDefaults: DebugPiletOptions = {
|
|
|
105
112
|
hmr: true,
|
|
106
113
|
optimizeModules: false,
|
|
107
114
|
schemaVersion: config.schemaVersion,
|
|
115
|
+
concurrency: cpuCount,
|
|
108
116
|
};
|
|
109
117
|
|
|
110
118
|
const injectorName = resolve(__dirname, '../injectors/pilet.js');
|
|
@@ -160,6 +168,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
160
168
|
open = debugPiletDefaults.open,
|
|
161
169
|
hmr = debugPiletDefaults.hmr,
|
|
162
170
|
logLevel = debugPiletDefaults.logLevel,
|
|
171
|
+
concurrency = debugPiletDefaults.concurrency,
|
|
163
172
|
optimizeModules = debugPiletDefaults.optimizeModules,
|
|
164
173
|
schemaVersion = debugPiletDefaults.schemaVersion,
|
|
165
174
|
_ = {},
|
|
@@ -196,58 +205,56 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
196
205
|
process.stdout.setMaxListeners(maxListeners);
|
|
197
206
|
process.stdin.setMaxListeners(maxListeners);
|
|
198
207
|
|
|
199
|
-
const pilets = await
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
krasConfig.directory = mocks;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
krasConfig.sources.push(mocks);
|
|
208
|
+
const pilets = await concurrentWorkers(allEntries, concurrency, async (entryModule) => {
|
|
209
|
+
const targetDir = dirname(entryModule);
|
|
210
|
+
const { peerDependencies, peerModules, root, appPackage, appFile, ignored, emulator, importmap } =
|
|
211
|
+
await retrievePiletData(targetDir, app);
|
|
212
|
+
const externals = [...Object.keys(peerDependencies), ...peerModules];
|
|
213
|
+
const mocks = join(targetDir, 'mocks');
|
|
214
|
+
const exists = await checkExistingDirectory(mocks);
|
|
215
|
+
|
|
216
|
+
if (exists) {
|
|
217
|
+
if (krasConfig.directory === undefined) {
|
|
218
|
+
krasConfig.directory = mocks;
|
|
214
219
|
}
|
|
215
220
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
hmr,
|
|
224
|
-
externals,
|
|
225
|
-
targetDir,
|
|
226
|
-
importmap,
|
|
227
|
-
entryModule: `./${relative(root, entryModule)}`,
|
|
228
|
-
logLevel,
|
|
229
|
-
version: schemaVersion,
|
|
230
|
-
ignored,
|
|
231
|
-
_,
|
|
232
|
-
},
|
|
233
|
-
bundlerName,
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
bundler.on((args) => {
|
|
237
|
-
hooks.afterBuild?.({ ...args, root, importmap, entryModule, schemaVersion, bundler });
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
return {
|
|
241
|
-
emulator,
|
|
242
|
-
appFile,
|
|
243
|
-
appVersion: appPackage.version,
|
|
244
|
-
externals,
|
|
245
|
-
piral: appPackage.name,
|
|
246
|
-
bundler,
|
|
221
|
+
krasConfig.sources.push(mocks);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
await hooks.beforeBuild?.({ root, importmap, entryModule, schemaVersion });
|
|
225
|
+
|
|
226
|
+
const bundler = await callPiletDebug(
|
|
227
|
+
{
|
|
247
228
|
root,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
229
|
+
piral: appPackage.name,
|
|
230
|
+
optimizeModules,
|
|
231
|
+
hmr,
|
|
232
|
+
externals,
|
|
233
|
+
targetDir,
|
|
234
|
+
importmap,
|
|
235
|
+
entryModule: `./${relative(root, entryModule)}`,
|
|
236
|
+
logLevel,
|
|
237
|
+
version: schemaVersion,
|
|
238
|
+
ignored,
|
|
239
|
+
_,
|
|
240
|
+
},
|
|
241
|
+
bundlerName,
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
bundler.on((args) => {
|
|
245
|
+
hooks.afterBuild?.({ ...args, root, importmap, entryModule, schemaVersion, bundler });
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
emulator,
|
|
250
|
+
appFile,
|
|
251
|
+
appVersion: appPackage.version,
|
|
252
|
+
externals,
|
|
253
|
+
piral: appPackage.name,
|
|
254
|
+
bundler,
|
|
255
|
+
root,
|
|
256
|
+
};
|
|
257
|
+
});
|
|
251
258
|
|
|
252
259
|
// sanity check see #250
|
|
253
260
|
checkSanity(pilets);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relative, dirname, basename, resolve } from 'path';
|
|
2
2
|
import { callPiletBuild } from '../bundler';
|
|
3
|
-
import { LogLevels, PiletSchemaVersion, PiletPublishSource } from '../types';
|
|
3
|
+
import { LogLevels, PiletSchemaVersion, PiletPublishSource, PiletPublishScheme } from '../types';
|
|
4
4
|
import {
|
|
5
5
|
postFile,
|
|
6
6
|
readBinary,
|
|
@@ -72,11 +72,21 @@ export interface PublishPiletOptions {
|
|
|
72
72
|
*/
|
|
73
73
|
fields?: Record<string, string>;
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Places additional headers that should be posted to the feed service.
|
|
77
|
+
*/
|
|
78
|
+
headers?: Record<string, string>;
|
|
79
|
+
|
|
75
80
|
/**
|
|
76
81
|
* Sets the bundler to use for building, if any specific.
|
|
77
82
|
*/
|
|
78
83
|
bundlerName?: string;
|
|
79
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Sets the authorization scheme to use.
|
|
87
|
+
*/
|
|
88
|
+
mode?: PiletPublishScheme;
|
|
89
|
+
|
|
80
90
|
/**
|
|
81
91
|
* Additional arguments for a specific bundler.
|
|
82
92
|
*/
|
|
@@ -90,8 +100,10 @@ export const publishPiletDefaults: PublishPiletOptions = {
|
|
|
90
100
|
cert: undefined,
|
|
91
101
|
logLevel: LogLevels.info,
|
|
92
102
|
schemaVersion: config.schemaVersion,
|
|
103
|
+
mode: 'basic',
|
|
93
104
|
from: 'local',
|
|
94
105
|
fields: {},
|
|
106
|
+
headers: {},
|
|
95
107
|
};
|
|
96
108
|
|
|
97
109
|
async function getFiles(
|
|
@@ -200,6 +212,8 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
|
|
|
200
212
|
schemaVersion = publishPiletDefaults.schemaVersion,
|
|
201
213
|
cert = config.cert ?? publishPiletDefaults.cert,
|
|
202
214
|
fields = publishPiletDefaults.fields,
|
|
215
|
+
headers = publishPiletDefaults.headers,
|
|
216
|
+
mode = publishPiletDefaults.mode,
|
|
203
217
|
_ = {},
|
|
204
218
|
bundlerName,
|
|
205
219
|
} = options;
|
|
@@ -240,7 +254,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
|
|
|
240
254
|
|
|
241
255
|
if (content) {
|
|
242
256
|
progress(`Publishing "%s" ...`, file, url);
|
|
243
|
-
const result = await postFile(url, apiKey, content, fields, ca);
|
|
257
|
+
const result = await postFile(url, mode, apiKey, content, fields, headers, ca);
|
|
244
258
|
|
|
245
259
|
if (result.success) {
|
|
246
260
|
successfulUploads.push(file);
|
package/src/commands.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
fromKeys,
|
|
16
16
|
bundlerKeys,
|
|
17
17
|
piralBuildTypeKeys,
|
|
18
|
+
publishModeKeys,
|
|
18
19
|
} from './helpers';
|
|
19
20
|
import {
|
|
20
21
|
ToolCommand,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
PiletPublishSource,
|
|
26
27
|
PiletSchemaVersion,
|
|
27
28
|
PiletBuildType,
|
|
29
|
+
PiletPublishScheme,
|
|
28
30
|
} from './types';
|
|
29
31
|
|
|
30
32
|
function specializeCommand(commands: Array<ToolCommand<any>>, command: ToolCommand<any>, suffix: string) {
|
|
@@ -404,6 +406,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
404
406
|
.number('log-level')
|
|
405
407
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
406
408
|
.default('log-level', apps.debugPiletDefaults.logLevel)
|
|
409
|
+
.number('concurrency')
|
|
410
|
+
.describe('concurrency', 'Sets the maximum number of concurrent build jobs.')
|
|
411
|
+
.default('concurrency', apps.debugPiletDefaults.concurrency)
|
|
407
412
|
.boolean('open')
|
|
408
413
|
.describe('open', 'Opens the pilet directly in the browser.')
|
|
409
414
|
.default('open', apps.debugPiletDefaults.open)
|
|
@@ -441,6 +446,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
441
446
|
logLevel: args['log-level'] as LogLevels,
|
|
442
447
|
open: args.open as boolean,
|
|
443
448
|
schemaVersion: args.schema as PiletSchemaVersion,
|
|
449
|
+
concurrency: args.concurrency as number,
|
|
444
450
|
feed: args.feed as string,
|
|
445
451
|
hooks: args.hooks as object,
|
|
446
452
|
_: args,
|
|
@@ -466,6 +472,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
466
472
|
.number('log-level')
|
|
467
473
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
468
474
|
.default('log-level', apps.buildPiletDefaults.logLevel)
|
|
475
|
+
.number('concurrency')
|
|
476
|
+
.describe('concurrency', 'Sets the maximum number of concurrent build jobs.')
|
|
477
|
+
.default('concurrency', apps.buildPiletDefaults.concurrency)
|
|
469
478
|
.boolean('source-maps')
|
|
470
479
|
.describe('source-maps', 'Creates source maps for the bundles.')
|
|
471
480
|
.default('source-maps', apps.buildPiletDefaults.sourceMaps)
|
|
@@ -513,6 +522,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
513
522
|
fresh: args.fresh as boolean,
|
|
514
523
|
logLevel: args['log-level'] as LogLevels,
|
|
515
524
|
schemaVersion: args.schema as PiletSchemaVersion,
|
|
525
|
+
concurrency: args.concurrency as number,
|
|
516
526
|
app: args.app as string,
|
|
517
527
|
hooks: args.hooks as object,
|
|
518
528
|
_: args,
|
|
@@ -579,6 +589,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
579
589
|
.choices('schema', schemaKeys)
|
|
580
590
|
.describe('schema', 'Sets the schema to be used when making a fresh build of the pilet.')
|
|
581
591
|
.default('schema', apps.publishPiletDefaults.schemaVersion)
|
|
592
|
+
.choices('mode', publishModeKeys)
|
|
593
|
+
.describe('mode', 'Sets the authorization mode to use.')
|
|
594
|
+
.default('mode', apps.publishPiletDefaults.mode)
|
|
582
595
|
.choices('bundler', availableBundlers)
|
|
583
596
|
.describe('bundler', 'Sets the bundler to use.')
|
|
584
597
|
.default('bundler', availableBundlers[0])
|
|
@@ -588,6 +601,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
588
601
|
.option('fields', undefined)
|
|
589
602
|
.describe('fields', 'Sets additional fields to be included in the feed service request.')
|
|
590
603
|
.default('fields', apps.publishPiletDefaults.fields)
|
|
604
|
+
.option('headers', undefined)
|
|
605
|
+
.describe('headers', 'Sets additional headers to be included in the feed service request.')
|
|
606
|
+
.default('headers', apps.publishPiletDefaults.headers)
|
|
591
607
|
.string('base')
|
|
592
608
|
.default('base', process.cwd())
|
|
593
609
|
.describe('base', 'Sets the base directory. By default the current directory is used.');
|
|
@@ -604,6 +620,8 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
604
620
|
from: args.from as PiletPublishSource,
|
|
605
621
|
schemaVersion: args.schema as PiletSchemaVersion,
|
|
606
622
|
fields: args.fields as Record<string, string>,
|
|
623
|
+
headers: args.headers as Record<string, string>,
|
|
624
|
+
mode: args.mode as PiletPublishScheme,
|
|
607
625
|
_: args,
|
|
608
626
|
});
|
|
609
627
|
},
|
package/src/common/http.test.ts
CHANGED
|
@@ -71,7 +71,7 @@ jest.mock('axios', () => ({
|
|
|
71
71
|
|
|
72
72
|
describe('HTTP Module', () => {
|
|
73
73
|
it('postFile form posts a file successfully should be ok', async () => {
|
|
74
|
-
const result = await postFile(apiUrl, '123', Buffer.from('example'));
|
|
74
|
+
const result = await postFile(apiUrl, 'basic', '123', Buffer.from('example'));
|
|
75
75
|
expect(result).toEqual({
|
|
76
76
|
response: undefined,
|
|
77
77
|
status: 200,
|
|
@@ -80,7 +80,7 @@ describe('HTTP Module', () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('postFile form fails to post file should be false', async () => {
|
|
83
|
-
const result = await postFile(apiUrl, '124', Buffer.from('example'));
|
|
83
|
+
const result = await postFile(apiUrl, 'basic', '124', Buffer.from('example'));
|
|
84
84
|
expect(result).toEqual({
|
|
85
85
|
response: '',
|
|
86
86
|
status: 401,
|
|
@@ -89,7 +89,7 @@ describe('HTTP Module', () => {
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
it('postFile form not found to post file should be false', async () => {
|
|
92
|
-
const result = await postFile('http://sample.com/', '', Buffer.from('example'));
|
|
92
|
+
const result = await postFile('http://sample.com/', 'basic', '', Buffer.from('example'));
|
|
93
93
|
expect(result).toEqual({
|
|
94
94
|
response: '',
|
|
95
95
|
status: 404,
|
|
@@ -99,7 +99,7 @@ describe('HTTP Module', () => {
|
|
|
99
99
|
|
|
100
100
|
it('postFile call results in error request', async () => {
|
|
101
101
|
errorRequest = true;
|
|
102
|
-
const result = await postFile('http://sample.com/', '', Buffer.from('example'));
|
|
102
|
+
const result = await postFile('http://sample.com/', 'basic', '', Buffer.from('example'));
|
|
103
103
|
expect(result).toEqual({
|
|
104
104
|
response: undefined,
|
|
105
105
|
status: 500,
|
|
@@ -110,7 +110,7 @@ describe('HTTP Module', () => {
|
|
|
110
110
|
|
|
111
111
|
it('postFile call results in error other', async () => {
|
|
112
112
|
errorOther = true;
|
|
113
|
-
const result = await postFile('http://sample.com/', '', Buffer.from('example'));
|
|
113
|
+
const result = await postFile('http://sample.com/', 'basic', '', Buffer.from('example'));
|
|
114
114
|
expect(result).toEqual({
|
|
115
115
|
response: undefined,
|
|
116
116
|
status: 500,
|
|
@@ -121,7 +121,7 @@ describe('HTTP Module', () => {
|
|
|
121
121
|
|
|
122
122
|
it('postFile call results in error response', async () => {
|
|
123
123
|
errorResponse = true;
|
|
124
|
-
let result = await postFile('http://sample.com/', '', Buffer.from('example'));
|
|
124
|
+
let result = await postFile('http://sample.com/', 'basic', '', Buffer.from('example'));
|
|
125
125
|
expect(result).toEqual({
|
|
126
126
|
response: 'This component is not available anymore.',
|
|
127
127
|
status: 410,
|
|
@@ -129,7 +129,7 @@ describe('HTTP Module', () => {
|
|
|
129
129
|
});
|
|
130
130
|
errorResponse = false;
|
|
131
131
|
errorResponse2 = true;
|
|
132
|
-
result = await postFile('http://sample.com/', '', Buffer.from('example'));
|
|
132
|
+
result = await postFile('http://sample.com/', 'basic', '', Buffer.from('example'));
|
|
133
133
|
expect(result).toEqual({
|
|
134
134
|
response: 'This component is not available anymore.',
|
|
135
135
|
status: 410,
|