barrelize 1.2.0 → 1.2.2
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/README.md +27 -10
- package/lib/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ Barrelize simplifies module exports by creating clean, centralized `index.js` or
|
|
|
7
7
|
[](https://www.npmjs.com/package/barrelize)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
|
+

|
|
11
|
+
|
|
10
12
|
## Features
|
|
11
13
|
|
|
12
14
|
- **Automatic Barrel Generation**: Scans directories and creates index files with exports for all modules.
|
|
@@ -54,11 +56,17 @@ npx barrelize init barrelize.json # Creates config at specified path
|
|
|
54
56
|
|
|
55
57
|
### `barrelize [config path]`
|
|
56
58
|
|
|
57
|
-
Generates barrel (index) files based on your configuration.
|
|
59
|
+
Generates barrel (index) files based on your configuration. The tool will:
|
|
60
|
+
|
|
61
|
+
- Create or update index files in specified directories
|
|
62
|
+
- Export all matching files based on include/exclude patterns
|
|
63
|
+
- Order exports according to your configuration
|
|
64
|
+
- Apply path replacements
|
|
65
|
+
- Format exports according to your style preferences
|
|
58
66
|
|
|
59
67
|
```bash
|
|
60
|
-
npx barrelize
|
|
61
|
-
npx barrelize
|
|
68
|
+
npx barrelize # Uses default .barrelize config
|
|
69
|
+
npx barrelize custom.json # Uses specified config file
|
|
62
70
|
```
|
|
63
71
|
|
|
64
72
|
## Configuration
|
|
@@ -67,26 +75,35 @@ Create a `.barrelize` file in your project root. The configuration file uses JSO
|
|
|
67
75
|
|
|
68
76
|
```jsonc
|
|
69
77
|
{
|
|
78
|
+
"$schema": "node_modules/barrelize/schema.json",
|
|
79
|
+
// Global settings (can be overridden per directory)
|
|
80
|
+
"singleQuote": true, // Use single quotes for exports (default: true)
|
|
81
|
+
"semi": true, // Add semicolons after exports (default: true)
|
|
82
|
+
"insertFinalNewline": true, // Add newline at end of file (default: true)
|
|
70
83
|
// Configure multiple directories to generate barrels for
|
|
71
84
|
"directories": [
|
|
72
85
|
{
|
|
73
|
-
// Root directory to start from
|
|
86
|
+
// Root directory to start from (default: "")
|
|
74
87
|
"path": "src",
|
|
75
|
-
// Files to include in the barrel
|
|
88
|
+
// Files to include in the barrel (default: ["**/*.ts"])
|
|
76
89
|
"include": ["**/*.ts", "**/*.tsx"],
|
|
77
|
-
// Files to exclude from the barrel
|
|
90
|
+
// Files to exclude from the barrel (default: [])
|
|
78
91
|
"exclude": ["**/*.test.ts", "**/*.spec.ts"],
|
|
79
|
-
// Optional ordering of exports
|
|
92
|
+
// Optional ordering of exports (default: [])
|
|
80
93
|
"order": ["types", "constants", "utils"],
|
|
81
|
-
//
|
|
82
|
-
"
|
|
94
|
+
// Name of the index file (default: "index.ts")
|
|
95
|
+
"indexFilePath": "index.ts",
|
|
83
96
|
// Optional string replacements in export paths
|
|
84
97
|
"replace": [
|
|
85
98
|
{
|
|
86
99
|
"find": ".ts$",
|
|
87
100
|
"replacement": ""
|
|
88
101
|
}
|
|
89
|
-
]
|
|
102
|
+
],
|
|
103
|
+
// Override global settings per directory if needed
|
|
104
|
+
"singleQuote": true,
|
|
105
|
+
"semi": true,
|
|
106
|
+
"insertFinalNewline": true
|
|
90
107
|
}
|
|
91
108
|
]
|
|
92
109
|
}
|
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
|
|
594
|
+
const version = "1.2.1";
|
|
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) => {
|
|
@@ -8986,7 +8986,7 @@ async function generateBarrels(rootPath, configPath, config) {
|
|
|
8986
8986
|
colorize(indexFileRelativePath, TerminalColor.CYAN),
|
|
8987
8987
|
colorize(exportedText, TerminalColor.GRAY)
|
|
8988
8988
|
);
|
|
8989
|
-
|
|
8989
|
+
continue;
|
|
8990
8990
|
}
|
|
8991
8991
|
await writeFile(indexFileAbsolutePath, content);
|
|
8992
8992
|
const { insertions, deletions } = pathsDifferences(oldPaths, paths);
|
|
@@ -8998,7 +8998,7 @@ async function generateBarrels(rootPath, configPath, config) {
|
|
|
8998
8998
|
colorize(`${exportedText}${insertionsText}${deletionsText}`, TerminalColor.GRAY)
|
|
8999
8999
|
);
|
|
9000
9000
|
printDifferences(insertions, deletions);
|
|
9001
|
-
|
|
9001
|
+
continue;
|
|
9002
9002
|
}
|
|
9003
9003
|
await writeFile(indexFileAbsolutePath, content);
|
|
9004
9004
|
console.log(
|