piral-cli 0.15.0-alpha.4034 → 0.15.0-alpha.4098
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 +7 -5
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.d.ts +5 -0
- package/lib/apps/debug-pilet.js +10 -7
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/index.js +5 -1
- package/lib/apps/index.js.map +1 -1
- package/lib/apps/new-pilet.js +4 -3
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/build/bundler-calls.d.ts +1 -1
- package/lib/build/run-build-pilet.js.map +1 -1
- package/lib/build/run-build-piral.js.map +1 -1
- package/lib/build/run-debug-mono-piral.js +5 -5
- package/lib/build/run-debug-mono-piral.js.map +1 -1
- package/lib/build/run-debug-pilet.js.map +1 -1
- package/lib/build/run-debug-piral.js.map +1 -1
- package/lib/commands.js +8 -0
- package/lib/commands.js.map +1 -1
- package/lib/common/clients/npm.js +10 -4
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.js +10 -4
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/yarn.js +10 -4
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/config.js.map +1 -1
- package/lib/common/importmap.js +23 -3
- package/lib/common/importmap.js.map +1 -1
- package/lib/common/index.js +5 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/package.d.ts +7 -0
- package/lib/common/package.js +30 -9
- package/lib/common/package.js.map +1 -1
- package/lib/common/scaffold.js.map +1 -1
- package/lib/external/index.js +482 -462
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/injectors/pilet.d.ts +2 -0
- package/lib/injectors/pilet.js +18 -14
- package/lib/injectors/pilet.js.map +1 -1
- package/lib/rules/pilet-has-externals-as-peers.js +1 -1
- package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
- package/lib/types/common.d.ts +3 -1
- package/lib/types/index.js +5 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/public.d.ts +1 -0
- package/package.json +2 -2
- package/src/apps/build-pilet.ts +14 -5
- package/src/apps/debug-pilet.ts +18 -5
- package/src/apps/new-pilet.ts +4 -3
- package/src/build/bundler-calls.ts +1 -1
- package/src/build/run-build-pilet.ts +1 -1
- package/src/build/run-build-piral.ts +1 -1
- package/src/build/run-debug-mono-piral.ts +6 -4
- package/src/build/run-debug-pilet.ts +1 -1
- package/src/build/run-debug-piral.ts +1 -1
- package/src/commands.ts +8 -0
- package/src/common/clients/npm.ts +12 -4
- package/src/common/clients/pnpm.ts +12 -4
- package/src/common/clients/yarn.ts +12 -4
- package/src/common/config.ts +3 -3
- package/src/common/importmap.ts +29 -3
- package/src/common/package.test.ts +2 -2
- package/src/common/package.ts +31 -11
- package/src/common/scaffold.ts +1 -0
- package/src/injectors/pilet.test.ts +6 -0
- package/src/injectors/pilet.ts +22 -15
- package/src/rules/pilet-has-externals-as-peers.ts +2 -2
- package/src/types/common.ts +3 -1
- package/src/types/public.ts +1 -0
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,kDAAgC;AAChC,iDAA+B;AAC/B,iDAA+B"}
|
package/lib/injectors/pilet.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface Pilet {
|
|
|
9
9
|
}
|
|
10
10
|
export interface PiletInjectorConfig extends KrasInjectorConfig {
|
|
11
11
|
pilets: Array<Pilet>;
|
|
12
|
+
publicUrl: string;
|
|
12
13
|
meta: string;
|
|
13
14
|
api: string;
|
|
14
15
|
app: string;
|
|
@@ -21,6 +22,7 @@ interface PiletMetadata {
|
|
|
21
22
|
export default class PiletInjector implements KrasInjector {
|
|
22
23
|
config: PiletInjectorConfig;
|
|
23
24
|
private piletApi;
|
|
25
|
+
private indexPath;
|
|
24
26
|
constructor(options: PiletInjectorConfig, config: KrasConfiguration, core: EventEmitter);
|
|
25
27
|
get active(): boolean;
|
|
26
28
|
set active(value: boolean);
|
package/lib/injectors/pilet.js
CHANGED
|
@@ -57,7 +57,8 @@ class PiletInjector {
|
|
|
57
57
|
this.piletApi = /^https?:/.test(options.api)
|
|
58
58
|
? options.api
|
|
59
59
|
: `${config.ssl ? 'https' : 'http'}://${host}:${config.port}${options.api}`;
|
|
60
|
-
const { pilets, api } = options;
|
|
60
|
+
const { pilets, api, publicUrl } = options;
|
|
61
|
+
this.indexPath = `${publicUrl}index.html`;
|
|
61
62
|
const cbs = {};
|
|
62
63
|
core.on('user-connected', (e) => {
|
|
63
64
|
if (e.target === '*' && e.url === api.substring(1)) {
|
|
@@ -168,24 +169,27 @@ class PiletInjector {
|
|
|
168
169
|
return this.sendContent(content, external_1.mime.getType(target), url);
|
|
169
170
|
}
|
|
170
171
|
handle(req) {
|
|
171
|
-
const { app, api } = this.config;
|
|
172
|
-
const path = req.url.substring(1).split('?')[0];
|
|
172
|
+
const { app, api, publicUrl } = this.config;
|
|
173
173
|
if (!req.target) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
if (req.url.startsWith(publicUrl)) {
|
|
175
|
+
const path = req.url.substring(publicUrl.length).split('?')[0];
|
|
176
|
+
const target = (0, path_1.join)(app, path);
|
|
177
|
+
if ((0, fs_1.existsSync)(target) && (0, fs_1.statSync)(target).isFile()) {
|
|
178
|
+
if (req.url === this.indexPath) {
|
|
179
|
+
return this.sendIndexFile(target, req.url);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return this.sendFile(target, req.url);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else if (req.url !== this.indexPath) {
|
|
186
|
+
return this.handle(Object.assign(Object.assign({}, req), { url: this.indexPath }));
|
|
178
187
|
}
|
|
179
|
-
return this.sendFile(target, req.url);
|
|
180
|
-
}
|
|
181
|
-
else if (req.url !== '/index.html') {
|
|
182
|
-
return this.handle(Object.assign(Object.assign({}, req), { url: '/index.html' }));
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
return undefined;
|
|
186
188
|
}
|
|
189
|
+
return undefined;
|
|
187
190
|
}
|
|
188
191
|
else if (req.target === api) {
|
|
192
|
+
const path = req.url.substring(1).split('?')[0];
|
|
189
193
|
return this.sendResponse(path, req.url);
|
|
190
194
|
}
|
|
191
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pilet.js","sourceRoot":"","sources":["../../src/injectors/pilet.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA0B;AAC1B,+BAA4B;AAE5B,2BAAwD;AAExD,uCAAoC;AACpC,yCAAkD;AAClD,6CAA0C;AAC1C,0CAA0C;AAG1C,MAAM,EAAE,IAAI,EAAE,GAAG,eAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"pilet.js","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G,CAAC,GAAG,CAAC,CAAC;SACzC;IACH,CAAC;CACF;AAxKD,gCAwKC"}
|
|
@@ -26,7 +26,7 @@ Received: Missing "${missingNames.join('", "')}".
|
|
|
26
26
|
function default_1(context, options = 'ignore') {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
if (options !== 'ignore') {
|
|
29
|
-
const
|
|
29
|
+
const externals = yield (0, common_1.retrieveExternals)(context.data.appRoot, context.data.appPackage);
|
|
30
30
|
const markedPeerDependencies = Object.keys(context.peerDependencies);
|
|
31
31
|
const markedPeerModules = context.peerModules;
|
|
32
32
|
const missingExternals = externals
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pilet-has-externals-as-peers.js","sourceRoot":"","sources":["../../src/rules/pilet-has-externals-as-peers.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"pilet-has-externals-as-peers.js","sourceRoot":"","sources":["../../src/rules/pilet-has-externals-as-peers.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,sCAAiF;AAIjF,SAAS,UAAU,CAAC,OAAyB,EAAE,KAAa,EAAE,OAAgC;IAC5F,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,CAAC,KAAK,CACX;MACA,KAAK;;qBAEU,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;CAC7C,CACI,CAAC;KACH;AACH,CAAC;AAED;;GAEG;AACH,mBAA+B,OAAyB,EAAE,UAAmB,QAAQ;;QACnF,IAAI,OAAO,KAAK,QAAQ,EAAE;YACxB,MAAM,SAAS,GAAG,MAAM,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACzF,MAAM,sBA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M,CAAC,KAAK,EAAE,CAAC;yBAChB;qBACF;iBACF;gBAED,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,GAAI;oBAC3C,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,EAAE;wBAC1B,gBAAgB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;qBAC/B;iBACF;aACF;YAED,UAAU,CACR,OAAO,EACP,kBAAkB,EAClB,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CACxC,CAAC;YACF,UAAU,CACR,OAAO,EACP,aAAa,EACb,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CACzC,CAAC;SACH;IACH,CAAC;CAAA;AAlDD,4BAkDC"}
|
package/lib/types/common.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ export interface TemplateFileLocation {
|
|
|
50
50
|
}
|
|
51
51
|
export interface PiletsInfo {
|
|
52
52
|
files: Array<string | TemplateFileLocation>;
|
|
53
|
-
|
|
53
|
+
template: string;
|
|
54
|
+
externals?: Array<string>;
|
|
54
55
|
devDependencies: Record<string, string | true>;
|
|
55
56
|
scripts: Record<string, string>;
|
|
56
57
|
validators: Record<string, any>;
|
|
@@ -94,6 +95,7 @@ export interface PiletRuleContext extends RuleContext {
|
|
|
94
95
|
importmap: Array<SharedDependency>;
|
|
95
96
|
}
|
|
96
97
|
export interface PiralData {
|
|
98
|
+
appRoot: string;
|
|
97
99
|
appFile: string;
|
|
98
100
|
appPackage: any;
|
|
99
101
|
piletPackage: any;
|
package/lib/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB"}
|
package/lib/types/public.d.ts
CHANGED
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.4098",
|
|
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": "02ef35574b29cc5dd93c515bfdf27dd523893b28"
|
|
82
82
|
}
|
package/src/apps/build-pilet.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
checkAppShellPackage,
|
|
22
22
|
cpuCount,
|
|
23
23
|
concurrentWorkers,
|
|
24
|
+
normalizePublicUrl,
|
|
24
25
|
} from '../common';
|
|
25
26
|
|
|
26
27
|
interface PiletData {
|
|
@@ -39,7 +40,7 @@ function createMetadata(outDir: string, outFile: string, pilets: Array<PiletData
|
|
|
39
40
|
name: p.package.name,
|
|
40
41
|
version: p.package.version,
|
|
41
42
|
link: `${publicPath}${p.id}/${p.outFile}`,
|
|
42
|
-
...getPiletSpecMeta(p.path,
|
|
43
|
+
...getPiletSpecMeta(p.path, `${publicPath}${p.id}/`),
|
|
43
44
|
})),
|
|
44
45
|
);
|
|
45
46
|
}
|
|
@@ -74,6 +75,11 @@ export interface BuildPiletOptions {
|
|
|
74
75
|
*/
|
|
75
76
|
target?: string;
|
|
76
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Sets the public URL (path) of the bundle. Only for release output.
|
|
80
|
+
*/
|
|
81
|
+
publicUrl?: string;
|
|
82
|
+
|
|
77
83
|
/**
|
|
78
84
|
* States if minifaction or other post-bundle transformations should be performed.
|
|
79
85
|
*/
|
|
@@ -151,6 +157,7 @@ export interface BuildPiletOptions {
|
|
|
151
157
|
export const buildPiletDefaults: BuildPiletOptions = {
|
|
152
158
|
entry: './src/index',
|
|
153
159
|
target: './dist/index.js',
|
|
160
|
+
publicUrl: '/',
|
|
154
161
|
minify: true,
|
|
155
162
|
logLevel: LogLevels.info,
|
|
156
163
|
type: 'default',
|
|
@@ -167,10 +174,11 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
167
174
|
const {
|
|
168
175
|
entry = buildPiletDefaults.entry,
|
|
169
176
|
target = buildPiletDefaults.target,
|
|
177
|
+
publicUrl: originalPublicUrl = buildPiletDefaults.publicUrl,
|
|
178
|
+
logLevel = buildPiletDefaults.logLevel,
|
|
170
179
|
minify = buildPiletDefaults.minify,
|
|
171
180
|
sourceMaps = buildPiletDefaults.sourceMaps,
|
|
172
181
|
contentHash = buildPiletDefaults.contentHash,
|
|
173
|
-
logLevel = buildPiletDefaults.logLevel,
|
|
174
182
|
fresh = buildPiletDefaults.fresh,
|
|
175
183
|
concurrency = buildPiletDefaults.concurrency,
|
|
176
184
|
optimizeModules = buildPiletDefaults.optimizeModules,
|
|
@@ -182,6 +190,7 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
182
190
|
bundlerName,
|
|
183
191
|
app,
|
|
184
192
|
} = options;
|
|
193
|
+
const publicUrl = normalizePublicUrl(originalPublicUrl);
|
|
185
194
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
186
195
|
const entryList = Array.isArray(entry) ? entry : [entry];
|
|
187
196
|
setLogLevel(logLevel);
|
|
@@ -279,7 +288,7 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
279
288
|
|
|
280
289
|
await copyPilets(outDir, pilets);
|
|
281
290
|
|
|
282
|
-
await createMetadata(outDir, '$pilet-api', pilets,
|
|
291
|
+
await createMetadata(outDir, '$pilet-api', pilets, publicUrl);
|
|
283
292
|
|
|
284
293
|
if (isEmulator) {
|
|
285
294
|
// in case of an emulator assets are not "seen" by the bundler, so we
|
|
@@ -300,7 +309,7 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
300
309
|
contentHash,
|
|
301
310
|
minify,
|
|
302
311
|
externals: [],
|
|
303
|
-
publicUrl
|
|
312
|
+
publicUrl,
|
|
304
313
|
outFile: 'index.html',
|
|
305
314
|
outDir,
|
|
306
315
|
entryFiles: appFile,
|
|
@@ -322,7 +331,7 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
322
331
|
|
|
323
332
|
await copyPilets(outDir, pilets);
|
|
324
333
|
|
|
325
|
-
await createMetadata(outDir, manifest, pilets,
|
|
334
|
+
await createMetadata(outDir, manifest, pilets, publicUrl);
|
|
326
335
|
|
|
327
336
|
logDone(`Manifest available at "${outDir}/${manifest}"!`);
|
|
328
337
|
}
|
package/src/apps/debug-pilet.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
logDone,
|
|
19
19
|
cpuCount,
|
|
20
20
|
concurrentWorkers,
|
|
21
|
+
normalizePublicUrl,
|
|
21
22
|
} from '../common';
|
|
22
23
|
|
|
23
24
|
export interface DebugPiletOptions {
|
|
@@ -59,6 +60,12 @@ export interface DebugPiletOptions {
|
|
|
59
60
|
*/
|
|
60
61
|
port?: number;
|
|
61
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Sets the publicUrl to use.
|
|
65
|
+
* By default, the server is assumed to be at root "/".
|
|
66
|
+
*/
|
|
67
|
+
publicUrl?: string;
|
|
68
|
+
|
|
62
69
|
/**
|
|
63
70
|
* Sets the maximum number of parallel build processes.
|
|
64
71
|
*/
|
|
@@ -116,6 +123,7 @@ export const debugPiletDefaults: DebugPiletOptions = {
|
|
|
116
123
|
entry: './src/index',
|
|
117
124
|
open: config.openBrowser,
|
|
118
125
|
port: config.port,
|
|
126
|
+
publicUrl: '/',
|
|
119
127
|
hmr: true,
|
|
120
128
|
optimizeModules: false,
|
|
121
129
|
schemaVersion: config.schemaVersion,
|
|
@@ -127,17 +135,19 @@ const injectorName = resolve(__dirname, '../injectors/pilet.js');
|
|
|
127
135
|
interface AppInfo {
|
|
128
136
|
emulator: boolean;
|
|
129
137
|
appFile: string;
|
|
138
|
+
publicUrl: string;
|
|
130
139
|
appVersion: string;
|
|
131
140
|
externals: Array<string>;
|
|
132
141
|
piral: string;
|
|
133
142
|
}
|
|
134
143
|
|
|
135
|
-
async function getOrMakeAppDir({ emulator, piral, appFile }: AppInfo, logLevel: LogLevels) {
|
|
144
|
+
async function getOrMakeAppDir({ emulator, piral, appFile, publicUrl }: AppInfo, logLevel: LogLevels) {
|
|
136
145
|
if (!emulator) {
|
|
137
146
|
const { externals, root, ignored } = await retrievePiletsInfo(appFile);
|
|
138
147
|
const { dir } = await callDebugPiralFromMonoRepo({
|
|
139
148
|
root,
|
|
140
149
|
optimizeModules: false,
|
|
150
|
+
publicUrl,
|
|
141
151
|
ignored,
|
|
142
152
|
externals,
|
|
143
153
|
piral,
|
|
@@ -175,6 +185,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
175
185
|
port = debugPiletDefaults.port,
|
|
176
186
|
open = debugPiletDefaults.open,
|
|
177
187
|
hmr = debugPiletDefaults.hmr,
|
|
188
|
+
publicUrl: originalPublicUrl = debugPiletDefaults.publicUrl,
|
|
178
189
|
logLevel = debugPiletDefaults.logLevel,
|
|
179
190
|
concurrency = debugPiletDefaults.concurrency,
|
|
180
191
|
optimizeModules = debugPiletDefaults.optimizeModules,
|
|
@@ -186,13 +197,14 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
186
197
|
appInstanceDir,
|
|
187
198
|
feed,
|
|
188
199
|
} = options;
|
|
200
|
+
const publicUrl = normalizePublicUrl(originalPublicUrl);
|
|
189
201
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
190
202
|
setLogLevel(logLevel);
|
|
191
203
|
|
|
192
204
|
await hooks.onBegin?.({ options, fullBase });
|
|
193
205
|
progress('Reading configuration ...');
|
|
194
206
|
const krasConfig = readKrasConfig({ port }, krasrc);
|
|
195
|
-
const api = config.piletApi
|
|
207
|
+
const api = `${publicUrl}${config.piletApi.replace(/^\/+/, '')}`;
|
|
196
208
|
const entryList = Array.isArray(entry) ? entry : [entry];
|
|
197
209
|
const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
|
|
198
210
|
log('generalDebug_0003', `Looking for (${multi ? 'multi' : 'single'}) "${entryList.join('", "')}" in "${fullBase}".`);
|
|
@@ -232,7 +244,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
232
244
|
krasConfig.sources.push(mocks);
|
|
233
245
|
}
|
|
234
246
|
|
|
235
|
-
await hooks.beforeBuild?.({ root, importmap, entryModule, schemaVersion });
|
|
247
|
+
await hooks.beforeBuild?.({ root, publicUrl, importmap, entryModule, schemaVersion });
|
|
236
248
|
|
|
237
249
|
const bundler = await callPiletDebug(
|
|
238
250
|
{
|
|
@@ -255,12 +267,13 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
255
267
|
);
|
|
256
268
|
|
|
257
269
|
bundler.on((args) => {
|
|
258
|
-
hooks.afterBuild?.({ ...args, root, importmap, entryModule, schemaVersion, bundler, outFile, outDir });
|
|
270
|
+
hooks.afterBuild?.({ ...args, root, publicUrl, importmap, entryModule, schemaVersion, bundler, outFile, outDir });
|
|
259
271
|
});
|
|
260
272
|
|
|
261
273
|
return {
|
|
262
274
|
emulator,
|
|
263
275
|
appFile,
|
|
276
|
+
publicUrl,
|
|
264
277
|
appVersion: appPackage.version,
|
|
265
278
|
externals,
|
|
266
279
|
piral: appPackage.name,
|
|
@@ -294,7 +307,6 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
294
307
|
krasConfig.injectors = defaultConfig.injectors;
|
|
295
308
|
}
|
|
296
309
|
|
|
297
|
-
const publicUrl = '/';
|
|
298
310
|
const { pilet: piletInjector, ...otherInjectors } = krasConfig.injectors;
|
|
299
311
|
const injectorConfig = {
|
|
300
312
|
meta: 'debug-meta.json',
|
|
@@ -303,6 +315,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
303
315
|
active: true,
|
|
304
316
|
pilets,
|
|
305
317
|
app: appDir,
|
|
318
|
+
publicUrl,
|
|
306
319
|
handle: ['/', api],
|
|
307
320
|
api,
|
|
308
321
|
};
|
package/src/apps/new-pilet.ts
CHANGED
|
@@ -101,7 +101,7 @@ export const newPiletDefaults: NewPiletOptions = {
|
|
|
101
101
|
forceOverwrite: ForceOverwrite.no,
|
|
102
102
|
language: config.language,
|
|
103
103
|
install: true,
|
|
104
|
-
template:
|
|
104
|
+
template: undefined,
|
|
105
105
|
logLevel: LogLevels.info,
|
|
106
106
|
npmClient: config.npmClient,
|
|
107
107
|
bundlerName: 'none',
|
|
@@ -184,7 +184,7 @@ always-auth=true`,
|
|
|
184
184
|
|
|
185
185
|
const isEmulator = checkAppShellPackage(piralInfo);
|
|
186
186
|
|
|
187
|
-
const { preScaffold, postScaffold, files } = getPiletsInfo(piralInfo);
|
|
187
|
+
const { preScaffold, postScaffold, files, template: preSelectedTemplate } = getPiletsInfo(piralInfo);
|
|
188
188
|
|
|
189
189
|
if (preScaffold) {
|
|
190
190
|
progress(`Running preScaffold script ...`);
|
|
@@ -195,7 +195,8 @@ always-auth=true`,
|
|
|
195
195
|
progress(`Taking care of templating ...`);
|
|
196
196
|
|
|
197
197
|
const data = getPiletScaffoldData(language, root, packageName, variables);
|
|
198
|
-
|
|
198
|
+
const chosenTemplate = template || preSelectedTemplate || 'default';
|
|
199
|
+
await scaffoldPiletSourceFiles(chosenTemplate, registry, data, forceOverwrite);
|
|
199
200
|
|
|
200
201
|
if (isEmulator) {
|
|
201
202
|
// in the emulator case we get the files (and files_once) from the contained tarballs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { fork, ChildProcess } from 'child_process';
|
|
3
|
-
import { Bundler, BundleDetails, BaseBundleParameters } from '../types';
|
|
3
|
+
import type { Bundler, BundleDetails, BaseBundleParameters } from '../types';
|
|
4
4
|
|
|
5
5
|
function getPath(name: string) {
|
|
6
6
|
return resolve(__dirname, '..', '..', 'lib', 'build', `run-${name}.js`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PiletSchemaVersion, LogLevels, SharedDependency, PiletBuildHandler } from '../types';
|
|
2
1
|
import { setStandardEnvs } from '../common';
|
|
2
|
+
import type { PiletSchemaVersion, LogLevels, SharedDependency, PiletBuildHandler } from '../types';
|
|
3
3
|
|
|
4
4
|
let handler: PiletBuildHandler;
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { LogLevels, PiralBuildHandler } from '../types';
|
|
2
|
-
import { setStandardEnvs, progress, logReset } from '../common';
|
|
3
1
|
import { resolve } from 'path';
|
|
2
|
+
import { setStandardEnvs, progress, logReset } from '../common';
|
|
3
|
+
import type { LogLevels, PiralBuildHandler } from '../types';
|
|
4
4
|
|
|
5
5
|
let handler: PiralBuildHandler;
|
|
6
6
|
|
|
@@ -11,6 +11,7 @@ function run(
|
|
|
11
11
|
piral: string,
|
|
12
12
|
hmr: boolean,
|
|
13
13
|
externals: Array<string>,
|
|
14
|
+
publicUrl: string,
|
|
14
15
|
entryFiles: string,
|
|
15
16
|
logLevel: LogLevels,
|
|
16
17
|
args: any,
|
|
@@ -20,7 +21,7 @@ function run(
|
|
|
20
21
|
setStandardEnvs({
|
|
21
22
|
piral,
|
|
22
23
|
dependencies: externals,
|
|
23
|
-
publicPath:
|
|
24
|
+
publicPath: publicUrl,
|
|
24
25
|
production: false,
|
|
25
26
|
debugPiral: true,
|
|
26
27
|
debugPilet: true,
|
|
@@ -37,7 +38,7 @@ function run(
|
|
|
37
38
|
sourceMaps: true,
|
|
38
39
|
contentHash: false,
|
|
39
40
|
minify: false,
|
|
40
|
-
publicUrl
|
|
41
|
+
publicUrl,
|
|
41
42
|
hmr,
|
|
42
43
|
logLevel,
|
|
43
44
|
watch: true,
|
|
@@ -61,6 +62,7 @@ process.on('message', async (msg) => {
|
|
|
61
62
|
msg.piral,
|
|
62
63
|
true,
|
|
63
64
|
msg.externals,
|
|
65
|
+
msg.publicUrl,
|
|
64
66
|
msg.entryFiles,
|
|
65
67
|
msg.logLevel,
|
|
66
68
|
msg,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setStandardEnvs } from '../common';
|
|
1
2
|
import type {
|
|
2
3
|
PiletSchemaVersion,
|
|
3
4
|
LogLevels,
|
|
@@ -5,7 +6,6 @@ import type {
|
|
|
5
6
|
BundleHandlerResponse,
|
|
6
7
|
PiletBuildHandler,
|
|
7
8
|
} from '../types';
|
|
8
|
-
import { setStandardEnvs } from '../common';
|
|
9
9
|
|
|
10
10
|
let handler: PiletBuildHandler;
|
|
11
11
|
let bundler: BundleHandlerResponse;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BundleHandlerResponse, LogLevels, PiralBuildHandler } from '../types';
|
|
2
1
|
import { setStandardEnvs } from '../common';
|
|
2
|
+
import type { BundleHandlerResponse, LogLevels, PiralBuildHandler } from '../types';
|
|
3
3
|
|
|
4
4
|
let handler: PiralBuildHandler;
|
|
5
5
|
let bundler: BundleHandlerResponse;
|
package/src/commands.ts
CHANGED
|
@@ -410,6 +410,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
410
410
|
.string('target')
|
|
411
411
|
.describe('target', 'Sets the target directory or file of bundling.')
|
|
412
412
|
.default('target', apps.debugPiletDefaults.target)
|
|
413
|
+
.string('public-url')
|
|
414
|
+
.describe('public-url', 'Sets the public URL (path) of the application.')
|
|
415
|
+
.default('public-url', apps.debugPiletDefaults.publicUrl)
|
|
413
416
|
.number('port')
|
|
414
417
|
.describe('port', 'Sets the port of the local development server.')
|
|
415
418
|
.default('port', apps.debugPiletDefaults.port)
|
|
@@ -448,6 +451,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
448
451
|
return apps.debugPilet(args.base as string, {
|
|
449
452
|
entry: args.source as string,
|
|
450
453
|
target: args.target as string,
|
|
454
|
+
publicUrl: args['public-url'] as string,
|
|
451
455
|
port: args.port as number,
|
|
452
456
|
hmr: args.hmr as boolean,
|
|
453
457
|
bundlerName: args.bundler as string,
|
|
@@ -480,6 +484,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
480
484
|
.string('target')
|
|
481
485
|
.describe('target', 'Sets the target file of bundling.')
|
|
482
486
|
.default('target', apps.buildPiletDefaults.target)
|
|
487
|
+
.string('public-url')
|
|
488
|
+
.describe('public-url', 'Sets the public URL (path) of the application.')
|
|
489
|
+
.default('public-url', apps.buildPiletDefaults.publicUrl)
|
|
483
490
|
.number('log-level')
|
|
484
491
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
485
492
|
.default('log-level', apps.buildPiletDefaults.logLevel)
|
|
@@ -523,6 +530,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
523
530
|
return apps.buildPilet(args.base as string, {
|
|
524
531
|
entry: args.source as string,
|
|
525
532
|
target: args.target as string,
|
|
533
|
+
publicUrl: args['public-url'] as string,
|
|
526
534
|
minify: args.minify as boolean,
|
|
527
535
|
contentHash: args['content-hash'] as boolean,
|
|
528
536
|
bundlerName: args.bundler as string,
|
|
@@ -24,10 +24,18 @@ export async function unpackPackage(packageRef: string, target = '.', ...flags:
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
try {
|
|
28
|
+
const ms = new MemoryStream();
|
|
29
|
+
await runNpmProcess(['install', packageRef, '--legacy-peer-deps', ...flags], target, ms);
|
|
30
|
+
log('generalDebug_0003', `npm install package result: ${ms.value}`);
|
|
31
|
+
return ms.value;
|
|
32
|
+
} catch (ex) {
|
|
33
|
+
log(
|
|
34
|
+
'generalError_0002',
|
|
35
|
+
`Could not install the package "${packageRef}" using npm. Make sure npm is correctly installed and accessible: ${ex}`,
|
|
36
|
+
);
|
|
37
|
+
throw ex;
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
export async function createPackage(target = '.', ...flags: Array<string>) {
|
|
@@ -29,8 +29,16 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
try {
|
|
33
|
+
const ms = new MemoryStream();
|
|
34
|
+
await runPnpmProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
35
|
+
log('generalDebug_0003', `Pnpm install package result: ${ms.value}`);
|
|
36
|
+
return ms.value;
|
|
37
|
+
} catch (ex) {
|
|
38
|
+
log(
|
|
39
|
+
'generalError_0002',
|
|
40
|
+
`Could not install the package "${packageRef}" using Pnpm. Make sure Pnpm is correctly installed and accessible: ${ex}`,
|
|
41
|
+
);
|
|
42
|
+
throw ex;
|
|
43
|
+
}
|
|
36
44
|
}
|
|
@@ -33,8 +33,16 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
try {
|
|
37
|
+
const ms = new MemoryStream();
|
|
38
|
+
await runYarnProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
39
|
+
log('generalDebug_0003', `Yarn install package result: ${ms.value}`);
|
|
40
|
+
return ms.value;
|
|
41
|
+
} catch (ex) {
|
|
42
|
+
log(
|
|
43
|
+
'generalError_0002',
|
|
44
|
+
`Could not install the package "${packageRef}" using Yarn. Make sure Yarn@1 is correctly installed and accessible: ${ex}`,
|
|
45
|
+
);
|
|
46
|
+
throw ex;
|
|
47
|
+
}
|
|
40
48
|
}
|
package/src/common/config.ts
CHANGED
|
@@ -72,11 +72,11 @@ export const config: PiralCliConfig = rc(
|
|
|
72
72
|
apiKeys: {},
|
|
73
73
|
url: undefined,
|
|
74
74
|
cert: undefined,
|
|
75
|
-
npmClient: 'npm',
|
|
76
|
-
bundler: 'webpack5',
|
|
75
|
+
npmClient: 'npm' as const,
|
|
76
|
+
bundler: 'webpack5' as const,
|
|
77
77
|
piletApi: '/$pilet-api',
|
|
78
78
|
validators: {},
|
|
79
|
-
schemaVersion: 'v2',
|
|
79
|
+
schemaVersion: 'v2' as const,
|
|
80
80
|
openBrowser: false,
|
|
81
81
|
port: 1234,
|
|
82
82
|
language: SourceLanguage.ts,
|