@featurevisor/core 4.3.0 → 4.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/lib/cli/cli.d.ts +2 -1
- package/lib/cli/cli.js +9 -6
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/options.js +61 -0
- package/lib/cli/options.js.map +1 -1
- package/lib/cli/plugins.js +7 -1
- package/lib/cli/plugins.js.map +1 -1
- package/lib/config/projectConfig.js +6 -0
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/convert/check.d.ts +33 -0
- package/lib/convert/check.js +377 -0
- package/lib/convert/check.js.map +1 -0
- package/lib/convert/config.d.ts +20 -0
- package/lib/convert/config.js +147 -0
- package/lib/convert/config.js.map +1 -0
- package/lib/convert/documents.d.ts +55 -0
- package/lib/convert/documents.js +195 -0
- package/lib/convert/documents.js.map +1 -0
- package/lib/convert/index.d.ts +7 -0
- package/lib/convert/index.js +35 -0
- package/lib/convert/index.js.map +1 -0
- package/lib/convert/plan.d.ts +41 -0
- package/lib/convert/plan.js +562 -0
- package/lib/convert/plan.js.map +1 -0
- package/lib/convert/project.d.ts +29 -0
- package/lib/convert/project.js +109 -0
- package/lib/convert/project.js.map +1 -0
- package/lib/convert/run.d.ts +3 -0
- package/lib/convert/run.js +224 -0
- package/lib/convert/run.js.map +1 -0
- package/lib/convert/tests.d.ts +22 -0
- package/lib/convert/tests.js +267 -0
- package/lib/convert/tests.js.map +1 -0
- package/lib/datasource/datasource.d.ts +2 -0
- package/lib/datasource/datasource.js +8 -0
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/parseError.d.ts +11 -0
- package/lib/datasource/parseError.js +33 -19
- package/lib/datasource/parseError.js.map +1 -1
- package/lib/formatter/formatDefinition.d.ts +32 -0
- package/lib/formatter/formatDefinition.js +161 -0
- package/lib/formatter/formatDefinition.js.map +1 -0
- package/lib/formatter/formatProject.d.ts +68 -0
- package/lib/formatter/formatProject.js +184 -0
- package/lib/formatter/formatProject.js.map +1 -0
- package/lib/formatter/index.d.ts +6 -0
- package/lib/formatter/index.js +49 -0
- package/lib/formatter/index.js.map +1 -0
- package/lib/formatter/layout.d.ts +26 -0
- package/lib/formatter/layout.js +175 -0
- package/lib/formatter/layout.js.map +1 -0
- package/lib/formatter/printFormatResult.d.ts +8 -0
- package/lib/formatter/printFormatResult.js +98 -0
- package/lib/formatter/printFormatResult.js.map +1 -0
- package/lib/formatter/run.d.ts +6 -0
- package/lib/formatter/run.js +92 -0
- package/lib/formatter/run.js.map +1 -0
- package/lib/formatter/since.d.ts +6 -0
- package/lib/formatter/since.js +80 -0
- package/lib/formatter/since.js.map +1 -0
- package/lib/formatter/style.d.ts +94 -0
- package/lib/formatter/style.js +237 -0
- package/lib/formatter/style.js.map +1 -0
- package/lib/linter/diagnostics.d.ts +12 -12
- package/lib/linter/featureSchema.js +14 -13
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/migrate/definitions.d.ts +46 -0
- package/lib/migrate/definitions.js +488 -0
- package/lib/migrate/definitions.js.map +1 -0
- package/lib/migrate/index.d.ts +6 -0
- package/lib/migrate/index.js +30 -0
- package/lib/migrate/index.js.map +1 -0
- package/lib/migrate/migrateProject.d.ts +33 -0
- package/lib/migrate/migrateProject.js +195 -0
- package/lib/migrate/migrateProject.js.map +1 -0
- package/lib/migrate/project.d.ts +31 -0
- package/lib/migrate/project.js +153 -0
- package/lib/migrate/project.js.map +1 -0
- package/lib/migrate/run.d.ts +3 -0
- package/lib/migrate/run.js +81 -0
- package/lib/migrate/run.js.map +1 -0
- package/lib/migrate/write.d.ts +10 -0
- package/lib/migrate/write.js +150 -0
- package/lib/migrate/write.js.map +1 -0
- package/lib/promoter/index.js +38 -2
- package/lib/promoter/index.js.map +1 -1
- package/lib/rewrite/diff.d.ts +2 -0
- package/lib/rewrite/diff.js +76 -0
- package/lib/rewrite/diff.js.map +1 -0
- package/lib/rewrite/files.d.ts +6 -0
- package/lib/rewrite/files.js +66 -0
- package/lib/rewrite/files.js.map +1 -0
- package/lib/rewrite/lines.d.ts +56 -0
- package/lib/rewrite/lines.js +204 -0
- package/lib/rewrite/lines.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,377 @@
|
|
|
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.applyPlan = applyPlan;
|
|
37
|
+
exports.checkPlan = checkPlan;
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const os = __importStar(require("node:os"));
|
|
40
|
+
const path = __importStar(require("node:path"));
|
|
41
|
+
const buildProject_1 = require("../builder/buildProject");
|
|
42
|
+
const config_1 = require("../config");
|
|
43
|
+
const datasource_1 = require("../datasource");
|
|
44
|
+
const lintProject_1 = require("../linter/lintProject");
|
|
45
|
+
const files_1 = require("../rewrite/files");
|
|
46
|
+
const sets_1 = require("../sets");
|
|
47
|
+
const report_1 = require("../tester/report");
|
|
48
|
+
const testProject_1 = require("../tester/testProject");
|
|
49
|
+
const config_2 = require("./config");
|
|
50
|
+
const plan_1 = require("./plan");
|
|
51
|
+
/** Applies a plan to a project at `root`, which may be a copy of the project it was made for */
|
|
52
|
+
function applyPlan(plan, planRoot, root = planRoot) {
|
|
53
|
+
const at = (filePath) => path.join(root, path.relative(planRoot, filePath));
|
|
54
|
+
for (const [filePath, content] of plan.writes) {
|
|
55
|
+
fs.mkdirSync(path.dirname(at(filePath)), { recursive: true });
|
|
56
|
+
fs.writeFileSync(at(filePath), content);
|
|
57
|
+
}
|
|
58
|
+
const emptied = new Set();
|
|
59
|
+
for (const filePath of plan.removes) {
|
|
60
|
+
if (!fs.existsSync(at(filePath)))
|
|
61
|
+
continue;
|
|
62
|
+
fs.rmSync(at(filePath));
|
|
63
|
+
emptied.add(path.dirname(at(filePath)));
|
|
64
|
+
}
|
|
65
|
+
// directories the conversion emptied, up to the project's root
|
|
66
|
+
for (let directory of [...emptied].sort((a, b) => b.length - a.length)) {
|
|
67
|
+
while (directory.startsWith(root + path.sep) && fs.existsSync(directory)) {
|
|
68
|
+
if (fs.readdirSync(directory).length > 0)
|
|
69
|
+
break;
|
|
70
|
+
fs.rmdirSync(directory);
|
|
71
|
+
directory = path.dirname(directory);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function nearestNodeModules(directory) {
|
|
76
|
+
for (let current = directory;; current = path.dirname(current)) {
|
|
77
|
+
const candidate = path.join(current, "node_modules");
|
|
78
|
+
if (fs.existsSync(candidate))
|
|
79
|
+
return candidate;
|
|
80
|
+
if (path.dirname(current) === current)
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function copyProject(root, config) {
|
|
85
|
+
const copy = fs.mkdtempSync(path.join(os.tmpdir(), "featurevisor-convert-"));
|
|
86
|
+
const skip = new Set([
|
|
87
|
+
path.join(root, "node_modules"),
|
|
88
|
+
path.join(root, ".git"),
|
|
89
|
+
config.datafilesDirectoryPath,
|
|
90
|
+
config.catalogDirectoryPath,
|
|
91
|
+
]);
|
|
92
|
+
fs.cpSync(root, copy, { recursive: true, filter: (source) => !skip.has(source) });
|
|
93
|
+
// configurations and custom parsers require packages from the project
|
|
94
|
+
const modules = nearestNodeModules(root);
|
|
95
|
+
if (modules)
|
|
96
|
+
fs.symlinkSync(modules, path.join(copy, "node_modules"), "dir");
|
|
97
|
+
return copy;
|
|
98
|
+
}
|
|
99
|
+
/** Whether a configuration's settings have the shape a plan converts to */
|
|
100
|
+
function hasShape(config, plan) {
|
|
101
|
+
return ((plan.to === "sets") === Boolean(config.sets) &&
|
|
102
|
+
(plan.to === "environments") === Array.isArray(config.environments));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The settings a configuration's text exports, read beside the copy's own under a name nothing
|
|
106
|
+
* has required yet, so the copy's configuration is required once, in its final form
|
|
107
|
+
*/
|
|
108
|
+
function settingsOf(copy, text) {
|
|
109
|
+
const probe = path.join(copy, `featurevisor.config.probe-${Date.now()}.js`);
|
|
110
|
+
fs.writeFileSync(probe, text);
|
|
111
|
+
try {
|
|
112
|
+
return require(probe);
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
fs.rmSync(probe);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Gives a copy the configuration the user is asked to write by hand: the project's own, with the
|
|
120
|
+
* new shape's settings over it, so the converted definitions can be checked before the user
|
|
121
|
+
* edits anything
|
|
122
|
+
*/
|
|
123
|
+
function writeConfigByHand(root, copy, plan) {
|
|
124
|
+
const own = "featurevisor.config.before-convert.js";
|
|
125
|
+
fs.copyFileSync(path.join(root, config_1.CONFIG_MODULE_NAME), path.join(copy, own));
|
|
126
|
+
const settings = [
|
|
127
|
+
...plan.config.remove.map((name) => ` ${name}: undefined,`),
|
|
128
|
+
...plan.config.add.map(([name, value]) => (0, config_2.writeSetting)(name, value)),
|
|
129
|
+
];
|
|
130
|
+
fs.writeFileSync(path.join(copy, config_1.CONFIG_MODULE_NAME), `module.exports = {\n ...require("./${own}"),\n${settings.join("\n")}\n};\n`);
|
|
131
|
+
}
|
|
132
|
+
/** Runs `work` without the output of the commands it calls */
|
|
133
|
+
async function quietly(work) {
|
|
134
|
+
const { log, warn, info } = console;
|
|
135
|
+
const write = process.stdout.write;
|
|
136
|
+
console.log = console.warn = console.info = () => undefined;
|
|
137
|
+
process.stdout.write = (() => true);
|
|
138
|
+
try {
|
|
139
|
+
return await work();
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
Object.assign(console, { log, warn, info });
|
|
143
|
+
process.stdout.write = write;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function dependencies(root, config) {
|
|
147
|
+
return {
|
|
148
|
+
rootDirectoryPath: root,
|
|
149
|
+
projectConfig: config,
|
|
150
|
+
datasource: new datasource_1.Datasource(config, root),
|
|
151
|
+
options: {},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** Each set of a project with sets, or the whole project, as lint and test run them */
|
|
155
|
+
async function executions(root, config) {
|
|
156
|
+
const { datasource } = dependencies(root, config);
|
|
157
|
+
return (await (0, sets_1.getProjectSetExecutions)(config, datasource)).map((execution) => ({
|
|
158
|
+
set: execution.set,
|
|
159
|
+
deps: { ...dependencies(root, execution.projectConfig), datasource: execution.datasource },
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
async function lintAll(root, config) {
|
|
163
|
+
const errors = [];
|
|
164
|
+
for (const { deps } of await executions(root, config)) {
|
|
165
|
+
errors.push(...(await (0, lintProject_1.lintProject)(deps, { json: true })).errors);
|
|
166
|
+
}
|
|
167
|
+
return errors;
|
|
168
|
+
}
|
|
169
|
+
async function runTests(root, config) {
|
|
170
|
+
const report = (0, report_1.createTestReport)();
|
|
171
|
+
let failed = false;
|
|
172
|
+
for (const { set, deps } of await executions(root, config)) {
|
|
173
|
+
const options = { quiet: true, onlyFailures: true, report, set: set || null };
|
|
174
|
+
failed = (await (0, testProject_1.testProject)({ ...deps, options }, options)) || failed;
|
|
175
|
+
}
|
|
176
|
+
return { failed, cases: report.summary.assertions.passed + report.summary.assertions.failed };
|
|
177
|
+
}
|
|
178
|
+
/** The datafiles built under a directory, by their paths in it */
|
|
179
|
+
function datafilesIn(directory) {
|
|
180
|
+
return (0, files_1.filesIn)(directory, "json").map((filePath) => path.relative(directory, filePath));
|
|
181
|
+
}
|
|
182
|
+
const ENTRIES = ["features", "segments", "variables"];
|
|
183
|
+
/**
|
|
184
|
+
* What differs between two datafiles of a lane. An entry both have must be byte identical. An
|
|
185
|
+
* entry only one has may be a dependency of another lane's rules, which `isCarried` decides.
|
|
186
|
+
*/
|
|
187
|
+
function compareDatafiles(before, after) {
|
|
188
|
+
const problems = [];
|
|
189
|
+
const fewer = [];
|
|
190
|
+
const more = [];
|
|
191
|
+
for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
192
|
+
if (!ENTRIES.includes(key)) {
|
|
193
|
+
if (JSON.stringify(before[key]) !== JSON.stringify(after[key]))
|
|
194
|
+
problems.push(key);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const a = before[key] || {};
|
|
198
|
+
const b = after[key] || {};
|
|
199
|
+
const kind = key.slice(0, -1);
|
|
200
|
+
for (const entry of new Set([...Object.keys(a), ...Object.keys(b)])) {
|
|
201
|
+
if (!(entry in b))
|
|
202
|
+
fewer.push(`${kind} ${entry}`);
|
|
203
|
+
else if (!(entry in a))
|
|
204
|
+
more.push(`${kind} ${entry}`);
|
|
205
|
+
else if (JSON.stringify(a[entry]) !== JSON.stringify(b[entry]))
|
|
206
|
+
problems.push(`${kind} ${entry}`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return { problems, fewer, more };
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether an entry only one side's datafile has is a dependency of another lane's rules. An
|
|
213
|
+
* environment's datafiles carry what any environment's rules use, so such an entry comes or goes
|
|
214
|
+
* between environments and sets. A segment is read only through the entries that name it, and a
|
|
215
|
+
* build takes in every segment they name, so one that comes or goes changes no evaluation. A
|
|
216
|
+
* feature or global variable can be read directly, so it must be named by some other entry in
|
|
217
|
+
* another lane's datafile. Any other that comes or goes is a fault in the conversion.
|
|
218
|
+
*/
|
|
219
|
+
function isCarried(entry, file, otherLanes) {
|
|
220
|
+
const [kind, key] = [entry.slice(0, entry.indexOf(" ")), entry.slice(entry.indexOf(" ") + 1)];
|
|
221
|
+
if (kind === "segment")
|
|
222
|
+
return true;
|
|
223
|
+
// conditions are JSON within the datafile's JSON, so a key is named in either quoting
|
|
224
|
+
const named = [JSON.stringify(key), JSON.stringify(JSON.stringify(key)).slice(1, -1)];
|
|
225
|
+
return otherLanes.some((directory) => {
|
|
226
|
+
const filePath = path.join(directory, file);
|
|
227
|
+
if (!fs.existsSync(filePath))
|
|
228
|
+
return false;
|
|
229
|
+
const datafile = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
230
|
+
return ENTRIES.some((group) => Object.entries(datafile[group] || {}).some(([other, value]) => !(group === `${kind}s` && other === key) &&
|
|
231
|
+
named.some((name) => JSON.stringify(value).includes(name))));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Checks a plan on a converted copy. When convert's edits to the configuration leave it in the
|
|
236
|
+
* old shape, the plan leaves the file for the user to edit, and the copy is checked as if they
|
|
237
|
+
* had.
|
|
238
|
+
*/
|
|
239
|
+
async function checkPlan(plan, root, config) {
|
|
240
|
+
const result = {
|
|
241
|
+
passed: false,
|
|
242
|
+
problems: [],
|
|
243
|
+
lanes: [],
|
|
244
|
+
added: [],
|
|
245
|
+
carried: [],
|
|
246
|
+
};
|
|
247
|
+
const outside = [...plan.writes.keys(), ...plan.removes].find((filePath) => !filePath.startsWith(root + path.sep));
|
|
248
|
+
if (outside) {
|
|
249
|
+
result.problems.push(`${outside} is outside the project, so convert cannot check it.`);
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
const copy = copyProject(root, config);
|
|
253
|
+
const builds = fs.mkdtempSync(path.join(os.tmpdir(), "featurevisor-convert-datafiles-"));
|
|
254
|
+
try {
|
|
255
|
+
return await quietly(async () => {
|
|
256
|
+
const lintBefore = await lintAll(root, config);
|
|
257
|
+
if (lintBefore.length > 0) {
|
|
258
|
+
result.problems.push(`Lint reports ${lintBefore.length} errors before converting. Fix them first, so the conversion can be checked.`);
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
const testsBefore = await runTests(root, config);
|
|
262
|
+
if (testsBefore.failed) {
|
|
263
|
+
result.problems.push("Tests fail before converting. Fix them first, so the conversion can be checked.");
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
applyPlan(plan, root, copy);
|
|
267
|
+
const edited = plan.writes.get(path.join(root, config_1.CONFIG_MODULE_NAME));
|
|
268
|
+
let converted;
|
|
269
|
+
try {
|
|
270
|
+
// a file convert's edits leave in the old shape is one for the user to edit, as is one
|
|
271
|
+
// convert could not edit at all
|
|
272
|
+
if (edited !== undefined && !hasShape(settingsOf(copy, edited), plan)) {
|
|
273
|
+
(0, plan_1.leaveConfigByHand)(plan.config, "its settings still give the old shape after convert's edits");
|
|
274
|
+
plan.writes.delete(path.join(root, config_1.CONFIG_MODULE_NAME));
|
|
275
|
+
}
|
|
276
|
+
if (plan.config.byHand)
|
|
277
|
+
writeConfigByHand(root, copy, plan);
|
|
278
|
+
converted = (0, config_1.getProjectConfig)(copy);
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
result.problems.push(`The converted configuration does not load: ${error.message}`);
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
if (!hasShape(converted, plan)) {
|
|
285
|
+
result.problems.push(`${config_1.CONFIG_MODULE_NAME} keeps the old shape even with the new shape's settings over it, so convert cannot check the conversion.`);
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
const options = { revision: "convert", stateFiles: false };
|
|
289
|
+
const beforeDir = path.join(builds, "before");
|
|
290
|
+
const afterDir = path.join(builds, "after");
|
|
291
|
+
try {
|
|
292
|
+
const lintAfter = await lintAll(copy, converted);
|
|
293
|
+
result.lint = lintAfter.length;
|
|
294
|
+
for (const error of lintAfter.slice(0, 10)) {
|
|
295
|
+
result.problems.push(`Lint after converting: ${path.relative(copy, path.resolve(copy, error.filePath))} ${error.path.join(".")}: ${error.message}`);
|
|
296
|
+
}
|
|
297
|
+
// tests and builds of a project lint rejects say nothing more
|
|
298
|
+
if (lintAfter.length > 0)
|
|
299
|
+
return result;
|
|
300
|
+
const testsAfter = await runTests(copy, converted);
|
|
301
|
+
result.tests = { before: testsBefore.cases, after: testsAfter.cases };
|
|
302
|
+
if (testsAfter.failed)
|
|
303
|
+
result.problems.push("Tests fail after converting.");
|
|
304
|
+
await (0, buildProject_1.buildProjectSets)(dependencies(root, config), { ...options, datafilesDir: beforeDir });
|
|
305
|
+
await (0, buildProject_1.buildProjectSets)(dependencies(copy, converted), {
|
|
306
|
+
...options,
|
|
307
|
+
datafilesDir: afterDir,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
// a converted project that cannot even be read is a fault in the conversion
|
|
312
|
+
result.problems.push(`The converted project fails: ${error.message}`);
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
const pairs = plan.from === "flat"
|
|
316
|
+
? plan.lanes.map((lane) => [lane, beforeDir, path.join(afterDir, lane)])
|
|
317
|
+
: plan.to === "flat"
|
|
318
|
+
? [[plan.keep, path.join(beforeDir, plan.keep), afterDir]]
|
|
319
|
+
: plan.lanes.map((lane) => [
|
|
320
|
+
lane,
|
|
321
|
+
path.join(beforeDir, lane),
|
|
322
|
+
path.join(afterDir, lane),
|
|
323
|
+
]);
|
|
324
|
+
// each lane's datafiles in the shape that has lanes, before and after
|
|
325
|
+
const laneDirectories = (shape, directory, except) => shape === "flat"
|
|
326
|
+
? []
|
|
327
|
+
: plan.lanes.filter((lane) => lane !== except).map((lane) => path.join(directory, lane));
|
|
328
|
+
for (const [lane, before, after] of pairs) {
|
|
329
|
+
result.lanes.push(lane);
|
|
330
|
+
const fewer = new Set();
|
|
331
|
+
const more = new Set();
|
|
332
|
+
const beforeFiles = datafilesIn(before);
|
|
333
|
+
const afterFiles = datafilesIn(after);
|
|
334
|
+
for (const file of beforeFiles) {
|
|
335
|
+
if (!afterFiles.includes(file)) {
|
|
336
|
+
result.problems.push(`${lane}: ${file} is no longer built.`);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
const read = (directory) => JSON.parse(fs.readFileSync(path.join(directory, file), "utf8"));
|
|
340
|
+
const compared = compareDatafiles(read(before), read(after));
|
|
341
|
+
for (const problem of compared.problems) {
|
|
342
|
+
result.problems.push(`${lane}: ${file} changes the ${problem}.`);
|
|
343
|
+
}
|
|
344
|
+
for (const entry of compared.fewer) {
|
|
345
|
+
if (isCarried(entry, file, laneDirectories(plan.from, beforeDir, lane)))
|
|
346
|
+
fewer.add(entry);
|
|
347
|
+
else
|
|
348
|
+
result.problems.push(`${lane}: ${file} no longer has the ${entry}.`);
|
|
349
|
+
}
|
|
350
|
+
for (const entry of compared.more) {
|
|
351
|
+
if (isCarried(entry, file, laneDirectories(plan.to, afterDir, lane)))
|
|
352
|
+
more.add(entry);
|
|
353
|
+
else
|
|
354
|
+
result.problems.push(`${lane}: ${file} now has the ${entry}.`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (fewer.size > 0) {
|
|
358
|
+
result.carried.push(`${lane} datafiles no longer carry ${[...fewer].sort().join(", ")}, which only other lanes' rules use.`);
|
|
359
|
+
}
|
|
360
|
+
if (more.size > 0) {
|
|
361
|
+
result.carried.push(`${lane} datafiles now also carry ${[...more].sort().join(", ")}, which other lanes' rules use.`);
|
|
362
|
+
}
|
|
363
|
+
for (const file of afterFiles) {
|
|
364
|
+
if (!beforeFiles.includes(file))
|
|
365
|
+
result.added.push(`${lane}/${file}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
result.passed = result.problems.length === 0;
|
|
369
|
+
return result;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
finally {
|
|
373
|
+
fs.rmSync(copy, { recursive: true, force: true });
|
|
374
|
+
fs.rmSync(builds, { recursive: true, force: true });
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/convert/check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,8BAoBC;AAoLD,8BAgKC;AA9YD,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAElC,0DAA2D;AAC3D,sCAAqF;AACrF,8CAA2C;AAC3C,uDAAwE;AACxE,4CAA2C;AAC3C,kCAAkD;AAClD,6CAAoD;AACpD,uDAAoD;AACpD,qCAAwC;AACxC,iCAAsD;AAwBtD,gGAAgG;AAChG,SAAgB,SAAS,CAAC,IAAU,EAAE,QAAgB,EAAE,IAAI,GAAG,QAAQ;IACrE,MAAM,EAAE,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IA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AAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edits featurevisor.config.js as text: removes top level settings of `module.exports` and adds
|
|
3
|
+
* new ones after its opening brace. Everything else in the file stays as written. A setting
|
|
4
|
+
* it cannot find, such as one spread in from another object, stays, and the result says which
|
|
5
|
+
* ones it removed.
|
|
6
|
+
*/
|
|
7
|
+
export interface ConfigEdit {
|
|
8
|
+
remove: string[];
|
|
9
|
+
/** Settings to add, by name. A list of values is an array written one value per line. */
|
|
10
|
+
add: [string, string | string[]][];
|
|
11
|
+
}
|
|
12
|
+
/** A setting as written in the exported object, a list of values one per line */
|
|
13
|
+
export declare function writeSetting(name: string, value: string | string[], indent?: string): string;
|
|
14
|
+
/** The edited text, and the settings it removed. Undefined when it exports no object to edit. */
|
|
15
|
+
export declare function editConfig(source: string, edit: ConfigEdit): {
|
|
16
|
+
text: string;
|
|
17
|
+
removed: string[];
|
|
18
|
+
} | undefined;
|
|
19
|
+
/** A JavaScript string literal in the quotes the configuration already uses */
|
|
20
|
+
export declare function quote(source: string, value: string): string;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Edits featurevisor.config.js as text: removes top level settings of `module.exports` and adds
|
|
4
|
+
* new ones after its opening brace. Everything else in the file stays as written. A setting
|
|
5
|
+
* it cannot find, such as one spread in from another object, stays, and the result says which
|
|
6
|
+
* ones it removed.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.writeSetting = writeSetting;
|
|
10
|
+
exports.editConfig = editConfig;
|
|
11
|
+
exports.quote = quote;
|
|
12
|
+
/** The index just past a value starting at `start`, at the next top level `,` or `}` */
|
|
13
|
+
function endOfValue(source, start) {
|
|
14
|
+
let depth = 0;
|
|
15
|
+
for (let index = start; index < source.length; index++) {
|
|
16
|
+
const char = source[index];
|
|
17
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
18
|
+
for (index++; index < source.length && source[index] !== char; index++) {
|
|
19
|
+
if (source[index] === "\\")
|
|
20
|
+
index++;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (char === "/" && source[index + 1] === "/") {
|
|
24
|
+
index = source.indexOf("\n", index);
|
|
25
|
+
if (index === -1)
|
|
26
|
+
return source.length;
|
|
27
|
+
}
|
|
28
|
+
else if (char === "/" && source[index + 1] === "*") {
|
|
29
|
+
index = source.indexOf("*/", index) + 1;
|
|
30
|
+
}
|
|
31
|
+
else if ("([{".includes(char)) {
|
|
32
|
+
depth++;
|
|
33
|
+
}
|
|
34
|
+
else if (")]}".includes(char)) {
|
|
35
|
+
if (depth === 0)
|
|
36
|
+
return index;
|
|
37
|
+
depth--;
|
|
38
|
+
}
|
|
39
|
+
else if (char === "," && depth === 0) {
|
|
40
|
+
return index;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return source.length;
|
|
44
|
+
}
|
|
45
|
+
/** Where the object `module.exports` is set to opens, or -1 */
|
|
46
|
+
function exportsStart(source) {
|
|
47
|
+
const match = /module\.exports\s*=\s*\{/.exec(source);
|
|
48
|
+
return match ? match.index + match[0].length - 1 : -1;
|
|
49
|
+
}
|
|
50
|
+
/** Where the object opening at `open` closes, past every property's value */
|
|
51
|
+
function endOfObject(source, open) {
|
|
52
|
+
let index = endOfValue(source, open + 1);
|
|
53
|
+
while (source[index] === ",")
|
|
54
|
+
index = endOfValue(source, index + 1);
|
|
55
|
+
return index;
|
|
56
|
+
}
|
|
57
|
+
/** The start and end of the top level property `name` of the exported object */
|
|
58
|
+
function findProperty(source, name) {
|
|
59
|
+
const open = exportsStart(source);
|
|
60
|
+
if (open === -1)
|
|
61
|
+
return undefined;
|
|
62
|
+
const close = endOfObject(source, open);
|
|
63
|
+
const pattern = new RegExp(`(^|[{,\\s])(["']?)${name}\\2\\s*:`, "g");
|
|
64
|
+
pattern.lastIndex = open + 1;
|
|
65
|
+
for (let match = pattern.exec(source); match && match.index < close; match = pattern.exec(source)) {
|
|
66
|
+
const keyStart = match.index + match[1].length;
|
|
67
|
+
// not in a comment, and not a property of an object nested in the exported one
|
|
68
|
+
const lineStart = source.lastIndexOf("\n", keyStart - 1) + 1;
|
|
69
|
+
if (source.slice(lineStart, keyStart).includes("//"))
|
|
70
|
+
continue;
|
|
71
|
+
if (depthOf(source.slice(open + 1, keyStart)) !== 0)
|
|
72
|
+
continue;
|
|
73
|
+
return [keyStart, endOfValue(source, match.index + match[0].length)];
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
/** How deep a position is in brackets, ignoring strings and comments */
|
|
78
|
+
function depthOf(text) {
|
|
79
|
+
let depth = 0;
|
|
80
|
+
for (let index = 0; index < text.length; index++) {
|
|
81
|
+
const char = text[index];
|
|
82
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
83
|
+
for (index++; index < text.length && text[index] !== char; index++) {
|
|
84
|
+
if (text[index] === "\\")
|
|
85
|
+
index++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (char === "/" && text[index + 1] === "/") {
|
|
89
|
+
const next = text.indexOf("\n", index);
|
|
90
|
+
index = next === -1 ? text.length : next;
|
|
91
|
+
}
|
|
92
|
+
else if ("([{".includes(char))
|
|
93
|
+
depth++;
|
|
94
|
+
else if (")]}".includes(char))
|
|
95
|
+
depth--;
|
|
96
|
+
}
|
|
97
|
+
return depth;
|
|
98
|
+
}
|
|
99
|
+
/** A setting as written in the exported object, a list of values one per line */
|
|
100
|
+
function writeSetting(name, value, indent = " ") {
|
|
101
|
+
const written = typeof value === "string"
|
|
102
|
+
? value
|
|
103
|
+
: `[${value.map((item) => `\n${indent}${indent}${item},`).join("")}\n${indent}]`;
|
|
104
|
+
return `${indent}${name}: ${written},`;
|
|
105
|
+
}
|
|
106
|
+
/** The edited text, and the settings it removed. Undefined when it exports no object to edit. */
|
|
107
|
+
function editConfig(source, edit) {
|
|
108
|
+
if (exportsStart(source) === -1)
|
|
109
|
+
return undefined;
|
|
110
|
+
let result = source;
|
|
111
|
+
const removed = [];
|
|
112
|
+
for (const name of edit.remove) {
|
|
113
|
+
const found = findProperty(result, name);
|
|
114
|
+
if (!found)
|
|
115
|
+
continue;
|
|
116
|
+
removed.push(name);
|
|
117
|
+
let [start, end] = found;
|
|
118
|
+
// the comma after the value, and the whole line when the setting has it to itself
|
|
119
|
+
if (result[end] === ",")
|
|
120
|
+
end++;
|
|
121
|
+
const lineStart = result.lastIndexOf("\n", start - 1) + 1;
|
|
122
|
+
const lineEnd = result.indexOf("\n", end);
|
|
123
|
+
if (!result.slice(lineStart, start).trim() &&
|
|
124
|
+
!result.slice(end, lineEnd === -1 ? undefined : lineEnd).trim()) {
|
|
125
|
+
start = lineStart;
|
|
126
|
+
end = lineEnd === -1 ? result.length : lineEnd + 1;
|
|
127
|
+
}
|
|
128
|
+
result = result.slice(0, start) + result.slice(end);
|
|
129
|
+
}
|
|
130
|
+
if (edit.add.length > 0) {
|
|
131
|
+
const open = exportsStart(result);
|
|
132
|
+
const indent = /\n([ \t]+)\S/.exec(result.slice(open))?.[1] || " ";
|
|
133
|
+
const lines = edit.add
|
|
134
|
+
.map(([name, value]) => `\n${writeSetting(name, value, indent)}`)
|
|
135
|
+
.join("");
|
|
136
|
+
result = result.slice(0, open + 1) + lines + result.slice(open + 1);
|
|
137
|
+
}
|
|
138
|
+
return { text: result, removed };
|
|
139
|
+
}
|
|
140
|
+
/** A JavaScript string literal in the quotes the configuration already uses */
|
|
141
|
+
function quote(source, value) {
|
|
142
|
+
const singles = (source.match(/'/g) || []).length;
|
|
143
|
+
const doubles = (source.match(/"/g) || []).length;
|
|
144
|
+
const mark = singles > doubles ? "'" : '"';
|
|
145
|
+
return `${mark}${value.replace(/\\/g, "\\\\").replace(new RegExp(mark, "g"), `\\${mark}`)}${mark}`;
|
|
146
|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{ type CustomParser } from "@featurevisor/parsers";
|
|
2
|
+
import { Document, YAMLMap, YAMLSeq } from "yaml";
|
|
3
|
+
import type { Node, Pair } from "yaml";
|
|
4
|
+
import type { EntityType } from "@featurevisor/types";
|
|
5
|
+
/**
|
|
6
|
+
* Definitions are edited as YAML documents whatever their parser, so one set of edits serves
|
|
7
|
+
* every format. A YAML file keeps its comments, and every file keeps the lines a conversion
|
|
8
|
+
* does not touch.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A file as a document. Aliases are written out in full, since splitting lanes apart can leave
|
|
12
|
+
* an alias without its anchor. `expanded` says whether there were any.
|
|
13
|
+
*/
|
|
14
|
+
export declare function load(source: string, parser: CustomParser): {
|
|
15
|
+
doc: Document;
|
|
16
|
+
expanded: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Whether fmt leaves a file as it is, so a converted file should be formatted too */
|
|
19
|
+
export declare function isFormatted(entityType: EntityType, text: string, parser: CustomParser): boolean;
|
|
20
|
+
/** The text as fmt writes it, or as it is when fmt cannot format it */
|
|
21
|
+
export declare function formatted(entityType: EntityType, text: string, parser: CustomParser): string;
|
|
22
|
+
/**
|
|
23
|
+
* The document as the file's new text, with the file's own lines where nothing changed, or
|
|
24
|
+
* the whole file as its parser writes it, which `merged` says. YAML keeps its comments either
|
|
25
|
+
* way and JSON has none, but a custom format may lose them. Undefined when the text would not
|
|
26
|
+
* read back as the document.
|
|
27
|
+
*/
|
|
28
|
+
export declare function render(source: string, doc: Document, parser: CustomParser): {
|
|
29
|
+
text: string;
|
|
30
|
+
merged: boolean;
|
|
31
|
+
} | undefined;
|
|
32
|
+
export declare function rootMap(doc: Document): YAMLMap | undefined;
|
|
33
|
+
export declare function pairOf(map: YAMLMap, key: string): Pair | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Replaces the map by lane at `key` with one lane's value, keeping the comments above that
|
|
36
|
+
* lane's key. Without one, the key goes, or becomes `empty` when given.
|
|
37
|
+
*/
|
|
38
|
+
export declare function takeLane(map: YAMLMap, key: string, lane: string, empty?: unknown): void;
|
|
39
|
+
/** Whether a map's keys are separated by blank lines, as in a formatted file */
|
|
40
|
+
export declare function isSpaced(map: YAMLMap | undefined): boolean;
|
|
41
|
+
/** Separates a list's items by a blank line, or by none, as `spaced` says */
|
|
42
|
+
export declare function spaceItems(list: {
|
|
43
|
+
items: unknown[];
|
|
44
|
+
}, spaced: boolean): void;
|
|
45
|
+
/** Groups the value at `key` by lane, a copy for each */
|
|
46
|
+
export declare function spreadLanes(map: YAMLMap, key: string, lanes: string[], spaced: boolean): void;
|
|
47
|
+
/** A map from lanes to their nodes, in lane order, leaving out lanes without one */
|
|
48
|
+
export declare function laneMap(values: [string, Node | undefined][], spaced: boolean): YAMLMap | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Sets `key` in a map, keeping its place when it is there already. A new key goes after the
|
|
51
|
+
* last of `after` the map has, and takes a blank line before it when the map's keys have them.
|
|
52
|
+
*/
|
|
53
|
+
export declare function setKey(map: YAMLMap, key: string, node: Node | undefined, after?: string[]): void;
|
|
54
|
+
export declare function nodeAt(map: YAMLMap, key: string): Node | undefined;
|
|
55
|
+
export declare function seqOf(node: unknown): YAMLSeq | undefined;
|