@featurevisor/core 4.1.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.
Files changed (111) hide show
  1. package/lib/builder/buildProject.js +24 -6
  2. package/lib/builder/buildProject.js.map +1 -1
  3. package/lib/builder/schemaV2.d.ts +47 -0
  4. package/lib/builder/schemaV2.js +529 -0
  5. package/lib/builder/schemaV2.js.map +1 -0
  6. package/lib/catalog.js +10 -2
  7. package/lib/catalog.js.map +1 -1
  8. package/lib/cli/cli.d.ts +2 -1
  9. package/lib/cli/cli.js +9 -6
  10. package/lib/cli/cli.js.map +1 -1
  11. package/lib/cli/options.js +61 -0
  12. package/lib/cli/options.js.map +1 -1
  13. package/lib/cli/plugins.js +7 -1
  14. package/lib/cli/plugins.js.map +1 -1
  15. package/lib/config/projectConfig.js +6 -0
  16. package/lib/config/projectConfig.js.map +1 -1
  17. package/lib/convert/check.d.ts +33 -0
  18. package/lib/convert/check.js +377 -0
  19. package/lib/convert/check.js.map +1 -0
  20. package/lib/convert/config.d.ts +20 -0
  21. package/lib/convert/config.js +147 -0
  22. package/lib/convert/config.js.map +1 -0
  23. package/lib/convert/documents.d.ts +55 -0
  24. package/lib/convert/documents.js +195 -0
  25. package/lib/convert/documents.js.map +1 -0
  26. package/lib/convert/index.d.ts +7 -0
  27. package/lib/convert/index.js +35 -0
  28. package/lib/convert/index.js.map +1 -0
  29. package/lib/convert/plan.d.ts +41 -0
  30. package/lib/convert/plan.js +562 -0
  31. package/lib/convert/plan.js.map +1 -0
  32. package/lib/convert/project.d.ts +29 -0
  33. package/lib/convert/project.js +109 -0
  34. package/lib/convert/project.js.map +1 -0
  35. package/lib/convert/run.d.ts +3 -0
  36. package/lib/convert/run.js +224 -0
  37. package/lib/convert/run.js.map +1 -0
  38. package/lib/convert/tests.d.ts +22 -0
  39. package/lib/convert/tests.js +267 -0
  40. package/lib/convert/tests.js.map +1 -0
  41. package/lib/datasource/datasource.d.ts +2 -0
  42. package/lib/datasource/datasource.js +8 -0
  43. package/lib/datasource/datasource.js.map +1 -1
  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/formatter/formatDefinition.d.ts +32 -0
  48. package/lib/formatter/formatDefinition.js +161 -0
  49. package/lib/formatter/formatDefinition.js.map +1 -0
  50. package/lib/formatter/formatProject.d.ts +68 -0
  51. package/lib/formatter/formatProject.js +184 -0
  52. package/lib/formatter/formatProject.js.map +1 -0
  53. package/lib/formatter/index.d.ts +6 -0
  54. package/lib/formatter/index.js +49 -0
  55. package/lib/formatter/index.js.map +1 -0
  56. package/lib/formatter/layout.d.ts +26 -0
  57. package/lib/formatter/layout.js +175 -0
  58. package/lib/formatter/layout.js.map +1 -0
  59. package/lib/formatter/printFormatResult.d.ts +8 -0
  60. package/lib/formatter/printFormatResult.js +98 -0
  61. package/lib/formatter/printFormatResult.js.map +1 -0
  62. package/lib/formatter/run.d.ts +6 -0
  63. package/lib/formatter/run.js +92 -0
  64. package/lib/formatter/run.js.map +1 -0
  65. package/lib/formatter/since.d.ts +6 -0
  66. package/lib/formatter/since.js +80 -0
  67. package/lib/formatter/since.js.map +1 -0
  68. package/lib/formatter/style.d.ts +94 -0
  69. package/lib/formatter/style.js +237 -0
  70. package/lib/formatter/style.js.map +1 -0
  71. package/lib/linter/diagnostics.d.ts +12 -12
  72. package/lib/linter/featureSchema.js +14 -13
  73. package/lib/linter/featureSchema.js.map +1 -1
  74. package/lib/linter/lintProject.js +45 -0
  75. package/lib/linter/lintProject.js.map +1 -1
  76. package/lib/linter/schemaV2Targets.d.ts +16 -0
  77. package/lib/linter/schemaV2Targets.js +62 -0
  78. package/lib/linter/schemaV2Targets.js.map +1 -0
  79. package/lib/linter/targetSchema.d.ts +4 -0
  80. package/lib/linter/targetSchema.js +5 -0
  81. package/lib/linter/targetSchema.js.map +1 -1
  82. package/lib/migrate/definitions.d.ts +46 -0
  83. package/lib/migrate/definitions.js +488 -0
  84. package/lib/migrate/definitions.js.map +1 -0
  85. package/lib/migrate/index.d.ts +6 -0
  86. package/lib/migrate/index.js +30 -0
  87. package/lib/migrate/index.js.map +1 -0
  88. package/lib/migrate/migrateProject.d.ts +33 -0
  89. package/lib/migrate/migrateProject.js +195 -0
  90. package/lib/migrate/migrateProject.js.map +1 -0
  91. package/lib/migrate/project.d.ts +31 -0
  92. package/lib/migrate/project.js +153 -0
  93. package/lib/migrate/project.js.map +1 -0
  94. package/lib/migrate/run.d.ts +3 -0
  95. package/lib/migrate/run.js +81 -0
  96. package/lib/migrate/run.js.map +1 -0
  97. package/lib/migrate/write.d.ts +10 -0
  98. package/lib/migrate/write.js +150 -0
  99. package/lib/migrate/write.js.map +1 -0
  100. package/lib/promoter/index.js +38 -2
  101. package/lib/promoter/index.js.map +1 -1
  102. package/lib/rewrite/diff.d.ts +2 -0
  103. package/lib/rewrite/diff.js +76 -0
  104. package/lib/rewrite/diff.js.map +1 -0
  105. package/lib/rewrite/files.d.ts +6 -0
  106. package/lib/rewrite/files.js +66 -0
  107. package/lib/rewrite/files.js.map +1 -0
  108. package/lib/rewrite/lines.d.ts +56 -0
  109. package/lib/rewrite/lines.js +204 -0
  110. package/lib/rewrite/lines.js.map +1 -0
  111. package/package.json +6 -6
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.load = load;
4
+ exports.isFormatted = isFormatted;
5
+ exports.formatted = formatted;
6
+ exports.render = render;
7
+ exports.rootMap = rootMap;
8
+ exports.pairOf = pairOf;
9
+ exports.takeLane = takeLane;
10
+ exports.isSpaced = isSpaced;
11
+ exports.spaceItems = spaceItems;
12
+ exports.spreadLanes = spreadLanes;
13
+ exports.laneMap = laneMap;
14
+ exports.setKey = setKey;
15
+ exports.nodeAt = nodeAt;
16
+ exports.seqOf = seqOf;
17
+ const parsers_1 = require("@featurevisor/parsers");
18
+ const yaml_1 = require("yaml");
19
+ const formatDefinition_1 = require("../formatter/formatDefinition");
20
+ const lines_1 = require("../rewrite/lines");
21
+ /**
22
+ * Definitions are edited as YAML documents whatever their parser, so one set of edits serves
23
+ * every format. A YAML file keeps its comments, and every file keeps the lines a conversion
24
+ * does not touch.
25
+ */
26
+ /**
27
+ * A file as a document. Aliases are written out in full, since splitting lanes apart can leave
28
+ * an alias without its anchor. `expanded` says whether there were any.
29
+ */
30
+ function load(source, parser) {
31
+ if (parser !== parsers_1.parsers.yml)
32
+ return { doc: new yaml_1.Document(parser.parse(source)), expanded: false };
33
+ const doc = (0, yaml_1.parseDocument)((0, lines_1.lineEndings)(source).text);
34
+ let expanded = false;
35
+ (0, yaml_1.visit)(doc, {
36
+ Alias(_, alias) {
37
+ expanded = true;
38
+ const target = alias.resolve(doc);
39
+ return target ? target.clone() : yaml_1.visit.REMOVE;
40
+ },
41
+ });
42
+ if (expanded) {
43
+ (0, yaml_1.visit)(doc, {
44
+ Node(_, node) {
45
+ if ("anchor" in node)
46
+ delete node.anchor;
47
+ },
48
+ });
49
+ }
50
+ return { doc, expanded };
51
+ }
52
+ /** Whether fmt leaves a file as it is, so a converted file should be formatted too */
53
+ function isFormatted(entityType, text, parser) {
54
+ try {
55
+ const result = (0, formatDefinition_1.formatDefinition)(entityType, text, parser);
56
+ return !result.changed && !result.declined && !result.ignored;
57
+ }
58
+ catch {
59
+ return false;
60
+ }
61
+ }
62
+ /** The text as fmt writes it, or as it is when fmt cannot format it */
63
+ function formatted(entityType, text, parser) {
64
+ try {
65
+ return (0, formatDefinition_1.formatDefinition)(entityType, text, parser).output;
66
+ }
67
+ catch {
68
+ return text;
69
+ }
70
+ }
71
+ /**
72
+ * The document as the file's new text, with the file's own lines where nothing changed, or
73
+ * the whole file as its parser writes it, which `merged` says. YAML keeps its comments either
74
+ * way and JSON has none, but a custom format may lose them. Undefined when the text would not
75
+ * read back as the document.
76
+ */
77
+ function render(source, doc, parser) {
78
+ const value = doc.toJS();
79
+ return (0, lines_1.rewriteFile)(source, parser, value, (text) => {
80
+ if (parser !== parsers_1.parsers.yml)
81
+ return (0, lines_1.renderValues)(parser, parser.parse(text), value);
82
+ const options = (0, lines_1.yamlOptions)(text);
83
+ return { base: (0, yaml_1.parseDocument)(text).toString(options), changed: doc.toString(options) };
84
+ });
85
+ }
86
+ function rootMap(doc) {
87
+ return (0, yaml_1.isMap)(doc.contents) ? doc.contents : undefined;
88
+ }
89
+ function pairOf(map, key) {
90
+ return map.items.find((pair) => (0, yaml_1.isScalar)(pair.key) && String(pair.key.value) === key);
91
+ }
92
+ /**
93
+ * Replaces the map by lane at `key` with one lane's value, keeping the comments above that
94
+ * lane's key. Without one, the key goes, or becomes `empty` when given.
95
+ */
96
+ function takeLane(map, key, lane, empty) {
97
+ const pair = pairOf(map, key);
98
+ if (!pair || !(0, yaml_1.isMap)(pair.value))
99
+ return;
100
+ const lanes = pair.value;
101
+ const lanePair = pairOf(lanes, lane);
102
+ if (lanePair && lanePair.value) {
103
+ const node = lanePair.value;
104
+ // a comment above the first lane belongs to the map of lanes
105
+ const above = lanes.items[0] === lanePair ? lanes.commentBefore : undefined;
106
+ const comment = joinComments(above, lanePair.key.commentBefore);
107
+ node.commentBefore = joinComments(comment, node.commentBefore);
108
+ trimTrailingComment(node);
109
+ pair.value = node;
110
+ }
111
+ else if (empty !== undefined) {
112
+ pair.value = new yaml_1.Document(empty).contents;
113
+ }
114
+ else {
115
+ map.delete(key);
116
+ }
117
+ }
118
+ function joinComments(...comments) {
119
+ const joined = comments.filter(Boolean).join("\n");
120
+ return joined || undefined;
121
+ }
122
+ /** A comment after a value ends at its last line, as blank lines between keys are their own */
123
+ function trimTrailingComment(node) {
124
+ if (node.comment)
125
+ node.comment = node.comment.replace(/\n+$/, "");
126
+ }
127
+ /** Whether a map's keys are separated by blank lines, as in a formatted file */
128
+ function isSpaced(map) {
129
+ return Boolean(map && map.items.slice(1).some((pair) => pair.key?.spaceBefore));
130
+ }
131
+ /** Separates a list's items by a blank line, or by none, as `spaced` says */
132
+ function spaceItems(list, spaced) {
133
+ list.items.forEach((item, index) => {
134
+ if (item && typeof item === "object")
135
+ item.spaceBefore = spaced && index > 0;
136
+ });
137
+ }
138
+ /** Groups the value at `key` by lane, a copy for each */
139
+ function spreadLanes(map, key, lanes, spaced) {
140
+ const pair = pairOf(map, key);
141
+ if (!pair || pair.value === null || pair.value === undefined)
142
+ return;
143
+ const value = pair.value;
144
+ pair.value = laneMap(lanes.map((lane) => [lane, value.clone()]), spaced);
145
+ }
146
+ /** A map from lanes to their nodes, in lane order, leaving out lanes without one */
147
+ function laneMap(values, spaced) {
148
+ const map = new yaml_1.YAMLMap();
149
+ for (const [lane, node] of values) {
150
+ if (!node)
151
+ continue;
152
+ const key = new yaml_1.Scalar(lane);
153
+ key.spaceBefore = spaced && map.items.length > 0;
154
+ trimTrailingComment(node);
155
+ map.set(key, node);
156
+ }
157
+ return map.items.length > 0 ? map : undefined;
158
+ }
159
+ /**
160
+ * Sets `key` in a map, keeping its place when it is there already. A new key goes after the
161
+ * last of `after` the map has, and takes a blank line before it when the map's keys have them.
162
+ */
163
+ function setKey(map, key, node, after) {
164
+ const pair = pairOf(map, key);
165
+ if (node === undefined) {
166
+ if (pair)
167
+ map.delete(key);
168
+ return;
169
+ }
170
+ if (pair) {
171
+ pair.value = node;
172
+ return;
173
+ }
174
+ const spaced = isSpaced(map);
175
+ const scalar = new yaml_1.Scalar(key);
176
+ map.set(scalar, node);
177
+ const items = map.items;
178
+ if (after) {
179
+ const added = items.pop();
180
+ let index = 0;
181
+ items.forEach((item, at) => {
182
+ if ((0, yaml_1.isScalar)(item.key) && after.includes(String(item.key.value)))
183
+ index = at + 1;
184
+ });
185
+ items.splice(index, 0, added);
186
+ }
187
+ scalar.spaceBefore = spaced && items[0] !== items.find((item) => item.key === scalar);
188
+ }
189
+ function nodeAt(map, key) {
190
+ return pairOf(map, key)?.value || undefined;
191
+ }
192
+ function seqOf(node) {
193
+ return (0, yaml_1.isSeq)(node) ? node : undefined;
194
+ }
195
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/convert/documents.ts"],"names":[],"mappings":";;AA4BA,oBAmBC;AAGD,kCAOC;AAGD,8BAMC;AAQD,wBAWC;AAED,0BAEC;AAED,wBAEC;AAMD,4BAkBC;AAaD,4BAIC;AAGD,gCAIC;AAGD,kCAQC;AAGD,0BAaC;AAMD,wBAuBC;AAED,wBAEC;AAED,sBAEC;AA7MD,mDAAmE;AACnE,+BAUc;AAId,oEAAiE;AACjE,4CAAuF;AAEvF;;;;GAIG;AAEH;;;GAGG;AACH,SAAgB,IAAI,CAAC,MAAc,EAAE,MAAoB;IACvD,IAAI,MAAM,KAAK,iBAAO,CAAC,GAAG;QAAE,OAAO,EAAE,GAAG,EAAE,IAAI,eAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAChG,MAAM,GAAG,GAAG,IAAA,oBAAa,EAAC,IAAA,mBAAW,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAA,YAAK,EAAC,GAAG,EAAE;QACT,KAAK,CAAC,CAAC,EAAE,KAAK;YACZ,QAAQ,GAAG,IAAI,CAAC;YAChB,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,MAAM,CAAC,CAAC,CAAE,MAAM,CAAC,KAAK,EAAW,CAAC,CAAC,CAAC,YAAK,CAAC,MAAM,CAAC;QAC1D,CAAC;KACF,CAAC,CAAC;IACH,IAAI,QAAQ,EAAE,CAAC;QACb,IAAA,YAAK,EAAC,GAAG,EAAE;YACT,IAAI,CAAC,CAAC,EAAE,IAAI;gBACV,IAAI,QAAQ,IAAI,IAAI;oBAAE,OAAQ,IAA4B,CAAC,MAAM,CAAC;YACpE,CAA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,EAAE,GAAG,CAAC,EAAE,KAA0B,IAAI,SAAS,CAAC;AACpE,CAAC;AAED,SAAgB,KAAK,CAAC,IAAa;IACjC,OAAO,IAAA,YAAK,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACxC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Plugin } from "../cli";
2
+ /**
3
+ * `featurevisor convert` changes a project's shape, between no environments and no sets,
4
+ * environments, and sets. A project rarely runs it, so the command loads its code only when it
5
+ * runs, and nothing else imports from here.
6
+ */
7
+ export declare const convertPlugin: Plugin;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertPlugin = void 0;
4
+ /**
5
+ * `featurevisor convert` changes a project's shape, between no environments and no sets,
6
+ * environments, and sets. A project rarely runs it, so the command loads its code only when it
7
+ * runs, and nothing else imports from here.
8
+ */
9
+ exports.convertPlugin = {
10
+ command: "convert",
11
+ description: "Convert a project between environments, sets, and neither",
12
+ handler: async function (options) {
13
+ const { runConversion } = require("./run");
14
+ return runConversion(options);
15
+ },
16
+ examples: [
17
+ {
18
+ command: "convert --to=sets",
19
+ description: "Preview turning each environment into a set",
20
+ },
21
+ {
22
+ command: "convert --to=sets --apply",
23
+ description: "Turn each environment into a set",
24
+ },
25
+ {
26
+ command: "convert --to=environments --environments=staging,production",
27
+ description: "Give a project without environments staging and production",
28
+ },
29
+ {
30
+ command: "convert --to=flat --keep=production --apply",
31
+ description: "Keep only production, without environments or sets",
32
+ },
33
+ ],
34
+ };
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/convert/index.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACU,QAAA,aAAa,GAAW;IACnC,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,2DAA2D;IACxE,OAAO,EAAE,KAAK,WAAW,OAAO;QAC9B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,OAAO,CAA2B,CAAC;QACrE,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IACD,QAAQ,EAAE;QACR;YACE,OAAO,EAAE,mBAAmB;YAC5B,WAAW,EAAE,6CAA6C;SAC3D;QACD;YACE,OAAO,EAAE,2BAA2B;YACpC,WAAW,EAAE,kCAAkC;SAChD;QACD;YACE,OAAO,EAAE,6DAA6D;YACtE,WAAW,EAAE,4DAA4D;SAC1E;QACD;YACE,OAAO,EAAE,6CAA6C;YACtD,WAAW,EAAE,oDAAoD;SAClE;KACF;CACF,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type Project, type Shape } from "./project";
2
+ export interface Plan {
3
+ from: Project["shape"];
4
+ to: Shape;
5
+ /** The environments or sets, in order */
6
+ lanes: string[];
7
+ /** The lane a conversion to flat keeps */
8
+ keep?: string;
9
+ /** New contents by absolute path: definitions, specs, state and the configuration */
10
+ writes: Map<string, string>;
11
+ /** Absolute paths to delete */
12
+ removes: Set<string>;
13
+ /** featurevisor.config.js: what convert changes in it, or leaves for the user to change */
14
+ config: ConfigPlan;
15
+ /** What stops the conversion */
16
+ conflicts: string[];
17
+ /** What changes that is not a definition's meaning, or what a conversion to flat drops */
18
+ differences: string[];
19
+ /** What to change outside the project afterwards */
20
+ next: string[];
21
+ }
22
+ /** featurevisor.config.js in a plan */
23
+ export interface ConfigPlan {
24
+ /** What convert changed, or what the user changes by hand, as the summary says it */
25
+ edits: string[];
26
+ /** Settings the new shape cannot have */
27
+ remove: string[];
28
+ /** Settings the new shape adds, as JavaScript, with how the summary says it */
29
+ add: [name: string, value: string | string[], says: string][];
30
+ /** Why the user edits it after converting, when convert cannot */
31
+ byHand?: string;
32
+ }
33
+ /** Leaves the configuration for the user to change after converting, saying why */
34
+ export declare function leaveConfigByHand(config: ConfigPlan, reason: string): void;
35
+ export interface ConvertOptions {
36
+ to: Shape;
37
+ /** Lanes to create from a flat project, or the order of environments made from sets */
38
+ lanes?: string[];
39
+ keep?: string;
40
+ }
41
+ export declare function planConversion(project: Project, options: ConvertOptions): Plan;