@featurevisor/core 4.3.0 → 4.5.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.
Files changed (148) hide show
  1. package/lib/cli/cli.d.ts +2 -1
  2. package/lib/cli/cli.js +9 -6
  3. package/lib/cli/cli.js.map +1 -1
  4. package/lib/cli/options.js +69 -0
  5. package/lib/cli/options.js.map +1 -1
  6. package/lib/cli/plugins.js +7 -1
  7. package/lib/cli/plugins.js.map +1 -1
  8. package/lib/config/projectConfig.d.ts +10 -0
  9. package/lib/config/projectConfig.js +14 -0
  10. package/lib/config/projectConfig.js.map +1 -1
  11. package/lib/convert/check.d.ts +33 -0
  12. package/lib/convert/check.js +411 -0
  13. package/lib/convert/check.js.map +1 -0
  14. package/lib/convert/config.d.ts +20 -0
  15. package/lib/convert/config.js +147 -0
  16. package/lib/convert/config.js.map +1 -0
  17. package/lib/convert/documents.d.ts +40 -0
  18. package/lib/convert/documents.js +154 -0
  19. package/lib/convert/documents.js.map +1 -0
  20. package/lib/convert/index.d.ts +7 -0
  21. package/lib/convert/index.js +47 -0
  22. package/lib/convert/index.js.map +1 -0
  23. package/lib/convert/plan.d.ts +53 -0
  24. package/lib/convert/plan.js +669 -0
  25. package/lib/convert/plan.js.map +1 -0
  26. package/lib/convert/project.d.ts +29 -0
  27. package/lib/convert/project.js +109 -0
  28. package/lib/convert/project.js.map +1 -0
  29. package/lib/convert/run.d.ts +3 -0
  30. package/lib/convert/run.js +241 -0
  31. package/lib/convert/run.js.map +1 -0
  32. package/lib/convert/tests.d.ts +22 -0
  33. package/lib/convert/tests.js +267 -0
  34. package/lib/convert/tests.js.map +1 -0
  35. package/lib/datasource/conditionLocations.d.ts +9 -0
  36. package/lib/datasource/conditionLocations.js +70 -0
  37. package/lib/datasource/conditionLocations.js.map +1 -0
  38. package/lib/datasource/datasource.d.ts +11 -0
  39. package/lib/datasource/datasource.js +26 -6
  40. package/lib/datasource/datasource.js.map +1 -1
  41. package/lib/datasource/expressions.d.ts +36 -0
  42. package/lib/datasource/expressions.js +118 -0
  43. package/lib/datasource/expressions.js.map +1 -0
  44. package/lib/datasource/parseError.d.ts +11 -0
  45. package/lib/datasource/parseError.js +33 -19
  46. package/lib/datasource/parseError.js.map +1 -1
  47. package/lib/diff/conditions.d.ts +23 -0
  48. package/lib/diff/conditions.js +86 -0
  49. package/lib/diff/conditions.js.map +1 -0
  50. package/lib/diff/details.d.ts +7 -1
  51. package/lib/diff/details.js +54 -25
  52. package/lib/diff/details.js.map +1 -1
  53. package/lib/diff/index.d.ts +5 -0
  54. package/lib/diff/index.js +17 -2
  55. package/lib/diff/index.js.map +1 -1
  56. package/lib/evaluate/explain.d.ts +4 -1
  57. package/lib/evaluate/explain.js +35 -14
  58. package/lib/evaluate/explain.js.map +1 -1
  59. package/lib/evaluate/index.js +9 -5
  60. package/lib/evaluate/index.js.map +1 -1
  61. package/lib/formatter/expressions.d.ts +21 -0
  62. package/lib/formatter/expressions.js +79 -0
  63. package/lib/formatter/expressions.js.map +1 -0
  64. package/lib/formatter/formatDefinition.d.ts +46 -0
  65. package/lib/formatter/formatDefinition.js +201 -0
  66. package/lib/formatter/formatDefinition.js.map +1 -0
  67. package/lib/formatter/formatProject.d.ts +70 -0
  68. package/lib/formatter/formatProject.js +186 -0
  69. package/lib/formatter/formatProject.js.map +1 -0
  70. package/lib/formatter/index.d.ts +6 -0
  71. package/lib/formatter/index.js +53 -0
  72. package/lib/formatter/index.js.map +1 -0
  73. package/lib/formatter/layout.d.ts +26 -0
  74. package/lib/formatter/layout.js +175 -0
  75. package/lib/formatter/layout.js.map +1 -0
  76. package/lib/formatter/printFormatResult.d.ts +9 -0
  77. package/lib/formatter/printFormatResult.js +100 -0
  78. package/lib/formatter/printFormatResult.js.map +1 -0
  79. package/lib/formatter/run.d.ts +6 -0
  80. package/lib/formatter/run.js +97 -0
  81. package/lib/formatter/run.js.map +1 -0
  82. package/lib/formatter/simplify.d.ts +14 -0
  83. package/lib/formatter/simplify.js +21 -0
  84. package/lib/formatter/simplify.js.map +1 -0
  85. package/lib/formatter/since.d.ts +6 -0
  86. package/lib/formatter/since.js +80 -0
  87. package/lib/formatter/since.js.map +1 -0
  88. package/lib/formatter/style.d.ts +105 -0
  89. package/lib/formatter/style.js +248 -0
  90. package/lib/formatter/style.js.map +1 -0
  91. package/lib/linter/conditionKinds.js +2 -54
  92. package/lib/linter/conditionKinds.js.map +1 -1
  93. package/lib/linter/conditionSchema.js +42 -13
  94. package/lib/linter/conditionSchema.js.map +1 -1
  95. package/lib/linter/diagnostics.d.ts +14 -14
  96. package/lib/linter/expressionDiagnostics.d.ts +28 -0
  97. package/lib/linter/expressionDiagnostics.js +127 -0
  98. package/lib/linter/expressionDiagnostics.js.map +1 -0
  99. package/lib/linter/featureSchema.d.ts +2 -2
  100. package/lib/linter/featureSchema.js +14 -13
  101. package/lib/linter/featureSchema.js.map +1 -1
  102. package/lib/linter/lintProject.d.ts +7 -0
  103. package/lib/linter/lintProject.js +300 -52
  104. package/lib/linter/lintProject.js.map +1 -1
  105. package/lib/linter/listTypes.d.ts +7 -0
  106. package/lib/linter/listTypes.js +19 -0
  107. package/lib/linter/listTypes.js.map +1 -0
  108. package/lib/linter/printError.d.ts +2 -0
  109. package/lib/linter/printError.js +1 -0
  110. package/lib/linter/printError.js.map +1 -1
  111. package/lib/linter/requiredVariablesSchema.js +129 -13
  112. package/lib/linter/requiredVariablesSchema.js.map +1 -1
  113. package/lib/migrate/definitions.d.ts +46 -0
  114. package/lib/migrate/definitions.js +488 -0
  115. package/lib/migrate/definitions.js.map +1 -0
  116. package/lib/migrate/index.d.ts +6 -0
  117. package/lib/migrate/index.js +30 -0
  118. package/lib/migrate/index.js.map +1 -0
  119. package/lib/migrate/migrateProject.d.ts +33 -0
  120. package/lib/migrate/migrateProject.js +195 -0
  121. package/lib/migrate/migrateProject.js.map +1 -0
  122. package/lib/migrate/project.d.ts +31 -0
  123. package/lib/migrate/project.js +153 -0
  124. package/lib/migrate/project.js.map +1 -0
  125. package/lib/migrate/run.d.ts +3 -0
  126. package/lib/migrate/run.js +81 -0
  127. package/lib/migrate/run.js.map +1 -0
  128. package/lib/migrate/write.d.ts +10 -0
  129. package/lib/migrate/write.js +150 -0
  130. package/lib/migrate/write.js.map +1 -0
  131. package/lib/promoter/index.js +85 -4
  132. package/lib/promoter/index.js.map +1 -1
  133. package/lib/rewrite/conditions.d.ts +73 -0
  134. package/lib/rewrite/conditions.js +485 -0
  135. package/lib/rewrite/conditions.js.map +1 -0
  136. package/lib/rewrite/diff.d.ts +2 -0
  137. package/lib/rewrite/diff.js +76 -0
  138. package/lib/rewrite/diff.js.map +1 -0
  139. package/lib/rewrite/documents.d.ts +25 -0
  140. package/lib/rewrite/documents.js +54 -0
  141. package/lib/rewrite/documents.js.map +1 -0
  142. package/lib/rewrite/files.d.ts +6 -0
  143. package/lib/rewrite/files.js +66 -0
  144. package/lib/rewrite/files.js.map +1 -0
  145. package/lib/rewrite/lines.d.ts +56 -0
  146. package/lib/rewrite/lines.js +205 -0
  147. package/lib/rewrite/lines.js.map +1 -0
  148. package/package.json +5 -4
