@zokugun/artifact 0.8.0 → 0.9.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/lib/commands/add.js +67 -37
- package/lib/commands/list.js +2 -2
- package/lib/commands/outdated.js +2 -2
- package/lib/commands/remove.js +12 -18
- package/lib/commands/update.js +36 -21
- package/lib/compositors/codec.d.ts +3 -0
- package/lib/compositors/codec.js +46 -0
- package/lib/compositors/compose.d.ts +1 -0
- package/lib/compositors/compose.js +4 -0
- package/lib/compositors/index.d.ts +1 -0
- package/lib/compositors/index.js +3 -1
- package/lib/compositors/json.js +3 -66
- package/lib/compositors/rc.js +3 -56
- package/lib/compositors/yaml.js +24 -3
- package/lib/configs/install/read-install-config.d.ts +2 -5
- package/lib/configs/install/read-install-config.js +20 -18
- package/lib/configs/install/write-install-config.d.ts +2 -2
- package/lib/configs/install/write-install-config.js +2 -1
- package/lib/configs/package/read-package-config.d.ts +2 -1
- package/lib/configs/package/read-package-config.js +96 -10
- package/lib/configs/utils/constants.d.ts +2 -2
- package/lib/configs/utils/constants.js +2 -2
- package/lib/configs/utils/merge-upsert-property.js +0 -8
- package/lib/configs/utils/normalize-file-always.js +5 -0
- package/lib/configs/utils/normalize-file-upsert.d.ts +2 -1
- package/lib/configs/utils/normalize-file-upsert.js +12 -5
- package/lib/journeys/commitlint/index.d.ts +1 -1
- package/lib/journeys/config.ts/index.d.ts +1 -1
- package/lib/journeys/config.ts/index.js +2 -6
- package/lib/journeys/default/index.d.ts +1 -1
- package/lib/journeys/gitignore/index.d.ts +1 -1
- package/lib/journeys/ignore/index.d.ts +1 -1
- package/lib/journeys/index.d.ts +2 -2
- package/lib/journeys/index.js +9 -11
- package/lib/journeys/npmignore/index.d.ts +1 -1
- package/lib/journeys/package/index.d.ts +1 -1
- package/lib/journeys/rc/index.d.ts +1 -1
- package/lib/journeys/tsconfig/index.d.ts +1 -1
- package/lib/parsers/index.d.ts +4 -0
- package/lib/parsers/index.js +41 -0
- package/lib/parsers/json.d.ts +4 -2
- package/lib/parsers/json.js +7 -2
- package/lib/parsers/jsonc/parse.d.ts +2 -5
- package/lib/parsers/jsonc/parse.js +8 -6
- package/lib/parsers/to-format.d.ts +2 -0
- package/lib/parsers/to-format.js +50 -0
- package/lib/parsers/yaml.d.ts +4 -2
- package/lib/parsers/yaml.js +7 -2
- package/lib/routes/command.js +7 -0
- package/lib/routes/index.d.ts +4 -3
- package/lib/routes/index.js +9 -7
- package/lib/routes/{list-sort-concat.d.ts → list-concat-after.d.ts} +1 -1
- package/lib/routes/{list-sort-concat.js → list-concat-after.js} +2 -2
- package/lib/routes/merge-dot-js.d.ts +2 -0
- package/lib/routes/merge-dot-js.js +8 -0
- package/lib/steps/configure-install-file-actions.js +1 -20
- package/lib/steps/configure-update-file-actions.js +1 -20
- package/lib/steps/execute-first-block.js +1 -1
- package/lib/steps/index.d.ts +0 -2
- package/lib/steps/index.js +4 -3
- package/lib/steps/merge-text-files.d.ts +1 -1
- package/lib/steps/merge-text-files.js +6 -2
- package/lib/steps/read-files.d.ts +1 -1
- package/lib/steps/read-files.js +56 -42
- package/lib/steps/read-incoming-config.js +1 -1
- package/lib/steps/remove-files.d.ts +1 -1
- package/lib/steps/remove-files.js +3 -2
- package/lib/steps/rename-files.d.ts +1 -1
- package/lib/steps/rename-files.js +3 -2
- package/lib/steps/validate-newer-package.d.ts +1 -1
- package/lib/steps/validate-newer-package.js +13 -2
- package/lib/types/config.d.ts +11 -7
- package/lib/types/context.d.ts +23 -3
- package/lib/types/context.js +6 -0
- package/lib/types/travel.d.ts +1 -0
- package/lib/utils/build-journey-plan.d.ts +2 -2
- package/lib/utils/build-route.d.ts +1 -1
- package/lib/utils/build-route.js +50 -19
- package/lib/utils/build-travel-plan.js +1 -0
- package/lib/utils/command/merge-and-chains.js +1 -1
- package/lib/utils/command/merge-command-records.js +1 -1
- package/lib/utils/command/merge-parts-by-prefix.js +12 -1
- package/lib/utils/command/merge-semicolon-segments.js +161 -4
- package/lib/utils/fnmatch.d.ts +1 -0
- package/lib/utils/fnmatch.js +11 -0
- package/lib/utils/get-format.js +2 -9
- package/lib/utils/load-package.d.ts +6 -0
- package/lib/utils/load-package.js +26 -0
- package/lib/utils/template.js +1 -3
- package/package.json +128 -127
- package/lib/journeys/fixpack/index.d.ts +0 -2
- package/lib/journeys/fixpack/index.js +0 -16
- package/lib/steps/validate-not-present-package.d.ts +0 -3
- package/lib/steps/validate-not-present-package.js +0 -24
- package/lib/utils/try-json.d.ts +0 -1
- package/lib/utils/try-json.js +0 -11
|
@@ -68,33 +68,35 @@ async function readInstallConfig(targetPath) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
function normalizeConfig(data,
|
|
71
|
+
function normalizeConfig(data, file) {
|
|
72
72
|
const artifacts = {};
|
|
73
73
|
const install = {};
|
|
74
|
+
const journeys = {};
|
|
75
|
+
const routes = {};
|
|
74
76
|
let update = {};
|
|
75
77
|
let variables = {};
|
|
76
78
|
if (!data) {
|
|
77
79
|
return (0, xtry_1.ok)({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
file,
|
|
81
|
+
artifacts,
|
|
82
|
+
install,
|
|
83
|
+
journeys,
|
|
84
|
+
routes,
|
|
85
|
+
update,
|
|
86
|
+
variables,
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
if (!(0, is_it_type_1.isRecord)(data)) {
|
|
88
|
-
return (0, xtry_1.err)(`Config file ${
|
|
90
|
+
return (0, xtry_1.err)(`Config file ${file.name} must export an object.`);
|
|
89
91
|
}
|
|
90
92
|
if ((0, is_it_type_1.isString)(data.$schema)) {
|
|
91
93
|
const match = constants_js_1.VERSION_INSTALL_REGEX.exec(data.$schema);
|
|
92
94
|
if (!match) {
|
|
93
|
-
return (0, xtry_1.err)(`Cannot validate the "$schema" in the project's "${
|
|
95
|
+
return (0, xtry_1.err)(`Cannot validate the "$schema" in the project's "${file.name}".`);
|
|
94
96
|
}
|
|
95
97
|
const version = Number.parseInt(match[2], 10);
|
|
96
98
|
if (version > constants_js_1.MAX_VERSION) {
|
|
97
|
-
return (0, xtry_1.err)(`Don't support newer version (v${version}) in the project's "${
|
|
99
|
+
return (0, xtry_1.err)(`Don't support newer version (v${version}) in the project's "${file.name}".`);
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
if ((0, is_it_type_1.isArray)(data.artifacts)) {
|
|
@@ -142,12 +144,12 @@ function normalizeConfig(data, configStats) {
|
|
|
142
144
|
variables = data.variables;
|
|
143
145
|
}
|
|
144
146
|
return (0, xtry_1.ok)({
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
file,
|
|
148
|
+
artifacts,
|
|
149
|
+
install,
|
|
150
|
+
journeys,
|
|
151
|
+
routes,
|
|
152
|
+
update,
|
|
153
|
+
variables,
|
|
152
154
|
});
|
|
153
155
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AsyncDResult } from '@zokugun/xtry';
|
|
2
|
-
import { type InstallConfig
|
|
2
|
+
import { type InstallConfig } from '../../types/config.js';
|
|
3
3
|
import { type Options } from '../../types/context.js';
|
|
4
4
|
import { type Format } from '../../types/format.js';
|
|
5
|
-
export declare function writeInstallConfig(config: InstallConfig,
|
|
5
|
+
export declare function writeInstallConfig(config: InstallConfig, formats: Format[], targetPath: string, options: Options): AsyncDResult;
|
|
@@ -13,7 +13,7 @@ const yaml_1 = __importDefault(require("yaml"));
|
|
|
13
13
|
const apply_formatting_js_1 = require("../../steps/apply-formatting.js");
|
|
14
14
|
const insert_final_new_line_js_1 = require("../../steps/insert-final-new-line.js");
|
|
15
15
|
const constants_js_1 = require("../utils/constants.js");
|
|
16
|
-
async function writeInstallConfig(config,
|
|
16
|
+
async function writeInstallConfig(config, formats, targetPath, options) {
|
|
17
17
|
const exported = {
|
|
18
18
|
$schema: `https://raw.githubusercontent.com/zokugun/artifact/v${constants_js_1.VERSION_RELEASE}/schemas/v${constants_js_1.MAX_VERSION}/install.json`,
|
|
19
19
|
artifacts: config.artifacts,
|
|
@@ -24,6 +24,7 @@ async function writeInstallConfig(config, { name, finalNewLine, indent, type },
|
|
|
24
24
|
if ((0, is_it_type_1.isNonEmptyRecord)(config.variables)) {
|
|
25
25
|
exported.variables = config.variables;
|
|
26
26
|
}
|
|
27
|
+
const { name, type, indent, finalNewLine } = config.file;
|
|
27
28
|
const file = {
|
|
28
29
|
name,
|
|
29
30
|
data: type === 'yaml' ? yaml_1.default.stringify(exported) : JSON.stringify(exported, null, '\t'),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type AsyncDResult } from '@zokugun/xtry';
|
|
2
2
|
import { type PackageConfig } from '../../types/config.js';
|
|
3
|
-
|
|
3
|
+
import { type Route } from '../../types/travel.js';
|
|
4
|
+
export declare function readPackageConfig(targetPath: string, gRoutes: Record<string, Route<any>>): AsyncDResult<PackageConfig>;
|
|
@@ -9,12 +9,17 @@ const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
|
|
|
9
9
|
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
10
10
|
const xtry_1 = require("@zokugun/xtry");
|
|
11
11
|
const yaml_1 = __importDefault(require("yaml"));
|
|
12
|
+
const index_js_1 = require("../../compositors/index.js");
|
|
13
|
+
const to_format_js_1 = require("../../parsers/to-format.js");
|
|
14
|
+
const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
|
|
15
|
+
const build_route_js_1 = require("../../utils/build-route.js");
|
|
16
|
+
const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
|
|
12
17
|
const constants_js_1 = require("../utils/constants.js");
|
|
13
18
|
const merge_upsert_property_js_1 = require("../utils/merge-upsert-property.js");
|
|
14
19
|
const normalize_file_always_js_1 = require("../utils/normalize-file-always.js");
|
|
15
20
|
const normalize_file_uninstall_js_1 = require("../utils/normalize-file-uninstall.js");
|
|
16
21
|
const normalize_file_upsert_js_1 = require("../utils/normalize-file-upsert.js");
|
|
17
|
-
async function readPackageConfig(targetPath) {
|
|
22
|
+
async function readPackageConfig(targetPath, gRoutes) {
|
|
18
23
|
let content;
|
|
19
24
|
let name;
|
|
20
25
|
let type;
|
|
@@ -26,27 +31,29 @@ async function readPackageConfig(targetPath) {
|
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
if (!content) {
|
|
29
|
-
return normalizeConfig(content, name);
|
|
34
|
+
return normalizeConfig(content, name, gRoutes);
|
|
30
35
|
}
|
|
31
36
|
if (type === 'json') {
|
|
32
|
-
return normalizeConfig(JSON.parse(content), name);
|
|
37
|
+
return normalizeConfig(JSON.parse(content), name, gRoutes);
|
|
33
38
|
}
|
|
34
39
|
else if (type === 'yaml') {
|
|
35
|
-
return normalizeConfig(yaml_1.default.parse(content), name);
|
|
40
|
+
return normalizeConfig(yaml_1.default.parse(content), name, gRoutes);
|
|
36
41
|
}
|
|
37
42
|
else {
|
|
38
43
|
try {
|
|
39
|
-
return normalizeConfig(JSON.parse(content), name);
|
|
44
|
+
return normalizeConfig(JSON.parse(content), name, gRoutes);
|
|
40
45
|
}
|
|
41
46
|
catch {
|
|
42
|
-
return normalizeConfig(yaml_1.default.parse(content), name);
|
|
47
|
+
return normalizeConfig(yaml_1.default.parse(content), name, gRoutes);
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
|
-
function normalizeConfig(data, source) {
|
|
51
|
+
function normalizeConfig(data, source, gRoutes) {
|
|
47
52
|
let xtends;
|
|
48
53
|
const install = [];
|
|
54
|
+
const journeys = {};
|
|
49
55
|
let orphan = false;
|
|
56
|
+
const routes = {};
|
|
50
57
|
const uninstall = [];
|
|
51
58
|
let update = [];
|
|
52
59
|
let variables = {};
|
|
@@ -55,7 +62,9 @@ function normalizeConfig(data, source) {
|
|
|
55
62
|
return (0, xtry_1.ok)({
|
|
56
63
|
extends: xtends,
|
|
57
64
|
install,
|
|
65
|
+
journeys,
|
|
58
66
|
orphan,
|
|
67
|
+
routes,
|
|
59
68
|
uninstall,
|
|
60
69
|
update,
|
|
61
70
|
variables,
|
|
@@ -92,7 +101,7 @@ function normalizeConfig(data, source) {
|
|
|
92
101
|
}
|
|
93
102
|
if ((0, is_it_type_1.isRecord)(data.install)) {
|
|
94
103
|
for (const [key, value] of Object.entries(data.install)) {
|
|
95
|
-
const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'install');
|
|
104
|
+
const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'install', journeys, routes);
|
|
96
105
|
if (normalized.fails) {
|
|
97
106
|
return normalized;
|
|
98
107
|
}
|
|
@@ -104,7 +113,7 @@ function normalizeConfig(data, source) {
|
|
|
104
113
|
}
|
|
105
114
|
else if ((0, is_it_type_1.isRecord)(data.update)) {
|
|
106
115
|
for (const [key, value] of Object.entries(data.update)) {
|
|
107
|
-
const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'update');
|
|
116
|
+
const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'update', journeys, routes);
|
|
108
117
|
if (normalized.fails) {
|
|
109
118
|
return normalized;
|
|
110
119
|
}
|
|
@@ -122,7 +131,7 @@ function normalizeConfig(data, source) {
|
|
|
122
131
|
}
|
|
123
132
|
if ((0, is_it_type_1.isRecord)(data.upsert)) {
|
|
124
133
|
for (const [key, value] of Object.entries(data.upsert)) {
|
|
125
|
-
const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'upsert');
|
|
134
|
+
const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'upsert', journeys, routes);
|
|
126
135
|
if (normalized.fails) {
|
|
127
136
|
return normalized;
|
|
128
137
|
}
|
|
@@ -168,10 +177,87 @@ function normalizeConfig(data, source) {
|
|
|
168
177
|
});
|
|
169
178
|
}
|
|
170
179
|
}
|
|
180
|
+
if ((0, is_it_type_1.isRecord)(data.routes)) {
|
|
181
|
+
for (const [key, value] of Object.entries(data.routes)) {
|
|
182
|
+
const route = (0, build_route_js_1.buildRoute)(value);
|
|
183
|
+
if (route.fails) {
|
|
184
|
+
return route;
|
|
185
|
+
}
|
|
186
|
+
routes[key] = route.value;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if ((0, is_it_type_1.isArray)(data.journeys)) {
|
|
190
|
+
for (const value of data.journeys) {
|
|
191
|
+
if (!(0, is_it_type_1.isRecord)(value)) {
|
|
192
|
+
return (0, xtry_1.err)('Journey must be an object.');
|
|
193
|
+
}
|
|
194
|
+
if (!(0, is_it_type_1.isNonBlankString)(value.name)) {
|
|
195
|
+
return (0, xtry_1.err)('Journey\'s name must be a string.');
|
|
196
|
+
}
|
|
197
|
+
const { name } = value;
|
|
198
|
+
let route;
|
|
199
|
+
if ((0, is_it_type_1.isString)(value.route)) {
|
|
200
|
+
route = routes[value.route] ?? gRoutes[value.route];
|
|
201
|
+
}
|
|
202
|
+
if (!route) {
|
|
203
|
+
const result = (0, build_route_js_1.buildRoute)(value.route);
|
|
204
|
+
if (result.fails) {
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
route = result.value;
|
|
208
|
+
}
|
|
209
|
+
if (!route) {
|
|
210
|
+
return (0, xtry_1.err)('Cannot find journey\'s route.');
|
|
211
|
+
}
|
|
212
|
+
const travels = [];
|
|
213
|
+
if ((0, is_it_type_1.isArray)(value.travels)) {
|
|
214
|
+
for (const data of value.travels) {
|
|
215
|
+
if (!(0, is_it_type_1.isRecord)(data)) {
|
|
216
|
+
return (0, xtry_1.err)('Travel must be an object.');
|
|
217
|
+
}
|
|
218
|
+
if (!(0, is_it_type_1.isNonBlankString)(data.path)) {
|
|
219
|
+
return (0, xtry_1.err)('Travel\'s path must be a string.');
|
|
220
|
+
}
|
|
221
|
+
const { path } = data;
|
|
222
|
+
let finalRoute;
|
|
223
|
+
if ((0, is_it_type_1.isNonNullable)(data.format)) {
|
|
224
|
+
if (data.format === 'json') {
|
|
225
|
+
finalRoute = (0, index_js_1.json)(route);
|
|
226
|
+
}
|
|
227
|
+
else if (data.format === 'yaml') {
|
|
228
|
+
finalRoute = (0, index_js_1.yaml)(route);
|
|
229
|
+
}
|
|
230
|
+
else if ((0, is_it_type_1.isArray)(data.format, (value) => value === 'json' || value === 'jsonc' || value === 'yaml')) {
|
|
231
|
+
const codecs = data.format.map((value) => (0, to_format_js_1.toFormat)(value));
|
|
232
|
+
finalRoute = (0, index_js_1.codec)(codecs, route);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else if (path.endsWith('.json')) {
|
|
236
|
+
finalRoute = (0, index_js_1.json)(route);
|
|
237
|
+
}
|
|
238
|
+
else if (path.endsWith('.yaml') || path.endsWith('.yml')) {
|
|
239
|
+
finalRoute = (0, index_js_1.yaml)(route);
|
|
240
|
+
}
|
|
241
|
+
else if (path.endsWith('.js') || path.endsWith('.cjs') || path.endsWith('.mjs') || path.endsWith('.ts')) {
|
|
242
|
+
finalRoute = route;
|
|
243
|
+
}
|
|
244
|
+
if (!finalRoute) {
|
|
245
|
+
return (0, xtry_1.err)('Cannot find travel\'s path\'s route.');
|
|
246
|
+
}
|
|
247
|
+
travels.push([path, finalRoute]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const travel = (0, build_travel_plan_js_1.buildTravelPlan)(...travels);
|
|
251
|
+
const journey = (0, build_journey_plan_js_1.buildJourneyPlan)(travel);
|
|
252
|
+
journeys[name] = journey;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
171
255
|
return (0, xtry_1.ok)({
|
|
172
256
|
extends: xtends,
|
|
173
257
|
install,
|
|
258
|
+
journeys,
|
|
174
259
|
orphan,
|
|
260
|
+
routes,
|
|
175
261
|
uninstall,
|
|
176
262
|
update,
|
|
177
263
|
variables,
|
|
@@ -5,7 +5,7 @@ export declare const CONFIG_LOCATIONS: ({
|
|
|
5
5
|
name: string;
|
|
6
6
|
type?: undefined;
|
|
7
7
|
})[];
|
|
8
|
-
export declare const MAX_VERSION =
|
|
8
|
+
export declare const MAX_VERSION = 2;
|
|
9
9
|
export declare const VERSION_INSTALL_REGEX: RegExp;
|
|
10
10
|
export declare const VERSION_PACKAGE_REGEX: RegExp;
|
|
11
|
-
export declare const VERSION_RELEASE = "0.
|
|
11
|
+
export declare const VERSION_RELEASE = "0.9.0";
|
|
@@ -18,7 +18,7 @@ exports.CONFIG_LOCATIONS = [
|
|
|
18
18
|
name: '.artifactrc',
|
|
19
19
|
},
|
|
20
20
|
];
|
|
21
|
-
exports.MAX_VERSION =
|
|
21
|
+
exports.MAX_VERSION = 2;
|
|
22
22
|
exports.VERSION_INSTALL_REGEX = /https:\/\/raw.githubusercontent.com\/zokugun\/artifact\/v([\d.]+)\/schemas\/v(\d+)\/install.json/;
|
|
23
23
|
exports.VERSION_PACKAGE_REGEX = /https:\/\/raw.githubusercontent.com\/zokugun\/artifact\/v([\d.]+)\/schemas\/v(\d+)\/package.json/;
|
|
24
|
-
exports.VERSION_RELEASE = '0.
|
|
24
|
+
exports.VERSION_RELEASE = '0.9.0';
|
|
@@ -56,14 +56,6 @@ function merge(currentValue, newValue) {
|
|
|
56
56
|
currentValue.rename = newValue.rename;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
if (newValue.route) {
|
|
60
|
-
if (currentValue.route) {
|
|
61
|
-
return (0, xtry_1.err)('Not Implemented: route');
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
currentValue.route = newValue.route;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
59
|
if ((0, is_it_type_1.isNonEmptyArray)(newValue.transforms)) {
|
|
68
60
|
if ((0, is_it_type_1.isNonEmptyArray)(currentValue.transforms)) {
|
|
69
61
|
if (!(0, lodash_es_1.isEqual)(currentValue.transforms, newValue.transforms)) {
|
|
@@ -9,6 +9,7 @@ function normalizeFileAlways(pattern, data) {
|
|
|
9
9
|
return (0, xtry_1.err)('"always" must be an object.');
|
|
10
10
|
}
|
|
11
11
|
let ifExists = 'merge';
|
|
12
|
+
let route;
|
|
12
13
|
let transforms = [];
|
|
13
14
|
if ((0, is_it_type_1.isString)(data.if_exists)) {
|
|
14
15
|
if (data.if_exists === 'overwrite' || data.if_exists === 'remove' || data.if_exists === 'skip') {
|
|
@@ -18,12 +19,16 @@ function normalizeFileAlways(pattern, data) {
|
|
|
18
19
|
else if (data.remove === true) {
|
|
19
20
|
ifExists = 'remove';
|
|
20
21
|
}
|
|
22
|
+
if ((0, is_it_type_1.isRecord)(data.route)) {
|
|
23
|
+
route = data.route;
|
|
24
|
+
}
|
|
21
25
|
if ((0, is_it_type_1.isArray)(data.transforms, is_transform_js_1.isTransform)) {
|
|
22
26
|
transforms = data.transforms;
|
|
23
27
|
}
|
|
24
28
|
return (0, xtry_1.ok)({
|
|
25
29
|
ifExists,
|
|
26
30
|
pattern,
|
|
31
|
+
route,
|
|
27
32
|
transforms,
|
|
28
33
|
});
|
|
29
34
|
} // }}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type DResult } from '@zokugun/xtry';
|
|
2
2
|
import { type UpsertFileConfig } from '../../types/config.js';
|
|
3
|
-
|
|
3
|
+
import { type JourneyPlan, type Route } from '../../types/travel.js';
|
|
4
|
+
export declare function normalizeFileUpsert(pattern: string, data: unknown, name: 'install' | 'update' | 'upsert', journeys?: Record<string, JourneyPlan>, routes?: Record<string, Route<any>>): DResult<UpsertFileConfig>;
|
|
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeFileUpsert = normalizeFileUpsert;
|
|
4
4
|
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
5
5
|
const xtry_1 = require("@zokugun/xtry");
|
|
6
|
+
const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
|
|
7
|
+
const build_route_js_1 = require("../../utils/build-route.js");
|
|
8
|
+
const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
|
|
6
9
|
const is_transform_js_1 = require("./is-transform.js");
|
|
7
|
-
function normalizeFileUpsert(pattern, data, name) {
|
|
10
|
+
function normalizeFileUpsert(pattern, data, name, journeys, routes) {
|
|
8
11
|
if (!(0, is_it_type_1.isRecord)(data)) {
|
|
9
12
|
return (0, xtry_1.err)(`"${name}" must be an object.`);
|
|
10
13
|
}
|
|
@@ -12,7 +15,6 @@ function normalizeFileUpsert(pattern, data, name) {
|
|
|
12
15
|
let ifExists = 'merge';
|
|
13
16
|
let ifMissing = 'merge';
|
|
14
17
|
let rename;
|
|
15
|
-
let route;
|
|
16
18
|
let transforms = [];
|
|
17
19
|
if ((0, is_it_type_1.isArray)(data.filter, is_it_type_1.isString)) {
|
|
18
20
|
filter = data.filter;
|
|
@@ -37,8 +39,14 @@ function normalizeFileUpsert(pattern, data, name) {
|
|
|
37
39
|
if ((0, is_it_type_1.isString)(data.rename)) {
|
|
38
40
|
rename = data.rename;
|
|
39
41
|
}
|
|
40
|
-
if ((0, is_it_type_1.isRecord)(data.route)) {
|
|
41
|
-
route = data.route;
|
|
42
|
+
if (journeys && routes && (0, is_it_type_1.isRecord)(data.route)) {
|
|
43
|
+
const route = (0, build_route_js_1.buildRoute)(data.route);
|
|
44
|
+
if (route.fails) {
|
|
45
|
+
return route;
|
|
46
|
+
}
|
|
47
|
+
const travel = (0, build_travel_plan_js_1.buildTravelPlan)([pattern, route.value]);
|
|
48
|
+
const journey = (0, build_journey_plan_js_1.buildJourneyPlan)(travel);
|
|
49
|
+
journeys[pattern] = journey;
|
|
42
50
|
}
|
|
43
51
|
if ((0, is_it_type_1.isArray)(data.transforms, is_transform_js_1.isTransform)) {
|
|
44
52
|
transforms = data.transforms;
|
|
@@ -49,7 +57,6 @@ function normalizeFileUpsert(pattern, data, name) {
|
|
|
49
57
|
ifMissing,
|
|
50
58
|
pattern,
|
|
51
59
|
rename,
|
|
52
|
-
route,
|
|
53
60
|
transforms,
|
|
54
61
|
});
|
|
55
62
|
} // }}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const index_js_1 = require("../../routes/index.js");
|
|
4
4
|
const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
|
|
5
5
|
const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
|
|
6
|
-
|
|
7
|
-
const data = (0, configdotts_merge_1.merge)(current, incoming);
|
|
8
|
-
return data;
|
|
9
|
-
}
|
|
10
|
-
const travelPlan = (0, build_travel_plan_js_1.buildTravelPlan)([/\.config\.ts/, route]);
|
|
6
|
+
const travelPlan = (0, build_travel_plan_js_1.buildTravelPlan)([/\.config\.ts/, index_js_1.mergeDotJs]);
|
|
11
7
|
exports.default = (0, build_journey_plan_js_1.buildJourneyPlan)(travelPlan);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
package/lib/journeys/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Journey } from '../types/travel.js';
|
|
2
|
-
export declare function getJourney(filename: string): Journey | undefined;
|
|
1
|
+
import { type JourneyPlan, type Journey } from '../types/travel.js';
|
|
2
|
+
export declare function getJourney(filename: string, plans?: JourneyPlan[]): Journey | undefined;
|
package/lib/journeys/index.js
CHANGED
|
@@ -8,26 +8,24 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const index_js_1 = __importDefault(require("./commitlint/index.js"));
|
|
9
9
|
const index_js_2 = __importDefault(require("./config.ts/index.js"));
|
|
10
10
|
const index_js_3 = __importDefault(require("./default/index.js"));
|
|
11
|
-
const index_js_4 = __importDefault(require("./
|
|
12
|
-
const index_js_5 = __importDefault(require("./
|
|
13
|
-
const index_js_6 = __importDefault(require("./
|
|
14
|
-
const index_js_7 = __importDefault(require("./
|
|
15
|
-
const index_js_8 = __importDefault(require("./
|
|
16
|
-
const index_js_9 = __importDefault(require("./
|
|
17
|
-
const
|
|
18
|
-
const plans = [
|
|
11
|
+
const index_js_4 = __importDefault(require("./gitignore/index.js"));
|
|
12
|
+
const index_js_5 = __importDefault(require("./ignore/index.js"));
|
|
13
|
+
const index_js_6 = __importDefault(require("./npmignore/index.js"));
|
|
14
|
+
const index_js_7 = __importDefault(require("./package/index.js"));
|
|
15
|
+
const index_js_8 = __importDefault(require("./rc/index.js"));
|
|
16
|
+
const index_js_9 = __importDefault(require("./tsconfig/index.js"));
|
|
17
|
+
const DEFAULT_PLANS = [
|
|
19
18
|
index_js_1.default,
|
|
20
19
|
index_js_4.default,
|
|
21
20
|
index_js_5.default,
|
|
22
21
|
index_js_6.default,
|
|
23
22
|
index_js_7.default,
|
|
24
|
-
index_js_8.default,
|
|
25
|
-
index_js_10.default,
|
|
26
23
|
index_js_9.default,
|
|
24
|
+
index_js_8.default,
|
|
27
25
|
index_js_2.default,
|
|
28
26
|
index_js_3.default,
|
|
29
27
|
];
|
|
30
|
-
function getJourney(filename) {
|
|
28
|
+
function getJourney(filename, plans = DEFAULT_PLANS) {
|
|
31
29
|
const basename = path_1.default.basename(filename);
|
|
32
30
|
for (const plan of plans) {
|
|
33
31
|
const journey = plan(basename);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("../../types/travel.js").JourneyPlan;
|
|
2
2
|
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.YAML = exports.JSONC = exports.JSON = exports.toFormat = void 0;
|
|
37
|
+
var to_format_js_1 = require("./to-format.js");
|
|
38
|
+
Object.defineProperty(exports, "toFormat", { enumerable: true, get: function () { return to_format_js_1.toFormat; } });
|
|
39
|
+
exports.JSON = __importStar(require("./json.js"));
|
|
40
|
+
exports.JSONC = __importStar(require("./jsonc/index.js"));
|
|
41
|
+
exports.YAML = __importStar(require("./yaml.js"));
|
package/lib/parsers/json.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type ParseResult } from '../types/context.js';
|
|
2
|
+
import { type Transform } from './jsonc/transform.js';
|
|
3
|
+
export declare function parse(data: string): ParseResult;
|
|
4
|
+
export declare function stringify(data: Record<string, unknown>, _transform?: Transform): string;
|
package/lib/parsers/json.js
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parse = parse;
|
|
4
4
|
exports.stringify = stringify;
|
|
5
|
+
const sync_1 = require("@zokugun/xtry/sync");
|
|
5
6
|
function parse(data) {
|
|
6
|
-
|
|
7
|
+
const result = (0, sync_1.xtry)(() => JSON.parse(data));
|
|
8
|
+
if (result.fails) {
|
|
9
|
+
return (0, sync_1.err)((0, sync_1.stringifyError)(result.error));
|
|
10
|
+
}
|
|
11
|
+
return (0, sync_1.ok)({ data: result.value });
|
|
7
12
|
}
|
|
8
|
-
function stringify(data) {
|
|
13
|
+
function stringify(data, _transform) {
|
|
9
14
|
return JSON.stringify(data, null, '\t');
|
|
10
15
|
}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function parse(text: string
|
|
3
|
-
data: any;
|
|
4
|
-
transform: Transform | undefined;
|
|
5
|
-
};
|
|
1
|
+
import { type ParseResult } from '../../types/context.js';
|
|
2
|
+
export declare function parse(text: string): ParseResult;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parse = parse;
|
|
4
|
+
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
5
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
4
6
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
5
7
|
function parse(text) {
|
|
6
|
-
if (!text) {
|
|
7
|
-
return {
|
|
8
|
-
data:
|
|
8
|
+
if (!(0, is_it_type_1.isNonBlankString)(text)) {
|
|
9
|
+
return (0, xtry_1.ok)({
|
|
10
|
+
data: {},
|
|
9
11
|
transform: {},
|
|
10
|
-
};
|
|
12
|
+
});
|
|
11
13
|
}
|
|
12
14
|
const stack = [];
|
|
13
15
|
let current;
|
|
@@ -174,8 +176,8 @@ function parse(text) {
|
|
|
174
176
|
}
|
|
175
177
|
},
|
|
176
178
|
});
|
|
177
|
-
return {
|
|
179
|
+
return (0, xtry_1.ok)({
|
|
178
180
|
data: current,
|
|
179
181
|
transform,
|
|
180
|
-
};
|
|
182
|
+
});
|
|
181
183
|
}
|