piral-cli 1.7.0-beta.7498 → 1.7.0-beta.7504
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/common/emulator.js +54 -62
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/website.js +4 -2
- package/lib/common/website.js.map +1 -1
- package/lib/types/common.d.ts +2 -0
- package/lib/types/common.js.map +1 -1
- package/package.json +2 -2
- package/src/common/emulator.ts +85 -87
- package/src/common/website.ts +9 -7
- package/src/types/common.ts +2 -0
package/lib/common/emulator.js
CHANGED
|
@@ -12,18 +12,18 @@ const enums_1 = require("./enums");
|
|
|
12
12
|
const archive_1 = require("./archive");
|
|
13
13
|
const io_1 = require("./io");
|
|
14
14
|
const io_2 = require("./io");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
function makeFilesMap(files = []) {
|
|
16
|
+
return files
|
|
17
|
+
.filter((file) => file && (typeof file === 'string' || typeof file === 'object'))
|
|
18
|
+
.map((file) => (typeof file === 'string' ? { from: file, to: file } : file))
|
|
19
|
+
.filter((file) => typeof file.to === 'string' && typeof file.from === 'string')
|
|
20
|
+
.map((file) => ({
|
|
21
|
+
...file,
|
|
22
|
+
to: file.to.replace(/\\/g, '/'),
|
|
23
|
+
from: (0, path_1.join)('files', file.to).replace(/\\/g, '/'),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
async function makeExternals(sourceDir, piralPkg, externals) {
|
|
27
27
|
const externalPackages = await Promise.all(externals
|
|
28
28
|
.filter((ext) => ext.type === 'local' && (0, package_1.isValidDependency)(ext.name))
|
|
29
29
|
.map(async (external) => ({
|
|
@@ -49,19 +49,38 @@ async function createEmulatorSources(sourceDir, externals, targetDir, targetFile
|
|
|
49
49
|
}
|
|
50
50
|
return deps;
|
|
51
51
|
}, {});
|
|
52
|
+
return [externalDependencies, importmapEntries, optionalDependencies];
|
|
53
|
+
}
|
|
54
|
+
async function createScaffoldingTarballs(sourceDir, targetDir, files = []) {
|
|
55
|
+
const filesDir = (0, path_1.resolve)(targetDir, constants_1.filesTar);
|
|
56
|
+
const filesOnceDir = (0, path_1.resolve)(targetDir, constants_1.filesOnceTar);
|
|
57
|
+
await Promise.all([(0, io_1.createDirectory)(filesDir), (0, io_1.createDirectory)(filesOnceDir)]);
|
|
58
|
+
// for scaffolding we need to keep the files also available in the new package
|
|
59
|
+
await (0, package_1.copyScaffoldingFiles)(sourceDir, filesDir, files.filter((m) => typeof m === 'string' || !m.once));
|
|
60
|
+
// also to avoid information loss we should store the once-only files separately
|
|
61
|
+
await (0, package_1.copyScaffoldingFiles)(sourceDir, filesOnceDir, files.filter((m) => typeof m !== 'string' && m.once));
|
|
62
|
+
// since things like .gitignore are not properly treated by npm we pack the files (for standard and once only)
|
|
63
|
+
await Promise.all([
|
|
64
|
+
(0, archive_1.createTarball)(filesDir, targetDir, `${constants_1.filesTar}.tar`),
|
|
65
|
+
(0, archive_1.createTarball)(filesOnceDir, targetDir, `${constants_1.filesOnceTar}.tar`),
|
|
66
|
+
]);
|
|
67
|
+
// ... and remove the directory
|
|
68
|
+
await Promise.all([(0, io_1.removeDirectory)(filesDir), (0, io_1.removeDirectory)(filesOnceDir)]);
|
|
69
|
+
}
|
|
70
|
+
async function createEmulatorSources(sourceDir, externals, targetDir, targetFile, logLevel) {
|
|
71
|
+
const piralPkg = await (0, io_2.readJson)(sourceDir, constants_1.packageJson);
|
|
72
|
+
const piralJsonPkg = await (0, io_2.readJson)(sourceDir, constants_1.piralJson);
|
|
73
|
+
const pilets = {
|
|
74
|
+
...piralPkg.pilets,
|
|
75
|
+
...piralJsonPkg.pilets,
|
|
76
|
+
};
|
|
77
|
+
const allDeps = {
|
|
78
|
+
...piralPkg.devDependencies,
|
|
79
|
+
...piralPkg.dependencies,
|
|
80
|
+
};
|
|
52
81
|
const rootDir = (0, path_1.resolve)(targetDir, '..');
|
|
53
82
|
const appDir = (0, path_1.relative)(rootDir, targetDir);
|
|
54
|
-
const
|
|
55
|
-
const filesOnceDir = (0, path_1.resolve)(rootDir, constants_1.filesOnceTar);
|
|
56
|
-
const filesMap = files
|
|
57
|
-
.filter((file) => file && (typeof file === 'string' || typeof file === 'object'))
|
|
58
|
-
.map((file) => (typeof file === 'string' ? { from: file, to: file } : file))
|
|
59
|
-
.filter((file) => typeof file.to === 'string' && typeof file.from === 'string')
|
|
60
|
-
.map((file) => ({
|
|
61
|
-
...file,
|
|
62
|
-
to: file.to.replace(/\\/g, '/'),
|
|
63
|
-
from: (0, path_1.join)('files', file.to).replace(/\\/g, '/'),
|
|
64
|
-
}));
|
|
83
|
+
const [externalDependencies, importmapEntries, optionalDependencies] = await makeExternals(sourceDir, piralPkg, externals);
|
|
65
84
|
// do not modify an existing JSON
|
|
66
85
|
await (0, io_2.createFileIfNotExists)(rootDir, constants_1.packageJson, '{}');
|
|
67
86
|
// patch the JSON relevant for the project
|
|
@@ -77,7 +96,7 @@ async function createEmulatorSources(sourceDir, externals, targetDir, targetFile
|
|
|
77
96
|
},
|
|
78
97
|
pilets: {
|
|
79
98
|
...pilets,
|
|
80
|
-
files:
|
|
99
|
+
files: makeFilesMap(pilets.files),
|
|
81
100
|
},
|
|
82
101
|
piralCLI: {
|
|
83
102
|
version: info_1.cliVersion,
|
|
@@ -101,11 +120,6 @@ async function createEmulatorSources(sourceDir, externals, targetDir, targetFile
|
|
|
101
120
|
cpu: piralPkg.cpu,
|
|
102
121
|
publishConfig: piralPkg.publishConfig,
|
|
103
122
|
});
|
|
104
|
-
await Promise.all([(0, io_1.createDirectory)(filesDir), (0, io_1.createDirectory)(filesOnceDir)]);
|
|
105
|
-
// for scaffolding we need to keep the files also available in the new package
|
|
106
|
-
await (0, package_1.copyScaffoldingFiles)(sourceDir, filesDir, files.filter((m) => typeof m === 'string' || !m.once));
|
|
107
|
-
// also to avoid information loss we should store the once-only files separately
|
|
108
|
-
await (0, package_1.copyScaffoldingFiles)(sourceDir, filesOnceDir, files.filter((m) => typeof m !== 'string' && m.once));
|
|
109
123
|
// we just want to make sure that "files" mentioned in the original package.json are respected in the package
|
|
110
124
|
await (0, package_1.copyScaffoldingFiles)(sourceDir, rootDir, piralPkg.files ?? []);
|
|
111
125
|
// actually including this one hints that the app shell should have been included - which is forbidden
|
|
@@ -115,13 +129,8 @@ async function createEmulatorSources(sourceDir, externals, targetDir, targetFile
|
|
|
115
129
|
});
|
|
116
130
|
// generate the associated index.d.ts
|
|
117
131
|
await (0, declaration_1.createPiralDeclaration)(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, enums_1.ForceOverwrite.yes, logLevel);
|
|
118
|
-
//
|
|
119
|
-
await
|
|
120
|
-
(0, archive_1.createTarball)(filesDir, rootDir, `${constants_1.filesTar}.tar`),
|
|
121
|
-
(0, archive_1.createTarball)(filesOnceDir, rootDir, `${constants_1.filesOnceTar}.tar`),
|
|
122
|
-
]);
|
|
123
|
-
// ... and remove the directory
|
|
124
|
-
await Promise.all([(0, io_1.removeDirectory)(filesDir), (0, io_1.removeDirectory)(filesOnceDir)]);
|
|
132
|
+
// generate the files.tar and files_once.tar files
|
|
133
|
+
await createScaffoldingTarballs(sourceDir, rootDir, pilets.files);
|
|
125
134
|
return rootDir;
|
|
126
135
|
}
|
|
127
136
|
exports.createEmulatorSources = createEmulatorSources;
|
|
@@ -136,31 +145,7 @@ async function createEmulatorWebsite(sourceDir, externals, targetDir, targetFile
|
|
|
136
145
|
...piralPkg.devDependencies,
|
|
137
146
|
...piralPkg.dependencies,
|
|
138
147
|
};
|
|
139
|
-
const
|
|
140
|
-
.filter((ext) => ext.type === 'local' && (0, package_1.isValidDependency)(ext.name))
|
|
141
|
-
.map(async (external) => ({
|
|
142
|
-
name: external.name,
|
|
143
|
-
version: await (0, package_1.findDependencyVersion)(piralPkg, sourceDir, external),
|
|
144
|
-
optional: external.isAsync,
|
|
145
|
-
})));
|
|
146
|
-
const externalDependencies = externalPackages.reduce((deps, dep) => {
|
|
147
|
-
if (!dep.optional) {
|
|
148
|
-
deps[dep.name] = dep.version;
|
|
149
|
-
}
|
|
150
|
-
return deps;
|
|
151
|
-
}, {});
|
|
152
|
-
const importmapEntries = externalPackages.reduce((deps, dep) => {
|
|
153
|
-
if (!dep.optional) {
|
|
154
|
-
deps[dep.name] = dep.name;
|
|
155
|
-
}
|
|
156
|
-
return deps;
|
|
157
|
-
}, {});
|
|
158
|
-
const optionalDependencies = externalPackages.reduce((deps, dep) => {
|
|
159
|
-
if (dep.optional) {
|
|
160
|
-
deps[dep.name] = dep.name;
|
|
161
|
-
}
|
|
162
|
-
return deps;
|
|
163
|
-
}, {});
|
|
148
|
+
const [externalDependencies, importmapEntries, optionalDependencies] = await makeExternals(sourceDir, piralPkg, externals);
|
|
164
149
|
const allFiles = await (0, io_1.matchFiles)(targetDir, '*');
|
|
165
150
|
const data = {
|
|
166
151
|
name: piralPkg.name,
|
|
@@ -168,13 +153,18 @@ async function createEmulatorWebsite(sourceDir, externals, targetDir, targetFile
|
|
|
168
153
|
version: piralPkg.version,
|
|
169
154
|
timestamp: new Date().toISOString(),
|
|
170
155
|
scaffolding: {
|
|
171
|
-
pilets
|
|
156
|
+
pilets: {
|
|
157
|
+
...pilets,
|
|
158
|
+
files: makeFilesMap(pilets.files),
|
|
159
|
+
},
|
|
172
160
|
cli: info_1.cliVersion,
|
|
173
161
|
},
|
|
174
162
|
files: {
|
|
175
163
|
typings: 'index.d.ts',
|
|
176
164
|
main: (0, path_1.basename)(targetFile),
|
|
177
165
|
app: 'index.html',
|
|
166
|
+
always: `${constants_1.filesTar}.tar`,
|
|
167
|
+
once: `${constants_1.filesOnceTar}.tar`,
|
|
178
168
|
assets: allFiles.map((file) => (0, path_1.relative)(targetDir, file)),
|
|
179
169
|
},
|
|
180
170
|
importmap: {
|
|
@@ -191,6 +181,8 @@ async function createEmulatorWebsite(sourceDir, externals, targetDir, targetFile
|
|
|
191
181
|
await (0, io_2.writeJson)(targetDir, constants_1.emulatorJson, data, true);
|
|
192
182
|
// generate the associated index.d.ts
|
|
193
183
|
await (0, declaration_1.createPiralDeclaration)(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, enums_1.ForceOverwrite.yes, logLevel);
|
|
184
|
+
// generate the files.tar and files_once.tar files
|
|
185
|
+
await createScaffoldingTarballs(sourceDir, targetDir, pilets.files);
|
|
194
186
|
return targetDir;
|
|
195
187
|
}
|
|
196
188
|
exports.createEmulatorWebsite = createEmulatorWebsite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/common/emulator.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/common/emulator.ts"],"names":[],"mappings":";;;AAAA,+BAAkE;AAClE,uCAA6G;AAC7G,yCAA6D;AAC7D,2CAA2F;AAC3F,iCAAoC;AACpC,+BAAyC;AACzC,+CAAuD;AACvD,mCAAyC;AACzC,uCAA0C;AAC1C,6BAA6F;AAC7F,6BAAsF;AAGtF,SAAS,YAAY,CAAC,QAA8C,EAAE;IACpE,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;SAChF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC3E,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;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AAC,OAAO,CAAC,CAAC;IAEhC,gBAAgB;IAChB,MAAM,KAAK,GAAG,MAAM,IAAA,iBAAY,EAAC,OAAO,CAAC,CAAC;IAE1C,UAAU;IACV,MAAM,OAAO,CAAC,GAAG,CACf,KAAK;SACF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACxC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,cAAO,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACrC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,cAAS,EAAC,IAAI,CAAC,CAAC,CAClC,CAAC;AACJ,CAAC;AAdD,0CAcC"}
|
package/lib/common/website.js
CHANGED
|
@@ -32,9 +32,11 @@ async function requestManifest(url, interactive, httpsAgent) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
async function downloadEmulatorFiles(manifestUrl, target, files, httpsAgent) {
|
|
35
|
-
const requiredFiles = [files.typings, files.main, files.app];
|
|
35
|
+
const requiredFiles = [files.typings, files.main, files.app, files.always, files.once];
|
|
36
36
|
const opts = (0, http_1.getAxiosOptions)(manifestUrl);
|
|
37
|
-
await Promise.all(requiredFiles
|
|
37
|
+
await Promise.all(requiredFiles
|
|
38
|
+
.filter((file) => file && typeof file === 'string')
|
|
39
|
+
.map(async (file) => {
|
|
38
40
|
const url = new URL(file, manifestUrl);
|
|
39
41
|
const res = await external_1.axios.default.get(url.href, { ...opts, httpsAgent, responseType: 'arraybuffer' });
|
|
40
42
|
const data = res.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"website.js","sourceRoot":"","sources":["../../src/common/website.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,+BAAgD;AAChD,yCAA6D;AAC7D,iCAAoG;AACpG,2CAA0C;AAC1C,qCAAwC;AACxC,mCAAyC;AACzC,6BAA8D;AAC9D,6B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S,EAAE,KAAK,CAAC,CAAC;IACzC,MAAM,IAAA,oBAAe,EAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACpF,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACtD,CAAC;AAZD,kEAYC"}
|
package/lib/types/common.d.ts
CHANGED
package/lib/types/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;AA8EA,IAAY,SA2BX;AA3BD,WAAY,SAAS;IACnB;;OAEG;IACH,iDAAY,CAAA;IACZ;;OAEG;IACH,2CAAS,CAAA;IACT;;OAEG;IACH,+CAAW,CAAA;IACX;;OAEG;IACH,yCAAQ,CAAA;IACR;;;OAGG;IACH,+CAAW,CAAA;IACX;;;OAGG;IACH,2CAAS,CAAA;AACX,CAAC,EA3BW,SAAS,yBAAT,SAAS,QA2BpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.7504",
|
|
4
4
|
"description": "The standard CLI for creating and building a Piral instance or a Pilet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"typescript": "^5.0.0",
|
|
82
82
|
"yargs": "^15.0.0"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "a22c325acd985de5e7ab9dd33081f2a9d5374ab2"
|
|
85
85
|
}
|
package/src/common/emulator.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join, resolve, relative, basename } from 'path';
|
|
1
|
+
import { join, resolve, relative, basename, extname } from 'path';
|
|
2
2
|
import { findDependencyVersion, copyScaffoldingFiles, isValidDependency, flattenExternals } from './package';
|
|
3
3
|
import { createPiralStubIndexIfNotExists } from './template';
|
|
4
4
|
import { filesTar, filesOnceTar, packageJson, piralJson, emulatorJson } from './constants';
|
|
@@ -11,25 +11,19 @@ import { createDirectory, removeDirectory, matchFiles, removeAny, getFileNames }
|
|
|
11
11
|
import { updateExistingJson, readJson, writeJson, createFileIfNotExists } from './io';
|
|
12
12
|
import { EmulatorWebsiteManifest, LogLevels, SharedDependency, PiletsInfo, TemplateFileLocation } from '../types';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...piralJsonPkg.pilets,
|
|
26
|
-
};
|
|
27
|
-
const files: Array<string | TemplateFileLocation> = pilets.files ?? [];
|
|
28
|
-
const allDeps = {
|
|
29
|
-
...piralPkg.devDependencies,
|
|
30
|
-
...piralPkg.dependencies,
|
|
31
|
-
};
|
|
14
|
+
function makeFilesMap(files: Array<string | TemplateFileLocation> = []): Array<TemplateFileLocation> {
|
|
15
|
+
return files
|
|
16
|
+
.filter((file) => file && (typeof file === 'string' || typeof file === 'object'))
|
|
17
|
+
.map((file) => (typeof file === 'string' ? { from: file, to: file } : file))
|
|
18
|
+
.filter((file) => typeof file.to === 'string' && typeof file.from === 'string')
|
|
19
|
+
.map((file) => ({
|
|
20
|
+
...file,
|
|
21
|
+
to: file.to.replace(/\\/g, '/'),
|
|
22
|
+
from: join('files', file.to).replace(/\\/g, '/'),
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
32
25
|
|
|
26
|
+
async function makeExternals(sourceDir: string, piralPkg: any, externals: Array<SharedDependency>) {
|
|
33
27
|
const externalPackages = await Promise.all(
|
|
34
28
|
externals
|
|
35
29
|
.filter((ext) => ext.type === 'local' && isValidDependency(ext.name))
|
|
@@ -63,20 +57,65 @@ export async function createEmulatorSources(
|
|
|
63
57
|
return deps;
|
|
64
58
|
}, {} as Record<string, string>);
|
|
65
59
|
|
|
60
|
+
return [externalDependencies, importmapEntries, optionalDependencies] as const;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function createScaffoldingTarballs(sourceDir: string, targetDir: string, files: Array<string | TemplateFileLocation> = []) {
|
|
64
|
+
const filesDir = resolve(targetDir, filesTar);
|
|
65
|
+
const filesOnceDir = resolve(targetDir, filesOnceTar);
|
|
66
|
+
|
|
67
|
+
await Promise.all([createDirectory(filesDir), createDirectory(filesOnceDir)]);
|
|
68
|
+
|
|
69
|
+
// for scaffolding we need to keep the files also available in the new package
|
|
70
|
+
await copyScaffoldingFiles(
|
|
71
|
+
sourceDir,
|
|
72
|
+
filesDir,
|
|
73
|
+
files.filter((m) => typeof m === 'string' || !m.once),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// also to avoid information loss we should store the once-only files separately
|
|
77
|
+
await copyScaffoldingFiles(
|
|
78
|
+
sourceDir,
|
|
79
|
+
filesOnceDir,
|
|
80
|
+
files.filter((m) => typeof m !== 'string' && m.once),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// since things like .gitignore are not properly treated by npm we pack the files (for standard and once only)
|
|
84
|
+
await Promise.all([
|
|
85
|
+
createTarball(filesDir, targetDir, `${filesTar}.tar`),
|
|
86
|
+
createTarball(filesOnceDir, targetDir, `${filesOnceTar}.tar`),
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
// ... and remove the directory
|
|
90
|
+
await Promise.all([removeDirectory(filesDir), removeDirectory(filesOnceDir)]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function createEmulatorSources(
|
|
94
|
+
sourceDir: string,
|
|
95
|
+
externals: Array<SharedDependency>,
|
|
96
|
+
targetDir: string,
|
|
97
|
+
targetFile: string,
|
|
98
|
+
logLevel: LogLevels,
|
|
99
|
+
) {
|
|
100
|
+
const piralPkg = await readJson(sourceDir, packageJson);
|
|
101
|
+
const piralJsonPkg = await readJson(sourceDir, piralJson);
|
|
102
|
+
const pilets: PiletsInfo = {
|
|
103
|
+
...piralPkg.pilets,
|
|
104
|
+
...piralJsonPkg.pilets,
|
|
105
|
+
};
|
|
106
|
+
const allDeps = {
|
|
107
|
+
...piralPkg.devDependencies,
|
|
108
|
+
...piralPkg.dependencies,
|
|
109
|
+
};
|
|
110
|
+
|
|
66
111
|
const rootDir = resolve(targetDir, '..');
|
|
67
112
|
const appDir = relative(rootDir, targetDir);
|
|
68
|
-
const filesDir = resolve(rootDir, filesTar);
|
|
69
|
-
const filesOnceDir = resolve(rootDir, filesOnceTar);
|
|
70
113
|
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
...file,
|
|
77
|
-
to: file.to.replace(/\\/g, '/'),
|
|
78
|
-
from: join('files', file.to).replace(/\\/g, '/'),
|
|
79
|
-
}));
|
|
114
|
+
const [externalDependencies, importmapEntries, optionalDependencies] = await makeExternals(
|
|
115
|
+
sourceDir,
|
|
116
|
+
piralPkg,
|
|
117
|
+
externals,
|
|
118
|
+
);
|
|
80
119
|
|
|
81
120
|
// do not modify an existing JSON
|
|
82
121
|
await createFileIfNotExists(rootDir, packageJson, '{}');
|
|
@@ -94,7 +133,7 @@ export async function createEmulatorSources(
|
|
|
94
133
|
},
|
|
95
134
|
pilets: {
|
|
96
135
|
...pilets,
|
|
97
|
-
files:
|
|
136
|
+
files: makeFilesMap(pilets.files),
|
|
98
137
|
},
|
|
99
138
|
piralCLI: {
|
|
100
139
|
version: cliVersion,
|
|
@@ -119,22 +158,6 @@ export async function createEmulatorSources(
|
|
|
119
158
|
publishConfig: piralPkg.publishConfig,
|
|
120
159
|
});
|
|
121
160
|
|
|
122
|
-
await Promise.all([createDirectory(filesDir), createDirectory(filesOnceDir)]);
|
|
123
|
-
|
|
124
|
-
// for scaffolding we need to keep the files also available in the new package
|
|
125
|
-
await copyScaffoldingFiles(
|
|
126
|
-
sourceDir,
|
|
127
|
-
filesDir,
|
|
128
|
-
files.filter((m) => typeof m === 'string' || !m.once),
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
// also to avoid information loss we should store the once-only files separately
|
|
132
|
-
await copyScaffoldingFiles(
|
|
133
|
-
sourceDir,
|
|
134
|
-
filesOnceDir,
|
|
135
|
-
files.filter((m) => typeof m !== 'string' && m.once),
|
|
136
|
-
);
|
|
137
|
-
|
|
138
161
|
// we just want to make sure that "files" mentioned in the original package.json are respected in the package
|
|
139
162
|
await copyScaffoldingFiles(sourceDir, rootDir, piralPkg.files ?? []);
|
|
140
163
|
|
|
@@ -147,14 +170,8 @@ export async function createEmulatorSources(
|
|
|
147
170
|
// generate the associated index.d.ts
|
|
148
171
|
await createPiralDeclaration(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, ForceOverwrite.yes, logLevel);
|
|
149
172
|
|
|
150
|
-
//
|
|
151
|
-
await
|
|
152
|
-
createTarball(filesDir, rootDir, `${filesTar}.tar`),
|
|
153
|
-
createTarball(filesOnceDir, rootDir, `${filesOnceTar}.tar`),
|
|
154
|
-
]);
|
|
155
|
-
|
|
156
|
-
// ... and remove the directory
|
|
157
|
-
await Promise.all([removeDirectory(filesDir), removeDirectory(filesOnceDir)]);
|
|
173
|
+
// generate the files.tar and files_once.tar files
|
|
174
|
+
await createScaffoldingTarballs(sourceDir, rootDir, pilets.files);
|
|
158
175
|
|
|
159
176
|
return rootDir;
|
|
160
177
|
}
|
|
@@ -177,38 +194,11 @@ export async function createEmulatorWebsite(
|
|
|
177
194
|
...piralPkg.dependencies,
|
|
178
195
|
};
|
|
179
196
|
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
name: external.name,
|
|
185
|
-
version: await findDependencyVersion(piralPkg, sourceDir, external),
|
|
186
|
-
optional: external.isAsync,
|
|
187
|
-
})),
|
|
197
|
+
const [externalDependencies, importmapEntries, optionalDependencies] = await makeExternals(
|
|
198
|
+
sourceDir,
|
|
199
|
+
piralPkg,
|
|
200
|
+
externals,
|
|
188
201
|
);
|
|
189
|
-
const externalDependencies = externalPackages.reduce((deps, dep) => {
|
|
190
|
-
if (!dep.optional) {
|
|
191
|
-
deps[dep.name] = dep.version;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return deps;
|
|
195
|
-
}, {} as Record<string, string>);
|
|
196
|
-
|
|
197
|
-
const importmapEntries = externalPackages.reduce((deps, dep) => {
|
|
198
|
-
if (!dep.optional) {
|
|
199
|
-
deps[dep.name] = dep.name;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return deps;
|
|
203
|
-
}, {} as Record<string, string>);
|
|
204
|
-
|
|
205
|
-
const optionalDependencies = externalPackages.reduce((deps, dep) => {
|
|
206
|
-
if (dep.optional) {
|
|
207
|
-
deps[dep.name] = dep.name;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return deps;
|
|
211
|
-
}, {} as Record<string, string>);
|
|
212
202
|
|
|
213
203
|
const allFiles = await matchFiles(targetDir, '*');
|
|
214
204
|
const data: EmulatorWebsiteManifest = {
|
|
@@ -217,13 +207,18 @@ export async function createEmulatorWebsite(
|
|
|
217
207
|
version: piralPkg.version,
|
|
218
208
|
timestamp: new Date().toISOString(),
|
|
219
209
|
scaffolding: {
|
|
220
|
-
pilets
|
|
210
|
+
pilets: {
|
|
211
|
+
...pilets,
|
|
212
|
+
files: makeFilesMap(pilets.files),
|
|
213
|
+
},
|
|
221
214
|
cli: cliVersion,
|
|
222
215
|
},
|
|
223
216
|
files: {
|
|
224
217
|
typings: 'index.d.ts',
|
|
225
218
|
main: basename(targetFile),
|
|
226
219
|
app: 'index.html',
|
|
220
|
+
always: `${filesTar}.tar`,
|
|
221
|
+
once: `${filesOnceTar}.tar`,
|
|
227
222
|
assets: allFiles.map((file) => relative(targetDir, file)),
|
|
228
223
|
},
|
|
229
224
|
importmap: {
|
|
@@ -243,6 +238,9 @@ export async function createEmulatorWebsite(
|
|
|
243
238
|
// generate the associated index.d.ts
|
|
244
239
|
await createPiralDeclaration(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, ForceOverwrite.yes, logLevel);
|
|
245
240
|
|
|
241
|
+
// generate the files.tar and files_once.tar files
|
|
242
|
+
await createScaffoldingTarballs(sourceDir, targetDir, pilets.files);
|
|
243
|
+
|
|
246
244
|
return targetDir;
|
|
247
245
|
}
|
|
248
246
|
|
package/src/common/website.ts
CHANGED
|
@@ -37,16 +37,18 @@ async function downloadEmulatorFiles(
|
|
|
37
37
|
files: EmulatorWebsiteManifestFiles,
|
|
38
38
|
httpsAgent?: Agent,
|
|
39
39
|
) {
|
|
40
|
-
const requiredFiles = [files.typings, files.main, files.app];
|
|
40
|
+
const requiredFiles = [files.typings, files.main, files.app, files.always, files.once];
|
|
41
41
|
const opts = getAxiosOptions(manifestUrl);
|
|
42
42
|
|
|
43
43
|
await Promise.all(
|
|
44
|
-
requiredFiles
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
requiredFiles
|
|
45
|
+
.filter((file) => file && typeof file === 'string')
|
|
46
|
+
.map(async (file) => {
|
|
47
|
+
const url = new URL(file, manifestUrl);
|
|
48
|
+
const res = await axios.default.get(url.href, { ...opts, httpsAgent, responseType: 'arraybuffer' });
|
|
49
|
+
const data: Buffer = res.data;
|
|
50
|
+
await writeBinary(target, file, data);
|
|
51
|
+
}),
|
|
50
52
|
);
|
|
51
53
|
}
|
|
52
54
|
|