@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,184 @@
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.formatProject = formatProject;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ const error_1 = require("../error");
40
+ const sets_1 = require("../sets");
41
+ const formatDefinition_1 = require("./formatDefinition");
42
+ const layout_1 = require("./layout");
43
+ const since_1 = require("./since");
44
+ const diff_1 = require("../rewrite/diff");
45
+ const LIST_KEYS = {
46
+ attribute: (datasource) => datasource.listAttributes(),
47
+ schema: (datasource) => datasource.listSchemas(),
48
+ segment: (datasource) => datasource.listSegments(),
49
+ feature: (datasource) => datasource.listFeatures(),
50
+ variable: (datasource) => datasource.listVariables(),
51
+ target: (datasource) => datasource.listTargets(),
52
+ test: (datasource) => datasource.listTests(),
53
+ scenario: (datasource) => datasource.listScenarios(),
54
+ };
55
+ function relative(filePath) {
56
+ return path.relative(process.cwd(), filePath) || filePath;
57
+ }
58
+ function toWantedPath(given) {
59
+ const absolute = path.resolve(given);
60
+ const directory = fs.existsSync(absolute) && fs.statSync(absolute).isDirectory();
61
+ return { absolute, directory, matched: false };
62
+ }
63
+ function isWanted(wanted, filePath) {
64
+ return wanted.directory
65
+ ? filePath.startsWith(wanted.absolute.endsWith(path.sep) ? wanted.absolute : wanted.absolute + path.sep)
66
+ : filePath === wanted.absolute;
67
+ }
68
+ function toFileError(error) {
69
+ if (error instanceof formatDefinition_1.FormatParseError) {
70
+ return { code: "parse_error", message: error.message, line: error.line, column: error.column };
71
+ }
72
+ // a guard caught a fault in the parser's format, which is never the author's
73
+ const message = error instanceof formatDefinition_1.FormatGuardError
74
+ ? `${error.message} The file was left as it is. Please report this.`
75
+ : error.message;
76
+ return { code: "format_guard", message };
77
+ }
78
+ /** Formats one file, writing it only when it changes and fmt is neither checking nor diffing */
79
+ function formatFile(file, parser, options) {
80
+ const filePath = path.resolve(file.filePath);
81
+ if (!options.stdin && !fs.existsSync(filePath)) {
82
+ file.error = { code: "missing_file", message: "File not found" };
83
+ return "error";
84
+ }
85
+ const source = options.stdin ? options.stdin.source : fs.readFileSync(filePath, "utf8");
86
+ try {
87
+ const { output, changed, declined, ignored } = (0, formatDefinition_1.formatDefinition)(file.entityType, source, parser, filePath);
88
+ if (options.stdin)
89
+ file.output = output;
90
+ if (ignored)
91
+ return "ignored";
92
+ if (declined)
93
+ return "declined";
94
+ if (!changed)
95
+ return "unchanged";
96
+ if (options.diff)
97
+ file.diff = (0, diff_1.unifiedDiff)(file.filePath, file.filePath, source, output);
98
+ if (!options.stdin && !options.check && !options.diff)
99
+ fs.writeFileSync(filePath, output);
100
+ return "changed";
101
+ }
102
+ catch (error) {
103
+ file.error = toFileError(error);
104
+ return "error";
105
+ }
106
+ }
107
+ /** Every definition file of the project, once each, across every Set unless one is picked */
108
+ async function* listDefinitionFiles(deps, options) {
109
+ const { projectConfig, datasource } = deps;
110
+ const entityTypes = options.entityType ? [options.entityType] : layout_1.FORMAT_ENTITY_TYPES;
111
+ const executions = await (0, sets_1.getProjectSetExecutions)(projectConfig, datasource, options.set);
112
+ const seen = new Set();
113
+ for (const execution of executions) {
114
+ for (const entityType of entityTypes) {
115
+ const keys = await LIST_KEYS[entityType](execution.datasource);
116
+ for (const key of keys) {
117
+ if (options.keyPattern && !options.keyPattern.test(key))
118
+ continue;
119
+ const filePath = execution.datasource.getEntitySourcePath(entityType, key);
120
+ if (!filePath) {
121
+ throw new error_1.FeaturevisorCLIError("fmt needs definitions stored as files. This project's datasource adapter does not expose file paths.", { code: "unsupported_adapter" });
122
+ }
123
+ const absolute = path.resolve(filePath);
124
+ if (seen.has(absolute))
125
+ continue;
126
+ seen.add(absolute);
127
+ yield {
128
+ ...(projectConfig.sets ? { set: execution.set } : {}),
129
+ entityType,
130
+ key,
131
+ filePath: relative(filePath),
132
+ status: "unchanged",
133
+ absolute,
134
+ };
135
+ }
136
+ }
137
+ }
138
+ }
139
+ /**
140
+ * Formats every definition file of a project in one run: attributes, schemas, segments,
141
+ * features, variables, targets, tests and scenarios, across every Set unless one is picked.
142
+ * Writes only files that change, unless checking or diffing. Given source on stdin, formats it
143
+ * as the file at its path instead, and writes nothing.
144
+ */
145
+ async function formatProject(deps, options = {}) {
146
+ const result = {
147
+ files: [],
148
+ skipped: [],
149
+ changed: 0,
150
+ declined: 0,
151
+ ignored: 0,
152
+ errors: 0,
153
+ };
154
+ const parser = deps.projectConfig.parser;
155
+ if (!(0, formatDefinition_1.canFormat)(parser))
156
+ return { ...result, unsupported: true };
157
+ const paths = options.stdin ? [options.stdin.filePath] : options.paths || [];
158
+ const wanted = paths.map(toWantedPath);
159
+ const changedFiles = options.since === undefined
160
+ ? undefined
161
+ : (0, since_1.getChangedFiles)(deps.rootDirectoryPath, options.since);
162
+ for await (const { absolute, ...file } of listDefinitionFiles(deps, options)) {
163
+ if (wanted.length > 0) {
164
+ const matches = wanted.filter((item) => isWanted(item, absolute));
165
+ if (matches.length === 0)
166
+ continue;
167
+ matches.forEach((item) => (item.matched = true));
168
+ }
169
+ // Git gives real paths, which a project reached through a symbolic link, or a Windows
170
+ // short name such as RUNNER~1, differs from
171
+ if (changedFiles && !changedFiles.has(fs.realpathSync.native(absolute)))
172
+ continue;
173
+ file.status = formatFile(file, parser, options);
174
+ result.files.push(file);
175
+ }
176
+ const count = (status) => result.files.filter((file) => file.status === status).length;
177
+ result.changed = count("changed");
178
+ result.declined = count("declined");
179
+ result.ignored = count("ignored");
180
+ result.errors = count("error");
181
+ result.skipped = wanted.filter((item) => !item.matched).map((item) => relative(item.absolute));
182
+ return result;
183
+ }
184
+ //# sourceMappingURL=formatProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatProject.js","sourceRoot":"","sources":["../../src/formatter/formatProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8MA,sCA6CC;AA3PD,4CAA8B;AAC9B,gDAAkC;AAOlC,oCAAgD;AAChD,kCAAkD;AAClD,yDAK4B;AAC5B,qCAA+C;AAC/C,mCAA0C;AAC1C,0CAA8C;AAkE9C,MAAM,SAAS,GAAsE;IACnF,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,cAAc,EAAE;IACtD,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE;IAChD,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE;IAClD,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE;IAClD,QAAQ,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE;IACpD,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE;IAChD,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,EAAE;IAC5C,QAAQ,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE;CACrD,CAAC;AAEF,SAAS,QAAQ,CAAC,QAAgB;IAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CAAC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AAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/F,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from "../cli";
2
+ /**
3
+ * `featurevisor fmt` lays out definitions in one house style. The command loads its code only
4
+ * when it runs, so other commands start without it.
5
+ */
6
+ export declare const fmtPlugin: Plugin;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fmtPlugin = void 0;
4
+ /**
5
+ * `featurevisor fmt` lays out definitions in one house style. The command loads its code only
6
+ * when it runs, so other commands start without it.
7
+ */
8
+ exports.fmtPlugin = {
9
+ command: "fmt [paths...]",
10
+ handler: async function (options) {
11
+ const { runFormat } = require("./run");
12
+ return runFormat(options);
13
+ },
14
+ examples: [
15
+ {
16
+ command: "fmt",
17
+ description: "Format every definition file in place",
18
+ },
19
+ {
20
+ command: "fmt --check",
21
+ description: "List files that need formatting and exit with 1 if any do, for CI",
22
+ },
23
+ {
24
+ command: "fmt --check --since=origin/main",
25
+ description: "Check only the files changed since the branch left main",
26
+ },
27
+ {
28
+ command: "fmt --diff",
29
+ description: "Show what formatting would change, without writing",
30
+ },
31
+ {
32
+ command: "fmt --check --diff",
33
+ description: "Show what formatting would change and exit with 1 if anything would, for CI",
34
+ },
35
+ {
36
+ command: "fmt features/checkout.yml segments",
37
+ description: "Format only the given files, and the files in the given directories",
38
+ },
39
+ {
40
+ command: "fmt --entity-type=feature --key-pattern=checkout",
41
+ description: "Format only matching features",
42
+ },
43
+ {
44
+ command: "fmt --stdin-filepath=features/checkout.yml < checkout.yml",
45
+ description: "Format text from stdin as the given file and print it, for editors",
46
+ },
47
+ ],
48
+ };
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,SAAS,GAAW;IAC/B,OAAO,EAAE,gBAAgB;IACzB,OAAO,EAAE,KAAK,WAAW,OAAO;QAC9B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,OAAO,CAA2B,CAAC;QACjE,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IACD,QAAQ,EAAE;QACR;YACE,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,uCAAuC;SACrD;QACD;YACE,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,mEAAmE;SACjF;QACD;YACE,OAAO,EAAE,iCAAiC;YAC1C,WAAW,EAAE,yDAAyD;SACvE;QACD;YACE,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,oDAAoD;SAClE;QACD;YACE,OAAO,EAAE,oBAAoB;YAC7B,WAAW,EAAE,6EAA6E;SAC3F;QACD;YACE,OAAO,EAAE,oCAAoC;YAC7C,WAAW,EAAE,qEAAqE;SACnF;QACD;YACE,OAAO,EAAE,kDAAkD;YAC3D,WAAW,EAAE,+BAA+B;SAC7C;QACD;YACE,OAAO,EAAE,2DAA2D;YACpE,WAAW,EAAE,oEAAoE;SAClF;KACF;CACF,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { FormatLayout, FormatPath } from "@featurevisor/parsers";
2
+ import type { EntityType } from "@featurevisor/types";
3
+ /**
4
+ * Where each kind of object sits in a definition, so the house style in style.ts reaches the
5
+ * right maps and lists. A parser's `format` receives the result as a FormatLayout.
6
+ *
7
+ * This file keeps the promise that formatting never changes a datafile. Only objects the
8
+ * builder rebuilds key by key are given a key order here: features, rules, force entries,
9
+ * variations, variablesSchema entries, segments, global variables and their overrides, and
10
+ * everything in test specs, which datafiles never hold. Values stay as written: variable
11
+ * values, context, condition leaves, compose references, and maps keyed by the author, such
12
+ * as variablesSchema or properties. Lists are never reordered, since rules, overrides,
13
+ * variations, conditions and mutations depend on their order.
14
+ */
15
+ /** Every kind of definition fmt formats, in the order it formats them */
16
+ export declare const FORMAT_ENTITY_TYPES: EntityType[];
17
+ /** The keys of the map at `path` in house order, then any others as they were written */
18
+ export declare function getKeyOrder(entityType: EntityType, path: FormatPath, keys: string[]): string[] | undefined;
19
+ /** Whether the map at `path` has a blank line between its entries */
20
+ export declare function isSpacedMap(entityType: EntityType, path: FormatPath): boolean;
21
+ /** Whether the list at `path` has a blank line between its items */
22
+ export declare function isSpacedList(entityType: EntityType, path: FormatPath): boolean;
23
+ /** The key order applied to a parsed value, for parsers that write from values */
24
+ export declare function orderValue(entityType: EntityType, value: unknown, path?: FormatPath): unknown;
25
+ /** The layout a parser's `format` applies to one kind of definition */
26
+ export declare function getFormatLayout(entityType: EntityType, extension?: string): FormatLayout;
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORMAT_ENTITY_TYPES = void 0;
4
+ exports.getKeyOrder = getKeyOrder;
5
+ exports.isSpacedMap = isSpacedMap;
6
+ exports.isSpacedList = isSpacedList;
7
+ exports.orderValue = orderValue;
8
+ exports.getFormatLayout = getFormatLayout;
9
+ const style_1 = require("./style");
10
+ /**
11
+ * Where each kind of object sits in a definition, so the house style in style.ts reaches the
12
+ * right maps and lists. A parser's `format` receives the result as a FormatLayout.
13
+ *
14
+ * This file keeps the promise that formatting never changes a datafile. Only objects the
15
+ * builder rebuilds key by key are given a key order here: features, rules, force entries,
16
+ * variations, variablesSchema entries, segments, global variables and their overrides, and
17
+ * everything in test specs, which datafiles never hold. Values stay as written: variable
18
+ * values, context, condition leaves, compose references, and maps keyed by the author, such
19
+ * as variablesSchema or properties. Lists are never reordered, since rules, overrides,
20
+ * variations, conditions and mutations depend on their order.
21
+ */
22
+ /** Every kind of definition fmt formats, in the order it formats them */
23
+ exports.FORMAT_ENTITY_TYPES = [
24
+ "attribute",
25
+ "schema",
26
+ "segment",
27
+ "feature",
28
+ "variable",
29
+ "target",
30
+ "test",
31
+ "scenario",
32
+ ];
33
+ const VALUE = { kind: "value" };
34
+ /** Children are given as a function, so a shape can hold itself, as schemas and overrides do */
35
+ function map(order, space = false, children) {
36
+ let resolved;
37
+ return { kind: "map", order, space, children: () => (resolved ?? (resolved = children?.() ?? {})) };
38
+ }
39
+ function dict(value, space = false) {
40
+ return { kind: "dict", value, space };
41
+ }
42
+ function list(item, space = false) {
43
+ return { kind: "list", item, space };
44
+ }
45
+ function byEnvironment(item, space, spaceEnvironments) {
46
+ return { kind: "byEnvironment", item, space, spaceEnvironments };
47
+ }
48
+ const { keyOrder, blankLines } = style_1.HOUSE_STYLE;
49
+ /** A whole file */
50
+ function file(order, children) {
51
+ return map(order, blankLines.topLevelKeys, children);
52
+ }
53
+ const schema = map(keyOrder.schema, false, () => schemaChildren());
54
+ function schemaChildren() {
55
+ return {
56
+ properties: dict(schema, blankLines.schemaProperties),
57
+ items: schema,
58
+ oneOf: list(schema),
59
+ };
60
+ }
61
+ const featureVariableOverrides = dict(list(map(keyOrder.featureVariableOverride), blankLines.featureVariableOverrides));
62
+ const variableOverride = map(keyOrder.variableOverride, false, () => ({
63
+ overrides: list(variableOverride, blankLines.variableOverrides),
64
+ }));
65
+ const check = map(keyOrder.check, false, () => ({
66
+ and: list(check, blankLines.checks),
67
+ or: list(check, blankLines.checks),
68
+ not: list(check, blankLines.checks),
69
+ }));
70
+ function assertionChildren() {
71
+ return {
72
+ checks: list(check, blankLines.checks),
73
+ children: list(assertion, blankLines.assertionChildren),
74
+ };
75
+ }
76
+ const assertion = map(keyOrder.assertion, false, assertionChildren);
77
+ const SHAPES = {
78
+ attribute: file(keyOrder.attribute, schemaChildren),
79
+ schema: file(keyOrder.schema, schemaChildren),
80
+ segment: file(keyOrder.segment),
81
+ feature: file(keyOrder.feature, () => ({
82
+ variablesSchema: dict(map(keyOrder.variableSchema, false, schemaChildren), blankLines.variablesSchema),
83
+ variations: list(map(keyOrder.variation, false, () => ({ variableOverrides: featureVariableOverrides })), blankLines.variations),
84
+ force: byEnvironment(map(keyOrder.force), blankLines.force, blankLines.forceEnvironments),
85
+ // true, false or a list of tags, or one of those by environment
86
+ expose: dict(VALUE, blankLines.exposeEnvironments),
87
+ rules: byEnvironment(map(keyOrder.rule, false, () => ({ variableOverrides: featureVariableOverrides })), blankLines.rules, blankLines.ruleEnvironments),
88
+ })),
89
+ variable: file(keyOrder.variable, () => ({
90
+ ...schemaChildren(),
91
+ overrides: byEnvironment(variableOverride, blankLines.variableOverrides, blankLines.variableOverrideEnvironments),
92
+ })),
93
+ target: file(keyOrder.target),
94
+ test: file(keyOrder.test, () => ({ assertions: list(assertion, blankLines.assertions) })),
95
+ // a scenario spec is one assertion at the top level of its file
96
+ scenario: file(keyOrder.assertion, assertionChildren),
97
+ };
98
+ function childShape(shape, key) {
99
+ switch (shape.kind) {
100
+ case "map":
101
+ return typeof key === "string" ? shape.children()[key] || VALUE : VALUE;
102
+ case "dict":
103
+ return typeof key === "string" ? shape.value : VALUE;
104
+ case "list":
105
+ return typeof key === "number" ? shape.item : VALUE;
106
+ case "byEnvironment":
107
+ // a list's item, or an environment's list
108
+ return typeof key === "number" ? shape.item : list(shape.item, shape.space);
109
+ default:
110
+ return VALUE;
111
+ }
112
+ }
113
+ function shapeAt(entityType, path) {
114
+ let shape = SHAPES[entityType];
115
+ for (const key of path) {
116
+ shape = childShape(shape, key);
117
+ if (shape.kind === "value")
118
+ return shape;
119
+ }
120
+ return shape;
121
+ }
122
+ /** The keys of the map at `path` in house order, then any others as they were written */
123
+ function getKeyOrder(entityType, path, keys) {
124
+ const shape = shapeAt(entityType, path);
125
+ if (shape.kind !== "map")
126
+ return undefined;
127
+ const known = new Set(shape.order);
128
+ return [
129
+ ...shape.order.filter((key) => keys.includes(key)),
130
+ ...keys.filter((key) => !known.has(key)),
131
+ ];
132
+ }
133
+ /** Whether the map at `path` has a blank line between its entries */
134
+ function isSpacedMap(entityType, path) {
135
+ const shape = shapeAt(entityType, path);
136
+ if (shape.kind === "map" || shape.kind === "dict")
137
+ return shape.space;
138
+ // the node at a byEnvironment path is a map only when it groups lists by environment
139
+ if (shape.kind === "byEnvironment")
140
+ return shape.spaceEnvironments;
141
+ return false;
142
+ }
143
+ /** Whether the list at `path` has a blank line between its items */
144
+ function isSpacedList(entityType, path) {
145
+ const shape = shapeAt(entityType, path);
146
+ return (shape.kind === "list" || shape.kind === "byEnvironment") && shape.space;
147
+ }
148
+ /** The key order applied to a parsed value, for parsers that write from values */
149
+ function orderValue(entityType, value, path = []) {
150
+ if (Array.isArray(value)) {
151
+ return value.map((item, index) => orderValue(entityType, item, [...path, index]));
152
+ }
153
+ if (!value || typeof value !== "object")
154
+ return value;
155
+ const record = value;
156
+ const keys = getKeyOrder(entityType, path, Object.keys(record)) || Object.keys(record);
157
+ return Object.fromEntries(keys.map((key) => [key, orderValue(entityType, record[key], [...path, key])]));
158
+ }
159
+ /** Extensions that take another one's section of the house style's formats */
160
+ const FORMAT_ALIASES = { yaml: "yml" };
161
+ /** The layout a parser's `format` applies to one kind of definition */
162
+ function getFormatLayout(entityType, extension) {
163
+ const formats = style_1.HOUSE_STYLE.formats;
164
+ const format = extension && (FORMAT_ALIASES[extension] ?? extension);
165
+ return {
166
+ indent: style_1.HOUSE_STYLE.indent,
167
+ orderKeys: (path, keys) => getKeyOrder(entityType, path, keys),
168
+ spaceEntries: (path) => isSpacedMap(entityType, path),
169
+ spaceItems: (path) => isSpacedList(entityType, path),
170
+ keepBlankLines: style_1.HOUSE_STYLE.keepBlankLines,
171
+ orderValue: (value) => orderValue(entityType, value),
172
+ options: { ...(format ? formats[format] : undefined) },
173
+ };
174
+ }
175
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/formatter/layout.ts"],"names":[],"mappings":";;;AAmKA,kCAYC;AAGD,kCAMC;AAGD,oCAGC;AAGD,gCAWC;AAMD,0CAYC;AA3ND,mCAAsC;AAEtC;;;;;;;;;;;GAWG;AAEH,yEAAyE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,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC;QAC9D,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC;QACrD,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC;QACpD,cAAc,EAAE,mBAAW,CAAC,cAAc;QAC1C,UAAU,EAAE,CAAI,KAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAM;QAC/D,OAAO,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { FormatProjectOptions, FormatProjectResult } from "./formatProject";
2
+ /**
3
+ * Prints the result of formatting source given on stdin. The formatted source goes to stdout
4
+ * for an editor, or what --check and --diff report, and an error goes to stderr. Source for a
5
+ * path that holds no definition comes back as it is.
6
+ */
7
+ export declare function printStdinResult(result: FormatProjectResult, options: FormatProjectOptions): void;
8
+ export declare function printFormatResult(result: FormatProjectResult, options: FormatProjectOptions): void;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printStdinResult = printStdinResult;
4
+ exports.printFormatResult = printFormatResult;
5
+ const cliFormat_1 = require("../tester/cliFormat");
6
+ function printError(file, log) {
7
+ const { line, column, message } = file.error;
8
+ const where = line ? `:${line}${column ? `:${column}` : ""}` : "";
9
+ log(cliFormat_1.CLI_FORMAT_RED, `${file.filePath}${where}`);
10
+ log(cliFormat_1.CLI_FORMAT_RED, ` => Error: ${message}`);
11
+ }
12
+ /**
13
+ * Prints the result of formatting source given on stdin. The formatted source goes to stdout
14
+ * for an editor, or what --check and --diff report, and an error goes to stderr. Source for a
15
+ * path that holds no definition comes back as it is.
16
+ */
17
+ function printStdinResult(result, options) {
18
+ const file = result.files[0];
19
+ if (file?.status === "error") {
20
+ printError(file, console.error);
21
+ }
22
+ else if (options.diff) {
23
+ if (file?.diff)
24
+ process.stdout.write(file.diff);
25
+ }
26
+ else if (options.check) {
27
+ if (file?.status === "changed")
28
+ console.log(file.filePath);
29
+ }
30
+ else {
31
+ process.stdout.write(file?.output ?? options.stdin.source);
32
+ }
33
+ }
34
+ function printFormatResult(result, options) {
35
+ const write = !options.check && !options.diff;
36
+ if (result.unsupported) {
37
+ console.log(cliFormat_1.CLI_FORMAT_YELLOW, "This project's parser has no format function, so fmt leaves its files as they are.");
38
+ return;
39
+ }
40
+ for (const file of result.files) {
41
+ if (file.status === "changed") {
42
+ if (options.diff && file.diff) {
43
+ process.stdout.write(file.diff);
44
+ }
45
+ else {
46
+ console.log(write ? `Formatted ${file.filePath}` : file.filePath);
47
+ }
48
+ }
49
+ else if (file.status === "declined") {
50
+ console.log(cliFormat_1.CLI_FORMAT_DIM, `Left ${file.filePath} as it is: the parser could not format it`);
51
+ }
52
+ else if (file.status === "error" && file.error) {
53
+ printError(file, console.log);
54
+ }
55
+ }
56
+ for (const skipped of result.skipped) {
57
+ console.log(cliFormat_1.CLI_FORMAT_DIM, `Skipped ${skipped}, no definitions of this project there`);
58
+ }
59
+ const total = result.files.length;
60
+ const files = (count) => `${count} ${count === 1 ? "file" : "files"}`;
61
+ console.log("");
62
+ if (total === 0) {
63
+ console.log(cliFormat_1.CLI_FORMAT_YELLOW, options.since === undefined
64
+ ? "No definition files matched"
65
+ : `No definition files changed since ${options.since}`);
66
+ return;
67
+ }
68
+ if (result.errors > 0) {
69
+ console.log(cliFormat_1.CLI_FORMAT_RED, `${files(result.errors)} could not be formatted`);
70
+ }
71
+ if (result.declined > 0) {
72
+ console.log(cliFormat_1.CLI_FORMAT_YELLOW, `${files(result.declined)} left unformatted by the parser`);
73
+ }
74
+ if (result.ignored > 0) {
75
+ console.log(cliFormat_1.CLI_FORMAT_DIM, `${files(result.ignored)} left as written by featurevisor-ignore`);
76
+ }
77
+ if (result.changed > 0) {
78
+ if (write) {
79
+ console.log(cliFormat_1.CLI_FORMAT_GREEN, `✔ Formatted ${files(result.changed)} of ${total}`);
80
+ }
81
+ else {
82
+ const verb = result.changed === 1 ? "needs" : "need";
83
+ const since = options.since === undefined ? "" : ` --since=${options.since}`;
84
+ console.log(cliFormat_1.CLI_FORMAT_YELLOW, `${files(result.changed)} of ${total} ${verb} formatting. Run: npx featurevisor fmt${since}`);
85
+ }
86
+ }
87
+ else if (result.errors === 0) {
88
+ const left = result.declined + result.ignored;
89
+ const formatted = total - left;
90
+ if (formatted === 1) {
91
+ console.log(cliFormat_1.CLI_FORMAT_GREEN, `✔ ${left > 0 ? "The other file" : "The file"} is formatted`);
92
+ }
93
+ else if (formatted > 1) {
94
+ console.log(cliFormat_1.CLI_FORMAT_GREEN, `✔ ${left > 0 ? "The other" : "All"} ${files(formatted)} are formatted`);
95
+ }
96
+ }
97
+ }
98
+ //# sourceMappingURL=printFormatResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printFormatResult.js","sourceRoot":"","sources":["../../src/formatter/printFormatResult.ts"],"names":[],"mappings":";;AAoBA,4CAWC;AAED,8CA2EC;AA5GD,mDAK6B;AAG7B,SAAS,UAAU,CAAC,IAAsB,EAAE,GAAiC;IAC3E,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAM,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAClE,GAAG,CAAC,0BAAc,EAAE,GAAG,IAAI,CAAC,QAAQ,GAAG,KAAK,EAAE,CAAC,CAAC;IAChD,GAAG,CAAC,0BAAc,EAAE,eAAe,OAAO,EAAE,CAAC,CAAC;AAChD,CAAC;AA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AAI,SAAS,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,4BAAgB,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,eAAe,CAAC,CAAC;QAC9F,CAAC;aAAM,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CACT,4BAAgB,EAChB,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,gBAAgB,CACxE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { PluginHandlerOptions } from "../cli";
2
+ /**
3
+ * The command, as Prettier exits: 0 when formatted, 1 when --check finds files that need
4
+ * formatting, and 2 when fmt could not format, for errors to stand apart from work to do in CI
5
+ */
6
+ export declare function runFormat({ rootDirectoryPath, projectConfig, datasource, parsed, }: PluginHandlerOptions): Promise<number>;