piral-cli 1.4.0-beta.6243 → 1.4.0-beta.6247
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/add-piral-instance-pilet.js +2 -4
- package/lib/apps/add-piral-instance-pilet.js.map +1 -1
- package/lib/apps/new-pilet.js +2 -1
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/run-emulator-piral.js +3 -1
- package/lib/apps/run-emulator-piral.js.map +1 -1
- package/lib/build/bundler-calls.d.ts +2 -2
- package/lib/build/bundler-calls.js +4 -4
- package/lib/build/bundler-calls.js.map +1 -1
- package/lib/bundler.js +5 -5
- package/lib/bundler.js.map +1 -1
- package/lib/common/emulator.js +5 -4
- package/lib/common/emulator.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/npm.d.ts +1 -0
- package/lib/common/npm.js +16 -4
- package/lib/common/npm.js.map +1 -1
- package/lib/common/package.d.ts +6 -3
- package/lib/common/package.js +28 -20
- package/lib/common/package.js.map +1 -1
- package/lib/common/shell.d.ts +2 -2
- package/lib/common/shell.js +14 -5
- package/lib/common/shell.js.map +1 -1
- package/lib/common/website.d.ts +2 -0
- package/lib/common/website.js +70 -0
- package/lib/common/website.js.map +1 -0
- package/lib/types/common.d.ts +22 -0
- package/lib/types/common.js.map +1 -1
- package/lib/types/internal.d.ts +7 -4
- package/lib/types/public.d.ts +2 -1
- package/package.json +2 -2
- package/src/apps/add-piral-instance-pilet.ts +2 -1
- package/src/apps/new-pilet.ts +2 -1
- package/src/apps/run-emulator-piral.ts +3 -1
- package/src/build/bundler-calls.ts +4 -4
- package/src/bundler.test.ts +5 -5
- package/src/bundler.ts +5 -5
- package/src/common/emulator.ts +28 -32
- package/src/common/index.ts +1 -0
- package/src/common/npm.ts +16 -3
- package/src/common/package.ts +22 -36
- package/src/common/shell.ts +15 -14
- package/src/common/website.ts +67 -0
- package/src/types/common.ts +24 -0
- package/src/types/internal.ts +8 -7
- package/src/types/public.ts +2 -1
package/src/bundler.ts
CHANGED
|
@@ -122,7 +122,7 @@ export async function callPiralDebug(args: DebugPiralParameters, bundlerName?: s
|
|
|
122
122
|
try {
|
|
123
123
|
const action = bundler.actions.debugPiral;
|
|
124
124
|
const params = await prepareArgs(action, args);
|
|
125
|
-
return await callDynamic('debug-piral', action.path, params);
|
|
125
|
+
return await callDynamic('debug-piral', action.path, params, action.exec);
|
|
126
126
|
} catch (err) {
|
|
127
127
|
fail('bundlingFailed_0174', err);
|
|
128
128
|
}
|
|
@@ -134,7 +134,7 @@ export async function callPiletDebug(args: DebugPiletParameters, bundlerName?: s
|
|
|
134
134
|
try {
|
|
135
135
|
const action = bundler.actions.debugPilet;
|
|
136
136
|
const params = await prepareArgs(action, args);
|
|
137
|
-
return await callDynamic('debug-pilet', action.path, params);
|
|
137
|
+
return await callDynamic('debug-pilet', action.path, params, action.exec);
|
|
138
138
|
} catch (err) {
|
|
139
139
|
fail('bundlingFailed_0174', err);
|
|
140
140
|
}
|
|
@@ -146,7 +146,7 @@ export async function callPiralBuild(args: BuildPiralParameters, bundlerName?: s
|
|
|
146
146
|
try {
|
|
147
147
|
const action = bundler.actions.buildPiral;
|
|
148
148
|
const params = await prepareArgs(action, args);
|
|
149
|
-
const instance = await callStatic('build-piral', action.path, params);
|
|
149
|
+
const instance = await callStatic('build-piral', action.path, params, action.exec);
|
|
150
150
|
return instance.bundle;
|
|
151
151
|
} catch (err) {
|
|
152
152
|
fail('bundlingFailed_0174', err);
|
|
@@ -159,7 +159,7 @@ export async function callPiletBuild(args: BuildPiletParameters, bundlerName?: s
|
|
|
159
159
|
try {
|
|
160
160
|
const action = bundler.actions.buildPilet;
|
|
161
161
|
const params = await prepareArgs(action, args);
|
|
162
|
-
const instance = await callStatic('build-pilet', action.path, params);
|
|
162
|
+
const instance = await callStatic('build-pilet', action.path, params, action.exec);
|
|
163
163
|
return instance.bundle;
|
|
164
164
|
} catch (err) {
|
|
165
165
|
fail('bundlingFailed_0174', err);
|
|
@@ -175,7 +175,7 @@ export async function callDebugPiralFromMonoRepo(
|
|
|
175
175
|
try {
|
|
176
176
|
const action = bundler.actions.watchPiral;
|
|
177
177
|
const params = await prepareArgs(action, args);
|
|
178
|
-
const instance = await callStatic('debug-mono-piral', action.path, params);
|
|
178
|
+
const instance = await callStatic('debug-mono-piral', action.path, params, action.exec);
|
|
179
179
|
return instance.bundle;
|
|
180
180
|
} catch (err) {
|
|
181
181
|
fail('bundlingFailed_0174', err);
|
package/src/common/emulator.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { ForceOverwrite } from './enums';
|
|
|
9
9
|
import { createTarball } from './archive';
|
|
10
10
|
import { createDirectory, removeDirectory, matchFiles, removeAny, getFileNames } from './io';
|
|
11
11
|
import { updateExistingJson, readJson, writeJson, createFileIfNotExists } from './io';
|
|
12
|
-
import { LogLevels, SharedDependency, PiletsInfo, TemplateFileLocation } from '../types';
|
|
12
|
+
import { EmulatorWebsiteManifest, LogLevels, SharedDependency, PiletsInfo, TemplateFileLocation } from '../types';
|
|
13
13
|
|
|
14
14
|
export async function createEmulatorSources(
|
|
15
15
|
sourceDir: string,
|
|
@@ -102,7 +102,7 @@ export async function createEmulatorSources(
|
|
|
102
102
|
},
|
|
103
103
|
main: `./${join(appDir, 'index.js')}`,
|
|
104
104
|
typings: `./${join(appDir, 'index.d.ts')}`,
|
|
105
|
-
app: `./${join(appDir, '
|
|
105
|
+
app: `./${join(appDir, 'index.html')}`,
|
|
106
106
|
peerDependencies: {},
|
|
107
107
|
optionalDependencies,
|
|
108
108
|
devDependencies: {
|
|
@@ -211,38 +211,34 @@ export async function createEmulatorWebsite(
|
|
|
211
211
|
}, {} as Record<string, string>);
|
|
212
212
|
|
|
213
213
|
const allFiles = await matchFiles(targetDir, '*');
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
optional: optionalDependencies,
|
|
238
|
-
included: {
|
|
239
|
-
...allDeps,
|
|
240
|
-
...externalDependencies,
|
|
241
|
-
},
|
|
214
|
+
const data: EmulatorWebsiteManifest = {
|
|
215
|
+
name: piralPkg.name,
|
|
216
|
+
description: piralPkg.description,
|
|
217
|
+
version: piralPkg.version,
|
|
218
|
+
timestamp: new Date().toISOString(),
|
|
219
|
+
scaffolding: {
|
|
220
|
+
pilets,
|
|
221
|
+
cli: cliVersion,
|
|
222
|
+
},
|
|
223
|
+
files: {
|
|
224
|
+
typings: 'index.d.ts',
|
|
225
|
+
main: basename(targetFile),
|
|
226
|
+
app: 'index.html',
|
|
227
|
+
assets: allFiles.map((file) => relative(targetDir, file)),
|
|
228
|
+
},
|
|
229
|
+
importmap: {
|
|
230
|
+
imports: importmapEntries,
|
|
231
|
+
},
|
|
232
|
+
dependencies: {
|
|
233
|
+
optional: optionalDependencies,
|
|
234
|
+
included: {
|
|
235
|
+
...allDeps,
|
|
236
|
+
...externalDependencies,
|
|
242
237
|
},
|
|
243
238
|
},
|
|
244
|
-
|
|
245
|
-
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
await writeJson(targetDir, 'emulator.json', data, true);
|
|
246
242
|
|
|
247
243
|
// generate the associated index.d.ts
|
|
248
244
|
await createPiralDeclaration(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, ForceOverwrite.yes, logLevel);
|
package/src/common/index.ts
CHANGED
package/src/common/npm.ts
CHANGED
|
@@ -195,7 +195,7 @@ export function publishNpmPackage(
|
|
|
195
195
|
interactive = false,
|
|
196
196
|
): Promise<string> {
|
|
197
197
|
const { publishPackage, loginUser } = clients.npm;
|
|
198
|
-
return publishPackage(target, file, ...flags).catch(err => {
|
|
198
|
+
return publishPackage(target, file, ...flags).catch((err) => {
|
|
199
199
|
if (!interactive) {
|
|
200
200
|
throw err;
|
|
201
201
|
}
|
|
@@ -266,13 +266,13 @@ export function makeNpmAlias(name: string, version: string) {
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
export function isGitPackage(fullName: string) {
|
|
269
|
-
log('generalDebug_0003', 'Checking if its a
|
|
269
|
+
log('generalDebug_0003', 'Checking if its a git package ...');
|
|
270
270
|
|
|
271
271
|
if (fullName) {
|
|
272
272
|
const gitted = fullName.startsWith(gitPrefix);
|
|
273
273
|
|
|
274
274
|
if (gitted || /^(https?|ssh):\/\/.*\.git$/.test(fullName)) {
|
|
275
|
-
log('generalDebug_0003', 'Found a
|
|
275
|
+
log('generalDebug_0003', 'Found a git package by name.');
|
|
276
276
|
return true;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
@@ -280,6 +280,17 @@ export function isGitPackage(fullName: string) {
|
|
|
280
280
|
return false;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
export function isRemotePackage(fullName: string) {
|
|
284
|
+
log('generalDebug_0003', 'Checking if its a remote package ...');
|
|
285
|
+
|
|
286
|
+
if (fullName && /^https?:\/\/.*/.test(fullName)) {
|
|
287
|
+
log('generalDebug_0003', 'Found a remote package by name.');
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
|
|
283
294
|
export function makeGitUrl(fullName: string) {
|
|
284
295
|
const gitted = fullName.startsWith(gitPrefix);
|
|
285
296
|
return gitted ? fullName : `${gitPrefix}${fullName}`;
|
|
@@ -309,6 +320,8 @@ export async function dissectPackageName(
|
|
|
309
320
|
if (isGitPackage(fullName)) {
|
|
310
321
|
const gitUrl = makeGitUrl(fullName);
|
|
311
322
|
return [gitUrl, 'latest', false, 'git'];
|
|
323
|
+
} else if (isRemotePackage(fullName)) {
|
|
324
|
+
return [fullName, 'latest', false, 'remote'];
|
|
312
325
|
} else if (isLocalPackage(baseDir, fullName)) {
|
|
313
326
|
const fullPath = resolveAbsPath(baseDir, fullName);
|
|
314
327
|
const exists = await checkExists(fullPath);
|
package/src/common/package.ts
CHANGED
|
@@ -11,34 +11,15 @@ import { getHash, checkIsDirectory, matchFiles } from './io';
|
|
|
11
11
|
import { readJson, copy, updateExistingJson, findFile, checkExists } from './io';
|
|
12
12
|
import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath, tryResolvePackage, isNpmPackage } from './npm';
|
|
13
13
|
import { makePiletExternals, makeExternals, findPackageRoot, findSpecificVersion, makeNpmAlias } from './npm';
|
|
14
|
-
import {
|
|
14
|
+
import { scaffoldFromEmulatorWebsite } from './website';
|
|
15
15
|
import { getDependencies, getDependencyPackages, getDevDependencies } from './language';
|
|
16
16
|
import { getDevDependencyPackages, getFrameworkDependencies } from './language';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
bundlerNames,
|
|
24
|
-
frameworkLibs,
|
|
25
|
-
piralJson,
|
|
26
|
-
piletJson,
|
|
27
|
-
packageJson,
|
|
28
|
-
} from './constants';
|
|
29
|
-
import {
|
|
30
|
-
SourceLanguage,
|
|
31
|
-
Framework,
|
|
32
|
-
FileInfo,
|
|
33
|
-
PiletsInfo,
|
|
34
|
-
TemplateFileLocation,
|
|
35
|
-
PiletPackageData,
|
|
36
|
-
PiralPackageData,
|
|
37
|
-
SharedDependency,
|
|
38
|
-
PiletDefinition,
|
|
39
|
-
AppDefinition,
|
|
40
|
-
PiralInstancePackageData,
|
|
41
|
-
} from '../types';
|
|
17
|
+
import { piralJsonSchemaUrl, piletJsonSchemaUrl, filesTar, filesOnceTar, bundlerNames } from './constants';
|
|
18
|
+
import { frameworkLibs, declarationEntryExtensions, piralJson, piletJson, packageJson } from './constants';
|
|
19
|
+
import { getModulePath } from '../external';
|
|
20
|
+
import { PiletsInfo, SharedDependency, PiletDefinition, AppDefinition } from '../types';
|
|
21
|
+
import { SourceLanguage, PiralInstancePackageData, PiralInstanceDetails } from '../types';
|
|
22
|
+
import { Framework, FileInfo, TemplateFileLocation, PiletPackageData, PiralPackageData } from '../types';
|
|
42
23
|
|
|
43
24
|
export interface PiralInstanceData {
|
|
44
25
|
packageName: Framework;
|
|
@@ -168,10 +149,10 @@ export function getPiralPath(root: string, name: string) {
|
|
|
168
149
|
|
|
169
150
|
export async function findPiralInstance(
|
|
170
151
|
proposedApp: string,
|
|
171
|
-
|
|
172
|
-
|
|
152
|
+
rootDir: string,
|
|
153
|
+
details?: PiralInstanceDetails,
|
|
173
154
|
): Promise<PiralInstancePackageData> {
|
|
174
|
-
const path = findPackageRoot(proposedApp,
|
|
155
|
+
const path = findPackageRoot(proposedApp, rootDir);
|
|
175
156
|
|
|
176
157
|
if (path) {
|
|
177
158
|
log('generalDebug_0003', `Following the app package in "${path}" ...`);
|
|
@@ -180,8 +161,13 @@ export async function findPiralInstance(
|
|
|
180
161
|
const relPath = appPackage && appPackage.app;
|
|
181
162
|
appPackage.app = relPath && resolve(root, relPath);
|
|
182
163
|
appPackage.root = root;
|
|
183
|
-
appPackage.port = port;
|
|
164
|
+
appPackage.port = details?.port || 0;
|
|
184
165
|
return appPackage;
|
|
166
|
+
} else if (details?.url) {
|
|
167
|
+
const { url, ...rest } = details;
|
|
168
|
+
log('generalDebug_0003', `Piral instance not installed yet - trying from remote "${url}" ...`);
|
|
169
|
+
await scaffoldFromEmulatorWebsite(rootDir, url);
|
|
170
|
+
return await findPiralInstance(proposedApp, rootDir, rest);
|
|
185
171
|
}
|
|
186
172
|
|
|
187
173
|
fail('appInstanceNotFound_0010', proposedApp);
|
|
@@ -191,7 +177,7 @@ export async function findPiralInstances(
|
|
|
191
177
|
proposedApps: Array<string>,
|
|
192
178
|
piletPackage: PiletPackageData,
|
|
193
179
|
piletDefinition: undefined | PiletDefinition,
|
|
194
|
-
|
|
180
|
+
rootDir: string,
|
|
195
181
|
) {
|
|
196
182
|
if (proposedApps) {
|
|
197
183
|
// do nothing
|
|
@@ -209,7 +195,7 @@ export async function findPiralInstances(
|
|
|
209
195
|
if (proposedApps.length > 0) {
|
|
210
196
|
return Promise.all(
|
|
211
197
|
proposedApps.map((proposedApp) =>
|
|
212
|
-
findPiralInstance(proposedApp,
|
|
198
|
+
findPiralInstance(proposedApp, rootDir, piletDefinition?.piralInstances?.[proposedApp]),
|
|
213
199
|
),
|
|
214
200
|
);
|
|
215
201
|
}
|
|
@@ -220,7 +206,7 @@ export async function findPiralInstances(
|
|
|
220
206
|
export function readPiralPackage(root: string, name: string): Promise<PiralPackageData> {
|
|
221
207
|
log('generalDebug_0003', `Reading the piral package in "${root}" ...`);
|
|
222
208
|
const path = getPiralPath(root, name);
|
|
223
|
-
return readJson(path,
|
|
209
|
+
return readJson(path, packageJson);
|
|
224
210
|
}
|
|
225
211
|
|
|
226
212
|
export async function patchPiralPackage(
|
|
@@ -653,7 +639,7 @@ export async function patchPiletPackage(
|
|
|
653
639
|
version: string,
|
|
654
640
|
piralInfo: PiralPackageData,
|
|
655
641
|
fromEmulator: boolean,
|
|
656
|
-
newInfo?: { language: SourceLanguage; bundler: string },
|
|
642
|
+
newInfo?: { language: SourceLanguage; bundler: string; details: PiralInstanceDetails },
|
|
657
643
|
) {
|
|
658
644
|
log('generalDebug_0003', `Patching the package.json in "${root}" ...`);
|
|
659
645
|
const pkg = await getPiletPackage(root, name, version, piralInfo, fromEmulator, newInfo);
|
|
@@ -664,7 +650,7 @@ export async function patchPiletPackage(
|
|
|
664
650
|
await updateExistingJson(root, piletJson, {
|
|
665
651
|
$schema: piletJsonSchemaUrl,
|
|
666
652
|
piralInstances: {
|
|
667
|
-
[name]: {},
|
|
653
|
+
[name]: newInfo?.details || {},
|
|
668
654
|
},
|
|
669
655
|
});
|
|
670
656
|
log('generalDebug_0003', `Succesfully patched the pilet.json.`);
|
|
@@ -797,7 +783,7 @@ export async function retrievePiletData(target: string, app?: string) {
|
|
|
797
783
|
const root = await findPiletRoot(proposedRoot);
|
|
798
784
|
const piletPackage = await readJson(root, 'package.json');
|
|
799
785
|
const piletDefinition: PiletDefinition = piletJsonPath && (await readJson(proposedRoot, piletJson));
|
|
800
|
-
const appPackages = await findPiralInstances(app && [app], piletPackage, piletDefinition,
|
|
786
|
+
const appPackages = await findPiralInstances(app && [app], piletPackage, piletDefinition, root);
|
|
801
787
|
const apps: Array<AppDefinition> = [];
|
|
802
788
|
|
|
803
789
|
for (const appPackage of appPackages) {
|
package/src/common/shell.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { progress } from './log';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
getPackageVersion,
|
|
7
|
-
installNpmPackage,
|
|
8
|
-
isLinkedPackage,
|
|
9
|
-
} from './npm';
|
|
10
|
-
import { NpmClientType } from '../types';
|
|
2
|
+
import { scaffoldFromEmulatorWebsite } from './website';
|
|
3
|
+
import { combinePackageRef, getPackageName, getPackageVersion } from './npm';
|
|
4
|
+
import { dissectPackageName, installNpmPackage, isLinkedPackage } from './npm';
|
|
5
|
+
import { NpmClientType, PiralInstanceDetails } from '../types';
|
|
11
6
|
|
|
12
7
|
export async function installPiralInstance(
|
|
13
8
|
usedSource: string,
|
|
14
9
|
baseDir: string,
|
|
15
10
|
rootDir: string,
|
|
16
11
|
npmClient: NpmClientType,
|
|
17
|
-
): Promise<[name: string, version: string]> {
|
|
12
|
+
): Promise<[name: string, version: string, details: PiralInstanceDetails]> {
|
|
18
13
|
const [sourceName, sourceVersion, hadVersion, type] = await dissectPackageName(baseDir, usedSource);
|
|
19
|
-
const isLocal = isLinkedPackage(sourceName, type, hadVersion, rootDir);
|
|
20
14
|
|
|
21
|
-
if (
|
|
15
|
+
if (type === 'remote') {
|
|
16
|
+
progress(`Downloading emulator from %s ...`, sourceName);
|
|
17
|
+
const emulatorJson = await scaffoldFromEmulatorWebsite(rootDir, sourceName);
|
|
18
|
+
const details = {
|
|
19
|
+
url: sourceName,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return [emulatorJson.name, emulatorJson.version, details];
|
|
23
|
+
} else if (!isLinkedPackage(sourceName, type, hadVersion, rootDir)) {
|
|
22
24
|
const packageRef = combinePackageRef(sourceName, sourceVersion, type);
|
|
23
25
|
|
|
24
26
|
progress(`Installing npm package %s ...`, packageRef);
|
|
@@ -29,6 +31,5 @@ export async function installPiralInstance(
|
|
|
29
31
|
|
|
30
32
|
const packageName = await getPackageName(rootDir, sourceName, type);
|
|
31
33
|
const packageVersion = getPackageVersion(hadVersion, sourceName, sourceVersion, type, rootDir);
|
|
32
|
-
|
|
33
|
-
return [packageName, packageVersion];
|
|
34
|
+
return [packageName, packageVersion, {}];
|
|
34
35
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { resolve as resolveUrl } from 'url';
|
|
2
|
+
import { join, resolve } from 'path';
|
|
3
|
+
import { createPiralStubIndexIfNotExists } from './template';
|
|
4
|
+
import { packageJson } from './constants';
|
|
5
|
+
import { ForceOverwrite } from './enums';
|
|
6
|
+
import { createDirectory, writeBinary } from './io';
|
|
7
|
+
import { writeJson } from './io';
|
|
8
|
+
import { axios } from '../external';
|
|
9
|
+
import { EmulatorWebsiteManifestFiles, EmulatorWebsiteManifest } from '../types';
|
|
10
|
+
|
|
11
|
+
async function downloadEmulatorFiles(manifestUrl: string, target: string, files: EmulatorWebsiteManifestFiles) {
|
|
12
|
+
const requiredFiles = [files.typings, files.main, files.app];
|
|
13
|
+
|
|
14
|
+
await Promise.all(
|
|
15
|
+
requiredFiles.map(async (file) => {
|
|
16
|
+
const res = await axios.default.get(resolveUrl(manifestUrl, file), { responseType: 'arraybuffer' });
|
|
17
|
+
const data: Buffer = res.data;
|
|
18
|
+
await writeBinary(target, file, data);
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function scaffoldFromEmulatorWebsite(rootDir: string, manifestUrl: string) {
|
|
24
|
+
const response = await axios.default.get(manifestUrl);
|
|
25
|
+
const emulatorJson: EmulatorWebsiteManifest = response.data;
|
|
26
|
+
|
|
27
|
+
const targetDir = resolve(rootDir, 'node_modules', emulatorJson.name);
|
|
28
|
+
const appDirName = 'app';
|
|
29
|
+
const mainFile = 'index.js';
|
|
30
|
+
const appDir = resolve(targetDir, appDirName);
|
|
31
|
+
await createDirectory(appDir);
|
|
32
|
+
|
|
33
|
+
await writeJson(
|
|
34
|
+
targetDir,
|
|
35
|
+
packageJson,
|
|
36
|
+
{
|
|
37
|
+
name: emulatorJson.name,
|
|
38
|
+
description: emulatorJson.description,
|
|
39
|
+
version: emulatorJson.version,
|
|
40
|
+
importmap: emulatorJson.importmap,
|
|
41
|
+
pilets: emulatorJson.scaffolding.pilets,
|
|
42
|
+
piralCLI: {
|
|
43
|
+
version: emulatorJson.scaffolding.cli,
|
|
44
|
+
timestamp: emulatorJson.timestamp,
|
|
45
|
+
source: manifestUrl,
|
|
46
|
+
generated: true,
|
|
47
|
+
},
|
|
48
|
+
files: emulatorJson.files,
|
|
49
|
+
main: `./${join(appDirName, mainFile)}`,
|
|
50
|
+
typings: `./${join(appDirName, emulatorJson.files.typings)}`,
|
|
51
|
+
app: `./${join(appDirName, emulatorJson.files.app)}`,
|
|
52
|
+
peerDependencies: {},
|
|
53
|
+
optionalDependencies: emulatorJson.dependencies.optional,
|
|
54
|
+
devDependencies: emulatorJson.dependencies.included,
|
|
55
|
+
},
|
|
56
|
+
true,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// actually including this one hints that the app shell should have been included - which is forbidden
|
|
60
|
+
await createPiralStubIndexIfNotExists(appDir, mainFile, ForceOverwrite.yes, {
|
|
61
|
+
name: emulatorJson.name,
|
|
62
|
+
outFile: emulatorJson.files.main,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await downloadEmulatorFiles(manifestUrl, appDir, emulatorJson.files);
|
|
66
|
+
return emulatorJson;
|
|
67
|
+
}
|
package/src/types/common.ts
CHANGED
|
@@ -4,6 +4,30 @@ export interface Importmap {
|
|
|
4
4
|
exclude?: Array<string>;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
export interface EmulatorWebsiteManifestFiles {
|
|
8
|
+
typings: string;
|
|
9
|
+
main: string;
|
|
10
|
+
app: string;
|
|
11
|
+
assets: Array<string>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface EmulatorWebsiteManifest {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
version: string;
|
|
18
|
+
timestamp: string;
|
|
19
|
+
scaffolding: {
|
|
20
|
+
pilets: PiletsInfo;
|
|
21
|
+
cli: string;
|
|
22
|
+
};
|
|
23
|
+
files: EmulatorWebsiteManifestFiles;
|
|
24
|
+
importmap: Importmap;
|
|
25
|
+
dependencies: {
|
|
26
|
+
optional: Record<string, string>;
|
|
27
|
+
included: Record<string, string>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
7
31
|
export interface PackageData {
|
|
8
32
|
name: string;
|
|
9
33
|
version: string;
|
package/src/types/internal.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { LogLevels } from './common';
|
|
2
2
|
import type { ImportmapVersions, PiletSchemaVersion } from './public';
|
|
3
3
|
|
|
4
|
+
export interface PiralInstanceDetails {
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
port?: number;
|
|
7
|
+
path?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Shape of the pilet.json
|
|
6
13
|
*/
|
|
7
14
|
export interface PiletDefinition {
|
|
8
15
|
schemaVersion?: PiletSchemaVersion;
|
|
9
16
|
importmapVersions?: ImportmapVersions;
|
|
10
|
-
piralInstances?: Record<
|
|
11
|
-
string,
|
|
12
|
-
{
|
|
13
|
-
selected?: boolean;
|
|
14
|
-
port?: number;
|
|
15
|
-
}
|
|
16
|
-
>;
|
|
17
|
+
piralInstances?: Record<string, PiralInstanceDetails>;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export interface PackageFiles {
|
package/src/types/public.ts
CHANGED
|
@@ -136,6 +136,7 @@ export interface BundlerPrepareArgs<T> {
|
|
|
136
136
|
|
|
137
137
|
export interface BaseBundlerDefinition<T> {
|
|
138
138
|
path: string;
|
|
139
|
+
exec?: string;
|
|
139
140
|
prepare?: BundlerPrepareArgs<T>;
|
|
140
141
|
}
|
|
141
142
|
|
|
@@ -235,7 +236,7 @@ export type PiralBuildType = 'all' | 'release' | 'emulator' | 'emulator-sources'
|
|
|
235
236
|
|
|
236
237
|
export type PiletBuildType = 'default' | 'standalone' | 'manifest';
|
|
237
238
|
|
|
238
|
-
export type PackageType = 'registry' | 'file' | 'git';
|
|
239
|
+
export type PackageType = 'registry' | 'file' | 'git' | 'remote';
|
|
239
240
|
|
|
240
241
|
export type NpmClientType = 'npm' | 'yarn' | 'pnp' | 'pnpm' | 'lerna' | 'rush' | 'bun';
|
|
241
242
|
|