@@ -0,0 +1,411 @@
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 conditions_1 = require("../rewrite/conditions");
51
+ const plan_1 = require("./plan");
52
+ /** Applies a plan to a project at `root`, which may be a copy of the project it was made for */
53
+ function applyPlan(plan, planRoot, root = planRoot) {
54
+ const at = (filePath) => path.join(root, path.relative(planRoot, filePath));
55
+ for (const [filePath, content] of plan.writes) {
56
+ fs.mkdirSync(path.dirname(at(filePath)), { recursive: true });
57
+ fs.writeFileSync(at(filePath), content);
58
+ }
59
+ const emptied = new Set();
60
+ for (const filePath of plan.removes) {
61
+ if (!fs.existsSync(at(filePath)))
62
+ continue;
63
+ fs.rmSync(at(filePath));
64
+ emptied.add(path.dirname(at(filePath)));
65
+ }
66
+ // directories the conversion emptied, up to the project's root
67
+ for (let directory of [...emptied].sort((a, b) => b.length - a.length)) {
68
+ while (directory.startsWith(root + path.sep) && fs.existsSync(directory)) {
69
+ if (fs.readdirSync(directory).length > 0)
70
+ break;
71
+ fs.rmdirSync(directory);
72
+ directory = path.dirname(directory);
73
+ }
74
+ }
75
+ }
76
+ function nearestNodeModules(directory) {
77
+ for (let current = directory;; current = path.dirname(current)) {
78
+ const candidate = path.join(current, "node_modules");
79
+ if (fs.existsSync(candidate))
80
+ return candidate;
81
+ if (path.dirname(current) === current)
82
+ return undefined;
83
+ }
84
+ }
85
+ function copyProject(root, config) {
86
+ const copy = fs.mkdtempSync(path.join(os.tmpdir(), "featurevisor-convert-"));
87
+ const skip = new Set([
88
+ path.join(root, "node_modules"),
89
+ path.join(root, ".git"),
90
+ config.datafilesDirectoryPath,
91
+ config.catalogDirectoryPath,
92
+ ]);
93
+ fs.cpSync(root, copy, { recursive: true, filter: (source) => !skip.has(source) });
94
+ // configurations and custom parsers require packages from the project
95
+ const modules = nearestNodeModules(root);
96
+ if (modules)
97
+ fs.symlinkSync(modules, path.join(copy, "node_modules"), "dir");
98
+ return copy;
99
+ }
100
+ /** Whether a configuration's settings have the shape, or allow the conditions, a plan converts to */
101
+ function hasShape(config, plan) {
102
+ if ((0, plan_1.isConditionForm)(plan.to)) {
103
+ return (config.conditionExpressions === true) === (plan.to === "expressions");
104
+ }
105
+ return ((plan.to === "sets") === Boolean(config.sets) &&
106
+ (plan.to === "environments") === Array.isArray(config.environments));
107
+ }
108
+ /**
109
+ * The settings a configuration's text exports, read beside the copy's own under a name nothing
110
+ * has required yet, so the copy's configuration is required once, in its final form
111
+ */
112
+ function settingsOf(copy, text) {
113
+ const probe = path.join(copy, `featurevisor.config.probe-${Date.now()}.js`);
114
+ fs.writeFileSync(probe, text);
115
+ try {
116
+ return require(probe);
117
+ }
118
+ finally {
119
+ fs.rmSync(probe);
120
+ }
121
+ }
122
+ /**
123
+ * Gives a copy the configuration the user is asked to write by hand: the project's own, with the
124
+ * new shape's settings over it, so the converted definitions can be checked before the user
125
+ * edits anything
126
+ */
127
+ function writeConfigByHand(root, copy, plan) {
128
+ const own = "featurevisor.config.before-convert.js";
129
+ fs.copyFileSync(path.join(root, config_1.CONFIG_MODULE_NAME), path.join(copy, own));
130
+ const settings = [
131
+ ...plan.config.remove.map((name) => ` ${name}: undefined,`),
132
+ ...plan.config.add.map(([name, value]) => (0, config_2.writeSetting)(name, value)),
133
+ ];
134
+ fs.writeFileSync(path.join(copy, config_1.CONFIG_MODULE_NAME), `module.exports = {\n ...require("./${own}"),\n${settings.join("\n")}\n};\n`);
135
+ }
136
+ /** Runs `work` without the output of the commands it calls */
137
+ async function quietly(work) {
138
+ const { log, warn, info } = console;
139
+ const write = process.stdout.write;
140
+ console.log = console.warn = console.info = () => undefined;
141
+ process.stdout.write = (() => true);
142
+ try {
143
+ return await work();
144
+ }
145
+ finally {
146
+ Object.assign(console, { log, warn, info });
147
+ process.stdout.write = write;
148
+ }
149
+ }
150
+ function dependencies(root, config) {
151
+ return {
152
+ rootDirectoryPath: root,
153
+ projectConfig: config,
154
+ datasource: new datasource_1.Datasource(config, root),
155
+ options: {},
156
+ };
157
+ }
158
+ /** Each set of a project with sets, or the whole project, as lint and test run them */
159
+ async function executions(root, config) {
160
+ const { datasource } = dependencies(root, config);
161
+ return (await (0, sets_1.getProjectSetExecutions)(config, datasource)).map((execution) => ({
162
+ set: execution.set,
163
+ deps: { ...dependencies(root, execution.projectConfig), datasource: execution.datasource },
164
+ }));
165
+ }
166
+ async function lintAll(root, config) {
167
+ const errors = [];
168
+ for (const { deps } of await executions(root, config)) {
169
+ errors.push(...(await (0, lintProject_1.lintProject)(deps, { json: true })).errors);
170
+ }
171
+ return errors;
172
+ }
173
+ async function runTests(root, config) {
174
+ const report = (0, report_1.createTestReport)();
175
+ let failed = false;
176
+ for (const { set, deps } of await executions(root, config)) {
177
+ const options = { quiet: true, onlyFailures: true, report, set: set || null };
178
+ failed = (await (0, testProject_1.testProject)({ ...deps, options }, options)) || failed;
179
+ }
180
+ return { failed, cases: report.summary.assertions.passed + report.summary.assertions.failed };
181
+ }
182
+ /** The datafiles built under a directory, by their paths in it */
183
+ function datafilesIn(directory) {
184
+ return (0, files_1.filesIn)(directory, "json").map((filePath) => path.relative(directory, filePath));
185
+ }
186
+ const ENTRIES = ["features", "segments", "variables"];
187
+ /**
188
+ * A datafile entry with every `conditions` value in its simplest form and without its hash,
189
+ * for comparing entries whose conditions were simplified: two entries that evaluate the same
190
+ * are equal in this form. Conditions a datafile stores as JSON text are read first.
191
+ */
192
+ function simplestEntry(value, key) {
193
+ if (key === "conditions") {
194
+ const conditions = typeof value === "string" && /^[[{]/.test(value) ? JSON.parse(value) : value;
195
+ return (0, conditions_1.simplestConditions)(conditions);
196
+ }
197
+ if (Array.isArray(value))
198
+ return value.map((item) => simplestEntry(item));
199
+ if (!value || typeof value !== "object")
200
+ return value;
201
+ return Object.fromEntries(Object.entries(value)
202
+ .filter(([name]) => name !== "hash")
203
+ .map(([name, item]) => [name, simplestEntry(item, name)]));
204
+ }
205
+ /**
206
+ * What differs between two datafiles of a lane. An entry both have must be byte identical, or
207
+ * evaluate the same when the conversion simplified conditions. An entry only one has may be a
208
+ * dependency of another lane's rules, which `isCarried` decides.
209
+ */
210
+ function compareDatafiles(before, after, simplified = false) {
211
+ const same = (a, b) => simplified
212
+ ? JSON.stringify(simplestEntry(a)) === JSON.stringify(simplestEntry(b))
213
+ : JSON.stringify(a) === JSON.stringify(b);
214
+ const problems = [];
215
+ const fewer = [];
216
+ const more = [];
217
+ for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {
218
+ if (!ENTRIES.includes(key)) {
219
+ if (JSON.stringify(before[key]) !== JSON.stringify(after[key]))
220
+ problems.push(key);
221
+ continue;
222
+ }
223
+ const a = before[key] || {};
224
+ const b = after[key] || {};
225
+ const kind = key.slice(0, -1);
226
+ for (const entry of new Set([...Object.keys(a), ...Object.keys(b)])) {
227
+ if (!(entry in b))
228
+ fewer.push(`${kind} ${entry}`);
229
+ else if (!(entry in a))
230
+ more.push(`${kind} ${entry}`);
231
+ else if (!same(a[entry], b[entry]))
232
+ problems.push(`${kind} ${entry}`);
233
+ }
234
+ }
235
+ return { problems, fewer, more };
236
+ }
237
+ /**
238
+ * Whether an entry only one side's datafile has is a dependency of another lane's rules. An
239
+ * environment's datafiles carry what any environment's rules use, so such an entry comes or goes
240
+ * between environments and sets. A segment is read only through the entries that name it, and a
241
+ * build takes in every segment they name, so one that comes or goes changes no evaluation. A
242
+ * feature or global variable can be read directly, so it must be named by some other entry in
243
+ * another lane's datafile. Any other that comes or goes is a fault in the conversion.
244
+ */
245
+ function isCarried(entry, file, otherLanes) {
246
+ const [kind, key] = [entry.slice(0, entry.indexOf(" ")), entry.slice(entry.indexOf(" ") + 1)];
247
+ if (kind === "segment")
248
+ return true;
249
+ // conditions are JSON within the datafile's JSON, so a key is named in either quoting
250
+ const named = [JSON.stringify(key), JSON.stringify(JSON.stringify(key)).slice(1, -1)];
251
+ return otherLanes.some((directory) => {
252
+ const filePath = path.join(directory, file);
253
+ if (!fs.existsSync(filePath))
254
+ return false;
255
+ const datafile = JSON.parse(fs.readFileSync(filePath, "utf8"));
256
+ return ENTRIES.some((group) => Object.entries(datafile[group] || {}).some(([other, value]) => !(group === `${kind}s` && other === key) &&
257
+ named.some((name) => JSON.stringify(value).includes(name))));
258
+ });
259
+ }
260
+ /**
261
+ * Checks a plan on a converted copy. When convert's edits to the configuration leave it in the
262
+ * old shape, the plan leaves the file for the user to edit, and the copy is checked as if they
263
+ * had.
264
+ */
265
+ async function checkPlan(plan, root, config) {
266
+ const result = {
267
+ passed: false,
268
+ problems: [],
269
+ lanes: [],
270
+ added: [],
271
+ carried: [],
272
+ };
273
+ const outside = [...plan.writes.keys(), ...plan.removes].find((filePath) => !filePath.startsWith(root + path.sep));
274
+ if (outside) {
275
+ result.problems.push(`${outside} is outside the project, so convert cannot check it.`);
276
+ return result;
277
+ }
278
+ const copy = copyProject(root, config);
279
+ const builds = fs.mkdtempSync(path.join(os.tmpdir(), "featurevisor-convert-datafiles-"));
280
+ try {
281
+ return await quietly(async () => {
282
+ // expressions written back as trees are checked as if the project still allowed them
283
+ const lintBefore = await lintAll(root, plan.to === "trees" ? { ...config, conditionExpressions: true } : config);
284
+ if (lintBefore.length > 0) {
285
+ result.problems.push(`Lint reports ${lintBefore.length} errors before converting. Fix them first, so the conversion can be checked.`);
286
+ return result;
287
+ }
288
+ const testsBefore = await runTests(root, config);
289
+ if (testsBefore.failed) {
290
+ result.problems.push("Tests fail before converting. Fix them first, so the conversion can be checked.");
291
+ return result;
292
+ }
293
+ applyPlan(plan, root, copy);
294
+ const edited = plan.writes.get(path.join(root, config_1.CONFIG_MODULE_NAME));
295
+ let converted;
296
+ try {
297
+ // a file convert's edits leave in the old shape is one for the user to edit, as is one
298
+ // convert could not edit at all
299
+ if (edited !== undefined && !hasShape(settingsOf(copy, edited), plan)) {
300
+ (0, plan_1.leaveConfigByHand)(plan.config, "its settings still give the old shape after convert's edits");
301
+ plan.writes.delete(path.join(root, config_1.CONFIG_MODULE_NAME));
302
+ }
303
+ if (plan.config.byHand)
304
+ writeConfigByHand(root, copy, plan);
305
+ converted = (0, config_1.getProjectConfig)(copy);
306
+ }
307
+ catch (error) {
308
+ result.problems.push(`The converted configuration does not load: ${error.message}`);
309
+ return result;
310
+ }
311
+ if (!hasShape(converted, plan)) {
312
+ 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.`);
313
+ return result;
314
+ }
315
+ const options = { revision: "convert", stateFiles: false };
316
+ const beforeDir = path.join(builds, "before");
317
+ const afterDir = path.join(builds, "after");
318
+ try {
319
+ const lintAfter = await lintAll(copy, converted);
320
+ result.lint = lintAfter.length;
321
+ for (const error of lintAfter.slice(0, 10)) {
322
+ result.problems.push(`Lint after converting: ${path.relative(copy, path.resolve(copy, error.filePath))} ${error.path.join(".")}: ${error.message}`);
323
+ }
324
+ // tests and builds of a project lint rejects say nothing more
325
+ if (lintAfter.length > 0)
326
+ return result;
327
+ const testsAfter = await runTests(copy, converted);
328
+ result.tests = { before: testsBefore.cases, after: testsAfter.cases };
329
+ if (testsAfter.failed)
330
+ result.problems.push("Tests fail after converting.");
331
+ await (0, buildProject_1.buildProjectSets)(dependencies(root, config), { ...options, datafilesDir: beforeDir });
332
+ await (0, buildProject_1.buildProjectSets)(dependencies(copy, converted), {
333
+ ...options,
334
+ datafilesDir: afterDir,
335
+ });
336
+ }
337
+ catch (error) {
338
+ // a converted project that cannot even be read is a fault in the conversion
339
+ result.problems.push(`The converted project fails: ${error.message}`);
340
+ return result;
341
+ }
342
+ // conditions written another way keep every datafile where it was
343
+ const pairs = (0, plan_1.isConditionForm)(plan.to)
344
+ ? [["", beforeDir, afterDir]]
345
+ : plan.from === "flat"
346
+ ? plan.lanes.map((lane) => [lane, beforeDir, path.join(afterDir, lane)])
347
+ : plan.to === "flat"
348
+ ? [[plan.keep, path.join(beforeDir, plan.keep), afterDir]]
349
+ : plan.lanes.map((lane) => [
350
+ lane,
351
+ path.join(beforeDir, lane),
352
+ path.join(afterDir, lane),
353
+ ]);
354
+ // each lane's datafiles in the shape that has lanes, before and after
355
+ const laneDirectories = (shape, directory, except) => shape === "flat"
356
+ ? []
357
+ : plan.lanes.filter((lane) => lane !== except).map((lane) => path.join(directory, lane));
358
+ for (const [lane, before, after] of pairs) {
359
+ if (lane)
360
+ result.lanes.push(lane);
361
+ const at = (file) => (lane ? `${lane}: ${file}` : file);
362
+ // conditions written another way change no lane, so nothing comes or goes
363
+ const carries = (entry, file, directories) => !(0, plan_1.isConditionForm)(plan.to) && isCarried(entry, file, directories);
364
+ const fewer = new Set();
365
+ const more = new Set();
366
+ const beforeFiles = datafilesIn(before);
367
+ const afterFiles = datafilesIn(after);
368
+ for (const file of beforeFiles) {
369
+ if (!afterFiles.includes(file)) {
370
+ result.problems.push(`${at(file)} is no longer built.`);
371
+ continue;
372
+ }
373
+ const read = (directory) => JSON.parse(fs.readFileSync(path.join(directory, file), "utf8"));
374
+ const compared = compareDatafiles(read(before), read(after), Boolean(plan.simplified));
375
+ for (const problem of compared.problems) {
376
+ result.problems.push(`${at(file)} changes the ${problem}.`);
377
+ }
378
+ for (const entry of compared.fewer) {
379
+ if (carries(entry, file, laneDirectories(plan.from, beforeDir, lane)))
380
+ fewer.add(entry);
381
+ else
382
+ result.problems.push(`${at(file)} no longer has the ${entry}.`);
383
+ }
384
+ for (const entry of compared.more) {
385
+ if (carries(entry, file, laneDirectories(plan.to, afterDir, lane)))
386
+ more.add(entry);
387
+ else
388
+ result.problems.push(`${at(file)} now has the ${entry}.`);
389
+ }
390
+ }
391
+ if (fewer.size > 0) {
392
+ result.carried.push(`${lane} datafiles no longer carry ${[...fewer].sort().join(", ")}, which only other lanes' rules use.`);
393
+ }
394
+ if (more.size > 0) {
395
+ result.carried.push(`${lane} datafiles now also carry ${[...more].sort().join(", ")}, which other lanes' rules use.`);
396
+ }
397
+ for (const file of afterFiles) {
398
+ if (!beforeFiles.includes(file))
399
+ result.added.push(lane ? `${lane}/${file}` : file);
400
+ }
401
+ }
402
+ result.passed = result.problems.length === 0;
403
+ return result;
404
+ });
405
+ }
406
+ finally {
407
+ fs.rmSync(copy, { recursive: true, force: true });
408
+ fs.rmSync(builds, { recursive: true, force: true });
409
+ }
410
+ }
411
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/convert/check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,8BAoBC;AAqND,8BAyKC;AAzbD,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAElC,0DAA2D;AAC3D,sCAAqF;AACrF,8CAA2C;AAC3C,uDAAwE;AACxE,4CAA2C;AAC3C,kCAAkD;AAClD,6CAAoD;AACpD,uDAAoD;AACpD,qCAAwC;AACxC,sDAA2D;AAC3D,iCAAuE;AAwBvE,gGAAgG;AAChG,SAAgB,SAAS,CAAC,IAAU,EAAE,QAAgB,EAAE,IAAI,GAAG,QAAQ;IACrE,MAAM,EA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AAC,EAAE,CAAC;oBACnB,MAAM,CAAC,OAAO,CAAC,IAAI,CACjB,GAAG,IAAI,8BAA8B,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,sCAAsC,CACxG,CAAC;gBACJ,CAAC;gBACD,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;oBAClB,MAAM,CAAC,OAAO,CAAC,IAAI,CACjB,GAAG,IAAI,6BAA6B,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,iCAAiC,CACjG,CAAC;gBACJ,CAAC;gBACD,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;oBAC9B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;wBAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACtF,CAAC;YACH,CAAC;YAED,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;YAC7C,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,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
+ }
147
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/convert/config.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAwFH,oCAMC;AAGD,gCAmCC;AAGD,sBAKC;AApID,wFAAwF;AACxF,SAAS,UAAU,CAAC,MAAc,EAAE,KAAa;IAC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