zcb 0.3.4 → 0.3.6

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 (118) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/cli.cjs +1 -1
  3. package/dist/cjs/cli.cjs.map +1 -1
  4. package/dist/cjs/index.cjs +1 -1
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/templates/config.ts.hbs +1 -1
  7. package/dist/esm/cli.mjs +1 -1
  8. package/dist/esm/cli.mjs.map +1 -1
  9. package/dist/esm/index.mjs +1 -1
  10. package/dist/esm/index.mjs.map +1 -1
  11. package/dist/esm/templates/config.ts.hbs +1 -1
  12. package/dist/production.analysis.txt +23 -23
  13. package/dist/types/cjs/cli.d.cts +7 -1
  14. package/dist/types/cjs/cli.d.cts.map +1 -1
  15. package/dist/types/cjs/createConfigBuilder.d.cts +4 -4
  16. package/dist/types/cjs/createConfigBuilder.d.cts.map +1 -1
  17. package/dist/types/cjs/createConfigParser.d.cts.map +1 -1
  18. package/dist/types/cjs/transformers/runExperiments.d.cts.map +1 -1
  19. package/dist/types/cjs/utils/collateDefaultValues.d.cts +2 -2
  20. package/dist/types/cjs/utils/collateDefaultValues.d.cts.map +1 -1
  21. package/dist/types/cjs/utils/collateObjectPropertyDefaults.d.cts +2 -2
  22. package/dist/types/cjs/utils/collateObjectPropertyDefaults.d.cts.map +1 -1
  23. package/dist/types/cjs/utils/hasArrayInvalidDefaults.d.cts +3 -0
  24. package/dist/types/cjs/utils/hasArrayInvalidDefaults.d.cts.map +1 -0
  25. package/dist/types/cjs/utils/hasObjectPropertyDefaults.d.cts +3 -0
  26. package/dist/types/cjs/utils/hasObjectPropertyDefaults.d.cts.map +1 -0
  27. package/dist/types/cjs/utils/hasRecordInvalidDefaults.d.cts +3 -0
  28. package/dist/types/cjs/utils/hasRecordInvalidDefaults.d.cts.map +1 -0
  29. package/dist/types/cjs/utils/importValidateTransformWriteConfig.d.cts +2 -2
  30. package/dist/types/cjs/utils/importValidateTransformWriteConfig.d.cts.map +1 -1
  31. package/dist/types/cjs/utils/isInvalidPropertyOverride.d.cts +1 -1
  32. package/dist/types/cjs/utils/isInvalidPropertyOverride.d.cts.map +1 -1
  33. package/dist/types/cjs/utils/isPropertyReservedWord.d.cts.map +1 -1
  34. package/dist/types/cjs/utils/isSchemaValid.d.cts +2 -2
  35. package/dist/types/cjs/utils/isSchemaValid.d.cts.map +1 -1
  36. package/dist/types/cjs/utils/isValidPropertyDefinition.d.cts +2 -2
  37. package/dist/types/cjs/utils/isValidPropertyDefinition.d.cts.map +1 -1
  38. package/dist/types/cjs/utils/isValidValue.d.cts.map +1 -1
  39. package/dist/types/cjs/utils/transformConfig.d.cts.map +1 -1
  40. package/dist/types/cjs/utils/transformWriteConfig.d.cts.map +1 -1
  41. package/dist/types/esm/cli.d.ts +7 -1
  42. package/dist/types/esm/cli.d.ts.map +1 -1
  43. package/dist/types/esm/createConfigBuilder.d.ts +4 -4
  44. package/dist/types/esm/createConfigBuilder.d.ts.map +1 -1
  45. package/dist/types/esm/createConfigParser.d.ts.map +1 -1
  46. package/dist/types/esm/transformers/runExperiments.d.ts.map +1 -1
  47. package/dist/types/esm/utils/collateDefaultValues.d.ts +2 -2
  48. package/dist/types/esm/utils/collateDefaultValues.d.ts.map +1 -1
  49. package/dist/types/esm/utils/collateObjectPropertyDefaults.d.ts +2 -2
  50. package/dist/types/esm/utils/collateObjectPropertyDefaults.d.ts.map +1 -1
  51. package/dist/types/esm/utils/hasArrayInvalidDefaults.d.ts +3 -0
  52. package/dist/types/esm/utils/hasArrayInvalidDefaults.d.ts.map +1 -0
  53. package/dist/types/esm/utils/hasObjectPropertyDefaults.d.ts +3 -0
  54. package/dist/types/esm/utils/hasObjectPropertyDefaults.d.ts.map +1 -0
  55. package/dist/types/esm/utils/hasRecordInvalidDefaults.d.ts +3 -0
  56. package/dist/types/esm/utils/hasRecordInvalidDefaults.d.ts.map +1 -0
  57. package/dist/types/esm/utils/importValidateTransformWriteConfig.d.ts +2 -2
  58. package/dist/types/esm/utils/importValidateTransformWriteConfig.d.ts.map +1 -1
  59. package/dist/types/esm/utils/isInvalidPropertyOverride.d.ts +1 -1
  60. package/dist/types/esm/utils/isInvalidPropertyOverride.d.ts.map +1 -1
  61. package/dist/types/esm/utils/isPropertyReservedWord.d.ts.map +1 -1
  62. package/dist/types/esm/utils/isSchemaValid.d.ts +2 -2
  63. package/dist/types/esm/utils/isSchemaValid.d.ts.map +1 -1
  64. package/dist/types/esm/utils/isValidPropertyDefinition.d.ts +2 -2
  65. package/dist/types/esm/utils/isValidPropertyDefinition.d.ts.map +1 -1
  66. package/dist/types/esm/utils/isValidValue.d.ts.map +1 -1
  67. package/dist/types/esm/utils/transformConfig.d.ts.map +1 -1
  68. package/dist/types/esm/utils/transformWriteConfig.d.ts.map +1 -1
  69. package/dist/types/tsconfig.build.tsbuildinfo +1 -1
  70. package/package.json +49 -45
  71. package/pnpm-workspace.yaml +26 -0
  72. package/src/__testUtils__/builtConfig.ts +1 -1
  73. package/src/__testUtils__/configBuilder.ts +29 -23
  74. package/src/__testUtils__/schema.ts +2 -2
  75. package/src/cli.ts +9 -3
  76. package/src/createConfigBuilder.test.ts +30 -26
  77. package/src/createConfigBuilder.ts +45 -51
  78. package/src/createConfigParser.ts +1 -1
  79. package/src/createConfigReader.test.ts +2 -2
  80. package/src/createConfigReader.ts +2 -2
  81. package/src/templates/config.ts.hbs +1 -1
  82. package/src/transformers/cloneNonEnumerableValues.ts +1 -1
  83. package/src/transformers/runExperiments.ts +16 -5
  84. package/src/utils/collateDefaultValues.ts +15 -15
  85. package/src/utils/collateObjectPropertyDefaults.ts +6 -4
  86. package/src/utils/hasArrayInvalidDefaults.ts +6 -0
  87. package/src/utils/hasObjectPropertyDefaults.ts +5 -0
  88. package/src/utils/hasRecordInvalidDefaults.ts +6 -0
  89. package/src/utils/importValidateTransformWriteConfig.ts +25 -13
  90. package/src/utils/isInvalidPropertyOverride.ts +2 -2
  91. package/src/utils/isPropertyReservedWord.ts +1 -1
  92. package/src/utils/isSchemaValid.ts +2 -2
  93. package/src/utils/isValidPropertyDefinition.ts +3 -3
  94. package/src/utils/isValidValue.ts +1 -5
  95. package/src/utils/transformConfig.ts +8 -2
  96. package/src/utils/transformWriteConfig.test.ts +1 -1
  97. package/src/utils/transformWriteConfig.ts +6 -4
  98. package/dist/types/cjs/utils/arrayHasInvalidDefaults.d.cts +0 -3
  99. package/dist/types/cjs/utils/arrayHasInvalidDefaults.d.cts.map +0 -1
  100. package/dist/types/cjs/utils/jsonStringifyReplacer.d.cts +0 -109
  101. package/dist/types/cjs/utils/jsonStringifyReplacer.d.cts.map +0 -1
  102. package/dist/types/cjs/utils/objectPropertyHasDefaults.d.cts +0 -3
  103. package/dist/types/cjs/utils/objectPropertyHasDefaults.d.cts.map +0 -1
  104. package/dist/types/cjs/utils/recordHasInvalidDefaults.d.cts +0 -3
  105. package/dist/types/cjs/utils/recordHasInvalidDefaults.d.cts.map +0 -1
  106. package/dist/types/esm/utils/arrayHasInvalidDefaults.d.ts +0 -3
  107. package/dist/types/esm/utils/arrayHasInvalidDefaults.d.ts.map +0 -1
  108. package/dist/types/esm/utils/jsonStringifyReplacer.d.ts +0 -109
  109. package/dist/types/esm/utils/jsonStringifyReplacer.d.ts.map +0 -1
  110. package/dist/types/esm/utils/objectPropertyHasDefaults.d.ts +0 -3
  111. package/dist/types/esm/utils/objectPropertyHasDefaults.d.ts.map +0 -1
  112. package/dist/types/esm/utils/recordHasInvalidDefaults.d.ts +0 -3
  113. package/dist/types/esm/utils/recordHasInvalidDefaults.d.ts.map +0 -1
  114. package/src/__snapshots__/createConfigBuilder.test.ts.snap +0 -30
  115. package/src/utils/arrayHasInvalidDefaults.ts +0 -6
  116. package/src/utils/jsonStringifyReplacer.ts +0 -6
  117. package/src/utils/objectPropertyHasDefaults.ts +0 -5
  118. package/src/utils/recordHasInvalidDefaults.ts +0 -6
