piral-cli 1.3.0-beta.6013 → 1.3.0-beta.6047
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/pack.js +27 -11
- package/lib/common/pack.js.map +1 -1
- package/package.json +2 -2
- package/src/common/pack.test.ts +1 -0
- package/src/common/pack.ts +30 -18
package/lib/common/pack.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createPiletPackage = void 0;
|
|
13
|
-
const os_1 = require("os");
|
|
14
13
|
const path_1 = require("path");
|
|
15
14
|
const archive_1 = require("./archive");
|
|
16
15
|
const utils_1 = require("./utils");
|
|
@@ -29,6 +28,25 @@ function getPiletContentDir(root, packageData) {
|
|
|
29
28
|
return root;
|
|
30
29
|
});
|
|
31
30
|
}
|
|
31
|
+
function getUniqueFiles(files) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const file of files) {
|
|
35
|
+
const isDirectory = yield (0, io_1.checkIsDirectory)(file);
|
|
36
|
+
if (isDirectory) {
|
|
37
|
+
const names = yield (0, io_1.getFileNames)(file);
|
|
38
|
+
const subFiles = names.map((name) => (0, path_1.resolve)(file, name));
|
|
39
|
+
const items = yield getUniqueFiles(subFiles);
|
|
40
|
+
const unique = items.filter((m) => (0, utils_1.onlyUniqueFiles)(m, result.length, result));
|
|
41
|
+
result.push(...unique);
|
|
42
|
+
}
|
|
43
|
+
else if ((0, utils_1.onlyUniqueFiles)(file, result.length, result)) {
|
|
44
|
+
result.push(file);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
32
50
|
function createPiletPackage(baseDir, source, target) {
|
|
33
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
52
|
const root = (0, path_1.resolve)(baseDir, source);
|
|
@@ -56,23 +74,21 @@ function createPiletPackage(baseDir, source, target) {
|
|
|
56
74
|
const files = [(0, path_1.resolve)(root, 'package.json'), content];
|
|
57
75
|
const readme = (0, path_1.resolve)(root, 'README.md');
|
|
58
76
|
if (Array.isArray(pckg.files)) {
|
|
59
|
-
|
|
77
|
+
const additionalFiles = pckg.files
|
|
78
|
+
.filter((f) => typeof f === 'string')
|
|
79
|
+
.map((f) => (0, path_1.resolve)(root, f));
|
|
80
|
+
files.push(...additionalFiles);
|
|
60
81
|
}
|
|
61
82
|
if (yield (0, io_1.checkExists)(readme)) {
|
|
62
83
|
files.push(readme);
|
|
63
84
|
}
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
const uniqueFiles = files.filter(utils_1.onlyUniqueFiles);
|
|
67
|
-
(0, log_1.log)('generalDebug_0003', `Creating package with content from "${content}" ...`);
|
|
68
|
-
yield Promise.all(uniqueFiles.map((file) => (0, io_1.copy)(file, (0, path_1.resolve)(cwd, (0, path_1.relative)(root, file)))));
|
|
85
|
+
(0, log_1.log)('generalDebug_0003', `Reading out unique files from "${content}" ...`);
|
|
86
|
+
const uniqueFiles = yield getUniqueFiles(files);
|
|
69
87
|
(0, log_1.log)('generalDebug_0003', `Creating directory if not exist for "${file}" ...`);
|
|
70
88
|
yield (0, io_1.createDirectory)((0, path_1.dirname)(file));
|
|
71
89
|
(0, log_1.log)('generalDebug_0003', `Creating compressed archive at "${file}" relative to "${root}" ...`);
|
|
72
|
-
yield (0, archive_1.createTgz)(file,
|
|
73
|
-
(0, log_1.log)('generalDebug_0003', `Successfully created package from "${
|
|
74
|
-
yield (0, io_1.removeDirectory)(cwd);
|
|
75
|
-
(0, log_1.log)('generalDebug_0003', `Packed file "${file}".`);
|
|
90
|
+
yield (0, archive_1.createTgz)(file, root, uniqueFiles.map((file) => (0, path_1.relative)(root, file)));
|
|
91
|
+
(0, log_1.log)('generalDebug_0003', `Successfully created package "${file}" from "${root}".`);
|
|
76
92
|
return file;
|
|
77
93
|
});
|
|
78
94
|
}
|
package/lib/common/pack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.js","sourceRoot":"","sources":["../../src/common/pack.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"pack.js","sourceRoot":"","sources":["../../src/common/pack.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA4D;AAC5D,uCAAsC;AACtC,mCAA0C;AAC1C,+BAA4C;AAC5C,6BAA8F;AAC9F,uCAAsD;AAEtD,SAAe,kBAAkB,CAAC,IAAY,EAAE,WAAgB;;QAC9D,MAAM,KAAK,GAAG,IAAA,mCAAyB,EAAC,WAAW,CAAC,CAAC;QAErD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,IAAI,GAAG,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEjC,IAAI,MAAM,IAAA,gBAAW,EAAC,IAAI,CAAC,EAAE;gBAC3B,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;aACtB;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAED,SAAe,cAAc,CAAC,KAAoB;;QAChD,MAAM,MAAM,GAAkB,EAAE,CAAC;QAEjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC;YAEjD,IAAI,WAAW,EAAE;gBACf,MAAM,KAAK,GAAG,MAAM,IAAA,iBAAY,EAAC,IAAI,CAAC,CAAC;gBACvC,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC1D,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC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C,mBAAmB,EAAE,kCAAkC,OAAO,OAAO,CAAC,CAAC;QAC3E,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;QAEhD,IAAA,SAAG,EAAC,mBAAmB,EAAE,wCAAwC,IAAI,OAAO,CAAC,CAAC;QAC9E,MAAM,IAAA,oBAAe,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,CAAC;QAErC,IAAA,SAAG,EAAC,mBAAmB,EAAE,mCAAmC,IAAI,kBAAkB,IAAI,OAAO,CAAC,CAAC;QAC/F,MAAM,IAAA,mBAAS,EACb,IAAI,EACJ,IAAI,EACJ,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,eAAQ,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAChD,CAAC;QAEF,IAAA,SAAG,EAAC,mBAAmB,EAAE,iCAAiC,IAAI,WAAW,IAAI,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AA1DD,gDA0DC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.6047",
|
|
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": "05f6c110d27cc5d7b9ef334cb83b96c73c7d84bf"
|
|
85
85
|
}
|
package/src/common/pack.test.ts
CHANGED
|
@@ -6,6 +6,7 @@ let json: any = {};
|
|
|
6
6
|
jest.mock('./io', () => ({
|
|
7
7
|
readJson: jest.fn(() => json),
|
|
8
8
|
removeDirectory: jest.fn(() => Promise.resolve()),
|
|
9
|
+
checkIsDirectory: jest.fn(() => false),
|
|
9
10
|
makeTempDir: jest.fn(() => Promise.resolve('')),
|
|
10
11
|
copy: jest.fn(() => Promise.resolve()),
|
|
11
12
|
checkExists: jest.fn(() => Promise.resolve(true)),
|
package/src/common/pack.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolve, relative, join, dirname, basename } from 'path';
|
|
1
|
+
import { resolve, relative, dirname, basename } from 'path';
|
|
3
2
|
import { createTgz } from './archive';
|
|
4
3
|
import { onlyUniqueFiles } from './utils';
|
|
5
4
|
import { log, progress, fail } from './log';
|
|
6
|
-
import { readJson,
|
|
5
|
+
import { readJson, checkExists, createDirectory, checkIsDirectory, getFileNames } from './io';
|
|
7
6
|
import { getPossiblePiletMainPaths } from './inspect';
|
|
8
7
|
|
|
9
8
|
async function getPiletContentDir(root: string, packageData: any) {
|
|
@@ -20,6 +19,26 @@ async function getPiletContentDir(root: string, packageData: any) {
|
|
|
20
19
|
return root;
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
async function getUniqueFiles(files: Array<string>) {
|
|
23
|
+
const result: Array<string> = [];
|
|
24
|
+
|
|
25
|
+
for (const file of files) {
|
|
26
|
+
const isDirectory = await checkIsDirectory(file);
|
|
27
|
+
|
|
28
|
+
if (isDirectory) {
|
|
29
|
+
const names = await getFileNames(file);
|
|
30
|
+
const subFiles = names.map((name) => resolve(file, name));
|
|
31
|
+
const items = await getUniqueFiles(subFiles);
|
|
32
|
+
const unique = items.filter((m) => onlyUniqueFiles(m, result.length, result));
|
|
33
|
+
result.push(...unique);
|
|
34
|
+
} else if (onlyUniqueFiles(file, result.length, result)) {
|
|
35
|
+
result.push(file);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
export async function createPiletPackage(baseDir: string, source: string, target: string) {
|
|
24
43
|
const root = resolve(baseDir, source);
|
|
25
44
|
const dest = resolve(baseDir, target);
|
|
@@ -53,36 +72,29 @@ export async function createPiletPackage(baseDir: string, source: string, target
|
|
|
53
72
|
const readme = resolve(root, 'README.md');
|
|
54
73
|
|
|
55
74
|
if (Array.isArray(pckg.files)) {
|
|
56
|
-
|
|
75
|
+
const additionalFiles = pckg.files
|
|
76
|
+
.filter((f: string) => typeof f === 'string')
|
|
77
|
+
.map((f: string) => resolve(root, f));
|
|
78
|
+
files.push(...additionalFiles);
|
|
57
79
|
}
|
|
58
80
|
|
|
59
81
|
if (await checkExists(readme)) {
|
|
60
82
|
files.push(readme);
|
|
61
83
|
}
|
|
62
84
|
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const uniqueFiles = files.filter(onlyUniqueFiles);
|
|
66
|
-
log('generalDebug_0003', `Creating package with content from "${content}" ...`);
|
|
67
|
-
|
|
68
|
-
await Promise.all(uniqueFiles.map((file) => copy(file, resolve(cwd, relative(root, file)))));
|
|
85
|
+
log('generalDebug_0003', `Reading out unique files from "${content}" ...`);
|
|
86
|
+
const uniqueFiles = await getUniqueFiles(files);
|
|
69
87
|
|
|
70
88
|
log('generalDebug_0003', `Creating directory if not exist for "${file}" ...`);
|
|
71
|
-
|
|
72
89
|
await createDirectory(dirname(file));
|
|
73
90
|
|
|
74
91
|
log('generalDebug_0003', `Creating compressed archive at "${file}" relative to "${root}" ...`);
|
|
75
|
-
|
|
76
92
|
await createTgz(
|
|
77
93
|
file,
|
|
78
|
-
|
|
94
|
+
root,
|
|
79
95
|
uniqueFiles.map((file) => relative(root, file)),
|
|
80
96
|
);
|
|
81
97
|
|
|
82
|
-
log('generalDebug_0003', `Successfully created package from "${
|
|
83
|
-
|
|
84
|
-
await removeDirectory(cwd);
|
|
85
|
-
|
|
86
|
-
log('generalDebug_0003', `Packed file "${file}".`);
|
|
98
|
+
log('generalDebug_0003', `Successfully created package "${file}" from "${root}".`);
|
|
87
99
|
return file;
|
|
88
100
|
}
|