piral-cli 0.15.9-beta.5384 → 0.15.9-beta.5403
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.js +1 -0
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.js +1 -0
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.js +21 -39
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +21 -40
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/common/constants.d.ts +1 -1
- package/lib/common/constants.js +1 -0
- package/lib/common/constants.js.map +1 -1
- package/lib/common/declaration.js +1 -0
- package/lib/common/declaration.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/pack.js +3 -2
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +1 -0
- package/lib/common/package.js +13 -11
- package/lib/common/package.js.map +1 -1
- package/lib/common/platform.d.ts +13 -0
- package/lib/common/platform.js +13 -0
- package/lib/common/platform.js.map +1 -0
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.js +8 -0
- package/lib/common/utils.js.map +1 -0
- package/lib/messages.d.ts +81 -0
- package/lib/messages.js +89 -2
- package/lib/messages.js.map +1 -1
- package/lib/platforms/web.d.ts +3 -0
- package/lib/platforms/web.js +111 -0
- package/lib/platforms/web.js.map +1 -0
- package/lib/types/common.d.ts +29 -0
- package/package.json +2 -2
- package/src/apps/build-pilet.ts +3 -0
- package/src/apps/build-piral.ts +3 -0
- package/src/apps/debug-pilet.ts +24 -49
- package/src/apps/debug-piral.ts +26 -53
- package/src/common/constants.ts +1 -0
- package/src/common/declaration.ts +3 -1
- package/src/common/index.ts +1 -0
- package/src/common/pack.ts +3 -2
- package/src/common/package.ts +13 -12
- package/src/common/platform.ts +27 -0
- package/src/common/utils.ts +3 -0
- package/src/messages.ts +87 -0
- package/src/platforms/web.ts +135 -0
- package/src/types/common.ts +32 -0
package/lib/types/common.d.ts
CHANGED
|
@@ -82,6 +82,35 @@ export interface Bundler {
|
|
|
82
82
|
off(cb: (args: any) => void): void;
|
|
83
83
|
ready(): Promise<void>;
|
|
84
84
|
}
|
|
85
|
+
export interface PlatformStartModuleOptions {
|
|
86
|
+
appRoot: string;
|
|
87
|
+
appDir: string;
|
|
88
|
+
open: boolean;
|
|
89
|
+
fullBase: string;
|
|
90
|
+
feed: string | Array<string>;
|
|
91
|
+
publicUrl: string;
|
|
92
|
+
customkrasrc: string;
|
|
93
|
+
originalPort: number;
|
|
94
|
+
hooks: Record<string, Function>;
|
|
95
|
+
registerWatcher(file: string): void;
|
|
96
|
+
registerEnd(cb: () => void): void;
|
|
97
|
+
maxListeners: number;
|
|
98
|
+
pilets: Array<any>;
|
|
99
|
+
}
|
|
100
|
+
export interface PlatformStartShellOptions {
|
|
101
|
+
open: boolean;
|
|
102
|
+
fullBase: string;
|
|
103
|
+
root: string;
|
|
104
|
+
feed: string | Array<string>;
|
|
105
|
+
targetDir: string;
|
|
106
|
+
publicUrl: string;
|
|
107
|
+
bundler: Bundler;
|
|
108
|
+
customkrasrc: string;
|
|
109
|
+
originalPort: number;
|
|
110
|
+
hooks: Record<string, Function>;
|
|
111
|
+
registerWatcher(file: string): void;
|
|
112
|
+
registerEnd(cb: () => void): void;
|
|
113
|
+
}
|
|
85
114
|
export interface ReleaseProvider {
|
|
86
115
|
(directory: string, files: Array<string>, args: Record<string, string>, interactive: boolean): Promise<void>;
|
|
87
116
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli",
|
|
3
|
-
"version": "0.15.9-beta.
|
|
3
|
+
"version": "0.15.9-beta.5403",
|
|
4
4
|
"description": "The standard CLI for creating and building a Piral instance or a Pilet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"typescript": "^4.0.0",
|
|
81
81
|
"yargs": "^15.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "d1f1d5eabcf01612d13b5b09c2156d0dc906316b"
|
|
84
84
|
}
|
package/src/apps/build-pilet.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
normalizePublicUrl,
|
|
25
25
|
combinePiletExternals,
|
|
26
26
|
retrievePiletsInfo,
|
|
27
|
+
validateSharedDependencies,
|
|
27
28
|
} from '../common';
|
|
28
29
|
|
|
29
30
|
interface PiletData {
|
|
@@ -226,6 +227,8 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
|
|
|
226
227
|
const outDir = dirname(dest);
|
|
227
228
|
const outFile = basename(dest);
|
|
228
229
|
|
|
230
|
+
validateSharedDependencies(importmap);
|
|
231
|
+
|
|
229
232
|
if (fresh) {
|
|
230
233
|
progress('Removing output directory ...');
|
|
231
234
|
await removeDirectory(outDir);
|
package/src/apps/build-piral.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
packageEmulator,
|
|
18
18
|
normalizePublicUrl,
|
|
19
19
|
getDestination,
|
|
20
|
+
validateSharedDependencies,
|
|
20
21
|
} from '../common';
|
|
21
22
|
|
|
22
23
|
const releaseName = 'release';
|
|
@@ -168,6 +169,8 @@ export async function buildPiral(baseDir = process.cwd(), options: BuildPiralOpt
|
|
|
168
169
|
|
|
169
170
|
await checkCliCompatibility(root);
|
|
170
171
|
|
|
172
|
+
validateSharedDependencies(externals);
|
|
173
|
+
|
|
171
174
|
if (fresh) {
|
|
172
175
|
progress('Removing output directory ...');
|
|
173
176
|
await removeDirectory(dest.outDir);
|
package/src/apps/debug-pilet.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { join, dirname, resolve, relative, basename } from 'path';
|
|
2
|
-
import { readKrasConfig, krasrc, buildKrasWithCli } from 'kras';
|
|
3
2
|
import { callDebugPiralFromMonoRepo, callPiletDebug } from '../bundler';
|
|
4
3
|
import { AppDefinition, LogLevels, PiletSchemaVersion } from '../types';
|
|
5
4
|
import {
|
|
@@ -7,8 +6,6 @@ import {
|
|
|
7
6
|
retrievePiletData,
|
|
8
7
|
retrievePiletsInfo,
|
|
9
8
|
config,
|
|
10
|
-
openBrowser,
|
|
11
|
-
notifyServerOnline,
|
|
12
9
|
setLogLevel,
|
|
13
10
|
progress,
|
|
14
11
|
matchAnyPilet,
|
|
@@ -19,11 +16,11 @@ import {
|
|
|
19
16
|
concurrentWorkers,
|
|
20
17
|
normalizePublicUrl,
|
|
21
18
|
findFile,
|
|
22
|
-
createInitialKrasConfig,
|
|
23
|
-
getAvailablePort,
|
|
24
19
|
combinePiletExternals,
|
|
25
20
|
watcherTask,
|
|
26
21
|
flattenExternals,
|
|
22
|
+
validateSharedDependencies,
|
|
23
|
+
configurePlatform,
|
|
27
24
|
} from '../common';
|
|
28
25
|
|
|
29
26
|
export interface DebugPiletOptions {
|
|
@@ -237,7 +234,6 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
237
234
|
|
|
238
235
|
await watcherTask(async (watcherContext) => {
|
|
239
236
|
progress('Reading configuration ...');
|
|
240
|
-
const api = `${publicUrl}${config.piletApi.replace(/^\/+/, '')}`;
|
|
241
237
|
const entryList = Array.isArray(entry) ? entry : [entry];
|
|
242
238
|
const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
|
|
243
239
|
log(
|
|
@@ -269,6 +265,8 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
269
265
|
const outFile = basename(dest);
|
|
270
266
|
const mocksExists = await checkExistingDirectory(mocks);
|
|
271
267
|
|
|
268
|
+
validateSharedDependencies(importmap);
|
|
269
|
+
|
|
272
270
|
await hooks.beforeBuild?.({ root, publicUrl, importmap, entryModule, schemaVersion });
|
|
273
271
|
|
|
274
272
|
const bundler = await callPiletDebug(
|
|
@@ -330,52 +328,29 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
330
328
|
await Promise.all(
|
|
331
329
|
appInstances.sort(byPort).map(async ([appDir, appPort], i) => {
|
|
332
330
|
const appRoot = dirname(await findFile(appDir, 'package.json'));
|
|
331
|
+
const platform = configurePlatform();
|
|
333
332
|
await hooks.afterApp?.({ appInstanceDir, pilets });
|
|
334
333
|
const suggestedPort = appPort || originalPort + i;
|
|
335
|
-
const port = await getAvailablePort(suggestedPort);
|
|
336
|
-
|
|
337
|
-
const sources = pilets.map((m) => m.mocks).filter(Boolean);
|
|
338
|
-
const baseMocks = resolve(fullBase, 'mocks');
|
|
339
|
-
const krasBaseConfig = resolve(fullBase, krasrc);
|
|
340
|
-
const krasRootConfig = resolve(appRoot, krasrc);
|
|
341
|
-
const initial = createInitialKrasConfig(baseMocks, sources, { [api]: '' }, feed);
|
|
342
|
-
const configs = [krasBaseConfig, ...pilets.map((p) => resolve(p.root, krasrc)), krasRootConfig];
|
|
343
|
-
const required = {
|
|
344
|
-
injectors: {
|
|
345
|
-
piral: {
|
|
346
|
-
active: false,
|
|
347
|
-
},
|
|
348
|
-
pilet: {
|
|
349
|
-
active: true,
|
|
350
|
-
pilets,
|
|
351
|
-
app: appDir,
|
|
352
|
-
publicUrl,
|
|
353
|
-
handle: ['/', api],
|
|
354
|
-
api,
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
if (customkrasrc) {
|
|
360
|
-
configs.push(resolve(fullBase, customkrasrc));
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
configs.forEach(cfg => watcherContext.watch(cfg));
|
|
364
|
-
|
|
365
|
-
const krasConfig = readKrasConfig({ port, initial, required }, ...configs);
|
|
366
334
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
335
|
+
await platform.startModule({
|
|
336
|
+
appRoot,
|
|
337
|
+
appDir,
|
|
338
|
+
pilets,
|
|
339
|
+
customkrasrc,
|
|
340
|
+
feed,
|
|
341
|
+
fullBase,
|
|
342
|
+
hooks,
|
|
343
|
+
open,
|
|
344
|
+
originalPort: suggestedPort,
|
|
345
|
+
publicUrl,
|
|
346
|
+
maxListeners,
|
|
347
|
+
registerEnd(cb) {
|
|
348
|
+
return watcherContext.onClean(cb);
|
|
349
|
+
},
|
|
350
|
+
registerWatcher(file) {
|
|
351
|
+
return watcherContext.watch(file);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
379
354
|
}),
|
|
380
355
|
);
|
|
381
356
|
});
|
package/src/apps/debug-piral.ts
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { dirname, join, resolve } from 'path';
|
|
2
|
-
import { readKrasConfig, krasrc, buildKrasWithCli } from 'kras';
|
|
3
2
|
import { callPiralDebug } from '../bundler';
|
|
4
3
|
import { LogLevels } from '../types';
|
|
5
4
|
import {
|
|
6
5
|
retrievePiletsInfo,
|
|
7
6
|
retrievePiralRoot,
|
|
8
|
-
openBrowser,
|
|
9
7
|
checkCliCompatibility,
|
|
10
|
-
notifyServerOnline,
|
|
11
8
|
setLogLevel,
|
|
12
9
|
progress,
|
|
13
|
-
log,
|
|
14
10
|
config,
|
|
15
11
|
normalizePublicUrl,
|
|
12
|
+
configurePlatform,
|
|
16
13
|
logDone,
|
|
17
14
|
getDestination,
|
|
18
|
-
createInitialKrasConfig,
|
|
19
|
-
getAvailablePort,
|
|
20
|
-
checkExistingDirectory,
|
|
21
15
|
watcherTask,
|
|
16
|
+
validateSharedDependencies,
|
|
22
17
|
} from '../common';
|
|
23
18
|
|
|
24
19
|
export interface DebugPiralOptions {
|
|
@@ -126,7 +121,6 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
126
121
|
} = options;
|
|
127
122
|
const publicUrl = normalizePublicUrl(originalPublicUrl);
|
|
128
123
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
129
|
-
const port = await getAvailablePort(originalPort);
|
|
130
124
|
setLogLevel(logLevel);
|
|
131
125
|
|
|
132
126
|
await hooks.onBegin?.({ options, fullBase });
|
|
@@ -140,9 +134,12 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
140
134
|
const dest = getDestination(entryFiles, resolve(fullBase, target));
|
|
141
135
|
|
|
142
136
|
watcherContext.watch(join(root, 'package.json'));
|
|
137
|
+
watcherContext.watch(join(root, 'piral.json'));
|
|
143
138
|
|
|
144
139
|
await checkCliCompatibility(root);
|
|
145
140
|
|
|
141
|
+
validateSharedDependencies(externals);
|
|
142
|
+
|
|
146
143
|
await hooks.beforeBuild?.({ root, publicUrl, externals, entryFiles, piralInstances });
|
|
147
144
|
|
|
148
145
|
const bundler = await callPiralDebug(
|
|
@@ -151,7 +148,7 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
151
148
|
piralInstances,
|
|
152
149
|
optimizeModules,
|
|
153
150
|
hmr,
|
|
154
|
-
externals: externals.map(m => m.name),
|
|
151
|
+
externals: externals.map((m) => m.name),
|
|
155
152
|
publicUrl,
|
|
156
153
|
entryFiles,
|
|
157
154
|
logLevel,
|
|
@@ -172,55 +169,31 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
172
169
|
return { bundler, entryFiles, root };
|
|
173
170
|
});
|
|
174
171
|
|
|
172
|
+
const platform = configurePlatform();
|
|
173
|
+
|
|
175
174
|
const serverRef = await watcherTask(async (watcherContext) => {
|
|
176
175
|
watcherContext.dependOn(buildRef);
|
|
177
|
-
|
|
178
176
|
const { bundler, entryFiles, root } = buildRef.data;
|
|
179
177
|
const targetDir = dirname(entryFiles);
|
|
180
|
-
const krasBaseConfig = resolve(fullBase, krasrc);
|
|
181
|
-
const krasRootConfig = resolve(root, krasrc);
|
|
182
|
-
const mocks = join(targetDir, 'mocks');
|
|
183
|
-
const baseMocks = resolve(fullBase, 'mocks');
|
|
184
|
-
const mocksExist = await checkExistingDirectory(mocks);
|
|
185
|
-
const sources = [mocksExist ? mocks : undefined].filter(Boolean);
|
|
186
|
-
const initial = createInitialKrasConfig(baseMocks, sources);
|
|
187
|
-
const configs = [krasBaseConfig, krasRootConfig];
|
|
188
|
-
const required = {
|
|
189
|
-
injectors: {
|
|
190
|
-
piral: {
|
|
191
|
-
active: true,
|
|
192
|
-
handle: ['/'],
|
|
193
|
-
feed,
|
|
194
|
-
publicUrl,
|
|
195
|
-
bundler,
|
|
196
|
-
},
|
|
197
|
-
pilet: {
|
|
198
|
-
active: false,
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
if (customkrasrc) {
|
|
204
|
-
configs.push(resolve(fullBase, customkrasrc));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
configs.forEach(cfg => watcherContext.watch(cfg));
|
|
208
178
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
179
|
+
await platform.startShell({
|
|
180
|
+
bundler,
|
|
181
|
+
customkrasrc,
|
|
182
|
+
feed,
|
|
183
|
+
fullBase,
|
|
184
|
+
hooks,
|
|
185
|
+
open,
|
|
186
|
+
originalPort,
|
|
187
|
+
publicUrl,
|
|
188
|
+
root,
|
|
189
|
+
targetDir,
|
|
190
|
+
registerEnd(cb) {
|
|
191
|
+
return watcherContext.onClean(cb);
|
|
192
|
+
},
|
|
193
|
+
registerWatcher(file) {
|
|
194
|
+
return watcherContext.watch(file);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
224
197
|
});
|
|
225
198
|
|
|
226
199
|
await Promise.all([buildRef.end, serverRef.end]);
|
package/src/common/constants.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DeclOptions, generateDeclaration, createExcludePlugin, Logger } from 'd
|
|
|
2
2
|
import { dirname, basename, resolve, extname } from 'path';
|
|
3
3
|
import { progress, log, logWarn, logVerbose, logInfo } from './log';
|
|
4
4
|
import { ForceOverwrite } from './enums';
|
|
5
|
-
import { retrievePiralRoot, retrievePiletsInfo, flattenExternals } from './package';
|
|
5
|
+
import { retrievePiralRoot, retrievePiletsInfo, flattenExternals, validateSharedDependencies } from './package';
|
|
6
6
|
import { entryModuleExtensions, piralBaseRoot } from './constants';
|
|
7
7
|
import { readText, getEntryFiles, matchFiles, createFileIfNotExists } from './io';
|
|
8
8
|
import { getModulePath } from '../external';
|
|
@@ -172,6 +172,8 @@ export async function createPiralDeclaration(
|
|
|
172
172
|
logger: createLogger(),
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
validateSharedDependencies(externals);
|
|
176
|
+
|
|
175
177
|
if (options.apis.length) {
|
|
176
178
|
return await createDeclarationFile(options, baseDir, target, forceOverwrite);
|
|
177
179
|
}
|
package/src/common/index.ts
CHANGED
package/src/common/pack.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { tmpdir } from 'os';
|
|
2
2
|
import { resolve, relative, join, dirname, basename } from 'path';
|
|
3
3
|
import { createTgz } from './archive';
|
|
4
|
+
import { onlyUnique } from './utils';
|
|
4
5
|
import { log, progress, fail } from './log';
|
|
5
6
|
import { readJson, copy, removeDirectory, checkExists, makeTempDir, createDirectory } from './io';
|
|
6
7
|
import { getPossiblePiletMainPaths } from './inspect';
|
|
@@ -52,7 +53,7 @@ export async function createPiletPackage(baseDir: string, source: string, target
|
|
|
52
53
|
const readme = resolve(root, 'README.md');
|
|
53
54
|
|
|
54
55
|
if (Array.isArray(pckg.files)) {
|
|
55
|
-
files.push(...pckg.files.map(f => resolve(root, f)));
|
|
56
|
+
files.push(...pckg.files.map((f) => resolve(root, f)));
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
if (await checkExists(readme)) {
|
|
@@ -63,7 +64,7 @@ export async function createPiletPackage(baseDir: string, source: string, target
|
|
|
63
64
|
const cwd = await makeTempDir(prefix);
|
|
64
65
|
log('generalDebug_0003', `Creating package with content from "${content}" ...`);
|
|
65
66
|
|
|
66
|
-
await Promise.all(files.map((file) => copy(file, resolve(cwd, relative(root, file)))));
|
|
67
|
+
await Promise.all(files.filter(onlyUnique).map((file) => copy(file, resolve(cwd, relative(root, file)))));
|
|
67
68
|
|
|
68
69
|
log('generalDebug_0003', `Creating directory if not exist for "${file}" ...`);
|
|
69
70
|
|
package/src/common/package.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { unpackTarball } from './archive';
|
|
|
5
5
|
import { ForceOverwrite } from './enums';
|
|
6
6
|
import { checkAppShellCompatibility } from './compatibility';
|
|
7
7
|
import { deepMerge } from './merge';
|
|
8
|
+
import { onlyUnique } from './utils';
|
|
8
9
|
import { readImportmap } from './importmap';
|
|
9
10
|
import { getHash, checkIsDirectory, matchFiles } from './io';
|
|
10
11
|
import { readJson, copy, updateExistingJson, findFile, checkExists } from './io';
|
|
@@ -546,10 +547,6 @@ export async function findPackageVersion(rootPath: string, packageName: string |
|
|
|
546
547
|
return 'latest';
|
|
547
548
|
}
|
|
548
549
|
|
|
549
|
-
function onlyUnique<T>(value: T, index: number, self: Array<T>) {
|
|
550
|
-
return self.indexOf(value) === index;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
550
|
export function flattenExternals(dependencies: Array<SharedDependency>) {
|
|
554
551
|
return dependencies.map((m) => m.name).filter(onlyUnique);
|
|
555
552
|
}
|
|
@@ -601,13 +598,6 @@ export async function retrievePiletsInfo(entryFile: string) {
|
|
|
601
598
|
};
|
|
602
599
|
const framework = frameworkLibs.find((lib) => lib in dependencies.std || lib in dependencies.dev);
|
|
603
600
|
|
|
604
|
-
// See #591 - we should warn in case somebody shared piral packages
|
|
605
|
-
for (const external of externals) {
|
|
606
|
-
if (external.type === 'local' && external.name.startsWith('piral-') && external.name.indexOf('/') === -1) {
|
|
607
|
-
log('generalWarning_0001', `The dependency "${external.name}" should not be shared.`);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
601
|
return {
|
|
612
602
|
...info,
|
|
613
603
|
externals,
|
|
@@ -621,6 +611,17 @@ export async function retrievePiletsInfo(entryFile: string) {
|
|
|
621
611
|
};
|
|
622
612
|
}
|
|
623
613
|
|
|
614
|
+
export function validateSharedDependencies(externals: Array<SharedDependency>) {
|
|
615
|
+
// See #591 - we should warn in case somebody shared piral packages
|
|
616
|
+
for (const external of externals) {
|
|
617
|
+
const name = external.name;
|
|
618
|
+
|
|
619
|
+
if (external.type === 'local' && name.startsWith('piral-') && name.indexOf('/') === -1) {
|
|
620
|
+
log('invalidSharedDependency_0029', name);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
624
625
|
export function isValidDependency(name: string) {
|
|
625
626
|
// super simple check at the moment
|
|
626
627
|
// just to filter out things like "redux-saga/effects" and "@scope/redux-saga/effects"
|
|
@@ -773,7 +774,7 @@ export async function retrievePiletData(target: string, app?: string) {
|
|
|
773
774
|
const proposedRoot = piletJson ? dirname(piletJson) : target;
|
|
774
775
|
const root = await findPiletRoot(proposedRoot);
|
|
775
776
|
const piletPackage = await readJson(root, 'package.json');
|
|
776
|
-
const piletDefinition: PiletDefinition = piletJson && await readJson(proposedRoot, 'pilet.json');
|
|
777
|
+
const piletDefinition: PiletDefinition = piletJson && (await readJson(proposedRoot, 'pilet.json'));
|
|
777
778
|
const appPackages = await findPiralInstances(app && [app], piletPackage, piletDefinition, target);
|
|
778
779
|
const apps: Array<AppDefinition> = [];
|
|
779
780
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { fail } from './log';
|
|
2
|
+
import { PlatformStartShellOptions, PlatformStartModuleOptions } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface WebPlatformSettings {
|
|
5
|
+
platform: 'web';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface NodePlatformSettings {
|
|
9
|
+
platform: 'node';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PlatformSettings = WebPlatformSettings | NodePlatformSettings;
|
|
13
|
+
|
|
14
|
+
export interface PlatformTarget {
|
|
15
|
+
startShell(options: PlatformStartShellOptions): Promise<void>;
|
|
16
|
+
startModule(options: PlatformStartModuleOptions): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function configurePlatform(target: Partial<PlatformSettings> = {}): PlatformTarget {
|
|
20
|
+
const { platform = 'web' } = target;
|
|
21
|
+
|
|
22
|
+
if (platform === 'web') {
|
|
23
|
+
return require('../platforms/web');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return fail('platformNotSupported_0190', platform);
|
|
27
|
+
}
|
package/src/messages.ts
CHANGED
|
@@ -642,6 +642,70 @@ export function importMapFileNotFound_0028(dir: string, file: string): QuickMess
|
|
|
642
642
|
return [LogLevels.error, '0028', `The importmap "${file}" could not be found at "${dir}".`];
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
/**
|
|
646
|
+
* @kind Warning
|
|
647
|
+
*
|
|
648
|
+
* @summary
|
|
649
|
+
* The given dependency seems to be a Piral plugin and should not be exposed
|
|
650
|
+
* as a shared dependency.
|
|
651
|
+
*
|
|
652
|
+
* @abstract
|
|
653
|
+
* While you should be quite restrictive in general regarding sharing dependencies,
|
|
654
|
+
* there are some dependencies that should never be shared. One area are dependencies
|
|
655
|
+
* that are only meant for the app shell and don't make sense somewhere else.
|
|
656
|
+
*
|
|
657
|
+
* Even though many dependencies might exist that fall into that area the only ones
|
|
658
|
+
* we know for sure are the so-called Piral plugins. These are dependencies that only
|
|
659
|
+
* make sense to be used within an app shell, i.e., a Piral instance (or host application).
|
|
660
|
+
*
|
|
661
|
+
* When the Piral CLI detects that you want to share such a dependency from an app shell,
|
|
662
|
+
* or alternatively within a pilet directly, it will print a warning. There might be false
|
|
663
|
+
* positives here, so having an error here might be a bit too much. Nevertheless, depending
|
|
664
|
+
* on your scenario you might want to treat these warnings as errors.
|
|
665
|
+
*
|
|
666
|
+
* @see
|
|
667
|
+
* - [Sharing dependencies](https://docs.piral.io/concepts/I08-importmap)
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* Check the contents of the available package.json:
|
|
671
|
+
*
|
|
672
|
+
* ```sh
|
|
673
|
+
* cat package.json
|
|
674
|
+
* ```
|
|
675
|
+
*
|
|
676
|
+
* The displayed content should look similar to (i.e., contain an importmap such as):
|
|
677
|
+
*
|
|
678
|
+
* ```json
|
|
679
|
+
* {
|
|
680
|
+
* "importmap": {
|
|
681
|
+
* "imports": {
|
|
682
|
+
* "piral-ng": ""
|
|
683
|
+
* }
|
|
684
|
+
* }
|
|
685
|
+
* }
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* This would share the whole Piral plugin, which does not make much sense. First of all,
|
|
689
|
+
* the plugin is presumably already installed - it even could only be installed in a
|
|
690
|
+
* Piral instance. Second, there is no use of the exported function somewhere else.
|
|
691
|
+
*
|
|
692
|
+
* Instead, you potentially might want to share a submodule. For instance, in the example
|
|
693
|
+
* above the "piral-ng/common" submodule should be shared.
|
|
694
|
+
*
|
|
695
|
+
* ```json
|
|
696
|
+
* {
|
|
697
|
+
* "importmap": {
|
|
698
|
+
* "imports": {
|
|
699
|
+
* "piral-ng/common": ""
|
|
700
|
+
* }
|
|
701
|
+
* }
|
|
702
|
+
* }
|
|
703
|
+
* ```
|
|
704
|
+
*/
|
|
705
|
+
export function invalidSharedDependency_0029(name: string): QuickMessage {
|
|
706
|
+
return [LogLevels.warning, '0029', `The dependency "${name}" should not be shared.`];
|
|
707
|
+
}
|
|
708
|
+
|
|
645
709
|
/**
|
|
646
710
|
* @kind Error
|
|
647
711
|
*
|
|
@@ -2491,6 +2555,7 @@ export function invalidSchemaVersion_0171(schemaVersion: string, schemas: Array<
|
|
|
2491
2555
|
* - [Webpack](https://webpack.js.org)
|
|
2492
2556
|
* - [Parcel](https://parceljs.org)
|
|
2493
2557
|
* - [esbuild](https://esbuild.github.io)
|
|
2558
|
+
* - [rspack](https://www.rspack.dev/)
|
|
2494
2559
|
* - [Pluggable bundlers](https://docs.piral.io/concepts/T02-bundlers)
|
|
2495
2560
|
*
|
|
2496
2561
|
* @example
|
|
@@ -2523,6 +2588,7 @@ export function bundlerMissing_0172(bundlerName: string, installed: Array<string
|
|
|
2523
2588
|
* - [Webpack](https://webpack.js.org)
|
|
2524
2589
|
* - [Parcel](https://parceljs.org)
|
|
2525
2590
|
* - [esbuild](https://esbuild.github.io)
|
|
2591
|
+
* - [rspack](https://www.rspack.dev/)
|
|
2526
2592
|
* - [Pluggable bundlers](https://docs.piral.io/concepts/T02-bundlers)
|
|
2527
2593
|
*
|
|
2528
2594
|
* @example
|
|
@@ -2555,6 +2621,7 @@ export function defaultBundlerMissing_0173(): QuickMessage {
|
|
|
2555
2621
|
* - [Webpack](https://webpack.js.org)
|
|
2556
2622
|
* - [Parcel](https://parceljs.org)
|
|
2557
2623
|
* - [esbuild](https://esbuild.github.io)
|
|
2624
|
+
* - [rspack](https://www.rspack.dev/)
|
|
2558
2625
|
* - [Pluggable bundlers](https://docs.piral.io/concepts/T02-bundlers)
|
|
2559
2626
|
*
|
|
2560
2627
|
* @example
|
|
@@ -2663,6 +2730,26 @@ export function piletJsonNotAvailable_0180(root: string): QuickMessage {
|
|
|
2663
2730
|
return [LogLevels.warning, '0180', `No "pilet.json" was found for the pilet at "${root}".`];
|
|
2664
2731
|
}
|
|
2665
2732
|
|
|
2733
|
+
/**
|
|
2734
|
+
* @kind Error
|
|
2735
|
+
*
|
|
2736
|
+
* @summary
|
|
2737
|
+
* Using the given platform is not supported.
|
|
2738
|
+
*
|
|
2739
|
+
* @abstract
|
|
2740
|
+
* The Piral instance can run on multiple platforms. The platform is specified via
|
|
2741
|
+
* the piral.json file.
|
|
2742
|
+
*
|
|
2743
|
+
* The standard platform is "web", which starts a web server using the server
|
|
2744
|
+
* proxy kras.
|
|
2745
|
+
*
|
|
2746
|
+
* @example
|
|
2747
|
+
* (tbd)
|
|
2748
|
+
*/
|
|
2749
|
+
export function platformNotSupported_0190(platform: string): QuickMessage {
|
|
2750
|
+
return [LogLevels.error, '0190', `The given platform "${platform}" is not supported.`];
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2666
2753
|
/**
|
|
2667
2754
|
* @kind Warning
|
|
2668
2755
|
*
|