@@ -9,7 +9,7 @@ export interface ConfigReader<Config extends object> {
9
9
  }
10
10
 
11
11
  export const createConfigReader = <Config extends object>(config: Config): ConfigReader<Config> => {
12
- // Aimed at reducing the amount of work for typescript to resolve type.
12
+ // Aimed at reducing the amount of work for TypeScript to resolve type.
13
13
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
14
14
  return {
15
15
  read: <P extends Path<Config>>(path: P, variables?: Record<string, string | number>) => {
@@ -32,7 +32,7 @@ export const createConfigReader = <Config extends object>(config: Config): Confi
32
32
  }
33
33
 
34
34
  return Object.keys(variables).reduce<string>((acc, key) => {
35
- return acc.replace(new RegExp(`{{${key}}}`), String(variables[key]));
35
+ return acc.replace(new RegExp(`{{${key}}}`), () => String(variables[key]));
36
36
  }, output);
37
37
  },
38
38
  scope: <S extends Scope<Config>>(scope: S) => {
@@ -1,4 +1,4 @@
1
- /* eslint-disable prettier/prettier, import-x/no-default-export, unicorn/numeric-separators-style, unicorn/no-null */
1
+ /* eslint-disable import-x/no-default-export, unicorn/numeric-separators-style, unicorn/no-null */
2
2
  /* This file is autogenerated, do not edit directly, your changes will not perist. */
3
3
 
4
4
  export default {{{ config }}} as const;
@@ -10,7 +10,7 @@ export const cloneNonEnumerableValues: TransformConfigHandlerSync = <
10
10
  config: Config2,
11
11
  ) => {
12
12
  for (const nonEnumerableKey of NON_ENUMERABLE_KEYS) {
13
- if (nonEnumerableKey in config) {
13
+ if (Object.hasOwn(config, nonEnumerableKey)) {
14
14
  Object.defineProperty(clone, nonEnumerableKey, {
15
15
  configurable: false,
16
16
  enumerable: false,
@@ -1,16 +1,27 @@
1
- import { type AnyRecord, type Buckets, type RunExperimentsCallback, type TransformConfigHandler } from '../types.ts';
1
+ import {
2
+ type AnyRecord,
3
+ type Buckets,
4
+ type RunExperimentsCallback,
5
+ type TransformConfigHandler,
6
+ type TransformConfigHandlerReturnType,
7
+ } from '../types.ts';
2
8
 
3
9
  export const runExperiments =
4
10
  (callback: RunExperimentsCallback): TransformConfigHandler =>
5
- async <Config extends AnyRecord>(clone: Config, config: Config) => {
11
+ async <Config extends AnyRecord>(
12
+ clone: Config,
13
+ config: Config,
14
+ ): Promise<TransformConfigHandlerReturnType<Config>> => {
6
15
  if ('__experiment' in config && typeof config.__experiment === 'object') {
7
- // As __experiment is private property, Typescript doesn't know what type is.
16
+ // As __experiment is private property, TypeScript doesn't know what type is.
8
17
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
9
18
  const { buckets, id } = config.__experiment as { buckets: Buckets<Config>; id: string };
10
19
  const bucket = await callback(id);
11
20
 
12
- if (bucket && bucket in buckets && buckets[bucket]) {
13
- return buckets[bucket];
21
+ if (Object.hasOwn(buckets, bucket)) {
22
+ // The check above essentially makes sure the value cannot be null
23
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
24
+ return buckets[bucket]!;
14
25
  }
15
26
  }
16
27
 
@@ -1,11 +1,11 @@
1
- import { type JSONSchema7 } from 'json-schema';
2
- import { arrayHasInvalidDefaults } from './arrayHasInvalidDefaults.ts';
1
+ import { type JSONSchema } from 'zod/v4/core';
3
2
  import { collateObjectPropertyDefaults } from './collateObjectPropertyDefaults.ts';
3
+ import { hasArrayInvalidDefaults } from './hasArrayInvalidDefaults.ts';
4
+ import { hasRecordInvalidDefaults } from './hasRecordInvalidDefaults.ts';
4
5
  import { RESERVED_KEYWORDS, isPropertyReservedWord } from './isPropertyReservedWord.ts';
5
6
  import { isValidPropertyDefinition } from './isValidPropertyDefinition.ts';
6
- import { recordHasInvalidDefaults } from './recordHasInvalidDefaults.ts';
7
7
 
8
- export const collateDefaultValues = <Config>(jsonSchema: JSONSchema7) => {
8
+ export const collateDefaultValues = <Config>(jsonSchema: JSONSchema.JSONSchema): Partial<Config> => {
9
9
  const defaultValues: Partial<Config> = {};
10
10
 
11
11
  for (const propertyName in jsonSchema.properties) {
@@ -17,39 +17,39 @@ export const collateDefaultValues = <Config>(jsonSchema: JSONSchema7) => {
17
17
  );
18
18
  }
19
19
 
20
- // Typescript not inferring property is key of Config.
20
+ // TypeScript not inferring property is key of Config.
21
21
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
22
22
  const castPropertyName = propertyName as keyof Config;
23
23
  const propertyDefinition = jsonSchema.properties[propertyName];
24
24
 
25
25
  if (isValidPropertyDefinition(propertyDefinition)) {
26
26
  if (propertyDefinition.default) {
27
- // Typescript not inferring propertyDefinition.default is Config value.
27
+ // TypeScript not inferring propertyDefinition.default is Config value.
28
28
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
29
29
  defaultValues[castPropertyName] = propertyDefinition.default as Config[keyof Config];
30
30
  }
31
31
 
32
- if (propertyDefinition.type === 'array' && arrayHasInvalidDefaults(propertyDefinition)) {
32
+ if (propertyDefinition.type === 'array' && hasArrayInvalidDefaults(propertyDefinition)) {
33
33
  throw new Error(
34
- `When setting schema array defaults for the array assigned to "${String(
35
- castPropertyName,
36
- )}", set them on the array and not the item.`,
34
+ // ESLint unable to derive value can also be symbol or number
35
+ // eslint-disable-next-line unicorn/no-useless-coercion
36
+ `When setting schema array defaults for the array assigned to "${String(castPropertyName)}", set them on the array and not the item.`,
37
37
  );
38
38
  }
39
39
 
40
40
  if (propertyDefinition.type === 'object') {
41
- if (recordHasInvalidDefaults(propertyDefinition)) {
41
+ if (hasRecordInvalidDefaults(propertyDefinition)) {
42
42
  throw new Error(
43
- `When setting schema property defaults for the value of the record assigned to "${String(
44
- castPropertyName,
45
- )}", set them on the record and not the value.`,
43
+ // ESLint unable to derive value can also be symbol or number
44
+ // eslint-disable-next-line unicorn/no-useless-coercion
45
+ `When setting schema property defaults for the value of the record assigned to "${String(castPropertyName)}", set them on the record and not the value.`,
46
46
  );
47
47
  }
48
48
 
49
49
  const propertyDefaults = collateObjectPropertyDefaults(propertyDefinition);
50
50
 
51
51
  if (propertyDefaults) {
52
- // Typescript not inferring propertyDefaults is Config value.
52
+ // TypeScript not inferring propertyDefaults is Config value.
53
53
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
54
54
  defaultValues[castPropertyName] = propertyDefaults as Config[keyof Config];
55
55
  }
@@ -1,12 +1,14 @@
1
- import { type JSONSchema7 } from 'json-schema';
2
1
  import { isBoolean, isUndefined } from 'lodash-es';
3
2
  import { type Jsonifiable } from 'type-fest';
4
- import { objectPropertyHasDefaults } from './objectPropertyHasDefaults.ts';
3
+ import { type JSONSchema } from 'zod/v4/core';
4
+ import { hasObjectPropertyDefaults } from './hasObjectPropertyDefaults.ts';
5
5
 
6
- export const collateObjectPropertyDefaults = (propertyDefinition: JSONSchema7) => {
6
+ export const collateObjectPropertyDefaults = (
7
+ propertyDefinition: JSONSchema.JSONSchema,
8
+ ): Record<string, Jsonifiable> | undefined => {
7
9
  const { properties } = propertyDefinition;
8
10
 
9
- if (!properties || !objectPropertyHasDefaults(propertyDefinition)) {
11
+ if (!properties || !hasObjectPropertyDefaults(propertyDefinition)) {
10
12
  return;
11
13
  }
12
14
 
@@ -0,0 +1,6 @@
1
+ import { type JSONSchema } from 'zod/v4/core';
2
+
3
+ export const hasArrayInvalidDefaults = (propertyDefinition: JSONSchema.JSONSchema): boolean => {
4
+ const { items } = propertyDefinition;
5
+ return !!items && typeof items === 'object' && 'default' in items;
6
+ };
@@ -0,0 +1,5 @@
1
+ import { type JSONSchema } from 'zod/v4/core';
2
+
3
+ export const hasObjectPropertyDefaults = (propertyDefinition: JSONSchema.JSONSchema): boolean =>
4
+ !!propertyDefinition.properties &&
5
+ Object.values(propertyDefinition.properties).some(value => typeof value === 'object' && 'default' in value);
@@ -0,0 +1,6 @@
1
+ import { type JSONSchema } from 'zod/v4/core';
2
+
3
+ export const hasRecordInvalidDefaults = (propertyDefinition: JSONSchema.JSONSchema): boolean =>
4
+ !!propertyDefinition.additionalProperties &&
5
+ typeof propertyDefinition.additionalProperties === 'object' &&
6
+ 'default' in propertyDefinition.additionalProperties;
@@ -1,6 +1,6 @@
1
1
  import { resolve } from 'node:path';
2
2
  import shelljs from 'shelljs';
3
- import { type Commands } from '../cli.ts';
3
+ import { type CliCommands } from '../cli.ts';
4
4
  import { type ConfigBuilder } from '../createConfigBuilder.ts';
5
5
  import { type SetupExperimentsCallback } from '../types.ts';
6
6
  import { transformWriteConfig } from './transformWriteConfig.ts';
@@ -8,10 +8,12 @@ import { transformWriteConfig } from './transformWriteConfig.ts';
8
8
  export const importValidateTransformWriteConfig = (
9
9
  inputFile: string,
10
10
  outputFile: string,
11
- command: Commands,
11
+ command: CliCommands,
12
12
  experimentCallbackFile?: string,
13
- ) => {
13
+ ): void => {
14
14
  import(resolve(process.cwd(), inputFile))
15
+ // TODO: Will revisit
16
+ // eslint-disable-next-line unicorn/prefer-await
15
17
  .then(({ default: configBuilder }: { default: ConfigBuilder<object> }) => {
16
18
  if (!configBuilder.$validate()) {
17
19
  shelljs.echo(`zcd ${command} => invalid config`);
@@ -25,16 +27,22 @@ export const importValidateTransformWriteConfig = (
25
27
 
26
28
  if (experimentCallbackFile) {
27
29
  import(resolve(process.cwd(), experimentCallbackFile))
30
+ // TODO: Will revisit
31
+ // eslint-disable-next-line unicorn/prefer-await
28
32
  .then(({ default: experimentsCallback }: { default: SetupExperimentsCallback }) => {
29
33
  void transformWriteConfig(configBuilder.$values(), { experimentsCallback, outputFile });
30
34
  })
35
+ // TODO: Will revisit
36
+ // eslint-disable-next-line unicorn/prefer-await
31
37
  .catch((error: unknown) => {
32
- if (error instanceof Error) {
33
- shelljs.echo(`zcd ${command} => error message: ${error.message}`);
38
+ if (!(error instanceof Error)) {
39
+ return;
40
+ }
41
+
42
+ shelljs.echo(`zcd ${command} => error message: ${error.message}`);
34
43
 
35
- if (error.stack) {
36
- shelljs.echo(`zcd ${command} => error stack:\n${error.stack}\n`);
37
- }
44
+ if (error.stack) {
45
+ shelljs.echo(`zcd ${command} => error stack:\n${error.stack}\n`);
38
46
  }
39
47
  });
40
48
 
@@ -43,13 +51,17 @@ export const importValidateTransformWriteConfig = (
43
51
 
44
52
  void transformWriteConfig(configBuilder.$values(), { outputFile });
45
53
  })
54
+ // TODO: Will revisit
55
+ // eslint-disable-next-line unicorn/prefer-await
46
56
  .catch((error: unknown) => {
47
- if (error instanceof Error) {
48
- shelljs.echo(`zcd ${command} => error message: ${error.message}`);
57
+ if (!(error instanceof Error)) {
58
+ return;
59
+ }
60
+
61
+ shelljs.echo(`zcd ${command} => error message: ${error.message}`);
49
62
 
50
- if (error.stack) {
51
- shelljs.echo(`zcd ${command} => error stack:\n${error.stack}\n`);
52
- }
63
+ if (error.stack) {
64
+ shelljs.echo(`zcd ${command} => error stack:\n${error.stack}\n`);
53
65
  }
54
66
  });
55
67
  };
@@ -1,3 +1,3 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- export const isInvalidPropertyOverride = (propertyValue: any, override = false) =>
3
- !override && propertyValue !== undefined;
2
+ export const isInvalidPropertyOverride = (propertyValue: any, isOverride = false): boolean =>
3
+ !isOverride && propertyValue !== undefined;
@@ -10,4 +10,4 @@ export const RESERVED_KEYWORDS = new Set([
10
10
  '$values',
11
11
  ]);
12
12
 
13
- export const isPropertyReservedWord = (propertyName: string) => RESERVED_KEYWORDS.has(propertyName);
13
+ export const isPropertyReservedWord = (propertyName: string): boolean => RESERVED_KEYWORDS.has(propertyName);
@@ -1,3 +1,3 @@
1
- import { type JSONSchema7 } from 'json-schema';
1
+ import { type JSONSchema } from 'zod/v4/core';
2
2
 
3
- export const isSchemaValid = (schema: JSONSchema7) => schema.type !== 'object';
3
+ export const isSchemaValid = (schema: JSONSchema.JSONSchema): boolean => schema.type !== 'object';
@@ -1,5 +1,5 @@
1
- import { type JSONSchema7, type JSONSchema7Definition } from 'json-schema';
1
+ import { type JSONSchema } from 'zod/v4/core';
2
2
 
3
3
  export const isValidPropertyDefinition = (
4
- propertyDefinition: JSONSchema7Definition | undefined,
5
- ): propertyDefinition is JSONSchema7 => typeof propertyDefinition === 'object';
4
+ propertyDefinition?: JSONSchema._JSONSchema,
5
+ ): propertyDefinition is JSONSchema.JSONSchema => !!propertyDefinition && typeof propertyDefinition === 'object';
@@ -18,11 +18,7 @@ export const isValidValue = (value: unknown, depth = 0): boolean => {
18
18
  }
19
19
 
20
20
  if (Array.isArray(value)) {
21
- if (value.every(v => isValidValue(v, depth + 1))) {
22
- return true;
23
- }
24
-
25
- return false;
21
+ return value.every(v => isValidValue(v, depth + 1));
26
22
  }
27
23
 
28
24
  return true;
@@ -51,7 +51,7 @@ export const transformConfig = async <Config extends AnyRecord>(
51
51
  if (isPlainObject(value)) {
52
52
  transform[key] = await transformConfig(value, handler);
53
53
  } else if (Array.isArray(value)) {
54
- // transformArraySync returns an any type.
54
+ // TODO: Need to look at this
55
55
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
56
56
  transform[key] = (await transformArray(value, handler)) as Config[Extract<keyof Config, string>];
57
57
  } else {
@@ -107,15 +107,21 @@ export const transformConfigSync = <Config extends AnyRecord>(
107
107
  }
108
108
 
109
109
  for (const key in config) {
110
+ // TODO: Need to look at this
111
+
110
112
  const value = config[key];
111
113
 
112
114
  if (isPlainObject(value)) {
115
+ // TODO: Need to look at this
116
+
113
117
  transform[key] = transformConfigSync(value, handler);
114
118
  } else if (Array.isArray(value)) {
115
- // transformArraySync returns an any type.
119
+ // TODO: Need to look at this
116
120
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
117
121
  transform[key] = transformArraySync(value, handler) as Config[Extract<keyof Config, string>];
118
122
  } else {
123
+ // TODO: Need to look at this
124
+
119
125
  transform[key] = value;
120
126
  }
121
127
  }
@@ -23,7 +23,7 @@ describe('transformWriteConfig', () => {
23
23
  });
24
24
 
25
25
  expect(outputFileSync.mock.calls[0]?.[1]).toMatchInlineSnapshot(`
26
- "/* eslint-disable prettier/prettier, import-x/no-default-export, unicorn/numeric-separators-style, unicorn/no-null */
26
+ "/* eslint-disable import-x/no-default-export, unicorn/numeric-separators-style, unicorn/no-null */
27
27
  /* This file is autogenerated, do not edit directly, your changes will not perist. */
28
28
 
29
29
  export default {
@@ -1,7 +1,7 @@
1
1
  import { outputFileSync } from 'fs-extra/esm';
2
2
  import Handlebars from 'handlebars';
3
3
  import { readFileSync } from 'node:fs';
4
- import { dirname, resolve } from 'node:path';
4
+ import path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import shelljs from 'shelljs';
7
7
  import { removeDisabledSlices } from '../transformers/removeDisabledSlices.ts';
@@ -12,15 +12,17 @@ import { transformConfig } from './transformConfig.ts';
12
12
  export const transformWriteConfig = async <Config extends object>(
13
13
  config: Config,
14
14
  { experimentsCallback, outputFile }: WriteConfigOptions,
15
- ) => {
15
+ ): Promise<void> => {
16
16
  const handlers: TransformConfigHandler[] = [removeDisabledSlices];
17
17
 
18
18
  if (experimentsCallback) {
19
19
  handlers.push(setupExperiments(experimentsCallback));
20
20
  }
21
21
 
22
+ const dirname = path.dirname(fileURLToPath(import.meta.url));
23
+
22
24
  const template = Handlebars.compile(
23
- readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../templates/config.ts.hbs'), { encoding: 'utf8' }),
25
+ readFileSync(path.resolve(dirname, '../templates/config.ts.hbs'), { encoding: 'utf8' }),
24
26
  );
25
27
 
26
28
  const output = template({
@@ -35,5 +37,5 @@ export const transformWriteConfig = async <Config extends object>(
35
37
 
36
38
  shelljs.echo(`zcd watch => writing to file: ${outputFile}`);
37
39
  shelljs.echo(`zcd watch => content to write:\n${output}\n`);
38
- outputFileSync(resolve(process.cwd(), outputFile), output);
40
+ outputFileSync(path.resolve(process.cwd(), outputFile), output);
39
41
  };
@@ -1,3 +0,0 @@
1
- import { type JSONSchema7 } from 'json-schema';
2
- export declare const arrayHasInvalidDefaults: (propertyDefinition: JSONSchema7) => boolean | undefined;
3
- //# sourceMappingURL=arrayHasInvalidDefaults.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arrayHasInvalidDefaults.d.cts","sourceRoot":"","sources":["../../../../src/utils/arrayHasInvalidDefaults.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,uBAAuB,GAAI,oBAAoB,WAAW,wBAGtE,CAAC"}
@@ -1,109 +0,0 @@
1
- import { type Jsonifiable } from 'type-fest';
2
- export declare const jsonStringifyReplacer: (_key: string, value: Jsonifiable) => string | number | boolean | {
3
- [x: string]: Jsonifiable | undefined;
4
- } | {
5
- toJSON: () => Jsonifiable;
6
- } | import("type-fest/source/jsonifiable.js").JsonifiableArray | ({
7
- anyOf: import("zod-to-json-schema").JsonSchema7DateType[];
8
- } & {
9
- title?: string;
10
- default?: any;
11
- description?: string;
12
- markdownDescription?: string;
13
- } & {
14
- $schema?: string | undefined;
15
- definitions?: {
16
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
17
- } | undefined;
18
- }) | ({
19
- type: "object" | "array";
20
- } & {
21
- title?: string;
22
- default?: any;
23
- description?: string;
24
- markdownDescription?: string;
25
- } & {
26
- $schema?: string | undefined;
27
- definitions?: {
28
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
29
- } | undefined;
30
- }) | ({
31
- type: ("string" | "number" | "boolean" | "integer" | "null") | ("string" | "number" | "boolean" | "integer" | "null")[];
32
- } & {
33
- title?: string;
34
- default?: any;
35
- description?: string;
36
- markdownDescription?: string;
37
- } & {
38
- $schema?: string | undefined;
39
- definitions?: {
40
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
41
- } | undefined;
42
- }) | ({
43
- anyOf: import("zod-to-json-schema").JsonSchema7Type[];
44
- } & {
45
- title?: string;
46
- default?: any;
47
- description?: string;
48
- markdownDescription?: string;
49
- } & {
50
- $schema?: string | undefined;
51
- definitions?: {
52
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
53
- } | undefined;
54
- }) | (import("zod-to-json-schema").JsonSchema7UndefinedType & {
55
- title?: string;
56
- default?: any;
57
- description?: string;
58
- markdownDescription?: string;
59
- } & {
60
- $schema?: string | undefined;
61
- definitions?: {
62
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
63
- } | undefined;
64
- }) | (import("zod-to-json-schema").JsonSchema7AnyType & {
65
- title?: string;
66
- default?: any;
67
- description?: string;
68
- markdownDescription?: string;
69
- } & {
70
- $schema?: string | undefined;
71
- definitions?: {
72
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
73
- } | undefined;
74
- }) | ({
75
- anyOf: [import("zod-to-json-schema").JsonSchema7Type, import("zod-to-json-schema").JsonSchema7NullType];
76
- } & {
77
- title?: string;
78
- default?: any;
79
- description?: string;
80
- markdownDescription?: string;
81
- } & {
82
- $schema?: string | undefined;
83
- definitions?: {
84
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
85
- } | undefined;
86
- }) | ({
87
- type: [string, "null"];
88
- } & {
89
- title?: string;
90
- default?: any;
91
- description?: string;
92
- markdownDescription?: string;
93
- } & {
94
- $schema?: string | undefined;
95
- definitions?: {
96
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
97
- } | undefined;
98
- }) | (import("zod-to-json-schema").JsonSchema7AllOfType & {
99
- title?: string;
100
- default?: any;
101
- description?: string;
102
- markdownDescription?: string;
103
- } & {
104
- $schema?: string | undefined;
105
- definitions?: {
106
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
107
- } | undefined;
108
- }) | null;
109
- //# sourceMappingURL=jsonStringifyReplacer.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonStringifyReplacer.d.cts","sourceRoot":"","sources":["../../../../src/utils/jsonStringifyReplacer.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,EAAE,OAAO,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SACc,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type JSONSchema7 } from 'json-schema';
2
- export declare const objectPropertyHasDefaults: (propertyDefinition: JSONSchema7) => boolean | undefined;
3
- //# sourceMappingURL=objectPropertyHasDefaults.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectPropertyHasDefaults.d.cts","sourceRoot":"","sources":["../../../../src/utils/objectPropertyHasDefaults.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,yBAAyB,GAAI,oBAAoB,WAAW,wBAEoC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type JSONSchema7 } from 'json-schema';
2
- export declare const recordHasInvalidDefaults: (propertyDefinition: JSONSchema7) => boolean | undefined;
3
- //# sourceMappingURL=recordHasInvalidDefaults.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recordHasInvalidDefaults.d.cts","sourceRoot":"","sources":["../../../../src/utils/recordHasInvalidDefaults.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,wBAAwB,GAAI,oBAAoB,WAAW,wBAGlB,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type JSONSchema7 } from 'json-schema';
2
- export declare const arrayHasInvalidDefaults: (propertyDefinition: JSONSchema7) => boolean | undefined;
3
- //# sourceMappingURL=arrayHasInvalidDefaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arrayHasInvalidDefaults.d.ts","sourceRoot":"","sources":["../../../../src/utils/arrayHasInvalidDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,uBAAuB,GAAI,oBAAoB,WAAW,wBAGtE,CAAC"}
@@ -1,109 +0,0 @@
1
- import { type Jsonifiable } from 'type-fest';
2
- export declare const jsonStringifyReplacer: (_key: string, value: Jsonifiable) => string | number | boolean | {
3
- [x: string]: Jsonifiable | undefined;
4
- } | {
5
- toJSON: () => Jsonifiable;
6
- } | import("type-fest/source/jsonifiable.js").JsonifiableArray | ({
7
- anyOf: import("zod-to-json-schema").JsonSchema7DateType[];
8
- } & {
9
- title?: string;
10
- default?: any;
11
- description?: string;
12
- markdownDescription?: string;
13
- } & {
14
- $schema?: string | undefined;
15
- definitions?: {
16
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
17
- } | undefined;
18
- }) | ({
19
- type: "object" | "array";
20
- } & {
21
- title?: string;
22
- default?: any;
23
- description?: string;
24
- markdownDescription?: string;
25
- } & {
26
- $schema?: string | undefined;
27
- definitions?: {
28
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
29
- } | undefined;
30
- }) | ({
31
- type: ("string" | "number" | "boolean" | "integer" | "null") | ("string" | "number" | "boolean" | "integer" | "null")[];
32
- } & {
33
- title?: string;
34
- default?: any;
35
- description?: string;
36
- markdownDescription?: string;
37
- } & {
38
- $schema?: string | undefined;
39
- definitions?: {
40
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
41
- } | undefined;
42
- }) | ({
43
- anyOf: import("zod-to-json-schema").JsonSchema7Type[];
44
- } & {
45
- title?: string;
46
- default?: any;
47
- description?: string;
48
- markdownDescription?: string;
49
- } & {
50
- $schema?: string | undefined;
51
- definitions?: {
52
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
53
- } | undefined;
54
- }) | (import("zod-to-json-schema").JsonSchema7UndefinedType & {
55
- title?: string;
56
- default?: any;
57
- description?: string;
58
- markdownDescription?: string;
59
- } & {
60
- $schema?: string | undefined;
61
- definitions?: {
62
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
63
- } | undefined;
64
- }) | (import("zod-to-json-schema").JsonSchema7AnyType & {
65
- title?: string;
66
- default?: any;
67
- description?: string;
68
- markdownDescription?: string;
69
- } & {
70
- $schema?: string | undefined;
71
- definitions?: {
72
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
73
- } | undefined;
74
- }) | ({
75
- anyOf: [import("zod-to-json-schema").JsonSchema7Type, import("zod-to-json-schema").JsonSchema7NullType];
76
- } & {
77
- title?: string;
78
- default?: any;
79
- description?: string;
80
- markdownDescription?: string;
81
- } & {
82
- $schema?: string | undefined;
83
- definitions?: {
84
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
85
- } | undefined;
86
- }) | ({
87
- type: [string, "null"];
88
- } & {
89
- title?: string;
90
- default?: any;
91
- description?: string;
92
- markdownDescription?: string;
93
- } & {
94
- $schema?: string | undefined;
95
- definitions?: {
96
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
97
- } | undefined;
98
- }) | (import("zod-to-json-schema").JsonSchema7AllOfType & {
99
- title?: string;
100
- default?: any;
101
- description?: string;
102
- markdownDescription?: string;
103
- } & {
104
- $schema?: string | undefined;
105
- definitions?: {
106
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
107
- } | undefined;
108
- }) | null;
109
- //# sourceMappingURL=jsonStringifyReplacer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonStringifyReplacer.d.ts","sourceRoot":"","sources":["../../../../src/utils/jsonStringifyReplacer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,EAAE,OAAO,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SACc,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type JSONSchema7 } from 'json-schema';
2
- export declare const objectPropertyHasDefaults: (propertyDefinition: JSONSchema7) => boolean | undefined;
3
- //# sourceMappingURL=objectPropertyHasDefaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectPropertyHasDefaults.d.ts","sourceRoot":"","sources":["../../../../src/utils/objectPropertyHasDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,yBAAyB,GAAI,oBAAoB,WAAW,wBAEoC,CAAC"}