@feigi/fleet-ctl 3.114.1 → 3.114.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/label-map.mjs +21 -7
package/package.json
CHANGED
package/scripts/label-map.mjs
CHANGED
|
@@ -74,9 +74,13 @@
|
|
|
74
74
|
// label-map.mjs show [<role>] the mapped string for <role>, or the whole
|
|
75
75
|
// `roles` object as JSON with no role.
|
|
76
76
|
// `show` exits 0 printed; 1 no cache or an
|
|
77
|
-
// invalid one, the message naming `ensure
|
|
78
|
-
//
|
|
79
|
-
//
|
|
77
|
+
// invalid one, the message naming `ensure`,
|
|
78
|
+
// or a cache that exists and cannot be read,
|
|
79
|
+
// the message naming the errno as a
|
|
80
|
+
// filesystem fault and its repair before
|
|
81
|
+
// `ensure`; 2 an unknown role or no
|
|
82
|
+
// repository. Any other verb is a usage
|
|
83
|
+
// refusal, exit 2.
|
|
80
84
|
//
|
|
81
85
|
// Zero deps: node builtins and sibling scripts only.
|
|
82
86
|
|
|
@@ -175,8 +179,10 @@ export function writeLabelMap(map, { cwd = process.cwd() } = {}) {
|
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
// The parsed cache of the repository `cwd` belongs to, with its path. Throws
|
|
178
|
-
// LabelMapUnreadable, its message naming `ensure`, when the file is absent
|
|
179
|
-
//
|
|
182
|
+
// LabelMapUnreadable, its message naming `ensure`, when the file is absent or
|
|
183
|
+
// does not parse; when it exists and cannot be read, the message names the
|
|
184
|
+
// errno as a filesystem fault and its repair before `ensure`.
|
|
185
|
+
// FleetDirUnresolvable outside a repository.
|
|
180
186
|
function loadCache(cwd) {
|
|
181
187
|
const file = fleetFile(LABEL_MAP_FILE, { cwd });
|
|
182
188
|
let text;
|
|
@@ -184,7 +190,12 @@ function loadCache(cwd) {
|
|
|
184
190
|
text = readFileSync(file, "utf8");
|
|
185
191
|
} catch (e) {
|
|
186
192
|
if (e.code === "ENOENT") throw new LabelMapUnreadable(`no Label map at ${file}: ${DERIVE}`);
|
|
187
|
-
throw new LabelMapUnreadable(
|
|
193
|
+
throw new LabelMapUnreadable(
|
|
194
|
+
`cannot read the Label map at ${file} (${e.code ?? e.message}): a filesystem fault, not a map fault — `
|
|
195
|
+
+ `make that path a readable file (check its and .fleet/'s permissions, and that .fleet/ is a directory) `
|
|
196
|
+
+ `or remove what is in the way, then ${DERIVE}`,
|
|
197
|
+
{ cause: e },
|
|
198
|
+
);
|
|
188
199
|
}
|
|
189
200
|
try {
|
|
190
201
|
return { file, cache: JSON.parse(text) };
|
|
@@ -203,7 +214,10 @@ const inRoleOrder = (roles) => Object.fromEntries(LABEL_ROLES.map((role) => [rol
|
|
|
203
214
|
* The `roles` object (every Label role -> its string) of the cache of the
|
|
204
215
|
* repository `cwd` belongs to. Throws LabelMapUnreadable, its message naming
|
|
205
216
|
* `ensure`, when the cache is absent, does not parse, lacks a role or breaks
|
|
206
|
-
* the string rules;
|
|
217
|
+
* the string rules; when the cache exists and cannot be read (e.g. EACCES,
|
|
218
|
+
* EISDIR, ENOTDIR), its message names the errno as a filesystem fault, not a
|
|
219
|
+
* map fault, and the repair, then `ensure` as the following step. Throws
|
|
220
|
+
* FleetDirUnresolvable outside a repository.
|
|
207
221
|
*/
|
|
208
222
|
export function readLabelMap({ cwd = process.cwd() } = {}) {
|
|
209
223
|
const { file, cache } = loadCache(cwd);
|