@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.
@@ -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 === type) {
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
- console.log(
301
- `❌ ${breadcrumbString} — Does not match expected type: ${type}`,
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
- if (categorize(packageJSON["author"]) === "string") {
331
- field(["author"], "object");
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", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubing/dev-config",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Common dev configs for projects.",
5
5
  "author": {
6
6
  "name": "Lucas Garron",