@zokugun/artifact 0.3.1 → 0.4.0
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 +124 -37
- package/lib/cli.js +8 -2
- package/lib/commands/add.js +35 -41
- package/lib/commands/index.js +3 -1
- package/lib/commands/list.js +47 -0
- package/lib/commands/update.js +32 -17
- package/lib/compositors/compose.js +6 -10
- package/lib/configs/index.js +18 -0
- package/lib/configs/install/index.js +9 -0
- package/lib/configs/install/read-install-config.js +121 -0
- package/lib/configs/install/update-install-config.js +16 -0
- package/lib/{config/write-config.js → configs/install/write-install-config.js} +8 -8
- package/lib/configs/package/index.js +5 -0
- package/lib/{config/read-config.js → configs/package/read-package-config.js} +15 -32
- package/lib/journeys/config.ts/index.js +11 -0
- package/lib/journeys/index.js +2 -0
- package/lib/journeys/package/index.js +0 -1
- package/lib/parsers/jsonc/parse.js +1 -1
- package/lib/steps/apply-formatting.js +2 -2
- package/lib/steps/configure-branches.js +70 -0
- package/lib/steps/configure-install-file-actions.js +152 -0
- package/lib/steps/{validate-updatability.js → configure-update-file-actions.js} +10 -10
- package/lib/steps/copy-binary-files.js +19 -10
- package/lib/steps/execute-first-block.js +113 -0
- package/lib/steps/execute-next-block.js +23 -0
- package/lib/steps/index.js +45 -7
- package/lib/steps/merge-text-files.js +61 -31
- package/lib/steps/read-incoming-config.js +8 -3
- package/lib/steps/read-incoming-package.js +11 -2
- package/lib/steps/remove-files.js +41 -0
- package/lib/steps/validate-newer-package.js +1 -1
- package/lib/steps/validate-not-present-package.js +1 -1
- package/lib/utils/resolve-request.js +43 -0
- package/lib/utils/template.js +4 -3
- package/package.json +4 -3
- package/lib/config/index.js +0 -7
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.readInstallConfig = void 0;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
19
|
+
const places = [
|
|
20
|
+
{
|
|
21
|
+
name: '.artifactrc.yml',
|
|
22
|
+
type: 'yaml',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: '.artifactrc.yaml',
|
|
26
|
+
type: 'yaml',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: '.artifactrc.json',
|
|
30
|
+
type: 'json',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: '.artifactrc',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
function readInstallConfig(targetPath) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
let content;
|
|
39
|
+
let name;
|
|
40
|
+
let type;
|
|
41
|
+
for (const place of places) {
|
|
42
|
+
try {
|
|
43
|
+
content = yield fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
|
|
44
|
+
name = place.name;
|
|
45
|
+
type = place.type;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
catch (_a) {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!content) {
|
|
52
|
+
return {
|
|
53
|
+
config: {
|
|
54
|
+
artifacts: {},
|
|
55
|
+
install: {},
|
|
56
|
+
update: {},
|
|
57
|
+
},
|
|
58
|
+
configStats: {
|
|
59
|
+
name: '.artifactrc.yml',
|
|
60
|
+
type: 'yaml',
|
|
61
|
+
finalNewLine: true,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const finalNewLine = content.endsWith('\n');
|
|
66
|
+
let data;
|
|
67
|
+
if (type === 'json') {
|
|
68
|
+
data = JSON.parse(content);
|
|
69
|
+
}
|
|
70
|
+
else if (type === 'yaml') {
|
|
71
|
+
data = yaml_1.default.parse(content);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
try {
|
|
75
|
+
data = JSON.parse(content);
|
|
76
|
+
type = 'json';
|
|
77
|
+
}
|
|
78
|
+
catch (_b) {
|
|
79
|
+
data = yaml_1.default.parse(content);
|
|
80
|
+
type = 'yaml';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (typeof data.update === 'undefined') {
|
|
84
|
+
data.update = {};
|
|
85
|
+
}
|
|
86
|
+
if (isOldInstallConfig(data)) {
|
|
87
|
+
const config = {
|
|
88
|
+
artifacts: {},
|
|
89
|
+
install: data.install,
|
|
90
|
+
update: data.update,
|
|
91
|
+
};
|
|
92
|
+
for (const { name, version } of data.artifacts) {
|
|
93
|
+
config.artifacts[name] = {
|
|
94
|
+
version,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
config,
|
|
99
|
+
configStats: {
|
|
100
|
+
name: name,
|
|
101
|
+
type,
|
|
102
|
+
finalNewLine,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return {
|
|
108
|
+
config: data,
|
|
109
|
+
configStats: {
|
|
110
|
+
name: name,
|
|
111
|
+
type,
|
|
112
|
+
finalNewLine,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.readInstallConfig = readInstallConfig;
|
|
119
|
+
function isOldInstallConfig(config) {
|
|
120
|
+
return Array.isArray(config.artifacts);
|
|
121
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateInstallConfig = void 0;
|
|
4
|
+
function updateInstallConfig(config, { name, version, provides, requires }) {
|
|
5
|
+
const artifact = {
|
|
6
|
+
version,
|
|
7
|
+
};
|
|
8
|
+
if (requires) {
|
|
9
|
+
artifact.requires = requires;
|
|
10
|
+
}
|
|
11
|
+
if (provides) {
|
|
12
|
+
artifact.provides = provides;
|
|
13
|
+
}
|
|
14
|
+
config.artifacts[name] = artifact;
|
|
15
|
+
}
|
|
16
|
+
exports.updateInstallConfig = updateInstallConfig;
|
|
@@ -12,20 +12,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.writeInstallConfig = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
18
|
const lodash_1 = require("lodash");
|
|
19
19
|
const yaml_1 = __importDefault(require("yaml"));
|
|
20
|
-
const apply_formatting_1 = require("
|
|
21
|
-
const insert_final_new_line_1 = require("
|
|
22
|
-
function
|
|
20
|
+
const apply_formatting_1 = require("../../steps/apply-formatting");
|
|
21
|
+
const insert_final_new_line_1 = require("../../steps/insert-final-new-line");
|
|
22
|
+
function writeInstallConfig(config, { name, finalNewLine, type }, formats, targetPath, options) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
const exported = {
|
|
25
|
-
artifacts:
|
|
25
|
+
artifacts: config.artifacts,
|
|
26
26
|
};
|
|
27
|
-
if (!(0, lodash_1.isPlainObject)(update) || !(0, lodash_1.isEmpty)(update)) {
|
|
28
|
-
exported.update = update;
|
|
27
|
+
if (!(0, lodash_1.isPlainObject)(config.update) || !(0, lodash_1.isEmpty)(config.update)) {
|
|
28
|
+
exported.update = config.update;
|
|
29
29
|
}
|
|
30
30
|
const file = {
|
|
31
31
|
name,
|
|
@@ -41,4 +41,4 @@ function writeConfig({ artifacts, update }, { name, finalNewLine, type }, format
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
exports.
|
|
44
|
+
exports.writeInstallConfig = writeInstallConfig;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readPackageConfig = void 0;
|
|
4
|
+
var read_package_config_1 = require("./read-package-config");
|
|
5
|
+
Object.defineProperty(exports, "readPackageConfig", { enumerable: true, get: function () { return read_package_config_1.readPackageConfig; } });
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.readPackageConfig = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
18
|
const yaml_1 = __importDefault(require("yaml"));
|
|
@@ -33,63 +33,46 @@ const places = [
|
|
|
33
33
|
name: '.artifactrc',
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
|
-
function
|
|
36
|
+
function readPackageConfig(targetPath) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
let
|
|
39
|
-
let name;
|
|
38
|
+
let content;
|
|
40
39
|
let type;
|
|
41
40
|
for (const place of places) {
|
|
42
41
|
try {
|
|
43
|
-
|
|
44
|
-
name = place.name;
|
|
42
|
+
content = yield fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
|
|
45
43
|
type = place.type;
|
|
46
44
|
break;
|
|
47
45
|
}
|
|
48
46
|
catch (_a) {
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
|
-
if (!
|
|
52
|
-
return
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: '.artifactrc.yml',
|
|
59
|
-
type: 'yaml',
|
|
60
|
-
finalNewLine: true,
|
|
61
|
-
},
|
|
62
|
-
];
|
|
49
|
+
if (!content) {
|
|
50
|
+
return {
|
|
51
|
+
install: {},
|
|
52
|
+
update: {},
|
|
53
|
+
};
|
|
63
54
|
}
|
|
64
|
-
const finalNewLine = data.endsWith('\n');
|
|
65
55
|
let config;
|
|
66
56
|
if (type === 'json') {
|
|
67
|
-
config = JSON.parse(
|
|
57
|
+
config = JSON.parse(content);
|
|
68
58
|
}
|
|
69
59
|
else if (type === 'yaml') {
|
|
70
|
-
config = yaml_1.default.parse(
|
|
60
|
+
config = yaml_1.default.parse(content);
|
|
71
61
|
}
|
|
72
62
|
else {
|
|
73
63
|
try {
|
|
74
|
-
config = JSON.parse(
|
|
64
|
+
config = JSON.parse(content);
|
|
75
65
|
type = 'json';
|
|
76
66
|
}
|
|
77
67
|
catch (_b) {
|
|
78
|
-
config = yaml_1.default.parse(
|
|
68
|
+
config = yaml_1.default.parse(content);
|
|
79
69
|
type = 'yaml';
|
|
80
70
|
}
|
|
81
71
|
}
|
|
82
72
|
if (typeof config.update === 'undefined') {
|
|
83
73
|
config.update = {};
|
|
84
74
|
}
|
|
85
|
-
return
|
|
86
|
-
config,
|
|
87
|
-
{
|
|
88
|
-
name: name,
|
|
89
|
-
type,
|
|
90
|
-
finalNewLine,
|
|
91
|
-
},
|
|
92
|
-
];
|
|
75
|
+
return config;
|
|
93
76
|
});
|
|
94
77
|
}
|
|
95
|
-
exports.
|
|
78
|
+
exports.readPackageConfig = readPackageConfig;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const configdotts_merge_1 = require("@zokugun/configdotts-merge");
|
|
4
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
5
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
6
|
+
function route({ current, incoming }) {
|
|
7
|
+
const data = (0, configdotts_merge_1.merge)(current, incoming);
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/\.config\.ts/, route]);
|
|
11
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
|
package/lib/journeys/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getJourney = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const commitlint_1 = __importDefault(require("./commitlint"));
|
|
9
|
+
const config_ts_1 = __importDefault(require("./config.ts"));
|
|
9
10
|
const default_1 = __importDefault(require("./default"));
|
|
10
11
|
const fixpack_1 = __importDefault(require("./fixpack"));
|
|
11
12
|
const gitignore_1 = __importDefault(require("./gitignore"));
|
|
@@ -23,6 +24,7 @@ const plans = [
|
|
|
23
24
|
package_1.default,
|
|
24
25
|
tsconfig_1.default,
|
|
25
26
|
rc_1.default,
|
|
27
|
+
config_ts_1.default,
|
|
26
28
|
default_1.default,
|
|
27
29
|
];
|
|
28
30
|
function getJourney(filename) {
|
|
@@ -180,7 +180,7 @@ function parse(text) {
|
|
|
180
180
|
},
|
|
181
181
|
onError(error, _offset, _length, _startLine, _startCharacter) {
|
|
182
182
|
// console.log('onError', error, _startLine, _startCharacter)
|
|
183
|
-
if ((error === 3 /* PropertyNameExpected */ || error === 4 /* ValueExpected */) && lastKid) {
|
|
183
|
+
if ((error === 3 /* ParseErrorCode.PropertyNameExpected */ || error === 4 /* ParseErrorCode.ValueExpected */) && lastKid) {
|
|
184
184
|
lastKid.separator = true;
|
|
185
185
|
}
|
|
186
186
|
},
|
|
@@ -55,8 +55,8 @@ function indentWithSpace(data, size) {
|
|
|
55
55
|
}
|
|
56
56
|
} // }}}
|
|
57
57
|
function indentWithTab(data) {
|
|
58
|
-
const { type, indent } = (0, detect_indent_1.default)(data);
|
|
59
|
-
if (type === 'space') {
|
|
58
|
+
const { type, indent, amount } = (0, detect_indent_1.default)(data);
|
|
59
|
+
if (type === 'space' && amount > 1) {
|
|
60
60
|
return data.replace(new RegExp(indent, 'gm'), '\t');
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.configureBranches = void 0;
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const globby_1 = __importDefault(require("globby"));
|
|
19
|
+
function configureBranches(context) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const cwd = node_path_1.default.join(context.incomingPath, 'branches');
|
|
22
|
+
if (yield fs_extra_1.default.pathExists(cwd)) {
|
|
23
|
+
const directories = yield (0, globby_1.default)('*', {
|
|
24
|
+
cwd,
|
|
25
|
+
onlyDirectories: true,
|
|
26
|
+
});
|
|
27
|
+
const bucket = [];
|
|
28
|
+
for (const directory of directories) {
|
|
29
|
+
const match = /^\[(@[\w-]+:[\w-]+|[\w-]+)(?::([\w-]+))?]$/.exec(directory);
|
|
30
|
+
if (match) {
|
|
31
|
+
const [branch, name, variant] = match;
|
|
32
|
+
const packageName = name.replace(/:/g, '/');
|
|
33
|
+
const artifact = context.config.artifacts[packageName];
|
|
34
|
+
let found = false;
|
|
35
|
+
if (artifact) {
|
|
36
|
+
if (variant) {
|
|
37
|
+
if (Array.isArray(artifact.requires)) {
|
|
38
|
+
if (artifact.requires.includes(variant)) {
|
|
39
|
+
found = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (Array.isArray(artifact.provides)) {
|
|
43
|
+
if (artifact.provides.includes(variant)) {
|
|
44
|
+
found = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
found = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
found = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (found) {
|
|
56
|
+
bucket.push({
|
|
57
|
+
name: context.incomingName,
|
|
58
|
+
version: context.incomingVersion,
|
|
59
|
+
variant: context.incomingVariant,
|
|
60
|
+
branch,
|
|
61
|
+
incomingPath: node_path_1.default.join(cwd, directory),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
context.blocks.unshift(...bucket);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
exports.configureBranches = configureBranches;
|
|
@@ -0,0 +1,152 @@
|
|
|
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.configureInstallFileActions = 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 configureInstallFileActions(context) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const { install } = context.incomingConfig;
|
|
94
|
+
if (!install) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const overwritings = [];
|
|
98
|
+
const filters = {};
|
|
99
|
+
const routes = {};
|
|
100
|
+
for (const [file, fileUpdate] of Object.entries(install)) {
|
|
101
|
+
const { overwrite, remove, filter, route } = fileUpdate;
|
|
102
|
+
if (remove) {
|
|
103
|
+
context.removedPatterns.push(file);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (overwrite) {
|
|
107
|
+
overwritings.push(file);
|
|
108
|
+
}
|
|
109
|
+
if (filter) {
|
|
110
|
+
filters[file] = filter;
|
|
111
|
+
}
|
|
112
|
+
if (route) {
|
|
113
|
+
const { alias } = route;
|
|
114
|
+
if (alias) {
|
|
115
|
+
routes[file] = {
|
|
116
|
+
alias,
|
|
117
|
+
travel: buildTravel(route),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
routes[file] = {
|
|
122
|
+
travel: buildTravel(route),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (overwritings.length > 0) {
|
|
128
|
+
context.onExisting = (file) => (0, micromatch_1.isMatch)(file, overwritings) ? 'overwrite' : 'merge';
|
|
129
|
+
}
|
|
130
|
+
if (!(0, lodash_1.isEmpty)(filters)) {
|
|
131
|
+
context.filters = (file) => {
|
|
132
|
+
for (const [pattern, value] of Object.entries(filters)) {
|
|
133
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (!(0, lodash_1.isEmpty)(routes)) {
|
|
141
|
+
context.routes = (file) => {
|
|
142
|
+
for (const [pattern, route] of Object.entries(routes)) {
|
|
143
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
144
|
+
return route;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
exports.configureInstallFileActions = configureInstallFileActions;
|
|
@@ -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.
|
|
12
|
+
exports.configureUpdateFileActions = void 0;
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
14
|
const micromatch_1 = require("micromatch");
|
|
15
15
|
const compositors_1 = require("../compositors");
|
|
@@ -88,18 +88,18 @@ function buildTravel(route) {
|
|
|
88
88
|
throw new Error('Can\'t build route');
|
|
89
89
|
}
|
|
90
90
|
} // }}}
|
|
91
|
-
function
|
|
91
|
+
function configureUpdateFileActions(context) {
|
|
92
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
93
|
const { update } = context.incomingConfig;
|
|
94
94
|
if (typeof update === 'boolean') {
|
|
95
95
|
if (!update) {
|
|
96
|
-
context.
|
|
97
|
-
context.
|
|
96
|
+
context.onExisting = () => 'skip';
|
|
97
|
+
context.onMissing = () => 'skip';
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
else if ((0, lodash_1.isPlainObject)(update)) {
|
|
101
|
+
const existings = [];
|
|
101
102
|
const missings = [];
|
|
102
|
-
const updates = [];
|
|
103
103
|
const filters = {};
|
|
104
104
|
const routes = {};
|
|
105
105
|
for (const [file, fileUpdate] of Object.entries(update)) {
|
|
@@ -108,7 +108,7 @@ function validateUpdatability(context) {
|
|
|
108
108
|
missings.push(file);
|
|
109
109
|
}
|
|
110
110
|
if (update === false) {
|
|
111
|
-
|
|
111
|
+
existings.push(file);
|
|
112
112
|
}
|
|
113
113
|
if (filter) {
|
|
114
114
|
filters[file] = filter;
|
|
@@ -129,10 +129,10 @@ function validateUpdatability(context) {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
if (missings.length > 0) {
|
|
132
|
-
context.onMissing = (file) => (0, micromatch_1.isMatch)(file, missings);
|
|
132
|
+
context.onMissing = (file) => (0, micromatch_1.isMatch)(file, missings) ? 'skip' : 'continue';
|
|
133
133
|
}
|
|
134
|
-
if (
|
|
135
|
-
context.
|
|
134
|
+
if (existings.length > 0) {
|
|
135
|
+
context.onExisting = (file) => (0, micromatch_1.isMatch)(file, existings) ? 'skip' : 'merge';
|
|
136
136
|
}
|
|
137
137
|
if (!(0, lodash_1.isEmpty)(filters)) {
|
|
138
138
|
context.filters = (file) => {
|
|
@@ -157,4 +157,4 @@ function validateUpdatability(context) {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
exports.
|
|
160
|
+
exports.configureUpdateFileActions = configureUpdateFileActions;
|
|
@@ -15,23 +15,32 @@ 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,
|
|
18
|
+
function copyBinaryFiles({ binaryFiles, incomingPath, targetPath, onExisting, onMissing, 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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const source = path_1.default.join(cwd, file.source);
|
|
23
|
+
const target = path_1.default.join(targetPath, file.target);
|
|
24
|
+
const exists = yield fs_extra_1.default.pathExists(target);
|
|
25
|
+
if (exists) {
|
|
26
|
+
switch (onExisting(file.source)) {
|
|
27
|
+
case 'merge':
|
|
28
|
+
break;
|
|
29
|
+
case 'overwrite':
|
|
30
|
+
break;
|
|
31
|
+
case 'skip':
|
|
32
|
+
continue;
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
continue
|
|
35
|
+
else {
|
|
36
|
+
switch (onMissing(file.source)) {
|
|
37
|
+
case 'continue':
|
|
38
|
+
break;
|
|
39
|
+
case 'skip':
|
|
40
|
+
continue;
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
|
-
|
|
34
|
-
const target = path_1.default.join(targetPath, file.target);
|
|
43
|
+
yield fs_extra_1.default.ensureFile(target);
|
|
35
44
|
yield fs_extra_1.default.copyFile(source, target);
|
|
36
45
|
if (options.verbose) {
|
|
37
46
|
console.log(`${file.target} has been written as a binary file`);
|