@zokugun/artifact 0.7.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/README.md +22 -2
- package/lib/cli.js +16 -11
- package/lib/commands/add.js +95 -22
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.js +3 -1
- package/lib/commands/list.js +25 -7
- package/lib/commands/outdated.d.ts +1 -0
- package/lib/commands/outdated.js +73 -0
- package/lib/commands/remove.js +39 -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-listing-config.d.ts +7 -0
- package/lib/configs/package/read-listing-config.js +71 -0
- 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/format-table.d.ts +1 -0
- package/lib/utils/format-table.js +58 -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/lib/utils/time-difference.d.ts +1 -0
- package/lib/utils/time-difference.js +28 -0
- package/package.json +128 -125
- 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
package/lib/compositors/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.yaml = exports.rc = exports.mapSort = exports.json = exports.fork = exports.compose = void 0;
|
|
3
|
+
exports.yaml = exports.rc = exports.mapSort = exports.json = exports.fork = exports.compose = exports.codec = void 0;
|
|
4
|
+
var codec_js_1 = require("./codec.js");
|
|
5
|
+
Object.defineProperty(exports, "codec", { enumerable: true, get: function () { return codec_js_1.codec; } });
|
|
4
6
|
var compose_js_1 = require("./compose.js");
|
|
5
7
|
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_js_1.compose; } });
|
|
6
8
|
var fork_js_1 = require("./fork.js");
|
package/lib/compositors/json.js
CHANGED
|
@@ -1,71 +1,8 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.json = json;
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const JSONC = __importStar(require("../parsers/jsonc/index.js"));
|
|
40
|
-
const index_js_1 = require("../routes/index.js");
|
|
41
|
-
const apply_transforms_js_1 = require("../utils/apply-transforms.js");
|
|
42
|
-
const flow_js_1 = require("../utils/flow.js");
|
|
43
|
-
const compose_js_1 = require("./compose.js");
|
|
44
|
-
const fork_js_1 = require("./fork.js");
|
|
45
|
-
function tryJson(value) {
|
|
46
|
-
try {
|
|
47
|
-
return JSON.parse(value);
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const merge = (0, compose_js_1.compose)({
|
|
54
|
-
$$default: (0, fork_js_1.fork)([is_it_type_1.isArray, index_js_1.listConcat], [is_it_type_1.isRecord, async (...args) => merge(...args)], index_js_1.primitive),
|
|
55
|
-
});
|
|
4
|
+
const index_js_1 = require("../parsers/index.js");
|
|
5
|
+
const codec_js_1 = require("./codec.js");
|
|
56
6
|
function json(...routes) {
|
|
57
|
-
return
|
|
58
|
-
const currentData = current && tryJson(current);
|
|
59
|
-
const incomingData = incoming && tryJson(incoming);
|
|
60
|
-
if ((!current || currentData) && (!incoming || incomingData)) {
|
|
61
|
-
return await (0, flow_js_1.flow)(...routes, (0, apply_transforms_js_1.applyTransforms)(transforms), JSON.stringify)({ current: currentData, incoming: incomingData, filters, ignores, transforms });
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
const { data: currentData, transform: currentTransform } = JSONC.parse(current);
|
|
65
|
-
const { data: incomingData, transform: incomingTransform } = JSONC.parse(incoming);
|
|
66
|
-
const mergedTransform = await merge({ current: currentTransform, incoming: incomingTransform });
|
|
67
|
-
const toJSON = (data) => JSONC.stringify(data, mergedTransform);
|
|
68
|
-
return await (0, flow_js_1.flow)(...routes, (0, apply_transforms_js_1.applyTransforms)(transforms), toJSON)({ current: currentData, incoming: incomingData, filters, ignores, transforms });
|
|
69
|
-
}
|
|
70
|
-
};
|
|
7
|
+
return (0, codec_js_1.codec)([index_js_1.JSON, index_js_1.JSONC], ...routes);
|
|
71
8
|
}
|
package/lib/compositors/rc.js
CHANGED
|
@@ -1,61 +1,8 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.rc = rc;
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const JSON = __importStar(require("../parsers/json.js"));
|
|
40
|
-
const YAML = __importStar(require("../parsers/yaml.js"));
|
|
41
|
-
const apply_transforms_js_1 = require("../utils/apply-transforms.js");
|
|
42
|
-
const flow_js_1 = require("../utils/flow.js");
|
|
43
|
-
const try_json_js_1 = require("../utils/try-json.js");
|
|
4
|
+
const index_js_1 = require("../parsers/index.js");
|
|
5
|
+
const codec_js_1 = require("./codec.js");
|
|
44
6
|
function rc(...routes) {
|
|
45
|
-
return
|
|
46
|
-
const currentData = current && ((0, try_json_js_1.tryJSON)(current) ?? YAML.parse(current));
|
|
47
|
-
const incomingData = incoming && (0, try_json_js_1.tryJSON)(incoming);
|
|
48
|
-
if (incomingData) {
|
|
49
|
-
return await (0, flow_js_1.flow)(...routes, (0, apply_transforms_js_1.applyTransforms)(transforms), JSON.stringify)({ current: currentData, incoming: incomingData, filters, ignores });
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const incomingData = incoming && YAML.parse(incoming);
|
|
53
|
-
if ((0, lodash_es_1.isArray)(incomingData) || (0, is_it_type_1.isRecord)(incomingData)) {
|
|
54
|
-
return await (0, flow_js_1.flow)(...routes, (0, apply_transforms_js_1.applyTransforms)(transforms), YAML.stringify)({ current: currentData, incoming: incomingData, filters, ignores });
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
return incoming;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
7
|
+
return (0, codec_js_1.codec)([index_js_1.JSON, index_js_1.YAML], ...routes);
|
|
61
8
|
}
|
package/lib/compositors/yaml.js
CHANGED
|
@@ -34,13 +34,34 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.yaml = yaml;
|
|
37
|
+
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
37
38
|
const YAML = __importStar(require("../parsers/yaml.js"));
|
|
38
39
|
const apply_transforms_js_1 = require("../utils/apply-transforms.js");
|
|
39
40
|
const flow_js_1 = require("../utils/flow.js");
|
|
40
41
|
function yaml(...routes) {
|
|
41
42
|
return async ({ current, incoming, filters, ignores, transforms }) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (!(0, is_it_type_1.isNonBlankString)(current)) {
|
|
44
|
+
return incoming;
|
|
45
|
+
}
|
|
46
|
+
const currentResult = YAML.parse(current);
|
|
47
|
+
if (currentResult.fails) {
|
|
48
|
+
return incoming;
|
|
49
|
+
}
|
|
50
|
+
if ((0, is_it_type_1.isNonBlankString)(incoming)) {
|
|
51
|
+
const incomingResult = YAML.parse(incoming);
|
|
52
|
+
if (incomingResult.fails) {
|
|
53
|
+
return current;
|
|
54
|
+
}
|
|
55
|
+
const incomingData = incomingResult.value.data;
|
|
56
|
+
if (!(0, is_it_type_1.isArray)(incomingData) && !(0, is_it_type_1.isRecord)(incomingData)) {
|
|
57
|
+
return incoming;
|
|
58
|
+
}
|
|
59
|
+
const run = (0, flow_js_1.flow)(...routes, (0, apply_transforms_js_1.applyTransforms)(transforms), YAML.stringify);
|
|
60
|
+
return run({ current: currentResult.value.data, incoming: incomingData, filters, ignores });
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const run = (0, flow_js_1.flow)(...routes, (0, apply_transforms_js_1.applyTransforms)(transforms), YAML.stringify);
|
|
64
|
+
return run({ current: currentResult.value.data, filters, ignores });
|
|
65
|
+
}
|
|
45
66
|
};
|
|
46
67
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { type AsyncDResult } from '@zokugun/xtry';
|
|
2
|
-
import { type InstallConfig
|
|
3
|
-
export declare function readInstallConfig(targetPath: string): AsyncDResult<
|
|
4
|
-
config: InstallConfig;
|
|
5
|
-
configStats: InstallConfigStats;
|
|
6
|
-
}>;
|
|
2
|
+
import { type InstallConfig } from '../../types/config.js';
|
|
3
|
+
export declare function readInstallConfig(targetPath: string): AsyncDResult<InstallConfig>;
|
|
@@ -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'),
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
exports.readListingConfig = readListingConfig;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
|
|
9
|
+
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
10
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
11
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
12
|
+
const CONFIG_LOCATIONS = [
|
|
13
|
+
{
|
|
14
|
+
name: 'artifact-listing.yml',
|
|
15
|
+
type: 'yaml',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'artifact-listing.yaml',
|
|
19
|
+
type: 'yaml',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'artifact-listing.json',
|
|
23
|
+
type: 'json',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
async function readListingConfig(targetPath) {
|
|
27
|
+
let content;
|
|
28
|
+
let name;
|
|
29
|
+
let type;
|
|
30
|
+
for (const place of CONFIG_LOCATIONS) {
|
|
31
|
+
const result = await async_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf8');
|
|
32
|
+
if (!result.fails) {
|
|
33
|
+
content = result.value;
|
|
34
|
+
({ name, type } = place);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!content) {
|
|
38
|
+
return normalizeConfig(content, name);
|
|
39
|
+
}
|
|
40
|
+
if (type === 'json') {
|
|
41
|
+
return normalizeConfig(JSON.parse(content), name);
|
|
42
|
+
}
|
|
43
|
+
else if (type === 'yaml') {
|
|
44
|
+
return normalizeConfig(yaml_1.default.parse(content), name);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
try {
|
|
48
|
+
return normalizeConfig(JSON.parse(content), name);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return normalizeConfig(yaml_1.default.parse(content), name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function normalizeConfig(data, source) {
|
|
56
|
+
if (!(0, is_it_type_1.isArray)(data)) {
|
|
57
|
+
return (0, xtry_1.err)(`Listing file ${source} must export an array.`);
|
|
58
|
+
}
|
|
59
|
+
for (const entry of data) {
|
|
60
|
+
if (!(0, is_it_type_1.isRecord)(entry)) {
|
|
61
|
+
return (0, xtry_1.err)('Listing entry must be an object.');
|
|
62
|
+
}
|
|
63
|
+
if (!(0, is_it_type_1.isString)(entry.name)) {
|
|
64
|
+
return (0, xtry_1.err)('Listing entry/name must be a string.');
|
|
65
|
+
}
|
|
66
|
+
if (!(0, is_it_type_1.isString)(entry.description)) {
|
|
67
|
+
return (0, xtry_1.err)('Listing entry/description must be a string.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return (0, xtry_1.ok)(data);
|
|
71
|
+
} // }}}
|
|
@@ -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>;
|