barrelize 1.1.3 → 1.1.4

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/lib/index.js CHANGED
@@ -591,7 +591,7 @@ class CAC extends EventEmitter {
591
591
  }
592
592
  const cac = (name2 = "") => new CAC(name2);
593
593
  const name = "barrelize";
594
- const version = "1.1.2";
594
+ const version = "1.1.3";
595
595
  function cliInit() {
596
596
  const cli = cac(name);
597
597
  cli.command("[config path]", `Generate 'index.ts' files for all directories`).action(async (config) => {
@@ -882,6 +882,7 @@ async function runGenerateCommand(options) {
882
882
  await generateBarrels(rootPath, validatedConfig.data);
883
883
  }
884
884
  const configTemplate = {
885
+ $schema: "node_modules/barrelize/schema.json",
885
886
  directories: [
886
887
  {
887
888
  path: "src",
@@ -912,8 +913,8 @@ async function runInitCommand(baseConfigFilePath) {
912
913
  console.log(colorize(configTemplateJson, TerminalColor.GREEN));
913
914
  }
914
915
  const validateConfig = (() => {
915
- const _io0 = (input, _exceptionable = true) => Array.isArray(input.directories) && input.directories.every((elem, _index1) => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io1(elem, _exceptionable)) && (1 === Object.keys(input).length || Object.keys(input).every((key2) => {
916
- if (["directories"].some((prop) => key2 === prop))
916
+ const _io0 = (input, _exceptionable = true) => (void 0 === input.$schema || "string" === typeof input.$schema) && (Array.isArray(input.directories) && input.directories.every((elem, _index1) => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io1(elem, _exceptionable))) && (1 === Object.keys(input).length || Object.keys(input).every((key2) => {
917
+ if (["$schema", "directories"].some((prop) => key2 === prop))
917
918
  return true;
918
919
  const value = input[key2];
919
920
  if (void 0 === value)
@@ -936,7 +937,11 @@ const validateConfig = (() => {
936
937
  return true;
937
938
  return false;
938
939
  }));
939
- const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.directories) || _report(_exceptionable, {
940
+ const _vo0 = (input, _path, _exceptionable = true) => [void 0 === input.$schema || "string" === typeof input.$schema || _report(_exceptionable, {
941
+ path: _path + ".$schema",
942
+ expected: "(string | undefined)",
943
+ value: input.$schema
944
+ }), (Array.isArray(input.directories) || _report(_exceptionable, {
940
945
  path: _path + ".directories",
941
946
  expected: "Array<__type>",
942
947
  value: input.directories
@@ -953,7 +958,7 @@ const validateConfig = (() => {
953
958
  expected: "Array<__type>",
954
959
  value: input.directories
955
960
  }), 1 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map((key2) => {
956
- if (["directories"].some((prop) => key2 === prop))
961
+ if (["$schema", "directories"].some((prop) => key2 === prop))
957
962
  return true;
958
963
  const value = input[key2];
959
964
  if (void 0 === value)
@@ -1,4 +1,5 @@
1
1
  export type Config = {
2
+ $schema?: string;
2
3
  directories: {
3
4
  path?: string;
4
5
  include?: string[];
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "barrelize",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Automatically generating index (barrel) files",
5
5
  "scripts": {
6
- "build": "vite build",
6
+ "build": "npm run schema && vite build",
7
+ "schema": "tsc src/schema/generate-schema.ts --outDir temp && node temp/schema/generate-schema.js > schema.json && rm -rf temp",
7
8
  "prepare": "ts-patch install",
8
9
  "test": "vitest run"
9
10
  },
@@ -39,7 +40,8 @@
39
40
  "sideEffects": false,
40
41
  "files": [
41
42
  "bin",
42
- "lib"
43
+ "lib",
44
+ "schema.json"
43
45
  ],
44
46
  "types": "./lib/src/index.d.ts",
45
47
  "exports": {
package/schema.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "$schema": {
5
+ "type": "string"
6
+ },
7
+ "directories": {
8
+ "type": "array",
9
+ "items": {
10
+ "type": "object",
11
+ "properties": {
12
+ "path": {
13
+ "type": "string"
14
+ },
15
+ "include": {
16
+ "type": "array",
17
+ "items": {
18
+ "type": "string"
19
+ }
20
+ },
21
+ "exclude": {
22
+ "type": "array",
23
+ "items": {
24
+ "type": "string"
25
+ }
26
+ },
27
+ "order": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "string"
31
+ }
32
+ },
33
+ "indexFilePath": {
34
+ "type": "string"
35
+ },
36
+ "keepFileExtension": {
37
+ "type": "boolean"
38
+ },
39
+ "replace": {
40
+ "type": "array",
41
+ "items": {
42
+ "type": "object",
43
+ "properties": {
44
+ "find": {
45
+ "type": "string"
46
+ },
47
+ "replacement": {
48
+ "type": "string"
49
+ }
50
+ },
51
+ "required": [
52
+ "find",
53
+ "replacement"
54
+ ]
55
+ }
56
+ }
57
+ },
58
+ "required": []
59
+ }
60
+ }
61
+ },
62
+ "required": [
63
+ "directories"
64
+ ]
65
+ }