@zokugun/artifact 0.6.1 → 0.6.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/lib/configs/install/read-install-config.js +1 -7
- package/lib/configs/install/write-install-config.js +0 -3
- package/lib/configs/package/read-package-config.js +1 -7
- package/lib/journeys/commitlint/index.js +4 -4
- package/lib/journeys/fixpack/index.js +4 -4
- package/lib/steps/replace-templates.js +0 -2
- package/lib/types/config.d.ts +3 -4
- package/lib/utils/template.d.ts +2 -1
- package/lib/utils/template.js +18 -6
- package/package.json +1 -1
|
@@ -70,7 +70,6 @@ async function readInstallConfig(targetPath) {
|
|
|
70
70
|
}
|
|
71
71
|
function normalizeConfig(data, configStats) {
|
|
72
72
|
const artifacts = {};
|
|
73
|
-
let constants = {};
|
|
74
73
|
const install = {};
|
|
75
74
|
let update = {};
|
|
76
75
|
let variables = {};
|
|
@@ -78,7 +77,6 @@ function normalizeConfig(data, configStats) {
|
|
|
78
77
|
return (0, xtry_1.ok)({
|
|
79
78
|
config: {
|
|
80
79
|
artifacts,
|
|
81
|
-
constants,
|
|
82
80
|
install,
|
|
83
81
|
update,
|
|
84
82
|
variables,
|
|
@@ -128,9 +126,6 @@ function normalizeConfig(data, configStats) {
|
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
|
-
if ((0, is_it_type_1.isRecord)(data.constants, (_key, value) => (0, is_it_type_1.isString)(value))) {
|
|
132
|
-
constants = data.constants;
|
|
133
|
-
}
|
|
134
129
|
if (data.update === false) {
|
|
135
130
|
update = false;
|
|
136
131
|
}
|
|
@@ -143,13 +138,12 @@ function normalizeConfig(data, configStats) {
|
|
|
143
138
|
update[key] = normalized.value;
|
|
144
139
|
}
|
|
145
140
|
}
|
|
146
|
-
if ((0, is_it_type_1.isRecord)(data.variables, (_key, value) => (0, is_it_type_1.
|
|
141
|
+
if ((0, is_it_type_1.isRecord)(data.variables, (_key, value) => (0, is_it_type_1.isPrimitive)(value))) {
|
|
147
142
|
variables = data.variables;
|
|
148
143
|
}
|
|
149
144
|
return (0, xtry_1.ok)({
|
|
150
145
|
config: {
|
|
151
146
|
artifacts,
|
|
152
|
-
constants,
|
|
153
147
|
install,
|
|
154
148
|
update,
|
|
155
149
|
variables,
|
|
@@ -21,9 +21,6 @@ async function writeInstallConfig(config, { name, finalNewLine, indent, type },
|
|
|
21
21
|
if ((0, is_it_type_1.isNonEmptyRecord)(config.update)) {
|
|
22
22
|
exported.update = config.update;
|
|
23
23
|
}
|
|
24
|
-
if ((0, is_it_type_1.isNonEmptyRecord)(config.constants)) {
|
|
25
|
-
exported.constants = config.constants;
|
|
26
|
-
}
|
|
27
24
|
if ((0, is_it_type_1.isNonEmptyRecord)(config.variables)) {
|
|
28
25
|
exported.variables = config.variables;
|
|
29
26
|
}
|
|
@@ -44,7 +44,6 @@ async function readPackageConfig(targetPath) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function normalizeConfig(data, source) {
|
|
47
|
-
let constants = {};
|
|
48
47
|
let xtends;
|
|
49
48
|
const install = [];
|
|
50
49
|
let orphan = false;
|
|
@@ -54,7 +53,6 @@ function normalizeConfig(data, source) {
|
|
|
54
53
|
let variants = {};
|
|
55
54
|
if (!data) {
|
|
56
55
|
return (0, xtry_1.ok)({
|
|
57
|
-
constants,
|
|
58
56
|
extends: xtends,
|
|
59
57
|
install,
|
|
60
58
|
orphan,
|
|
@@ -77,9 +75,6 @@ function normalizeConfig(data, source) {
|
|
|
77
75
|
return (0, xtry_1.err)(`Don't support newer version (v${version}) in the package's "${source}".`);
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
|
-
if ((0, is_it_type_1.isRecord)(data.constants, (_key, value) => (0, is_it_type_1.isString)(value))) {
|
|
81
|
-
constants = data.constants;
|
|
82
|
-
}
|
|
83
78
|
if ((0, is_it_type_1.isString)(data.extends)) {
|
|
84
79
|
xtends = data.extends;
|
|
85
80
|
}
|
|
@@ -89,7 +84,7 @@ function normalizeConfig(data, source) {
|
|
|
89
84
|
if (data.orphan === true) {
|
|
90
85
|
orphan = true;
|
|
91
86
|
}
|
|
92
|
-
if ((0, is_it_type_1.isRecord)(data.variables, (_key, value) => (0, is_it_type_1.
|
|
87
|
+
if ((0, is_it_type_1.isRecord)(data.variables, (_key, value) => (0, is_it_type_1.isPrimitive)(value))) {
|
|
93
88
|
variables = data.variables;
|
|
94
89
|
}
|
|
95
90
|
if ((0, is_it_type_1.isRecord)(data.variants, (_key, value) => (0, is_it_type_1.isString)(value) || (0, is_it_type_1.isNumber)(value))) {
|
|
@@ -174,7 +169,6 @@ function normalizeConfig(data, source) {
|
|
|
174
169
|
}
|
|
175
170
|
}
|
|
176
171
|
return (0, xtry_1.ok)({
|
|
177
|
-
constants,
|
|
178
172
|
extends: xtends,
|
|
179
173
|
install,
|
|
180
174
|
orphan,
|
|
@@ -4,14 +4,14 @@ const index_js_1 = require("../../compositors/index.js");
|
|
|
4
4
|
const index_js_2 = require("../../routes/index.js");
|
|
5
5
|
const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
|
|
6
6
|
const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
|
|
7
|
-
const mainRoute = (0, index_js_1.compose)({
|
|
7
|
+
const mainRoute = (0, index_js_1.mapSort)((0, index_js_1.compose)({
|
|
8
8
|
extends: index_js_2.listConcat,
|
|
9
9
|
parserPreset: index_js_2.primitive,
|
|
10
|
-
rules: (0, index_js_1.compose)({
|
|
10
|
+
rules: (0, index_js_1.mapSort)((0, index_js_1.compose)({
|
|
11
11
|
$$default: index_js_2.overwrite,
|
|
12
|
-
}),
|
|
12
|
+
})),
|
|
13
13
|
$$default: index_js_2.primitive,
|
|
14
|
-
});
|
|
14
|
+
}));
|
|
15
15
|
const jsonRoute = (0, index_js_1.json)(mainRoute);
|
|
16
16
|
const yamlRoute = (0, index_js_1.yaml)(mainRoute);
|
|
17
17
|
const rcRoute = (0, index_js_1.rc)(mainRoute);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
4
4
|
const index_js_1 = require("../../compositors/index.js");
|
|
5
5
|
const index_js_2 = require("../../routes/index.js");
|
|
6
6
|
const build_journey_plan_js_1 = require("../../utils/build-journey-plan.js");
|
|
7
7
|
const build_travel_plan_js_1 = require("../../utils/build-travel-plan.js");
|
|
8
|
-
const mainRoute = (0, index_js_1.compose)({
|
|
8
|
+
const mainRoute = (0, index_js_1.mapSort)((0, index_js_1.compose)({
|
|
9
9
|
sortToTop: index_js_2.listSortConcat,
|
|
10
|
-
$$default: (0, index_js_1.fork)([
|
|
11
|
-
});
|
|
10
|
+
$$default: (0, index_js_1.fork)([is_it_type_1.isArray, index_js_2.listConcat], [is_it_type_1.isRecord, index_js_2.mapConcat], index_js_2.primitive),
|
|
11
|
+
}));
|
|
12
12
|
const jsonRoute = (0, index_js_1.json)(mainRoute);
|
|
13
13
|
const yamlRoute = (0, index_js_1.yaml)(mainRoute);
|
|
14
14
|
const rcRoute = (0, index_js_1.rc)(mainRoute);
|
|
@@ -7,8 +7,6 @@ async function replaceTemplates({ textFiles, binaryFiles, targetPath, config, in
|
|
|
7
7
|
const variables = {
|
|
8
8
|
...incomingConfig?.variables,
|
|
9
9
|
...config?.variables,
|
|
10
|
-
...incomingConfig?.constants,
|
|
11
|
-
...config?.constants,
|
|
12
10
|
};
|
|
13
11
|
const engine = new template_js_1.TemplateEngine(targetPath, variables);
|
|
14
12
|
for (const file of textFiles) {
|
package/lib/types/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Primitive } from '@zokugun/is-it-type';
|
|
1
2
|
import { type Indent } from './format.js';
|
|
2
3
|
export type Request = {
|
|
3
4
|
name: string;
|
|
@@ -8,13 +9,12 @@ export type PackageManifest = {
|
|
|
8
9
|
version: string;
|
|
9
10
|
};
|
|
10
11
|
export type PackageConfig = {
|
|
11
|
-
constants: Record<string, string>;
|
|
12
12
|
extends?: string;
|
|
13
13
|
install: InstallFileConfig[];
|
|
14
14
|
orphan: boolean;
|
|
15
15
|
uninstall: UninstallFileConfig[];
|
|
16
16
|
update: false | UpdateFileConfig[];
|
|
17
|
-
variables: Record<string,
|
|
17
|
+
variables: Record<string, Primitive>;
|
|
18
18
|
variants: Record<string, string>;
|
|
19
19
|
};
|
|
20
20
|
export type Artifact = {
|
|
@@ -27,10 +27,9 @@ export type ArtifactResult = Artifact & {
|
|
|
27
27
|
};
|
|
28
28
|
export type InstallConfig = {
|
|
29
29
|
artifacts: Record<string, Artifact>;
|
|
30
|
-
constants: Record<string, string>;
|
|
31
30
|
install: Record<string, InstallFileConfig>;
|
|
32
31
|
update: false | Record<string, UpdateFileConfig>;
|
|
33
|
-
variables: Record<string,
|
|
32
|
+
variables: Record<string, Primitive>;
|
|
34
33
|
};
|
|
35
34
|
export type FileConfig<E> = {
|
|
36
35
|
ifExists: E;
|
package/lib/utils/template.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type Primitive } from '@zokugun/is-it-type';
|
|
1
2
|
import { type DResult } from '@zokugun/xtry';
|
|
2
3
|
export declare class TemplateEngine {
|
|
3
4
|
private readonly basePath;
|
|
4
5
|
private readonly fileCache;
|
|
5
6
|
private readonly variables;
|
|
6
7
|
private readonly variableCache;
|
|
7
|
-
constructor(basePath: string, variables?: Record<string,
|
|
8
|
+
constructor(basePath: string, variables?: Record<string, Primitive>);
|
|
8
9
|
render(template: string): DResult<string>;
|
|
9
10
|
private getValueByPath;
|
|
10
11
|
private parseFile;
|
package/lib/utils/template.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.TemplateEngine = void 0;
|
|
|
40
40
|
exports.unescapeCode = unescapeCode;
|
|
41
41
|
const path_1 = __importDefault(require("path"));
|
|
42
42
|
const sync_1 = __importDefault(require("@zokugun/fs-extra-plus/sync"));
|
|
43
|
+
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
43
44
|
const xtry_1 = require("@zokugun/xtry");
|
|
44
45
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
45
46
|
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
@@ -164,16 +165,27 @@ class TemplateEngine {
|
|
|
164
165
|
if (this.variableCache.has(name)) {
|
|
165
166
|
return (0, xtry_1.ok)(this.variableCache.get(name));
|
|
166
167
|
}
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
168
|
+
const value = this.variables[name];
|
|
169
|
+
if (!(0, is_it_type_1.isPrimitive)(value)) {
|
|
169
170
|
return (0, xtry_1.err)(`Invalid variable: ${name}.`);
|
|
170
171
|
}
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
172
|
+
const expression = String(value).trim();
|
|
173
|
+
if (expression.length === 0) {
|
|
174
|
+
return (0, xtry_1.err)(`Invalid variable: ${name}.`);
|
|
175
|
+
}
|
|
176
|
+
if (expression.at(0) === '=') {
|
|
177
|
+
const result = this.resolveExpression(expression.slice(1));
|
|
178
|
+
if (result.fails) {
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
this.variableCache.set(name, result.value);
|
|
173
182
|
return result;
|
|
174
183
|
}
|
|
175
|
-
|
|
176
|
-
|
|
184
|
+
else {
|
|
185
|
+
const value = expression.at(0) === '\\' && expression.at(1) === '=' ? expression.slice(1) : expression;
|
|
186
|
+
this.variableCache.set(name, value);
|
|
187
|
+
return (0, xtry_1.ok)(value);
|
|
188
|
+
}
|
|
177
189
|
} // }}}
|
|
178
190
|
splitPlaceholder(placeholder) {
|
|
179
191
|
const matches = PLACEHOLDER_REGEX.exec(placeholder);
|