piral-cli 0.15.0-alpha.3933 → 0.15.0-alpha.3975
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 +61 -54
- 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
|
@@ -189,6 +189,7 @@ export interface BundlerDefinition {
|
|
|
189
189
|
buildPilet: BuildPiletBundlerDefinition;
|
|
190
190
|
}
|
|
191
191
|
export declare type PiletSchemaVersion = 'none' | 'v0' | 'v1' | 'v2';
|
|
192
|
+
export declare type PiletPublishScheme = 'none' | 'digest' | 'bearer' | 'basic';
|
|
192
193
|
export declare type PiletPublishSource = 'local' | 'npm' | 'remote';
|
|
193
194
|
export declare type PiralBuildType = 'all' | 'release' | 'emulator' | 'emulator-sources';
|
|
194
195
|
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.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.3975",
|
|
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
|
"typescript": "^4.0.2",
|
|
79
79
|
"yargs": "^15.4.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "461d63cd1957359472018b32a56778da716d3406"
|
|
82
82
|
}
|
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 {
|
|
@@ -57,6 +59,11 @@ export interface DebugPiletOptions {
|
|
|
57
59
|
*/
|
|
58
60
|
port?: number;
|
|
59
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Sets the maximum number of parallel build processes.
|
|
64
|
+
*/
|
|
65
|
+
concurrency?: number;
|
|
66
|
+
|
|
60
67
|
/**
|
|
61
68
|
* Defines if hot module reloading (HMR) should be integrated for faster debugging.
|
|
62
69
|
*/
|
|
@@ -112,6 +119,7 @@ export const debugPiletDefaults: DebugPiletOptions = {
|
|
|
112
119
|
hmr: true,
|
|
113
120
|
optimizeModules: false,
|
|
114
121
|
schemaVersion: config.schemaVersion,
|
|
122
|
+
concurrency: cpuCount,
|
|
115
123
|
};
|
|
116
124
|
|
|
117
125
|
const injectorName = resolve(__dirname, '../injectors/pilet.js');
|
|
@@ -168,6 +176,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
168
176
|
open = debugPiletDefaults.open,
|
|
169
177
|
hmr = debugPiletDefaults.hmr,
|
|
170
178
|
logLevel = debugPiletDefaults.logLevel,
|
|
179
|
+
concurrency = debugPiletDefaults.concurrency,
|
|
171
180
|
optimizeModules = debugPiletDefaults.optimizeModules,
|
|
172
181
|
schemaVersion = debugPiletDefaults.schemaVersion,
|
|
173
182
|
_ = {},
|
|
@@ -204,63 +213,61 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
204
213
|
process.stdout.setMaxListeners(maxListeners);
|
|
205
214
|
process.stdin.setMaxListeners(maxListeners);
|
|
206
215
|
|
|
207
|
-
const pilets = await
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
krasConfig.directory = mocks;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
krasConfig.sources.push(mocks);
|
|
216
|
+
const pilets = await concurrentWorkers(allEntries, concurrency, async (entryModule) => {
|
|
217
|
+
const targetDir = dirname(entryModule);
|
|
218
|
+
const { peerDependencies, peerModules, root, appPackage, appFile, ignored, emulator, importmap } =
|
|
219
|
+
await retrievePiletData(targetDir, app);
|
|
220
|
+
const externals = [...Object.keys(peerDependencies), ...peerModules];
|
|
221
|
+
const mocks = join(targetDir, 'mocks');
|
|
222
|
+
const dest = resolve(root, target);
|
|
223
|
+
const outDir = dirname(dest);
|
|
224
|
+
const outFile = basename(dest);
|
|
225
|
+
const exists = await checkExistingDirectory(mocks);
|
|
226
|
+
|
|
227
|
+
if (exists) {
|
|
228
|
+
if (krasConfig.directory === undefined) {
|
|
229
|
+
krasConfig.directory = mocks;
|
|
225
230
|
}
|
|
226
231
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
hmr,
|
|
235
|
-
externals,
|
|
236
|
-
targetDir,
|
|
237
|
-
importmap,
|
|
238
|
-
outFile,
|
|
239
|
-
outDir,
|
|
240
|
-
entryModule: `./${relative(root, entryModule)}`,
|
|
241
|
-
logLevel,
|
|
242
|
-
version: schemaVersion,
|
|
243
|
-
ignored,
|
|
244
|
-
_,
|
|
245
|
-
},
|
|
246
|
-
bundlerName,
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
bundler.on((args) => {
|
|
250
|
-
hooks.afterBuild?.({ ...args, root, importmap, entryModule, schemaVersion, bundler, outFile, outDir });
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
return {
|
|
254
|
-
emulator,
|
|
255
|
-
appFile,
|
|
256
|
-
appVersion: appPackage.version,
|
|
257
|
-
externals,
|
|
258
|
-
piral: appPackage.name,
|
|
259
|
-
bundler,
|
|
232
|
+
krasConfig.sources.push(mocks);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
await hooks.beforeBuild?.({ root, importmap, entryModule, schemaVersion });
|
|
236
|
+
|
|
237
|
+
const bundler = await callPiletDebug(
|
|
238
|
+
{
|
|
260
239
|
root,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
240
|
+
piral: appPackage.name,
|
|
241
|
+
optimizeModules,
|
|
242
|
+
hmr,
|
|
243
|
+
externals,
|
|
244
|
+
targetDir,
|
|
245
|
+
importmap,
|
|
246
|
+
outFile,
|
|
247
|
+
outDir,
|
|
248
|
+
entryModule: `./${relative(root, entryModule)}`,
|
|
249
|
+
logLevel,
|
|
250
|
+
version: schemaVersion,
|
|
251
|
+
ignored,
|
|
252
|
+
_,
|
|
253
|
+
},
|
|
254
|
+
bundlerName,
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
bundler.on((args) => {
|
|
258
|
+
hooks.afterBuild?.({ ...args, root, importmap, entryModule, schemaVersion, bundler, outFile, outDir });
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
emulator,
|
|
263
|
+
appFile,
|
|
264
|
+
appVersion: appPackage.version,
|
|
265
|
+
externals,
|
|
266
|
+
piral: appPackage.name,
|
|
267
|
+
bundler,
|
|
268
|
+
root,
|
|
269
|
+
};
|
|
270
|
+
});
|
|
264
271
|
|
|
265
272
|
// sanity check see #250
|
|
266
273
|
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) {
|
|
@@ -414,6 +416,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
414
416
|
.number('log-level')
|
|
415
417
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
416
418
|
.default('log-level', apps.debugPiletDefaults.logLevel)
|
|
419
|
+
.number('concurrency')
|
|
420
|
+
.describe('concurrency', 'Sets the maximum number of concurrent build jobs.')
|
|
421
|
+
.default('concurrency', apps.debugPiletDefaults.concurrency)
|
|
417
422
|
.boolean('open')
|
|
418
423
|
.describe('open', 'Opens the pilet directly in the browser.')
|
|
419
424
|
.default('open', apps.debugPiletDefaults.open)
|
|
@@ -452,6 +457,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
452
457
|
logLevel: args['log-level'] as LogLevels,
|
|
453
458
|
open: args.open as boolean,
|
|
454
459
|
schemaVersion: args.schema as PiletSchemaVersion,
|
|
460
|
+
concurrency: args.concurrency as number,
|
|
455
461
|
feed: args.feed as string,
|
|
456
462
|
hooks: args.hooks as object,
|
|
457
463
|
_: args,
|
|
@@ -477,6 +483,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
477
483
|
.number('log-level')
|
|
478
484
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
479
485
|
.default('log-level', apps.buildPiletDefaults.logLevel)
|
|
486
|
+
.number('concurrency')
|
|
487
|
+
.describe('concurrency', 'Sets the maximum number of concurrent build jobs.')
|
|
488
|
+
.default('concurrency', apps.buildPiletDefaults.concurrency)
|
|
480
489
|
.boolean('source-maps')
|
|
481
490
|
.describe('source-maps', 'Creates source maps for the bundles.')
|
|
482
491
|
.default('source-maps', apps.buildPiletDefaults.sourceMaps)
|
|
@@ -524,6 +533,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
524
533
|
fresh: args.fresh as boolean,
|
|
525
534
|
logLevel: args['log-level'] as LogLevels,
|
|
526
535
|
schemaVersion: args.schema as PiletSchemaVersion,
|
|
536
|
+
concurrency: args.concurrency as number,
|
|
527
537
|
app: args.app as string,
|
|
528
538
|
hooks: args.hooks as object,
|
|
529
539
|
_: args,
|
|
@@ -590,6 +600,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
590
600
|
.choices('schema', schemaKeys)
|
|
591
601
|
.describe('schema', 'Sets the schema to be used when making a fresh build of the pilet.')
|
|
592
602
|
.default('schema', apps.publishPiletDefaults.schemaVersion)
|
|
603
|
+
.choices('mode', publishModeKeys)
|
|
604
|
+
.describe('mode', 'Sets the authorization mode to use.')
|
|
605
|
+
.default('mode', apps.publishPiletDefaults.mode)
|
|
593
606
|
.choices('bundler', availableBundlers)
|
|
594
607
|
.describe('bundler', 'Sets the bundler to use.')
|
|
595
608
|
.default('bundler', availableBundlers[0])
|
|
@@ -599,6 +612,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
599
612
|
.option('fields', undefined)
|
|
600
613
|
.describe('fields', 'Sets additional fields to be included in the feed service request.')
|
|
601
614
|
.default('fields', apps.publishPiletDefaults.fields)
|
|
615
|
+
.option('headers', undefined)
|
|
616
|
+
.describe('headers', 'Sets additional headers to be included in the feed service request.')
|
|
617
|
+
.default('headers', apps.publishPiletDefaults.headers)
|
|
602
618
|
.string('base')
|
|
603
619
|
.default('base', process.cwd())
|
|
604
620
|
.describe('base', 'Sets the base directory. By default the current directory is used.');
|
|
@@ -615,6 +631,8 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
615
631
|
from: args.from as PiletPublishSource,
|
|
616
632
|
schemaVersion: args.schema as PiletSchemaVersion,
|
|
617
633
|
fields: args.fields as Record<string, string>,
|
|
634
|
+
headers: args.headers as Record<string, string>,
|
|
635
|
+
mode: args.mode as PiletPublishScheme,
|
|
618
636
|
_: args,
|
|
619
637
|
});
|
|
620
638
|
},
|
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,
|