piral-cli 0.14.0-pre.2983 → 0.14.0-pre.3074
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/api.js +23 -23
- package/lib/api.js.map +1 -1
- package/lib/apps/build-pilet.js +18 -16
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.js +35 -34
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.js +28 -27
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +15 -14
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/declaration-piral.js +5 -3
- package/lib/apps/declaration-piral.js.map +1 -1
- package/lib/apps/new-pilet.js +40 -39
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.js +21 -20
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/pack-pilet.js +6 -4
- package/lib/apps/pack-pilet.js.map +1 -1
- package/lib/apps/publish-pilet.js +48 -47
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.js +23 -22
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +34 -33
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.js +20 -19
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/apps/validate-pilet.js +13 -11
- package/lib/apps/validate-pilet.js.map +1 -1
- package/lib/apps/validate-piral.js +12 -10
- package/lib/apps/validate-piral.js.map +1 -1
- package/lib/bundler.js +18 -18
- package/lib/bundler.js.map +1 -1
- package/lib/cli.js +2 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +12 -12
- package/lib/commands.js.map +1 -1
- package/lib/common/archive.js +8 -8
- package/lib/common/archive.js.map +1 -1
- package/lib/common/browser.js +2 -2
- package/lib/common/browser.js.map +1 -1
- package/lib/common/clients/lerna.js +4 -4
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.js +12 -12
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.js +5 -5
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/yarn.js +5 -5
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/compatibility.js +9 -9
- package/lib/common/compatibility.js.map +1 -1
- package/lib/common/config.d.ts +5 -1
- package/lib/common/config.js +2 -1
- package/lib/common/config.js.map +1 -1
- package/lib/common/declaration.js +19 -19
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/emulator.js +23 -23
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/envs.js +3 -3
- package/lib/common/envs.js.map +1 -1
- package/lib/common/hash.d.ts +1 -0
- package/lib/common/hash.js +8 -3
- package/lib/common/hash.js.map +1 -1
- package/lib/common/http.d.ts +1 -0
- package/lib/common/http.js +28 -14
- package/lib/common/http.js.map +1 -1
- package/lib/common/injectors.js +4 -4
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/inspect.js +4 -4
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/io.d.ts +1 -1
- package/lib/common/io.js +114 -93
- package/lib/common/io.js.map +1 -1
- package/lib/common/language.js +2 -2
- package/lib/common/language.js.map +1 -1
- package/lib/common/log.js +8 -8
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.js +43 -43
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +18 -18
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +3 -1
- package/lib/common/package.js +181 -80
- package/lib/common/package.js.map +1 -1
- package/lib/common/patcher.js +20 -20
- package/lib/common/patcher.js.map +1 -1
- package/lib/common/port.js +3 -3
- package/lib/common/port.js.map +1 -1
- package/lib/common/rules.js +4 -4
- package/lib/common/rules.js.map +1 -1
- package/lib/common/scaffold.js +15 -15
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/scripts.js +5 -5
- package/lib/common/scripts.js.map +1 -1
- package/lib/common/template.js +4 -4
- package/lib/common/template.js.map +1 -1
- package/lib/external/index.js +1369 -611
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/inject.js +2 -2
- package/lib/inject.js.map +1 -1
- package/lib/injectors/pilet.d.ts +1 -10
- package/lib/injectors/pilet.js +74 -27
- package/lib/injectors/pilet.js.map +1 -1
- package/lib/injectors/piral.js +4 -4
- package/lib/injectors/piral.js.map +1 -1
- package/lib/messages.d.ts +7 -2
- package/lib/messages.js +7 -2
- package/lib/messages.js.map +1 -1
- package/lib/pb-cli.js +1 -1
- package/lib/pb-cli.js.map +1 -1
- package/lib/pilet-cli.js +1 -1
- package/lib/pilet-cli.js.map +1 -1
- package/lib/piral-cli.js +1 -1
- package/lib/piral-cli.js.map +1 -1
- package/lib/plugin.js +10 -10
- package/lib/plugin.js.map +1 -1
- package/lib/release.js +3 -3
- package/lib/release.js.map +1 -1
- package/lib/resolvers.js +13 -13
- package/lib/resolvers.js.map +1 -1
- package/lib/rules/index.js +7 -7
- package/lib/rules/index.js.map +1 -1
- package/lib/rules/pilet-has-externals-as-peers.js +3 -3
- package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
- package/lib/rules/pilet-has-no-self-reference.js +1 -1
- package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
- package/lib/rules/pilet-stays-small.js +3 -3
- package/lib/rules/pilet-stays-small.js.map +1 -1
- package/lib/rules/pilet-uses-latest-piral.js +1 -1
- package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
- package/lib/rules/piral-entry-ends-with-html.js +1 -1
- package/lib/rules/piral-entry-ends-with-html.js.map +1 -1
- package/lib/rules/piral-has-valid-files.js +5 -5
- package/lib/rules/piral-has-valid-files.js.map +1 -1
- package/lib/runner.js +1 -1
- package/lib/runner.js.map +1 -1
- package/lib/select.js +6 -6
- package/lib/select.js.map +1 -1
- package/lib/types/common.d.ts +8 -0
- package/lib/types/public.d.ts +4 -2
- package/package.json +2 -2
- package/src/apps/build-pilet.ts +8 -5
- package/src/apps/build-piral.ts +4 -3
- package/src/apps/debug-pilet.ts +5 -4
- package/src/apps/debug-piral.ts +2 -1
- package/src/apps/declaration-piral.ts +3 -1
- package/src/apps/new-pilet.ts +3 -2
- package/src/apps/new-piral.ts +2 -1
- package/src/apps/pack-pilet.ts +3 -1
- package/src/apps/publish-pilet.ts +6 -5
- package/src/apps/publish-piral.ts +3 -2
- package/src/apps/upgrade-pilet.ts +4 -3
- package/src/apps/upgrade-piral.ts +2 -1
- package/src/apps/validate-pilet.ts +5 -2
- package/src/apps/validate-piral.ts +3 -1
- package/src/bundler.test.ts +18 -22
- package/src/common/config.ts +6 -1
- package/src/common/hash.ts +5 -0
- package/src/common/http.ts +18 -4
- package/src/common/io.ts +56 -33
- package/src/common/package.ts +118 -8
- package/src/helpers.ts +1 -1
- package/src/injectors/pilet.ts +82 -22
- package/src/messages.ts +7 -2
- package/src/types/common.ts +9 -0
- package/src/types/public.ts +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../src/common/declaration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAqF;AACrF,+BAA2D;AAC3D,+BAAoE;AACpE,+BAAsC;AAEtC,uCAAkE;AAClE,2CAAmE;AACnE,6BAAkF;AAGlF,SAAS,gBAAgB,CAAC,IAAY;;IACpC,IAAI;QACF,OAAO,MAAA,OAAO;aACX,OAAO,CAAC,yBAAa,EAAE;YACtB,KAAK,EAAE,CAAC,IAAI,CAAC;SACd,CAAC,0CACA,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAC/B;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI;QACF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,cAAO,
|
|
1
|
+
{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../src/common/declaration.ts"],"names":[],"mappings":";;;;;;;;;;;;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L,KAAK,EAAE,mBAAmB,CAAC,IAAI,CAAC;YAChC,IAAI,EAAE;gBACJ;oBACE,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;oBAC5B,IAAI,EAAE,UAAU;iBACjB;aACF;YACD,OAAO,EAAE,cAAc;YACvB,QAAQ;YACR,MAAM,EAAE,YAAY,EAAE;SACvB,CAAC;QACF,OAAO,MAAM,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IAC/E,CAAC;CAAA;AA7BD,wDA6BC"}
|
package/lib/common/emulator.js
CHANGED
|
@@ -24,30 +24,30 @@ const packageJson = 'package.json';
|
|
|
24
24
|
function createEmulatorSources(sourceDir, targetDir, targetFile, logLevel) {
|
|
25
25
|
var _a, _b, _c, _d, _e;
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const piralPkg = require(path_1.resolve(sourceDir, packageJson));
|
|
27
|
+
const piralPkg = require((0, path_1.resolve)(sourceDir, packageJson));
|
|
28
28
|
const files = (_b = (_a = piralPkg.pilets) === null || _a === void 0 ? void 0 : _a.files) !== null && _b !== void 0 ? _b : [];
|
|
29
|
-
const allExternals = npm_1.makeExternals((_c = piralPkg.pilets) === null || _c === void 0 ? void 0 : _c.externals);
|
|
29
|
+
const allExternals = (0, npm_1.makeExternals)((_c = piralPkg.pilets) === null || _c === void 0 ? void 0 : _c.externals);
|
|
30
30
|
const externalPackages = yield Promise.all(allExternals.filter(package_1.isValidDependency).map((name) => __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
return ({
|
|
32
32
|
name,
|
|
33
|
-
version: yield package_1.findDependencyVersion(piralPkg, sourceDir, name),
|
|
33
|
+
version: yield (0, package_1.findDependencyVersion)(piralPkg, sourceDir, name),
|
|
34
34
|
});
|
|
35
35
|
})));
|
|
36
36
|
const externalDependencies = externalPackages.reduce((deps, dep) => {
|
|
37
37
|
deps[dep.name] = dep.version;
|
|
38
38
|
return deps;
|
|
39
39
|
}, {});
|
|
40
|
-
const rootDir = path_1.resolve(targetDir, '..');
|
|
41
|
-
const appDir = path_1.relative(rootDir, targetDir);
|
|
42
|
-
const filesDir = path_1.resolve(rootDir, constants_1.filesTar);
|
|
43
|
-
const filesOnceDir = path_1.resolve(rootDir, constants_1.filesOnceTar);
|
|
40
|
+
const rootDir = (0, path_1.resolve)(targetDir, '..');
|
|
41
|
+
const appDir = (0, path_1.relative)(rootDir, targetDir);
|
|
42
|
+
const filesDir = (0, path_1.resolve)(rootDir, constants_1.filesTar);
|
|
43
|
+
const filesOnceDir = (0, path_1.resolve)(rootDir, constants_1.filesOnceTar);
|
|
44
44
|
const filesMap = files
|
|
45
45
|
.map((file) => (typeof file === 'string' ? { from: file, to: file } : file))
|
|
46
|
-
.map((file) => (Object.assign(Object.assign({}, file), { to: file.to.replace(/\\/g, '/'), from: path_1.join('files', file.from).replace(/\\/g, '/') })));
|
|
46
|
+
.map((file) => (Object.assign(Object.assign({}, file), { to: file.to.replace(/\\/g, '/'), from: (0, path_1.join)('files', file.from).replace(/\\/g, '/') })));
|
|
47
47
|
// do not modify an existing JSON
|
|
48
|
-
yield io_1.createFileIfNotExists(rootDir, packageJson, '{}');
|
|
48
|
+
yield (0, io_1.createFileIfNotExists)(rootDir, packageJson, '{}');
|
|
49
49
|
// patch the JSON relevant for th eproject
|
|
50
|
-
yield io_1.updateExistingJson(rootDir, packageJson, {
|
|
50
|
+
yield (0, io_1.updateExistingJson)(rootDir, packageJson, {
|
|
51
51
|
name: piralPkg.name,
|
|
52
52
|
description: piralPkg.description,
|
|
53
53
|
version: piralPkg.version,
|
|
@@ -72,27 +72,27 @@ function createEmulatorSources(sourceDir, targetDir, targetFile, logLevel) {
|
|
|
72
72
|
cpu: piralPkg.cpu,
|
|
73
73
|
publishConfig: piralPkg.publishConfig,
|
|
74
74
|
});
|
|
75
|
-
yield Promise.all([io_1.createDirectory(filesDir), io_1.createDirectory(filesOnceDir)]);
|
|
75
|
+
yield Promise.all([(0, io_1.createDirectory)(filesDir), (0, io_1.createDirectory)(filesOnceDir)]);
|
|
76
76
|
// for scaffolding we need to keep the files also available in the new package
|
|
77
|
-
yield package_1.copyScaffoldingFiles(sourceDir, filesDir, files.filter((m) => typeof m === 'string' || !m.once));
|
|
77
|
+
yield (0, package_1.copyScaffoldingFiles)(sourceDir, filesDir, files.filter((m) => typeof m === 'string' || !m.once));
|
|
78
78
|
// also to avoid information loss we should store the once-only files separately
|
|
79
|
-
yield package_1.copyScaffoldingFiles(sourceDir, filesOnceDir, files.filter((m) => typeof m !== 'string' && m.once));
|
|
79
|
+
yield (0, package_1.copyScaffoldingFiles)(sourceDir, filesOnceDir, files.filter((m) => typeof m !== 'string' && m.once));
|
|
80
80
|
// we just want to make sure that "files" mentioned in the original package.json are respected in the package
|
|
81
|
-
yield package_1.copyScaffoldingFiles(sourceDir, rootDir, (_d = piralPkg.files) !== null && _d !== void 0 ? _d : []);
|
|
81
|
+
yield (0, package_1.copyScaffoldingFiles)(sourceDir, rootDir, (_d = piralPkg.files) !== null && _d !== void 0 ? _d : []);
|
|
82
82
|
// actually including this one hints that the app shell should have been included - which is forbidden
|
|
83
|
-
yield template_1.createFileFromTemplateIfNotExists('piral', targetDir, 'index.js', enums_1.ForceOverwrite.yes, {
|
|
83
|
+
yield (0, template_1.createFileFromTemplateIfNotExists)('piral', targetDir, 'index.js', enums_1.ForceOverwrite.yes, {
|
|
84
84
|
name: piralPkg.name,
|
|
85
85
|
outFile: targetFile,
|
|
86
86
|
});
|
|
87
87
|
// generate the associated index.d.ts
|
|
88
|
-
yield declaration_1.createPiralDeclaration(sourceDir, (_e = piralPkg.app) !== null && _e !== void 0 ? _e : `./src/index.html`, targetDir, enums_1.ForceOverwrite.yes, logLevel);
|
|
88
|
+
yield (0, declaration_1.createPiralDeclaration)(sourceDir, (_e = piralPkg.app) !== null && _e !== void 0 ? _e : `./src/index.html`, targetDir, enums_1.ForceOverwrite.yes, logLevel);
|
|
89
89
|
// since things like .gitignore are not properly treated by NPM we pack the files (for standard and once only)
|
|
90
90
|
yield Promise.all([
|
|
91
|
-
archive_1.createTarball(filesDir, rootDir, `${constants_1.filesTar}.tar`),
|
|
92
|
-
archive_1.createTarball(filesOnceDir, rootDir, `${constants_1.filesOnceTar}.tar`),
|
|
91
|
+
(0, archive_1.createTarball)(filesDir, rootDir, `${constants_1.filesTar}.tar`),
|
|
92
|
+
(0, archive_1.createTarball)(filesOnceDir, rootDir, `${constants_1.filesOnceTar}.tar`),
|
|
93
93
|
]);
|
|
94
94
|
// ... and remove the directory
|
|
95
|
-
yield Promise.all([io_1.removeDirectory(filesDir), io_1.removeDirectory(filesOnceDir)]);
|
|
95
|
+
yield Promise.all([(0, io_1.removeDirectory)(filesDir), (0, io_1.removeDirectory)(filesOnceDir)]);
|
|
96
96
|
return rootDir;
|
|
97
97
|
});
|
|
98
98
|
}
|
|
@@ -100,14 +100,14 @@ exports.createEmulatorSources = createEmulatorSources;
|
|
|
100
100
|
function packageEmulator(rootDir) {
|
|
101
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
102
|
// finally package everything up
|
|
103
|
-
yield npm_1.createPackage(rootDir);
|
|
103
|
+
yield (0, npm_1.createPackage)(rootDir);
|
|
104
104
|
// get all files
|
|
105
|
-
const names = yield io_1.getFileNames(rootDir);
|
|
105
|
+
const names = yield (0, io_1.getFileNames)(rootDir);
|
|
106
106
|
// cleanup
|
|
107
107
|
yield Promise.all(names
|
|
108
108
|
.filter((name) => !name.endsWith('.tgz'))
|
|
109
|
-
.map((name) => path_1.resolve(rootDir, name))
|
|
110
|
-
.map((file) => io_1.removeAny(file)));
|
|
109
|
+
.map((name) => (0, path_1.resolve)(rootDir, name))
|
|
110
|
+
.map((file) => (0, io_1.removeAny)(file)));
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
exports.packageEmulator = packageEmulator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/common/emulator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AO,CAAC,GAAG,CACf,KAAK;aACF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;aACxC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,cAAO,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;aACrC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,cAAS,EAAC,IAAI,CAAC,CAAC,CAClC,CAAC;IACJ,CAAC;CAAA;AAdD,0CAcC"}
|
package/lib/common/envs.js
CHANGED
|
@@ -9,9 +9,9 @@ function hasPath(path) {
|
|
|
9
9
|
return paths.includes(path);
|
|
10
10
|
}
|
|
11
11
|
function setStandardEnvs(options) {
|
|
12
|
-
log_1.log('generalDebug_0003', `Setting environment variables in "${options.root}" ...`);
|
|
13
|
-
const packageJson = require(path_1.join(options.root, 'package.json'));
|
|
14
|
-
const binDir = path_1.join(options.root, 'node_modules', '.bin');
|
|
12
|
+
(0, log_1.log)('generalDebug_0003', `Setting environment variables in "${options.root}" ...`);
|
|
13
|
+
const packageJson = require((0, path_1.join)(options.root, 'package.json'));
|
|
14
|
+
const binDir = (0, path_1.join)(options.root, 'node_modules', '.bin');
|
|
15
15
|
process.env.BUILD_TIME = new Date().toDateString();
|
|
16
16
|
process.env.BUILD_TIME_FULL = new Date().toISOString();
|
|
17
17
|
process.env.BUILD_PCKG_VERSION = packageJson.version;
|
package/lib/common/envs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envs.js","sourceRoot":"","sources":["../../src/common/envs.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,+BAA4B;AAC5B,iCAAkE;AAGlE,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAa,CAAC,CAAC;IAC5D,O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strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.computeMd5 = exports.computeHash = void 0;
|
|
3
|
+
exports.computeIntegrity = exports.computeMd5 = exports.computeHash = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
function computeHash(content = '') {
|
|
6
|
-
return crypto_1.createHash('sha1').update(content).digest('hex');
|
|
6
|
+
return (0, crypto_1.createHash)('sha1').update(content).digest('hex');
|
|
7
7
|
}
|
|
8
8
|
exports.computeHash = computeHash;
|
|
9
9
|
function computeMd5(content = '') {
|
|
10
|
-
return crypto_1.createHash('md5').update(content).digest('hex');
|
|
10
|
+
return (0, crypto_1.createHash)('md5').update(content).digest('hex');
|
|
11
11
|
}
|
|
12
12
|
exports.computeMd5 = computeMd5;
|
|
13
|
+
function computeIntegrity(content) {
|
|
14
|
+
const sum = (0, crypto_1.createHash)('sha256').update(content).digest('base64');
|
|
15
|
+
return `sha256-${sum}`;
|
|
16
|
+
}
|
|
17
|
+
exports.computeIntegrity = computeIntegrity;
|
|
13
18
|
//# sourceMappingURL=hash.js.map
|
package/lib/common/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/common/hash.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,SAAgB,WAAW,CAAC,UAA2B,EAAE;IACvD,OAAO,mBAAU,
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/common/hash.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,SAAgB,WAAW,CAAC,UAA2B,EAAE;IACvD,OAAO,IAAA,mBAAU,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAFD,kCAEC;AAED,SAAgB,UAAU,CAAC,UAA2B,EAAE;IACtD,OAAO,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAFD,gCAEC;AAED,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,MAAM,GAAG,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClE,OAAO,UAAU,GAAG,EAAE,CAAC;AACzB,CAAC;AAHD,4CAGC"}
|
package/lib/common/http.d.ts
CHANGED
package/lib/common/http.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.postFile = exports.downloadFile = void 0;
|
|
3
|
+
exports.postFile = exports.downloadFile = exports.getHashFromUrl = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const https_1 = require("https");
|
|
6
6
|
const os_1 = require("os");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const log_1 = require("./log");
|
|
9
|
+
const hash_1 = require("./hash");
|
|
9
10
|
const external_1 = require("../external");
|
|
10
|
-
const os = os_1.platform();
|
|
11
|
+
const os = (0, os_1.platform)();
|
|
12
|
+
const standardHeaders = {
|
|
13
|
+
'user-agent': `piral-cli/http.node-${os}`,
|
|
14
|
+
};
|
|
11
15
|
function getMessage(body) {
|
|
12
16
|
if (typeof body === 'string') {
|
|
13
17
|
try {
|
|
@@ -29,31 +33,41 @@ function getMessage(body) {
|
|
|
29
33
|
return '';
|
|
30
34
|
}
|
|
31
35
|
function streamToFile(source, target) {
|
|
32
|
-
const dest = fs_1.createWriteStream(target);
|
|
36
|
+
const dest = (0, fs_1.createWriteStream)(target);
|
|
33
37
|
return new Promise((resolve, reject) => {
|
|
34
38
|
source.pipe(dest);
|
|
35
39
|
source.on('error', (err) => reject(err));
|
|
36
40
|
dest.on('finish', () => resolve([target]));
|
|
37
41
|
});
|
|
38
42
|
}
|
|
43
|
+
function getHashFromUrl(target) {
|
|
44
|
+
return external_1.axios.default
|
|
45
|
+
.get(target, {
|
|
46
|
+
responseType: 'arraybuffer',
|
|
47
|
+
headers: standardHeaders,
|
|
48
|
+
})
|
|
49
|
+
.then((res) => {
|
|
50
|
+
(0, log_1.log)('generalDebug_0003', `Received the contents from "${target}" (status: ${res.status}).`);
|
|
51
|
+
return (0, hash_1.computeHash)(res.data);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.getHashFromUrl = getHashFromUrl;
|
|
39
55
|
function downloadFile(target, ca) {
|
|
40
56
|
const httpsAgent = ca ? new https_1.Agent({ ca }) : undefined;
|
|
41
57
|
return external_1.axios.default
|
|
42
58
|
.get(target, {
|
|
43
59
|
responseType: 'stream',
|
|
44
|
-
headers:
|
|
45
|
-
'user-agent': `piral-cli/http.node-${os}`,
|
|
46
|
-
},
|
|
60
|
+
headers: standardHeaders,
|
|
47
61
|
httpsAgent,
|
|
48
62
|
})
|
|
49
63
|
.then((res) => {
|
|
50
64
|
const rid = Math.random().toString(36).split('.').pop();
|
|
51
|
-
const target = path_1.join(os_1.tmpdir(), `pilet_${rid}.tgz`);
|
|
52
|
-
log_1.log('generalDebug_0003', `Writing the downloaded file to "${target}".`);
|
|
65
|
+
const target = (0, path_1.join)((0, os_1.tmpdir)(), `pilet_${rid}.tgz`);
|
|
66
|
+
(0, log_1.log)('generalDebug_0003', `Writing the downloaded file to "${target}".`);
|
|
53
67
|
return streamToFile(res.data, target);
|
|
54
68
|
})
|
|
55
69
|
.catch((error) => {
|
|
56
|
-
log_1.log('failedHttpGet_0068', error.message);
|
|
70
|
+
(0, log_1.log)('failedHttpGet_0068', error.message);
|
|
57
71
|
return [];
|
|
58
72
|
});
|
|
59
73
|
}
|
|
@@ -63,7 +77,7 @@ function postFile(target, key, file, fields = {}, ca) {
|
|
|
63
77
|
const httpsAgent = ca ? new https_1.Agent({ ca }) : undefined;
|
|
64
78
|
Object.keys(fields).forEach((key) => form.append(key, fields[key]));
|
|
65
79
|
form.append('file', file, 'pilet.tgz');
|
|
66
|
-
const headers = Object.assign(Object.assign({}, form.getHeaders()),
|
|
80
|
+
const headers = Object.assign(Object.assign({}, form.getHeaders()), standardHeaders);
|
|
67
81
|
if (key) {
|
|
68
82
|
headers.authorization = `Basic ${key}`;
|
|
69
83
|
}
|
|
@@ -85,7 +99,7 @@ function postFile(target, key, file, fields = {}, ca) {
|
|
|
85
99
|
// that falls out of the range of 2xx
|
|
86
100
|
const { data, statusText, status } = error.response;
|
|
87
101
|
const message = getMessage(data) || '';
|
|
88
|
-
log_1.log('unsuccessfulHttpPost_0066', statusText, status, message);
|
|
102
|
+
(0, log_1.log)('unsuccessfulHttpPost_0066', statusText, status, message);
|
|
89
103
|
return {
|
|
90
104
|
status,
|
|
91
105
|
success: false,
|
|
@@ -99,7 +113,7 @@ function postFile(target, key, file, fields = {}, ca) {
|
|
|
99
113
|
const errorObj = error.toJSON();
|
|
100
114
|
errorMessage = (_a = errorObj === null || errorObj === void 0 ? void 0 : errorObj.message) !== null && _a !== void 0 ? _a : errorMessage;
|
|
101
115
|
}
|
|
102
|
-
log_1.log('failedHttpPost_0065', errorMessage);
|
|
116
|
+
(0, log_1.log)('failedHttpPost_0065', errorMessage);
|
|
103
117
|
return {
|
|
104
118
|
status: 500,
|
|
105
119
|
success: false,
|
|
@@ -110,11 +124,11 @@ function postFile(target, key, file, fields = {}, ca) {
|
|
|
110
124
|
// The request was made but no response was received
|
|
111
125
|
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
112
126
|
// http.ClientRequest in node.js
|
|
113
|
-
log_1.log('failedHttpPost_0065', error.request);
|
|
127
|
+
(0, log_1.log)('failedHttpPost_0065', error.request);
|
|
114
128
|
}
|
|
115
129
|
else {
|
|
116
130
|
// Something happened in setting up the request that triggered an Error
|
|
117
|
-
log_1.log('failedHttpPost_0065', error.message);
|
|
131
|
+
(0, log_1.log)('failedHttpPost_0065', error.message);
|
|
118
132
|
}
|
|
119
133
|
return {
|
|
120
134
|
status: 500,
|
package/lib/common/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/common/http.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,iCAA8B;AAE9B,2BAAsC;AACtC,2BAAuC;AACvC,+BAA4B;AAC5B,0CAA8C;AAE9C,MAAM,EAAE,GAAG,aAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/common/http.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,iCAA8B;AAE9B,2BAAsC;AACtC,2BAAuC;AACvC,+BAA4B;AAC5B,iCAAqC;AACrC,0CAA8C;AAE9C,MAAM,EAAE,GAAG,IAAA,aAAQ,GAAE,CAAC;AACtB,MAAM,eAAe,GAAG;IACtB,YAAY,EAAE,uBAAuB,EAAE,EAAE;CAC1C,CAAC;AAEF,SAAS,UAAU,CAAC,IAAmC;IACrD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,IAAI;YACF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,OAAO,OAAO,CAAC,OAAO,CAAC;SACxB;QAAC,OAAO,EAAE,EAAE;YACX,OAAO,IAAI,CAAC;SACb;KACF;SAAM,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC3C,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,OAAO,IAAI,CAAC,OAAO,CAAC;SACrB;aAAM;YACL,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC7B;KACF;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,YAAY,CAAC,MAAc,EAAE,MAAc;IAClD,MAAM,IAAI,GAAG,IAAA,sBAAiB,EAAC,MAAM,CAAC,CAAC;IACvC,OAAO,IAAI,OAAO,CAAgB,C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ACvE,IAAA,SAAG,EAAC,qBAAqB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SAC3C;QAED,OAAO;YACL,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,SAAS;SACpB,CAAC;IACJ,CAAC,CACF,CAAC;AACN,CAAC;AAhFD,4BAgFC"}
|
package/lib/common/injectors.js
CHANGED
|
@@ -16,11 +16,11 @@ function reorderInjectors(injectorName, injectorConfig, injectors) {
|
|
|
16
16
|
exports.reorderInjectors = reorderInjectors;
|
|
17
17
|
function notifyServerOnline(bundlers, api) {
|
|
18
18
|
return (svc) => {
|
|
19
|
-
log_1.log('generalDebug_0003', `The kras server for debugging is online!`);
|
|
19
|
+
(0, log_1.log)('generalDebug_0003', `The kras server for debugging is online!`);
|
|
20
20
|
const address = `${svc.protocol}://localhost:${chalk_1.default.green(svc.port)}`;
|
|
21
|
-
log_1.logInfo(`${emoji_1.liveIcon} Running at ${chalk_1.default.bold(address)}`);
|
|
22
|
-
log_1.logInfo(`${emoji_1.settingsIcon} Manage via ${chalk_1.default.bold(address + api)}`);
|
|
23
|
-
log_1.logReset();
|
|
21
|
+
(0, log_1.logInfo)(`${emoji_1.liveIcon} Running at ${chalk_1.default.bold(address)}`);
|
|
22
|
+
(0, log_1.logInfo)(`${emoji_1.settingsIcon} Manage via ${chalk_1.default.bold(address + api)}`);
|
|
23
|
+
(0, log_1.logReset)();
|
|
24
24
|
bundlers.forEach((bundler) => bundler.start());
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectors.js","sourceRoot":"","sources":["../../src/common/injectors.ts"],"names":[],"mappings":";;;AAAA,iCAA0B;AAE1B,mCAAiD;AACjD,+BAA+C;AAG/C,SAAgB,gBAAgB,CAAC,YAAoB,EAAE,cAAmB,EAAE,SAAqC;IAC/G,uBACE,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI;YAC1B,MAAM,EAAE,IAA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CAAC,OAAO,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC;QACnE,IAAA,cAAQ,GAAE,CAAC;QACX,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC;AATD,gDASC"}
|
package/lib/common/inspect.js
CHANGED
|
@@ -22,15 +22,15 @@ function getPiletMainPath(data, files) {
|
|
|
22
22
|
return paths.map((filePath) => `${packageRoot}${filePath}`).filter((filePath) => !!files[filePath])[0];
|
|
23
23
|
}
|
|
24
24
|
function inspectPackage(stream) {
|
|
25
|
-
return archive_1.unpackGzTar(stream).then((files) => getPackageJson(files));
|
|
25
|
+
return (0, archive_1.unpackGzTar)(stream).then((files) => getPackageJson(files));
|
|
26
26
|
}
|
|
27
27
|
exports.inspectPackage = inspectPackage;
|
|
28
28
|
function inspectPilet(stream) {
|
|
29
|
-
return archive_1.unpackGzTar(stream).then((files) => {
|
|
29
|
+
return (0, archive_1.unpackGzTar)(stream).then((files) => {
|
|
30
30
|
const data = getPackageJson(files);
|
|
31
31
|
const path = getPiletMainPath(data, files);
|
|
32
|
-
const root = path_1.dirname(path);
|
|
33
|
-
const main = path_1.basename(path);
|
|
32
|
+
const root = (0, path_1.dirname)(path);
|
|
33
|
+
const main = (0, path_1.basename)(path);
|
|
34
34
|
return Object.assign(Object.assign({}, data), { root,
|
|
35
35
|
main });
|
|
36
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/common/inspect.ts"],"names":[],"mappings":";;;AAAA,+BAAyC;AACzC,uCAAwC;AAGxC,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B,SAAS,cAAc,CAAC,KAAmB;IACzC,MAAM,QAAQ,GAAG,GAAG,WAAW,cAAc,CAAC;IAC9C,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM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,WAAW;QACvB,QAAQ,IAAI,CAAC,IAAI,WAAW;QAC5B,UAAU;QACV,eAAe;KAChB,CAAC;IACF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,WAAW,GAAG,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzG,CAAC;AAMD,SAAgB,cAAc,CAAC,MAA6B;IAC1D,OAAO,IAAA,qBAAW,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,wCAEC;AAED,SAAgB,YAAY,CAAC,MAA6B;IACxD,OAAO,IAAA,qBAAW,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC;QAC5B,uCACK,IAAI,KACP,IAAI;YACJ,IAAI,IACJ;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAZD,oCAYC"}
|
package/lib/common/io.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function checkExistingDirectory(target: string): Promise<boolean>
|
|
|
9
9
|
export declare function checkIsDirectory(target: string): Promise<boolean>;
|
|
10
10
|
export declare function getFileNames(target: string): Promise<string[]>;
|
|
11
11
|
export declare function findFile(topDir: string, fileName: string): Promise<string>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function matchAnyPilet(baseDir: string, patterns: Array<string>): Promise<string[]>;
|
|
13
13
|
export declare function matchFiles(baseDir: string, pattern: string): Promise<string[]>;
|
|
14
14
|
export declare function createFileIfNotExists(targetDir: string, fileName: string, content: Buffer | string, forceOverwrite?: ForceOverwrite): Promise<void>;
|
|
15
15
|
export declare function updateExistingFile(targetDir: string, fileName: string, content: string): Promise<void>;
|
package/lib/common/io.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getSourceFiles = exports.move = exports.removeFile = exports.remove = exports.copy = exports.updateExistingJson = exports.writeBinary = exports.writeText = exports.writeJson = exports.readText = exports.readBinary = exports.readJson = exports.mergeWithJson = exports.getHash = exports.updateExistingFile = exports.createFileIfNotExists = exports.matchFiles = exports.
|
|
12
|
+
exports.getSourceFiles = exports.move = exports.removeFile = exports.remove = exports.copy = exports.updateExistingJson = exports.writeBinary = exports.writeText = exports.writeJson = exports.readText = exports.readBinary = exports.readJson = exports.mergeWithJson = exports.getHash = exports.updateExistingFile = exports.createFileIfNotExists = exports.matchFiles = exports.matchAnyPilet = exports.findFile = exports.getFileNames = exports.checkIsDirectory = exports.checkExistingDirectory = exports.checkExists = exports.getEntryFiles = exports.createDirectory = exports.removeDirectory = exports.removeAny = void 0;
|
|
13
13
|
const rimraf = require("rimraf");
|
|
14
14
|
const typescript_1 = require("typescript");
|
|
15
15
|
const path_1 = require("path");
|
|
@@ -24,14 +24,14 @@ const interactive_1 = require("./interactive");
|
|
|
24
24
|
const external_1 = require("../external");
|
|
25
25
|
function promptOverwrite(file) {
|
|
26
26
|
const message = `The file ${file} exists already. Do you want to overwrite it?`;
|
|
27
|
-
return interactive_1.promptConfirm(message, false);
|
|
27
|
+
return (0, interactive_1.promptConfirm)(message, false);
|
|
28
28
|
}
|
|
29
29
|
function createDirectoryLegacy(targetDir) {
|
|
30
|
-
const initDir = path_1.isAbsolute(targetDir) ? path_1.sep : '';
|
|
30
|
+
const initDir = (0, path_1.isAbsolute)(targetDir) ? path_1.sep : '';
|
|
31
31
|
return targetDir.split(path_1.sep).reduce((parentDir, childDir) => {
|
|
32
|
-
const curDir = path_1.resolve(parentDir, childDir);
|
|
32
|
+
const curDir = (0, path_1.resolve)(parentDir, childDir);
|
|
33
33
|
try {
|
|
34
|
-
fs_1.mkdirSync(curDir);
|
|
34
|
+
(0, fs_1.mkdirSync)(curDir);
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
|
37
37
|
if (err.code === 'EEXIST') {
|
|
@@ -41,7 +41,7 @@ function createDirectoryLegacy(targetDir) {
|
|
|
41
41
|
throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
|
|
42
42
|
}
|
|
43
43
|
const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
|
|
44
|
-
if (!caughtErr || (caughtErr && curDir === path_1.resolve(targetDir))) {
|
|
44
|
+
if (!caughtErr || (caughtErr && curDir === (0, path_1.resolve)(targetDir))) {
|
|
45
45
|
throw err;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -49,7 +49,7 @@ function createDirectoryLegacy(targetDir) {
|
|
|
49
49
|
}, initDir);
|
|
50
50
|
}
|
|
51
51
|
function isFile(file) {
|
|
52
|
-
return fs_1.statSync(file).isFile();
|
|
52
|
+
return (0, fs_1.statSync)(file).isFile();
|
|
53
53
|
}
|
|
54
54
|
function isLegacy() {
|
|
55
55
|
const parts = info_1.nodeVersion.split('.');
|
|
@@ -68,7 +68,7 @@ function removeAny(target) {
|
|
|
68
68
|
}
|
|
69
69
|
exports.removeAny = removeAny;
|
|
70
70
|
function removeDirectory(targetDir) {
|
|
71
|
-
log_1.log('generalDebug_0003', `Removing the directory "${targetDir}" ...`);
|
|
71
|
+
(0, log_1.log)('generalDebug_0003', `Removing the directory "${targetDir}" ...`);
|
|
72
72
|
return new Promise((resolve, reject) => rimraf(targetDir, (err) => (err ? reject(err) : resolve())));
|
|
73
73
|
}
|
|
74
74
|
exports.removeDirectory = removeDirectory;
|
|
@@ -76,26 +76,26 @@ function createDirectory(targetDir) {
|
|
|
76
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
77
|
if (isLegacy()) {
|
|
78
78
|
try {
|
|
79
|
-
log_1.log('generalDebug_0003', `Trying to create "${targetDir}" in legacy mode ...`);
|
|
79
|
+
(0, log_1.log)('generalDebug_0003', `Trying to create "${targetDir}" in legacy mode ...`);
|
|
80
80
|
createDirectoryLegacy(targetDir);
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
83
|
catch (e) {
|
|
84
|
-
log_1.log('cannotCreateDirectory_0044');
|
|
85
|
-
log_1.log('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
84
|
+
(0, log_1.log)('cannotCreateDirectory_0044');
|
|
85
|
+
(0, log_1.log)('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
try {
|
|
90
|
-
log_1.log('generalDebug_0003', `Trying to create "${targetDir}" in modern mode ...`);
|
|
90
|
+
(0, log_1.log)('generalDebug_0003', `Trying to create "${targetDir}" in modern mode ...`);
|
|
91
91
|
yield new Promise((resolve, reject) => {
|
|
92
|
-
fs_1.mkdir(targetDir, { recursive: true }, (err) => (err ? reject(err) : resolve()));
|
|
92
|
+
(0, fs_1.mkdir)(targetDir, { recursive: true }, (err) => (err ? reject(err) : resolve()));
|
|
93
93
|
});
|
|
94
94
|
return true;
|
|
95
95
|
}
|
|
96
96
|
catch (e) {
|
|
97
|
-
log_1.log('cannotCreateDirectory_0044');
|
|
98
|
-
log_1.log('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
97
|
+
(0, log_1.log)('cannotCreateDirectory_0044');
|
|
98
|
+
(0, log_1.log)('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
101
|
});
|
|
@@ -103,14 +103,14 @@ function createDirectory(targetDir) {
|
|
|
103
103
|
exports.createDirectory = createDirectory;
|
|
104
104
|
function getEntryFiles(content, basePath) {
|
|
105
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
log_1.log('generalDebug_0003', `Extract entry files from "${basePath}".`);
|
|
106
|
+
(0, log_1.log)('generalDebug_0003', `Extract entry files from "${basePath}".`);
|
|
107
107
|
const matcher = /<script\s.*?src=(?:"(.*?)"|'(.*?)'|([^\s>]*)).*?>/gi;
|
|
108
108
|
const results = [];
|
|
109
109
|
let result = undefined;
|
|
110
110
|
while ((result = matcher.exec(content))) {
|
|
111
111
|
const src = result[1] || result[2] || result[3];
|
|
112
|
-
log_1.log('generalDebug_0003', `Found potential entry file "${src}".`);
|
|
113
|
-
const filePath = path_1.resolve(basePath, src);
|
|
112
|
+
(0, log_1.log)('generalDebug_0003', `Found potential entry file "${src}".`);
|
|
113
|
+
const filePath = (0, path_1.resolve)(basePath, src);
|
|
114
114
|
const exists = yield checkExists(filePath);
|
|
115
115
|
if (exists) {
|
|
116
116
|
results.push(filePath);
|
|
@@ -123,7 +123,7 @@ exports.getEntryFiles = getEntryFiles;
|
|
|
123
123
|
function checkExists(target) {
|
|
124
124
|
return new Promise((resolve) => {
|
|
125
125
|
if (target !== undefined) {
|
|
126
|
-
fs_1.exists(target, resolve);
|
|
126
|
+
(0, fs_1.exists)(target, resolve);
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
129
|
resolve(false);
|
|
@@ -133,9 +133,9 @@ function checkExists(target) {
|
|
|
133
133
|
exports.checkExists = checkExists;
|
|
134
134
|
function checkExistingDirectory(target) {
|
|
135
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
log_1.log('generalDebug_0003', `Checking directory "${target}" ...`);
|
|
136
|
+
(0, log_1.log)('generalDebug_0003', `Checking directory "${target}" ...`);
|
|
137
137
|
if (yield checkExists(target)) {
|
|
138
|
-
log_1.log('generalDebug_0003', `Target exists, but not yet clear if directory.`);
|
|
138
|
+
(0, log_1.log)('generalDebug_0003', `Target exists, but not yet clear if directory.`);
|
|
139
139
|
return yield checkIsDirectory(target);
|
|
140
140
|
}
|
|
141
141
|
return false;
|
|
@@ -144,9 +144,9 @@ function checkExistingDirectory(target) {
|
|
|
144
144
|
exports.checkExistingDirectory = checkExistingDirectory;
|
|
145
145
|
function checkIsDirectory(target) {
|
|
146
146
|
return new Promise((resolve) => {
|
|
147
|
-
fs_1.lstat(target, (err, stats) => {
|
|
147
|
+
(0, fs_1.lstat)(target, (err, stats) => {
|
|
148
148
|
if (err) {
|
|
149
|
-
resolve(path_1.extname(target) === '');
|
|
149
|
+
resolve((0, path_1.extname)(target) === '');
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
152
|
resolve(stats.isDirectory());
|
|
@@ -157,16 +157,16 @@ function checkIsDirectory(target) {
|
|
|
157
157
|
exports.checkIsDirectory = checkIsDirectory;
|
|
158
158
|
function getFileNames(target) {
|
|
159
159
|
return new Promise((resolve, reject) => {
|
|
160
|
-
fs_2.readdir(target, (err, files) => (err ? reject(err) : resolve(files)));
|
|
160
|
+
(0, fs_2.readdir)(target, (err, files) => (err ? reject(err) : resolve(files)));
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
exports.getFileNames = getFileNames;
|
|
164
164
|
function findFile(topDir, fileName) {
|
|
165
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const path = path_1.join(topDir, fileName);
|
|
166
|
+
const path = (0, path_1.join)(topDir, fileName);
|
|
167
167
|
const exists = yield checkExists(path);
|
|
168
168
|
if (!exists) {
|
|
169
|
-
const parentDir = path_1.resolve(topDir, '..');
|
|
169
|
+
const parentDir = (0, path_1.resolve)(topDir, '..');
|
|
170
170
|
if (parentDir !== topDir) {
|
|
171
171
|
return yield findFile(parentDir, fileName);
|
|
172
172
|
}
|
|
@@ -178,7 +178,7 @@ function findFile(topDir, fileName) {
|
|
|
178
178
|
exports.findFile = findFile;
|
|
179
179
|
function matchPattern(baseDir, pattern) {
|
|
180
180
|
return new Promise((resolve, reject) => {
|
|
181
|
-
external_1.glob(pattern, {
|
|
181
|
+
(0, external_1.glob)(pattern, {
|
|
182
182
|
cwd: baseDir,
|
|
183
183
|
nodir: true,
|
|
184
184
|
}, (err, files) => {
|
|
@@ -201,17 +201,23 @@ function matchAnyPattern(baseDir, pattern) {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
const preferences = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.esm', '.es', '.es6', '.html'];
|
|
204
|
-
function
|
|
204
|
+
function matchAnyPilet(baseDir, patterns) {
|
|
205
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
206
|
const matches = [];
|
|
207
|
+
const pilets = [];
|
|
208
|
+
const matched = (name, path) => {
|
|
209
|
+
pilets.push(name);
|
|
210
|
+
matches.push(path);
|
|
211
|
+
};
|
|
212
|
+
const nameOfPackageJson = 'package.json';
|
|
207
213
|
const exts = preferences.map((s) => s.substr(1)).join(',');
|
|
208
214
|
const allPatterns = patterns.reduce((agg, curr) => {
|
|
209
215
|
const patterns = [];
|
|
210
|
-
if (/[a-zA-Z0-9
|
|
211
|
-
patterns.push(curr, `${curr}.{${exts}}`, `${curr}
|
|
216
|
+
if (/[a-zA-Z0-9\-\*]+$/.test(curr) && !preferences.find((ext) => curr.endsWith(ext))) {
|
|
217
|
+
patterns.push(curr, `${curr}.{${exts}}`, `${curr}/${nameOfPackageJson}`);
|
|
212
218
|
}
|
|
213
219
|
else if (curr.endsWith('/')) {
|
|
214
|
-
patterns.push(`${curr}index.{${exts}}`, `${curr}
|
|
220
|
+
patterns.push(`${curr}index.{${exts}}`, `${curr}${nameOfPackageJson}`);
|
|
215
221
|
}
|
|
216
222
|
else {
|
|
217
223
|
patterns.push(curr);
|
|
@@ -221,54 +227,69 @@ function matchAny(baseDir, patterns) {
|
|
|
221
227
|
}, []);
|
|
222
228
|
yield Promise.all(allPatterns.map((patterns) => matchAnyPattern(baseDir, patterns).then(({ results, pattern }) => __awaiter(this, void 0, void 0, function* () {
|
|
223
229
|
if (!results.length) {
|
|
224
|
-
|
|
230
|
+
(0, log_1.log)('generalDebug_0003', `Found no potential entry points using "${pattern}".`);
|
|
225
231
|
}
|
|
226
232
|
else {
|
|
227
|
-
|
|
228
|
-
//
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
233
|
+
//TODO -> shouldn't take the first one,
|
|
234
|
+
// should be the first one, yes, but, PER pilet
|
|
235
|
+
// so that multiple pilets can be considered, too
|
|
236
|
+
(0, log_1.log)('generalDebug_0003', `Found ${results.length} potential entry points in "${pattern}".`);
|
|
237
|
+
for (const result of results) {
|
|
238
|
+
const fileName = (0, path_1.basename)(result);
|
|
239
|
+
if (fileName === nameOfPackageJson) {
|
|
240
|
+
(0, log_1.log)('generalDebug_0003', `Entry point is a "${nameOfPackageJson}" and needs further inspection.`);
|
|
241
|
+
const targetDir = (0, path_1.dirname)(result);
|
|
242
|
+
const { source, name } = yield readJson(targetDir, fileName);
|
|
243
|
+
if (!pilets.includes(name)) {
|
|
244
|
+
if (typeof source === 'string') {
|
|
245
|
+
(0, log_1.log)('generalDebug_0003', `Found a "source" field with value "${source}".`);
|
|
246
|
+
const target = (0, path_1.resolve)(targetDir, source);
|
|
247
|
+
const exists = yield checkExists(target);
|
|
248
|
+
if (exists) {
|
|
249
|
+
(0, log_1.log)('generalDebug_0003', `Taking existing target as "${target}".`);
|
|
250
|
+
matched(name, target);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
(0, log_1.log)('generalDebug_0003', `Source target "${target}" does not exist. Skipped.`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
(0, log_1.log)('generalDebug_0003', `No "source" field found. Trying combinations in "src".`);
|
|
258
|
+
const files = yield matchPattern(targetDir, `src/index.{${exts}}`);
|
|
259
|
+
if (files.length > 0) {
|
|
260
|
+
(0, log_1.log)('generalDebug_0003', `Found a result; taking "${files[0]}".`);
|
|
261
|
+
matched(name, files[0]);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
(0, log_1.log)('generalDebug_0003', `Found no results in "src". Skipped.`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
245
267
|
}
|
|
246
268
|
}
|
|
247
269
|
else {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
270
|
+
const packageJson = yield findFile(result, nameOfPackageJson);
|
|
271
|
+
if (packageJson) {
|
|
272
|
+
const targetDir = (0, path_1.dirname)(packageJson);
|
|
273
|
+
const { name } = yield readJson(targetDir, nameOfPackageJson);
|
|
274
|
+
if (!pilets.includes(name)) {
|
|
275
|
+
(0, log_1.log)('generalDebug_0003', `Entry point result is "${result}".`);
|
|
276
|
+
matched(name, result);
|
|
277
|
+
}
|
|
253
278
|
}
|
|
254
279
|
else {
|
|
255
|
-
log_1.log('generalDebug_0003', `
|
|
280
|
+
(0, log_1.log)('generalDebug_0003', `Could not find "${nameOfPackageJson}" for entry "${result}". Skipping.`);
|
|
256
281
|
}
|
|
257
282
|
}
|
|
258
283
|
}
|
|
259
|
-
else {
|
|
260
|
-
log_1.log('generalDebug_0003', `Entry point result is "${firstResult}".`);
|
|
261
|
-
matches.push(firstResult);
|
|
262
|
-
}
|
|
263
284
|
}
|
|
264
285
|
}))));
|
|
265
286
|
return matches;
|
|
266
287
|
});
|
|
267
288
|
}
|
|
268
|
-
exports.
|
|
289
|
+
exports.matchAnyPilet = matchAnyPilet;
|
|
269
290
|
function matchFiles(baseDir, pattern) {
|
|
270
291
|
return new Promise((resolve, reject) => {
|
|
271
|
-
external_1.glob(pattern, {
|
|
292
|
+
(0, external_1.glob)(pattern, {
|
|
272
293
|
cwd: baseDir,
|
|
273
294
|
absolute: true,
|
|
274
295
|
dot: true,
|
|
@@ -285,14 +306,14 @@ function matchFiles(baseDir, pattern) {
|
|
|
285
306
|
exports.matchFiles = matchFiles;
|
|
286
307
|
function createFileIfNotExists(targetDir, fileName, content, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
287
308
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
289
|
-
log_1.log('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
309
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
310
|
+
(0, log_1.log)('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
290
311
|
const exists = yield checkExists(targetFile);
|
|
291
312
|
if (!exists ||
|
|
292
313
|
forceOverwrite === enums_1.ForceOverwrite.yes ||
|
|
293
314
|
(forceOverwrite === enums_1.ForceOverwrite.prompt && (yield promptOverwrite(targetFile)))) {
|
|
294
|
-
yield createDirectory(path_1.dirname(targetFile));
|
|
295
|
-
log_1.log('generalDebug_0003', `Creating file "${targetFile}" ...`);
|
|
315
|
+
yield createDirectory((0, path_1.dirname)(targetFile));
|
|
316
|
+
(0, log_1.log)('generalDebug_0003', `Creating file "${targetFile}" ...`);
|
|
296
317
|
if (typeof content === 'string') {
|
|
297
318
|
yield writeText(targetDir, fileName, content);
|
|
298
319
|
}
|
|
@@ -305,13 +326,13 @@ function createFileIfNotExists(targetDir, fileName, content, forceOverwrite = en
|
|
|
305
326
|
exports.createFileIfNotExists = createFileIfNotExists;
|
|
306
327
|
function updateExistingFile(targetDir, fileName, content) {
|
|
307
328
|
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
309
|
-
log_1.log('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
329
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
330
|
+
(0, log_1.log)('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
310
331
|
const exists = yield checkExists(targetFile);
|
|
311
332
|
if (exists) {
|
|
312
|
-
log_1.log('generalDebug_0003', `Updating file "${targetFile}" ...`);
|
|
333
|
+
(0, log_1.log)('generalDebug_0003', `Updating file "${targetFile}" ...`);
|
|
313
334
|
yield new Promise((resolve, reject) => {
|
|
314
|
-
fs_2.writeFile(targetFile, content, 'utf8', (err) => (err ? reject(err) : resolve()));
|
|
335
|
+
(0, fs_2.writeFile)(targetFile, content, 'utf8', (err) => (err ? reject(err) : resolve()));
|
|
315
336
|
});
|
|
316
337
|
}
|
|
317
338
|
});
|
|
@@ -320,43 +341,43 @@ exports.updateExistingFile = updateExistingFile;
|
|
|
320
341
|
function getHash(targetFile) {
|
|
321
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
322
343
|
return new Promise((resolve) => {
|
|
323
|
-
fs_2.readFile(targetFile, (err, c) => (err ? resolve(undefined) : resolve(hash_1.computeHash(c))));
|
|
344
|
+
(0, fs_2.readFile)(targetFile, (err, c) => (err ? resolve(undefined) : resolve((0, hash_1.computeHash)(c))));
|
|
324
345
|
});
|
|
325
346
|
});
|
|
326
347
|
}
|
|
327
348
|
exports.getHash = getHash;
|
|
328
349
|
function mergeWithJson(targetDir, fileName, newContent) {
|
|
329
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
330
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
351
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
331
352
|
const content = yield new Promise((resolve, reject) => {
|
|
332
|
-
fs_2.readFile(targetFile, 'utf8', (err, c) => (err ? reject(err) : resolve(c)));
|
|
353
|
+
(0, fs_2.readFile)(targetFile, 'utf8', (err, c) => (err ? reject(err) : resolve(c)));
|
|
333
354
|
});
|
|
334
355
|
const originalContent = JSON.parse(content);
|
|
335
|
-
return merge_1.deepMerge(originalContent, newContent);
|
|
356
|
+
return (0, merge_1.deepMerge)(originalContent, newContent);
|
|
336
357
|
});
|
|
337
358
|
}
|
|
338
359
|
exports.mergeWithJson = mergeWithJson;
|
|
339
360
|
function readJson(targetDir, fileName) {
|
|
340
361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
341
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
362
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
342
363
|
const content = yield new Promise((resolve) => {
|
|
343
|
-
fs_2.readFile(targetFile, 'utf8', (err, c) => (err ? resolve('') : resolve(c)));
|
|
364
|
+
(0, fs_2.readFile)(targetFile, 'utf8', (err, c) => (err ? resolve('') : resolve(c)));
|
|
344
365
|
});
|
|
345
366
|
return JSON.parse(content || '{}');
|
|
346
367
|
});
|
|
347
368
|
}
|
|
348
369
|
exports.readJson = readJson;
|
|
349
370
|
function readBinary(targetDir, fileName) {
|
|
350
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
371
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
351
372
|
return new Promise((resolve) => {
|
|
352
|
-
fs_2.readFile(targetFile, (err, c) => (err ? resolve(undefined) : resolve(c)));
|
|
373
|
+
(0, fs_2.readFile)(targetFile, (err, c) => (err ? resolve(undefined) : resolve(c)));
|
|
353
374
|
});
|
|
354
375
|
}
|
|
355
376
|
exports.readBinary = readBinary;
|
|
356
377
|
function readText(targetDir, fileName) {
|
|
357
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
378
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
358
379
|
return new Promise((resolve) => {
|
|
359
|
-
fs_2.readFile(targetFile, 'utf8', (err, c) => (err ? resolve(undefined) : resolve(c)));
|
|
380
|
+
(0, fs_2.readFile)(targetFile, 'utf8', (err, c) => (err ? resolve(undefined) : resolve(c)));
|
|
360
381
|
});
|
|
361
382
|
}
|
|
362
383
|
exports.readText = readText;
|
|
@@ -371,9 +392,9 @@ function writeText(targetDir, fileName, content) {
|
|
|
371
392
|
}
|
|
372
393
|
exports.writeText = writeText;
|
|
373
394
|
function writeBinary(targetDir, fileName, data) {
|
|
374
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
395
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
375
396
|
return new Promise((resolve, reject) => {
|
|
376
|
-
fs_2.writeFile(targetFile, data, (err) => (err ? reject(err) : resolve()));
|
|
397
|
+
(0, fs_2.writeFile)(targetFile, data, (err) => (err ? reject(err) : resolve()));
|
|
377
398
|
});
|
|
378
399
|
}
|
|
379
400
|
exports.writeBinary = writeBinary;
|
|
@@ -386,11 +407,11 @@ function updateExistingJson(targetDir, fileName, newContent) {
|
|
|
386
407
|
exports.updateExistingJson = updateExistingJson;
|
|
387
408
|
function copy(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
388
409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
389
|
-
yield createDirectory(path_1.dirname(target));
|
|
410
|
+
yield createDirectory((0, path_1.dirname)(target));
|
|
390
411
|
try {
|
|
391
412
|
const flag = forceOverwrite === enums_1.ForceOverwrite.yes ? 0 : fs_2.constants.COPYFILE_EXCL;
|
|
392
413
|
yield new Promise((resolve, reject) => {
|
|
393
|
-
fs_2.copyFile(source, target, flag, (err) => (err ? reject(err) : resolve()));
|
|
414
|
+
(0, fs_2.copyFile)(source, target, flag, (err) => (err ? reject(err) : resolve()));
|
|
394
415
|
});
|
|
395
416
|
return true;
|
|
396
417
|
}
|
|
@@ -402,7 +423,7 @@ function copy(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
|
402
423
|
}
|
|
403
424
|
}
|
|
404
425
|
else {
|
|
405
|
-
log_1.log('didNotOverWriteFile_0045', target);
|
|
426
|
+
(0, log_1.log)('didNotOverWriteFile_0045', target);
|
|
406
427
|
}
|
|
407
428
|
}
|
|
408
429
|
return false;
|
|
@@ -418,7 +439,7 @@ function remove(target) {
|
|
|
418
439
|
exports.remove = remove;
|
|
419
440
|
function removeFile(target) {
|
|
420
441
|
return new Promise((resolve, reject) => {
|
|
421
|
-
fs_1.unlink(target, (err) => {
|
|
442
|
+
(0, fs_1.unlink)(target, (err) => {
|
|
422
443
|
if (err) {
|
|
423
444
|
reject(err);
|
|
424
445
|
}
|
|
@@ -433,8 +454,8 @@ function move(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
|
433
454
|
return __awaiter(this, void 0, void 0, function* () {
|
|
434
455
|
const dir = yield checkIsDirectory(target);
|
|
435
456
|
if (dir) {
|
|
436
|
-
const file = path_1.basename(source);
|
|
437
|
-
target = path_1.resolve(target, file);
|
|
457
|
+
const file = (0, path_1.basename)(source);
|
|
458
|
+
target = (0, path_1.resolve)(target, file);
|
|
438
459
|
}
|
|
439
460
|
const success = yield copy(source, target, forceOverwrite);
|
|
440
461
|
if (success) {
|
|
@@ -447,12 +468,12 @@ function move(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
|
447
468
|
exports.move = move;
|
|
448
469
|
function getSourceFiles(entry) {
|
|
449
470
|
return __awaiter(this, void 0, void 0, function* () {
|
|
450
|
-
const dir = path_1.dirname(entry);
|
|
451
|
-
log_1.log('generalDebug_0003', `Trying to get source files from "${dir}" ...`);
|
|
471
|
+
const dir = (0, path_1.dirname)(entry);
|
|
472
|
+
(0, log_1.log)('generalDebug_0003', `Trying to get source files from "${dir}" ...`);
|
|
452
473
|
const files = yield matchFiles(dir, '**/*.?(jsx|tsx|js|ts)');
|
|
453
474
|
return files.map((path) => {
|
|
454
|
-
const directory = path_1.dirname(path);
|
|
455
|
-
const name = path_1.basename(path);
|
|
475
|
+
const directory = (0, path_1.dirname)(path);
|
|
476
|
+
const name = (0, path_1.basename)(path);
|
|
456
477
|
return {
|
|
457
478
|
path,
|
|
458
479
|
directory,
|
|
@@ -461,7 +482,7 @@ function getSourceFiles(entry) {
|
|
|
461
482
|
return __awaiter(this, void 0, void 0, function* () {
|
|
462
483
|
const content = yield readText(directory, name);
|
|
463
484
|
if (name.endsWith('.ts') || name.endsWith('.tsx')) {
|
|
464
|
-
return typescript_1.transpileModule(content, {
|
|
485
|
+
return (0, typescript_1.transpileModule)(content, {
|
|
465
486
|
fileName: path,
|
|
466
487
|
moduleName: name,
|
|
467
488
|
compilerOptions: {
|