@highstate/cli 0.7.1 → 0.7.3
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/assets/tsconfig.base.json +21 -0
- package/dist/main.js +1285 -13978
- package/package.json +18 -8
- package/src/commands/build.ts +94 -0
- package/src/commands/designer.ts +73 -0
- package/src/main.ts +17 -0
- package/src/shared/index.ts +4 -0
- package/src/shared/logger.ts +54 -0
- package/src/shared/schema-transformer.ts +75 -0
- package/src/shared/services.ts +20 -0
- package/src/shared/source-hash-calculator.ts +219 -0
- package/dist/index-CfX7oR0h.js +0 -215
- package/dist/main-fVI30_8j.js +0 -520
package/dist/index-CfX7oR0h.js
DELETED
@@ -1,215 +0,0 @@
|
|
1
|
-
const simpleKeyRegExp = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
2
|
-
function getPrintable(value) {
|
3
|
-
if (value === null)
|
4
|
-
return `null`;
|
5
|
-
if (value === void 0)
|
6
|
-
return `undefined`;
|
7
|
-
if (value === ``)
|
8
|
-
return `an empty string`;
|
9
|
-
if (typeof value === "symbol")
|
10
|
-
return `<${value.toString()}>`;
|
11
|
-
if (Array.isArray(value))
|
12
|
-
return `an array`;
|
13
|
-
return JSON.stringify(value);
|
14
|
-
}
|
15
|
-
function computeKey(state, key) {
|
16
|
-
var _a, _b, _c;
|
17
|
-
if (typeof key === `number`) {
|
18
|
-
return `${(_a = state === null || state === void 0 ? void 0 : state.p) !== null && _a !== void 0 ? _a : `.`}[${key}]`;
|
19
|
-
} else if (simpleKeyRegExp.test(key)) {
|
20
|
-
return `${(_b = state === null || state === void 0 ? void 0 : state.p) !== null && _b !== void 0 ? _b : ``}.${key}`;
|
21
|
-
} else {
|
22
|
-
return `${(_c = state === null || state === void 0 ? void 0 : state.p) !== null && _c !== void 0 ? _c : `.`}[${JSON.stringify(key)}]`;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
function pushError({ errors, p } = {}, message) {
|
26
|
-
errors === null || errors === void 0 ? void 0 : errors.push(`${p !== null && p !== void 0 ? p : `.`}: ${message}`);
|
27
|
-
return false;
|
28
|
-
}
|
29
|
-
function makeCoercionFn(target, key) {
|
30
|
-
return (v) => {
|
31
|
-
const previous = target[key];
|
32
|
-
target[key] = v;
|
33
|
-
return makeCoercionFn(target, key).bind(null, previous);
|
34
|
-
};
|
35
|
-
}
|
36
|
-
function isUnknown() {
|
37
|
-
return makeValidator({
|
38
|
-
test: (value, state) => {
|
39
|
-
return true;
|
40
|
-
}
|
41
|
-
});
|
42
|
-
}
|
43
|
-
function isString() {
|
44
|
-
return makeValidator({
|
45
|
-
test: (value, state) => {
|
46
|
-
if (typeof value !== `string`)
|
47
|
-
return pushError(state, `Expected a string (got ${getPrintable(value)})`);
|
48
|
-
return true;
|
49
|
-
}
|
50
|
-
});
|
51
|
-
}
|
52
|
-
function isArray(spec, { delimiter } = {}) {
|
53
|
-
return makeValidator({
|
54
|
-
test: (value, state) => {
|
55
|
-
var _a;
|
56
|
-
const originalValue = value;
|
57
|
-
if (typeof value === `string` && typeof delimiter !== `undefined`) {
|
58
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {
|
59
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)
|
60
|
-
return pushError(state, `Unbound coercion result`);
|
61
|
-
value = value.split(delimiter);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
if (!Array.isArray(value))
|
65
|
-
return pushError(state, `Expected an array (got ${getPrintable(value)})`);
|
66
|
-
let valid = true;
|
67
|
-
for (let t = 0, T = value.length; t < T; ++t) {
|
68
|
-
valid = spec(value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid;
|
69
|
-
if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {
|
70
|
-
break;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
if (value !== originalValue)
|
74
|
-
state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]);
|
75
|
-
return valid;
|
76
|
-
}
|
77
|
-
});
|
78
|
-
}
|
79
|
-
function isTuple(spec, { delimiter } = {}) {
|
80
|
-
const lengthValidator = hasExactLength(spec.length);
|
81
|
-
return makeValidator({
|
82
|
-
test: (value, state) => {
|
83
|
-
var _a;
|
84
|
-
if (typeof value === `string` && typeof delimiter !== `undefined`) {
|
85
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {
|
86
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)
|
87
|
-
return pushError(state, `Unbound coercion result`);
|
88
|
-
value = value.split(delimiter);
|
89
|
-
state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]);
|
90
|
-
}
|
91
|
-
}
|
92
|
-
if (!Array.isArray(value))
|
93
|
-
return pushError(state, `Expected a tuple (got ${getPrintable(value)})`);
|
94
|
-
let valid = lengthValidator(value, Object.assign({}, state));
|
95
|
-
for (let t = 0, T = value.length; t < T && t < spec.length; ++t) {
|
96
|
-
valid = spec[t](value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid;
|
97
|
-
if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {
|
98
|
-
break;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
return valid;
|
102
|
-
}
|
103
|
-
});
|
104
|
-
}
|
105
|
-
function isRecord(spec, { keys: keySpec = null } = {}) {
|
106
|
-
const isArrayValidator = isArray(isTuple([keySpec !== null && keySpec !== void 0 ? keySpec : isString(), spec]));
|
107
|
-
return makeValidator({
|
108
|
-
test: (value, state) => {
|
109
|
-
var _a;
|
110
|
-
if (Array.isArray(value)) {
|
111
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {
|
112
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)
|
113
|
-
return pushError(state, `Unbound coercion result`);
|
114
|
-
if (!isArrayValidator(value, Object.assign(Object.assign({}, state), { coercion: void 0 })))
|
115
|
-
return false;
|
116
|
-
value = Object.fromEntries(value);
|
117
|
-
state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]);
|
118
|
-
return true;
|
119
|
-
}
|
120
|
-
}
|
121
|
-
if (typeof value !== `object` || value === null)
|
122
|
-
return pushError(state, `Expected an object (got ${getPrintable(value)})`);
|
123
|
-
const keys = Object.keys(value);
|
124
|
-
let valid = true;
|
125
|
-
for (let t = 0, T = keys.length; t < T && (valid || (state === null || state === void 0 ? void 0 : state.errors) != null); ++t) {
|
126
|
-
const key = keys[t];
|
127
|
-
const sub = value[key];
|
128
|
-
if (key === `__proto__` || key === `constructor`) {
|
129
|
-
valid = pushError(Object.assign(Object.assign({}, state), { p: computeKey(state, key) }), `Unsafe property name`);
|
130
|
-
continue;
|
131
|
-
}
|
132
|
-
if (keySpec !== null && !keySpec(key, state)) {
|
133
|
-
valid = false;
|
134
|
-
continue;
|
135
|
-
}
|
136
|
-
if (!spec(sub, Object.assign(Object.assign({}, state), { p: computeKey(state, key), coercion: makeCoercionFn(value, key) }))) {
|
137
|
-
valid = false;
|
138
|
-
continue;
|
139
|
-
}
|
140
|
-
}
|
141
|
-
return valid;
|
142
|
-
}
|
143
|
-
});
|
144
|
-
}
|
145
|
-
function isDict(spec, opts = {}) {
|
146
|
-
return isRecord(spec, opts);
|
147
|
-
}
|
148
|
-
function makeTrait(value) {
|
149
|
-
return () => {
|
150
|
-
return value;
|
151
|
-
};
|
152
|
-
}
|
153
|
-
function makeValidator({ test }) {
|
154
|
-
return makeTrait(test)();
|
155
|
-
}
|
156
|
-
function hasExactLength(length) {
|
157
|
-
return makeValidator({
|
158
|
-
test: (value, state) => {
|
159
|
-
if (!(value.length === length))
|
160
|
-
return pushError(state, `Expected to have a length of exactly ${length} elements (got ${value.length})`);
|
161
|
-
return true;
|
162
|
-
}
|
163
|
-
});
|
164
|
-
}
|
165
|
-
function cascade(spec, ...followups) {
|
166
|
-
const resolvedFollowups = Array.isArray(followups[0]) ? followups[0] : followups;
|
167
|
-
return makeValidator({
|
168
|
-
test: (value, state) => {
|
169
|
-
var _a, _b;
|
170
|
-
const context = { value };
|
171
|
-
const subCoercion = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined` ? makeCoercionFn(context, `value`) : void 0;
|
172
|
-
const subCoercions = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined` ? [] : void 0;
|
173
|
-
if (!spec(value, Object.assign(Object.assign({}, state), { coercion: subCoercion, coercions: subCoercions })))
|
174
|
-
return false;
|
175
|
-
const reverts = [];
|
176
|
-
if (typeof subCoercions !== `undefined`)
|
177
|
-
for (const [, coercion] of subCoercions)
|
178
|
-
reverts.push(coercion());
|
179
|
-
try {
|
180
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {
|
181
|
-
if (context.value !== value) {
|
182
|
-
if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)
|
183
|
-
return pushError(state, `Unbound coercion result`);
|
184
|
-
state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, context.value)]);
|
185
|
-
}
|
186
|
-
(_b = state === null || state === void 0 ? void 0 : state.coercions) === null || _b === void 0 ? void 0 : _b.push(...subCoercions);
|
187
|
-
}
|
188
|
-
return resolvedFollowups.every((spec2) => {
|
189
|
-
return spec2(context.value, state);
|
190
|
-
});
|
191
|
-
} finally {
|
192
|
-
for (const revert of reverts) {
|
193
|
-
revert();
|
194
|
-
}
|
195
|
-
}
|
196
|
-
}
|
197
|
-
});
|
198
|
-
}
|
199
|
-
function applyCascade(spec, ...followups) {
|
200
|
-
const resolvedFollowups = Array.isArray(followups[0]) ? followups[0] : followups;
|
201
|
-
return cascade(spec, resolvedFollowups);
|
202
|
-
}
|
203
|
-
var KeyRelationship;
|
204
|
-
(function(KeyRelationship2) {
|
205
|
-
KeyRelationship2["Forbids"] = "Forbids";
|
206
|
-
KeyRelationship2["Requires"] = "Requires";
|
207
|
-
})(KeyRelationship || (KeyRelationship = {}));
|
208
|
-
({
|
209
|
-
[KeyRelationship.Forbids]: {
|
210
|
-
},
|
211
|
-
[KeyRelationship.Requires]: {
|
212
|
-
}
|
213
|
-
});
|
214
|
-
|
215
|
-
export { KeyRelationship, applyCascade, cascade, hasExactLength, isArray, isDict, isRecord, isString, isTuple, isUnknown, makeTrait, makeValidator };
|