tsfmt 0.2.4 → 0.2.5

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.
@@ -7,6 +7,7 @@ export interface IndexGenerationOptions {
7
7
  export interface IndexGenerationConfig {
8
8
  enabled?: boolean;
9
9
  directories?: string[];
10
+ skipDirectories?: string[];
10
11
  options?: Partial<IndexGenerationOptions>;
11
12
  updateMainIndex?: boolean;
12
13
  }
@@ -62,7 +62,7 @@ class IndexGenerationRule extends BaseFormattingRule.BaseFormattingRule {
62
62
  ];
63
63
  return testPatterns.some((pattern) => pattern.test(fileName));
64
64
  }
65
- generateSingleDirectoryIndex(dir, options) {
65
+ generateSingleDirectoryIndex(dir, skipPaths, options) {
66
66
  try {
67
67
  const entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
68
68
  const exports$1 = [];
@@ -74,7 +74,11 @@ class IndexGenerationRule extends BaseFormattingRule.BaseFormattingRule {
74
74
  if (this.isTestDirectory(entry.name)) {
75
75
  continue;
76
76
  }
77
- const subIndexPath = path__namespace.join(dir, entry.name, options.indexFileName);
77
+ const subDir = path__namespace.join(dir, entry.name);
78
+ if (skipPaths.has(subDir)) {
79
+ continue;
80
+ }
81
+ const subIndexPath = path__namespace.join(subDir, options.indexFileName);
78
82
  if (fs__namespace.existsSync(subIndexPath)) {
79
83
  exports$1.push(`export * from "./${entry.name}";`);
80
84
  }
@@ -104,7 +108,7 @@ ${exports$1.join("\n")}
104
108
  console.warn(`Warning: Failed to generate index for ${dir}: ${error.message}`);
105
109
  }
106
110
  }
107
- generateIndexExportRecursive(dir, options) {
111
+ generateIndexExportRecursive(dir, skipPaths, options) {
108
112
  try {
109
113
  const entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
110
114
  for (const entry of entries) {
@@ -113,22 +117,25 @@ ${exports$1.join("\n")}
113
117
  continue;
114
118
  }
115
119
  const subDir = path__namespace.join(dir, entry.name);
116
- this.generateIndexExportRecursive(subDir, options);
120
+ if (skipPaths.has(subDir)) {
121
+ continue;
122
+ }
123
+ this.generateIndexExportRecursive(subDir, skipPaths, options);
117
124
  }
118
125
  }
119
- this.generateSingleDirectoryIndex(dir, options);
126
+ this.generateSingleDirectoryIndex(dir, skipPaths, options);
120
127
  } catch (error) {
121
128
  console.warn(`Warning: Failed to process directory ${dir}: ${error.message}`);
122
129
  }
123
130
  }
124
- generateIndexExport(dir, options) {
131
+ generateIndexExport(dir, skipPaths, options) {
125
132
  if (!fs__namespace.existsSync(dir)) {
126
133
  return;
127
134
  }
128
135
  if (options.recursive) {
129
- this.generateIndexExportRecursive(dir, options);
136
+ this.generateIndexExportRecursive(dir, skipPaths, options);
130
137
  } else {
131
- this.generateSingleDirectoryIndex(dir, options);
138
+ this.generateSingleDirectoryIndex(dir, skipPaths, options);
132
139
  }
133
140
  }
134
141
  discoverExportableModules(srcDir) {
@@ -180,9 +187,15 @@ ${exports$1}
180
187
  const config = this.getIndexGenerationConfig();
181
188
  const directories = config?.directories || [];
182
189
  const options = { ...this.defaultOptions, ...config?.options };
190
+ const skipPaths = new Set(
191
+ (config?.skipDirectories || []).map((d) => path__namespace.resolve(projectRoot, d))
192
+ );
183
193
  for (const dir of directories) {
184
194
  const fullDirPath = path__namespace.resolve(projectRoot, dir);
185
- this.generateIndexExport(fullDirPath, options);
195
+ if (skipPaths.has(fullDirPath)) {
196
+ continue;
197
+ }
198
+ this.generateIndexExport(fullDirPath, skipPaths, options);
186
199
  }
187
200
  if (config?.updateMainIndex !== false) {
188
201
  const srcDir = path__namespace.join(projectRoot, "src");
package/dist/index.d.ts CHANGED
@@ -2,4 +2,3 @@ export * from "./build-plugins";
2
2
  export * from "./core";
3
3
  export * from "./formatters";
4
4
  export * from "./shared";
5
- export { tsfmt } from "./tsfmt";
package/dist/index.js CHANGED
@@ -29,7 +29,6 @@ const StructuralIndentationRule = require("./core/formatters/rules/style/Structu
29
29
  const FormatterPipeline = require("./core/pipeline/FormatterPipeline.js");
30
30
  const _package = require("./formatters/package.js");
31
31
  const types = require("./shared/types.js");
32
- const tsfmt = require("./tsfmt.js");
33
32
  exports.transformGenericsPlugin = transformGenericsPlugin.transformGenericsPlugin;
34
33
  exports.ASTAnalyzer = ASTAnalyzer.ASTAnalyzer;
35
34
  exports.ASTTransformer = ASTTransformer.ASTTransformer;
@@ -65,4 +64,3 @@ exports.FormatterError = FormatterPipeline.FormatterError;
65
64
  exports.FormatterPipeline = FormatterPipeline.FormatterPipeline;
66
65
  exports.sortExportsKeys = _package.sortExportsKeys;
67
66
  exports.DefaultSortOptions = types.DefaultSortOptions;
68
- exports.tsfmt = tsfmt.tsfmt;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tsfmt",
3
3
  "author": "Encore Digital Group",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "description": "An opinionated TypeScript code formatter",
6
6
  "publishConfig": {
7
7
  "access": "public",
package/dist/tsfmt.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("./core/config/ConfigDefaults.js");
4
- require("./core/config/ConfigLoader.js");
5
- const ConfigMerger = require("./core/config/ConfigMerger.js");
6
- function tsfmt(config = {}) {
7
- return ConfigMerger.ConfigMerger.merge(config);
8
- }
9
- exports.tsfmt = tsfmt;