@zokugun/artifact 0.1.0 → 0.2.2
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/README.md +13 -6
- package/lib/cli.js +7 -2
- package/lib/commands/add.js +43 -9
- package/lib/commands/index.js +7 -0
- package/lib/commands/update.js +73 -0
- package/lib/compositors/compose.js +13 -5
- package/lib/compositors/index.js +3 -1
- package/lib/compositors/json.js +9 -5
- package/lib/compositors/map-sort.js +16 -0
- package/lib/compositors/rc.js +14 -4
- package/lib/compositors/yaml.js +8 -2
- package/lib/config/index.js +7 -0
- package/lib/{steps/read-target-config.js → config/read-config.js} +31 -14
- package/lib/config/write-config.js +44 -0
- package/lib/journeys/default/index.js +1 -1
- package/lib/journeys/fixpack/index.js +16 -0
- package/lib/journeys/index.js +7 -3
- package/lib/journeys/package/index.js +14 -14
- package/lib/journeys/rc/index.js +1 -1
- package/lib/journeys/tsconfig/index.js +20 -0
- package/lib/routes/command.js +30 -5
- package/lib/routes/index.js +5 -3
- package/lib/routes/lines-concat.js +1 -1
- package/lib/routes/list-sort-concat.js +42 -0
- package/lib/routes/{hash.js → map-concat.js} +3 -3
- package/lib/routes/overwrite.js +1 -1
- package/lib/routes/primitive.js +2 -2
- package/lib/steps/apply-formatting.js +1 -1
- package/lib/steps/copy-binary-files.js +12 -1
- package/lib/steps/index.js +29 -6
- package/lib/steps/merge-text-files.js +22 -7
- package/lib/steps/read-editor-config.js +6 -2
- package/lib/steps/read-files.js +10 -10
- package/lib/steps/read-incoming-config.js +20 -0
- package/lib/steps/read-incoming-package.js +3 -0
- package/lib/steps/validate-newer-package.js +25 -0
- package/lib/steps/validate-not-present-package.js +33 -0
- package/lib/steps/validate-updatability.js +160 -0
- package/lib/{utils/command → types}/command.js +0 -0
- package/lib/utils/command/join-command.js +6 -1
- package/lib/utils/dev-null.js +8 -0
- package/lib/utils/read-buffer.js +1 -1
- package/package.json +16 -8
- package/lib/install.js +0 -32
- package/lib/steps/update-target-config.js +0 -50
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
7
|
+
const compositors_1 = require("../../compositors");
|
|
8
|
+
const routes_1 = require("../../routes");
|
|
9
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
10
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
11
|
+
const mainRoute = (0, compositors_1.compose)({
|
|
12
|
+
compilerOptions: (0, compositors_1.compose)({
|
|
13
|
+
lib: routes_1.listConcat,
|
|
14
|
+
$$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [isPlainObject_1.default, routes_1.mapConcat], routes_1.primitive),
|
|
15
|
+
}),
|
|
16
|
+
$$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [isPlainObject_1.default, routes_1.mapConcat], routes_1.primitive),
|
|
17
|
+
});
|
|
18
|
+
const jsonRoute = (0, compositors_1.json)(mainRoute);
|
|
19
|
+
const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/tsconfig(?:\.\w+)?\.json$/, jsonRoute]);
|
|
20
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
|
package/lib/routes/command.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
4
|
const command_1 = require("../utils/command");
|
|
5
|
-
const
|
|
5
|
+
const list_concat_1 = require("./list-concat");
|
|
6
6
|
function command({ current, incoming }) {
|
|
7
|
+
var _a;
|
|
7
8
|
if (!incoming) {
|
|
8
9
|
return current !== null && current !== void 0 ? current : '';
|
|
9
10
|
}
|
|
@@ -12,10 +13,34 @@ function command({ current, incoming }) {
|
|
|
12
13
|
}
|
|
13
14
|
const currentCommand = (0, command_1.splitCommand)(current);
|
|
14
15
|
const incomingCommand = (0, command_1.splitCommand)(incoming);
|
|
15
|
-
const result =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const result = {};
|
|
17
|
+
for (const [name, instances] of Object.entries(incomingCommand)) {
|
|
18
|
+
if (currentCommand[name]) {
|
|
19
|
+
result[name] = [];
|
|
20
|
+
for (const [index, instance] of instances.entries()) {
|
|
21
|
+
if (currentCommand[name][index]) {
|
|
22
|
+
const currentInstance = currentCommand[name][index];
|
|
23
|
+
result[name].push({
|
|
24
|
+
args: (0, list_concat_1.listConcat)({
|
|
25
|
+
current: currentInstance.args,
|
|
26
|
+
incoming: instance.args,
|
|
27
|
+
}),
|
|
28
|
+
env: (0, list_concat_1.listConcat)({
|
|
29
|
+
current: currentInstance.env,
|
|
30
|
+
incoming: instance.env,
|
|
31
|
+
}),
|
|
32
|
+
separator: (_a = instance.separator) !== null && _a !== void 0 ? _a : currentInstance.separator,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result[name].push(instance);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
result[name] = instances;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
19
44
|
return (0, command_1.joinCommand)(result);
|
|
20
45
|
}
|
|
21
46
|
exports.command = command;
|
package/lib/routes/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.primitive = exports.overwrite = exports.listConcat = exports.linesConcat = exports.
|
|
3
|
+
exports.primitive = exports.overwrite = exports.listSortConcat = exports.listConcat = exports.linesConcat = exports.mapConcat = exports.command = void 0;
|
|
4
4
|
var command_1 = require("./command");
|
|
5
5
|
Object.defineProperty(exports, "command", { enumerable: true, get: function () { return command_1.command; } });
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "
|
|
6
|
+
var map_concat_1 = require("./map-concat");
|
|
7
|
+
Object.defineProperty(exports, "mapConcat", { enumerable: true, get: function () { return map_concat_1.mapConcat; } });
|
|
8
8
|
var lines_concat_1 = require("./lines-concat");
|
|
9
9
|
Object.defineProperty(exports, "linesConcat", { enumerable: true, get: function () { return lines_concat_1.linesConcat; } });
|
|
10
10
|
var list_concat_1 = require("./list-concat");
|
|
11
11
|
Object.defineProperty(exports, "listConcat", { enumerable: true, get: function () { return list_concat_1.listConcat; } });
|
|
12
|
+
var list_sort_concat_1 = require("./list-sort-concat");
|
|
13
|
+
Object.defineProperty(exports, "listSortConcat", { enumerable: true, get: function () { return list_sort_concat_1.listSortConcat; } });
|
|
12
14
|
var overwrite_1 = require("./overwrite");
|
|
13
15
|
Object.defineProperty(exports, "overwrite", { enumerable: true, get: function () { return overwrite_1.overwrite; } });
|
|
14
16
|
var primitive_1 = require("./primitive");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.linesConcat = void 0;
|
|
4
|
-
const trim_final_newline_1 = require("../utils/trim-final-newline");
|
|
5
4
|
const to_lines_1 = require("../utils/to-lines");
|
|
5
|
+
const trim_final_newline_1 = require("../utils/trim-final-newline");
|
|
6
6
|
const list_concat_1 = require("./list-concat");
|
|
7
7
|
function linesConcat({ current, incoming }) {
|
|
8
8
|
if (!incoming) {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listSortConcat = void 0;
|
|
4
|
+
function listSortConcat({ current, incoming }) {
|
|
5
|
+
if (!incoming) {
|
|
6
|
+
return current !== null && current !== void 0 ? current : [];
|
|
7
|
+
}
|
|
8
|
+
if (!current) {
|
|
9
|
+
return incoming;
|
|
10
|
+
}
|
|
11
|
+
const sorting = [];
|
|
12
|
+
const weight2values = {};
|
|
13
|
+
const hash2weights = {};
|
|
14
|
+
let lastWeight = 0;
|
|
15
|
+
for (const [index, value] of current.entries()) {
|
|
16
|
+
const hash = JSON.stringify(value);
|
|
17
|
+
if (!hash2weights[hash]) {
|
|
18
|
+
const weight = (index + 1) * 1000;
|
|
19
|
+
hash2weights[hash] = weight;
|
|
20
|
+
weight2values[weight] = value;
|
|
21
|
+
sorting.push(weight);
|
|
22
|
+
lastWeight = weight;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
let currentWeight = lastWeight;
|
|
26
|
+
for (const value of incoming) {
|
|
27
|
+
const hash = JSON.stringify(value);
|
|
28
|
+
if (hash2weights[hash]) {
|
|
29
|
+
currentWeight = hash2weights[hash];
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
++currentWeight;
|
|
33
|
+
hash2weights[hash] = currentWeight;
|
|
34
|
+
weight2values[currentWeight] = value;
|
|
35
|
+
sorting.push(currentWeight);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
sorting.sort((a, b) => a - b);
|
|
39
|
+
const result = sorting.map((weight) => weight2values[weight]);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
exports.listSortConcat = listSortConcat;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.mapConcat = void 0;
|
|
4
|
+
function mapConcat({ current, incoming }) {
|
|
5
5
|
if (!incoming) {
|
|
6
6
|
return current !== null && current !== void 0 ? current : {};
|
|
7
7
|
}
|
|
@@ -10,4 +10,4 @@ function hash({ current, incoming }) {
|
|
|
10
10
|
}
|
|
11
11
|
return Object.assign(Object.assign({}, current), incoming);
|
|
12
12
|
}
|
|
13
|
-
exports.
|
|
13
|
+
exports.mapConcat = mapConcat;
|
package/lib/routes/overwrite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.overwrite = void 0;
|
|
4
4
|
function overwrite({ current, incoming }) {
|
|
5
|
-
if (
|
|
5
|
+
if (typeof incoming === 'undefined') {
|
|
6
6
|
return current !== null && current !== void 0 ? current : [];
|
|
7
7
|
}
|
|
8
8
|
else {
|
package/lib/routes/primitive.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.primitive = void 0;
|
|
4
4
|
function primitive({ current, incoming }) {
|
|
5
|
-
if (
|
|
5
|
+
if (typeof incoming === 'undefined') {
|
|
6
6
|
return current !== null && current !== void 0 ? current : [];
|
|
7
7
|
}
|
|
8
|
-
if (
|
|
8
|
+
if (typeof current === 'undefined') {
|
|
9
9
|
return incoming;
|
|
10
10
|
}
|
|
11
11
|
if (current === incoming) {
|
|
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.applyFormatting = void 0;
|
|
16
|
-
const fnmatch_1 = __importDefault(require("editorconfig/src/lib/fnmatch"));
|
|
17
16
|
const detect_indent_1 = __importDefault(require("detect-indent"));
|
|
17
|
+
const fnmatch_1 = __importDefault(require("editorconfig/src/lib/fnmatch"));
|
|
18
18
|
const format_1 = require("../types/format");
|
|
19
19
|
function applyFormat(file, format) {
|
|
20
20
|
if (format.indentStyle === format_1.IndentStyle.SPACE) {
|
|
@@ -15,10 +15,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.copyBinaryFiles = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
-
function copyBinaryFiles({ binaryFiles, incomingPath, targetPath, options }) {
|
|
18
|
+
function copyBinaryFiles({ binaryFiles, incomingPath, targetPath, onMissing, onUpdate, options }) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const cwd = path_1.default.join(incomingPath, 'configs');
|
|
21
21
|
for (const file of binaryFiles) {
|
|
22
|
+
try {
|
|
23
|
+
yield fs_extra_1.default.access(path_1.default.join(targetPath, file));
|
|
24
|
+
if (onUpdate(file)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
if (onMissing(file)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
const source = path_1.default.join(cwd, file);
|
|
23
34
|
const target = path_1.default.join(targetPath, file);
|
|
24
35
|
yield fs_extra_1.default.copyFile(source, target);
|
package/lib/steps/index.js
CHANGED
|
@@ -16,9 +16,11 @@ const insert_final_new_line_1 = require("./insert-final-new-line");
|
|
|
16
16
|
const merge_text_files_1 = require("./merge-text-files");
|
|
17
17
|
const read_editor_config_1 = require("./read-editor-config");
|
|
18
18
|
const read_files_1 = require("./read-files");
|
|
19
|
+
const read_incoming_config_1 = require("./read-incoming-config");
|
|
19
20
|
const read_incoming_package_1 = require("./read-incoming-package");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
21
|
+
const validate_newer_package_1 = require("./validate-newer-package");
|
|
22
|
+
const validate_not_present_package_1 = require("./validate-not-present-package");
|
|
23
|
+
const validate_updatability_1 = require("./validate-updatability");
|
|
22
24
|
const write_text_files_1 = require("./write-text-files");
|
|
23
25
|
exports.steps = {
|
|
24
26
|
applyFormatting: apply_formatting_1.applyFormatting,
|
|
@@ -27,16 +29,37 @@ exports.steps = {
|
|
|
27
29
|
mergeTextFiles: merge_text_files_1.mergeTextFiles,
|
|
28
30
|
readEditorConfig: read_editor_config_1.readEditorConfig,
|
|
29
31
|
readFiles: read_files_1.readFiles,
|
|
32
|
+
readIncomingConfig: read_incoming_config_1.readIncomingConfig,
|
|
30
33
|
readIncomingPackage: read_incoming_package_1.readIncomingPackage,
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
validateNewerPackage: validate_newer_package_1.validateNewerPackage,
|
|
35
|
+
validateNotPresentPackage: validate_not_present_package_1.validateNotPresentPackage,
|
|
36
|
+
validateUpdatability: validate_updatability_1.validateUpdatability,
|
|
33
37
|
writeTextFiles: write_text_files_1.writeTextFiles,
|
|
34
38
|
};
|
|
35
39
|
function composeSteps(...steps) {
|
|
36
|
-
return (
|
|
40
|
+
return (targetPath, incomingPath, config, options) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const context = {
|
|
42
|
+
targetPath,
|
|
43
|
+
incomingPath,
|
|
44
|
+
onMissing: () => false,
|
|
45
|
+
onUpdate: () => false,
|
|
46
|
+
filters: () => undefined,
|
|
47
|
+
routes: () => undefined,
|
|
48
|
+
binaryFiles: [],
|
|
49
|
+
textFiles: [],
|
|
50
|
+
mergedTextFiles: [],
|
|
51
|
+
formats: [],
|
|
52
|
+
config,
|
|
53
|
+
options,
|
|
54
|
+
};
|
|
55
|
+
let skipped = false;
|
|
37
56
|
for (const step of steps) {
|
|
38
|
-
yield step(context)
|
|
57
|
+
if (yield step(context)) {
|
|
58
|
+
skipped = true;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
39
61
|
}
|
|
62
|
+
return skipped ? undefined : context;
|
|
40
63
|
});
|
|
41
64
|
}
|
|
42
65
|
exports.composeSteps = composeSteps;
|
|
@@ -16,18 +16,26 @@ exports.mergeTextFiles = void 0;
|
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
18
|
const journeys_1 = require("../journeys");
|
|
19
|
-
function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, options }) {
|
|
19
|
+
function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, onMissing, onUpdate, filters, routes, options }) {
|
|
20
|
+
var _a;
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
for (const file of textFiles) {
|
|
22
|
-
|
|
23
|
-
mergedTextFiles.push(file);
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const journey = (0, journeys_1.getJourney)(file.name);
|
|
23
|
+
const journey = (_a = routes(file.name)) !== null && _a !== void 0 ? _a : (0, journeys_1.getJourney)(file.name);
|
|
27
24
|
if (!journey) {
|
|
28
25
|
if (options.verbose) {
|
|
29
26
|
console.log(`${file.name}, no merger found`);
|
|
30
27
|
}
|
|
28
|
+
try {
|
|
29
|
+
yield fs_extra_1.default.access(path_1.default.join(targetPath, file.name));
|
|
30
|
+
if (onUpdate(file.name)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (_b) {
|
|
35
|
+
if (onMissing(file.name)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
31
39
|
mergedTextFiles.push(file);
|
|
32
40
|
continue;
|
|
33
41
|
}
|
|
@@ -35,12 +43,19 @@ function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, options }) {
|
|
|
35
43
|
let currentData;
|
|
36
44
|
try {
|
|
37
45
|
currentData = yield fs_extra_1.default.readFile(path_1.default.join(targetPath, name), 'utf-8');
|
|
46
|
+
if (onUpdate(name)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
|
-
catch (
|
|
50
|
+
catch (_c) {
|
|
51
|
+
if (onMissing(name)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
40
54
|
}
|
|
41
55
|
const data = journey.travel({
|
|
42
56
|
current: currentData,
|
|
43
57
|
incoming: file.data,
|
|
58
|
+
filters: filters(file.name),
|
|
44
59
|
});
|
|
45
60
|
mergedTextFiles.push({
|
|
46
61
|
name,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -33,8 +37,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
38
|
exports.readEditorConfig = void 0;
|
|
35
39
|
const path_1 = __importDefault(require("path"));
|
|
36
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
37
40
|
const editorconfig = __importStar(require("editorconfig"));
|
|
41
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
38
42
|
const format_1 = require("../types/format");
|
|
39
43
|
function buildFullGlob(glob) {
|
|
40
44
|
switch (glob.indexOf('/')) {
|
package/lib/steps/read-files.js
CHANGED
|
@@ -14,13 +14,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.readFiles = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const istextorbinary_1 = require("istextorbinary");
|
|
18
|
-
const globby_1 = __importDefault(require("globby"));
|
|
19
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const globby_1 = __importDefault(require("globby"));
|
|
19
|
+
const istextorbinary_1 = require("istextorbinary");
|
|
20
20
|
const read_buffer_1 = require("../utils/read-buffer");
|
|
21
|
-
function readFiles(
|
|
21
|
+
function readFiles({ incomingPath, textFiles, binaryFiles, options }) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const cwd = path_1.default.join(
|
|
23
|
+
const cwd = path_1.default.join(incomingPath, 'configs');
|
|
24
24
|
const files = yield (0, globby_1.default)(['**/*', '!**/*.lock', '!**/*-lock.*'], {
|
|
25
25
|
cwd,
|
|
26
26
|
dot: true,
|
|
@@ -33,30 +33,30 @@ function readFiles(context) {
|
|
|
33
33
|
if (data.startsWith('#!')) {
|
|
34
34
|
// the text file might be executable
|
|
35
35
|
const { mode } = yield fs_extra_1.default.stat(filePath);
|
|
36
|
-
|
|
36
|
+
textFiles.push({
|
|
37
37
|
name: file,
|
|
38
38
|
data,
|
|
39
39
|
mode,
|
|
40
40
|
finalNewLine,
|
|
41
41
|
});
|
|
42
|
-
if (
|
|
42
|
+
if (options.verbose) {
|
|
43
43
|
console.log(`${file} is a shebang file`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
|
|
47
|
+
textFiles.push({
|
|
48
48
|
name: file,
|
|
49
49
|
data,
|
|
50
50
|
finalNewLine,
|
|
51
51
|
});
|
|
52
|
-
if (
|
|
52
|
+
if (options.verbose) {
|
|
53
53
|
console.log(`${file} is a text file`);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
|
|
59
|
-
if (
|
|
58
|
+
binaryFiles.push(file);
|
|
59
|
+
if (options.verbose) {
|
|
60
60
|
console.log(`${file} is a binary file`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.readIncomingConfig = void 0;
|
|
13
|
+
const config_1 = require("../config");
|
|
14
|
+
function readIncomingConfig(context) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const [config] = yield (0, config_1.readConfig)(context.incomingPath);
|
|
17
|
+
context.incomingConfig = config;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.readIncomingConfig = readIncomingConfig;
|
|
@@ -19,6 +19,9 @@ function readIncomingPackage(context) {
|
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const filePath = path_1.default.resolve(context.incomingPath, './package.json');
|
|
21
21
|
context.incomingPackage = (yield fs_extra_1.default.readJSON(filePath));
|
|
22
|
+
if (!context.incomingPackage) {
|
|
23
|
+
throw new Error('The package of the incoming artifact can\'t be found.');
|
|
24
|
+
}
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
exports.readIncomingPackage = readIncomingPackage;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validateNewerPackage = void 0;
|
|
13
|
+
const semver_1 = require("semver");
|
|
14
|
+
function validateNewerPackage({ incomingPackage, config, options }) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
if (options.force) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const artifact = config.artifacts.find(({ name }) => name === incomingPackage.name);
|
|
20
|
+
if (artifact) {
|
|
21
|
+
return !(0, semver_1.gt)(incomingPackage.version, artifact.version);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.validateNewerPackage = validateNewerPackage;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validateNotPresentPackage = void 0;
|
|
13
|
+
function validateNotPresentPackage({ incomingPackage, config, options }) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (options.force) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { name } = incomingPackage;
|
|
19
|
+
const artifact = config.artifacts.find((artifact) => artifact.name === name);
|
|
20
|
+
if (artifact) {
|
|
21
|
+
if (options.skip) {
|
|
22
|
+
if (options.verbose) {
|
|
23
|
+
console.log('The incoming artifact is already present, skipping...');
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error('The incoming artifact has already been added.');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.validateNotPresentPackage = validateNotPresentPackage;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validateUpdatability = void 0;
|
|
13
|
+
const lodash_1 = require("lodash");
|
|
14
|
+
const micromatch_1 = require("micromatch");
|
|
15
|
+
const compositors_1 = require("../compositors");
|
|
16
|
+
const routes_1 = require("../routes");
|
|
17
|
+
function buildRoute(route) {
|
|
18
|
+
if (Array.isArray(route) && route.length > 0) {
|
|
19
|
+
let result = buildRoute(route[0]);
|
|
20
|
+
for (let i = 1; i < route.length; i++) {
|
|
21
|
+
if (route[i] === 'mapSort') {
|
|
22
|
+
result = (0, compositors_1.mapSort)(result);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error('Can\'t build route');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
else if ((0, lodash_1.isPlainObject)(route)) {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
32
|
+
const { compose: rtCompose, fork: rtFork, mapSort: rtMapSort } = route;
|
|
33
|
+
if (rtCompose) {
|
|
34
|
+
const map = {};
|
|
35
|
+
for (const [name, route] of Object.entries(rtCompose)) {
|
|
36
|
+
map[name] = buildRoute(route);
|
|
37
|
+
}
|
|
38
|
+
return (0, compositors_1.compose)(map);
|
|
39
|
+
}
|
|
40
|
+
else if (rtFork) {
|
|
41
|
+
const map = [];
|
|
42
|
+
if (rtFork.array) {
|
|
43
|
+
map.push([Array.isArray, buildRoute(rtFork.array)]);
|
|
44
|
+
}
|
|
45
|
+
if (rtFork.object) {
|
|
46
|
+
map.push([lodash_1.isPlainObject, buildRoute(rtFork.object)]);
|
|
47
|
+
}
|
|
48
|
+
if (rtFork.default) {
|
|
49
|
+
map.push(buildRoute(rtFork.default));
|
|
50
|
+
}
|
|
51
|
+
return (0, compositors_1.fork)(...map);
|
|
52
|
+
}
|
|
53
|
+
else if (rtMapSort) {
|
|
54
|
+
return (0, compositors_1.mapSort)(buildRoute(rtMapSort));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (route === 'command') {
|
|
58
|
+
return routes_1.command;
|
|
59
|
+
}
|
|
60
|
+
else if (route === 'linesConcat') {
|
|
61
|
+
return routes_1.linesConcat;
|
|
62
|
+
}
|
|
63
|
+
else if (route === 'listConcat') {
|
|
64
|
+
return routes_1.listConcat;
|
|
65
|
+
}
|
|
66
|
+
else if (route === 'mapConcat') {
|
|
67
|
+
return routes_1.mapConcat;
|
|
68
|
+
}
|
|
69
|
+
else if (route === 'overwrite') {
|
|
70
|
+
return routes_1.overwrite;
|
|
71
|
+
}
|
|
72
|
+
else if (route === 'primitive') {
|
|
73
|
+
return routes_1.primitive;
|
|
74
|
+
}
|
|
75
|
+
throw new Error('Can\'t build route');
|
|
76
|
+
} // }}}
|
|
77
|
+
function buildTravel(route) {
|
|
78
|
+
if (route.json) {
|
|
79
|
+
return (0, compositors_1.json)(buildRoute(route.json));
|
|
80
|
+
}
|
|
81
|
+
else if (route.rc) {
|
|
82
|
+
return (0, compositors_1.rc)(buildRoute(route.json));
|
|
83
|
+
}
|
|
84
|
+
else if (route.yaml) {
|
|
85
|
+
return (0, compositors_1.yaml)(buildRoute(route.json));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
throw new Error('Can\'t build route');
|
|
89
|
+
}
|
|
90
|
+
} // }}}
|
|
91
|
+
function validateUpdatability(context) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const { update } = context.incomingConfig;
|
|
94
|
+
if (typeof update === 'boolean') {
|
|
95
|
+
if (!update) {
|
|
96
|
+
context.onMissing = () => true;
|
|
97
|
+
context.onUpdate = () => true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if ((0, lodash_1.isPlainObject)(update)) {
|
|
101
|
+
const missings = [];
|
|
102
|
+
const updates = [];
|
|
103
|
+
const filters = {};
|
|
104
|
+
const routes = {};
|
|
105
|
+
for (const [file, fileUpdate] of Object.entries(update)) {
|
|
106
|
+
const { missing, update, filter, route } = fileUpdate;
|
|
107
|
+
if (missing === false) {
|
|
108
|
+
missings.push(file);
|
|
109
|
+
}
|
|
110
|
+
if (update === false) {
|
|
111
|
+
updates.push(file);
|
|
112
|
+
}
|
|
113
|
+
if (filter) {
|
|
114
|
+
filters[file] = filter;
|
|
115
|
+
}
|
|
116
|
+
if (route) {
|
|
117
|
+
const { alias } = route;
|
|
118
|
+
if (alias) {
|
|
119
|
+
routes[file] = {
|
|
120
|
+
alias,
|
|
121
|
+
travel: buildTravel(route),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
routes[file] = {
|
|
126
|
+
travel: buildTravel(route),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (missings.length > 0) {
|
|
132
|
+
context.onMissing = (file) => (0, micromatch_1.isMatch)(file, missings);
|
|
133
|
+
}
|
|
134
|
+
if (updates.length > 0) {
|
|
135
|
+
context.onUpdate = (file) => (0, micromatch_1.isMatch)(file, updates);
|
|
136
|
+
}
|
|
137
|
+
if (!(0, lodash_1.isEmpty)(filters)) {
|
|
138
|
+
context.filters = (file) => {
|
|
139
|
+
for (const [pattern, value] of Object.entries(filters)) {
|
|
140
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return undefined;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (!(0, lodash_1.isEmpty)(routes)) {
|
|
148
|
+
context.routes = (file) => {
|
|
149
|
+
for (const [pattern, route] of Object.entries(routes)) {
|
|
150
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
151
|
+
return route;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
exports.validateUpdatability = validateUpdatability;
|