@cubing/dev-config 0.6.0 → 0.6.1
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/bin/package.json.ts +14 -9
- package/package.json +1 -1
package/bin/package.json.ts
CHANGED
|
@@ -255,7 +255,7 @@ function traverse<T>(
|
|
|
255
255
|
|
|
256
256
|
function field<T>(
|
|
257
257
|
breadcrumbs: Breadcrumbs,
|
|
258
|
-
type: Categorization,
|
|
258
|
+
type: Categorization | Categorization[],
|
|
259
259
|
options?: {
|
|
260
260
|
optional?: boolean;
|
|
261
261
|
additionalChecks?: { [requirementMessage: string]: (t: T) => boolean };
|
|
@@ -277,8 +277,9 @@ function field<T>(
|
|
|
277
277
|
}
|
|
278
278
|
const [value] = maybeValue;
|
|
279
279
|
|
|
280
|
+
const typeArray = Array.isArray(type) ? type : [type];
|
|
280
281
|
const category = categorize(value);
|
|
281
|
-
if (category
|
|
282
|
+
if (typeArray.includes(category)) {
|
|
282
283
|
for (const [failureMessage, fn] of Object.entries(
|
|
283
284
|
options?.additionalChecks ?? {},
|
|
284
285
|
)) {
|
|
@@ -297,9 +298,15 @@ function field<T>(
|
|
|
297
298
|
} else if (type === "undefined") {
|
|
298
299
|
console.log(`❌ ${breadcrumbString} — Present (but must not be).`);
|
|
299
300
|
} else {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
if (Array.isArray(type)) {
|
|
302
|
+
console.log(
|
|
303
|
+
`❌ ${breadcrumbString} — Does not match an expected type: ${type.join(", ")}`,
|
|
304
|
+
);
|
|
305
|
+
} else {
|
|
306
|
+
console.log(
|
|
307
|
+
`❌ ${breadcrumbString} — Does not match expected type: ${type}`,
|
|
308
|
+
);
|
|
309
|
+
}
|
|
303
310
|
}
|
|
304
311
|
exitCode = 1;
|
|
305
312
|
return;
|
|
@@ -327,10 +334,8 @@ field(["version"], "string", {
|
|
|
327
334
|
field(["homepage"], "string", { optional: true });
|
|
328
335
|
field(["description"], "string");
|
|
329
336
|
// TODO: format author.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
} else {
|
|
333
|
-
field(["author"], "object");
|
|
337
|
+
field(["author"], ["string", "object"]);
|
|
338
|
+
if (categorize(packageJSON["author"]) === "object") {
|
|
334
339
|
field(["author", "name"], "string");
|
|
335
340
|
field(["author", "email"], "string");
|
|
336
341
|
field(["author", "url"], "string", {
|