zshy 0.0.4 → 0.0.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.
- package/out/index.js +0 -0
- package/out/utils.cjs +38 -40
- package/out/utils.js +38 -40
- package/package.json +1 -1
package/out/index.js
CHANGED
|
File without changes
|
package/out/utils.cjs
CHANGED
|
@@ -57,22 +57,27 @@ async function getEntryPoints(patterns) {
|
|
|
57
57
|
function readTsconfig(tsconfigPath) {
|
|
58
58
|
// Read and parse tsconfig.json
|
|
59
59
|
const configPath = path.resolve(tsconfigPath);
|
|
60
|
+
const configDir = path.dirname(configPath);
|
|
60
61
|
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
61
62
|
if (configFile.error) {
|
|
62
63
|
console.error("Error reading tsconfig.json:", ts.formatDiagnostic(configFile.error, {
|
|
63
|
-
getCurrentDirectory: () =>
|
|
64
|
+
getCurrentDirectory: () => configDir,
|
|
64
65
|
getCanonicalFileName: (fileName) => fileName,
|
|
65
66
|
getNewLine: () => ts.sys.newLine,
|
|
66
67
|
}));
|
|
67
68
|
process.exit(1);
|
|
68
69
|
}
|
|
69
|
-
// Parse the config
|
|
70
|
-
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config,
|
|
70
|
+
// Parse the config with explicit base path
|
|
71
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, {
|
|
72
|
+
...ts.sys,
|
|
73
|
+
// Override getCurrentDirectory to use the tsconfig directory
|
|
74
|
+
getCurrentDirectory: () => configDir,
|
|
75
|
+
}, configDir);
|
|
71
76
|
if (parsedConfig.errors.length > 0) {
|
|
72
77
|
console.error("❌ Error parsing tsconfig.json:");
|
|
73
78
|
for (const error of parsedConfig.errors) {
|
|
74
79
|
console.error(ts.formatDiagnostic(error, {
|
|
75
|
-
getCurrentDirectory: () =>
|
|
80
|
+
getCurrentDirectory: () => configDir,
|
|
76
81
|
getCanonicalFileName: (fileName) => fileName,
|
|
77
82
|
getNewLine: () => ts.sys.newLine,
|
|
78
83
|
}));
|
|
@@ -85,18 +90,6 @@ function readTsconfig(tsconfigPath) {
|
|
|
85
90
|
return parsedConfig.options;
|
|
86
91
|
}
|
|
87
92
|
async function compileProject(config, entryPoints) {
|
|
88
|
-
const exts = [];
|
|
89
|
-
// exts.push(config.jsExtension ?? ".js");
|
|
90
|
-
// exts.push(config.dtsExtension ?? ".d.ts");
|
|
91
|
-
// console.log(
|
|
92
|
-
// `🧱 Building${
|
|
93
|
-
// config.mode === "ts"
|
|
94
|
-
// ? ".js/.d.ts"
|
|
95
|
-
// : config.mode === "mts"
|
|
96
|
-
// ? ".mjs/.d.ts"
|
|
97
|
-
// : ".cjs/.d.ts"
|
|
98
|
-
// }...`,
|
|
99
|
-
// );
|
|
100
93
|
// Create compiler host
|
|
101
94
|
const host = ts.createCompilerHost(config.compilerOptions);
|
|
102
95
|
const originalWriteFile = host.writeFile;
|
|
@@ -212,23 +205,21 @@ async function compileProject(config, entryPoints) {
|
|
|
212
205
|
if (diagnostics.length > 0) {
|
|
213
206
|
const errorCount = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error).length;
|
|
214
207
|
const warningCount = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Warning).length;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
console.log(`... and ${errorCount - 5} more errors`);
|
|
231
|
-
}
|
|
208
|
+
if (errorCount > 0 || warningCount > 0) {
|
|
209
|
+
console.log(`⚠️ Found ${errorCount} error(s) and ${warningCount} warning(s)`);
|
|
210
|
+
console.log();
|
|
211
|
+
}
|
|
212
|
+
// Format diagnostics with color and context like tsc, keeping original order
|
|
213
|
+
const formatHost = {
|
|
214
|
+
getCurrentDirectory: () => process.cwd(),
|
|
215
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
216
|
+
getNewLine: () => ts.sys.newLine,
|
|
217
|
+
};
|
|
218
|
+
// Keep errors and warnings intermixed in their original order
|
|
219
|
+
const relevantDiagnostics = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error ||
|
|
220
|
+
d.category === ts.DiagnosticCategory.Warning);
|
|
221
|
+
if (relevantDiagnostics.length > 0) {
|
|
222
|
+
console.log(ts.formatDiagnosticsWithColorAndContext(relevantDiagnostics, formatHost));
|
|
232
223
|
}
|
|
233
224
|
}
|
|
234
225
|
// emit the files
|
|
@@ -247,13 +238,20 @@ async function compileProject(config, entryPoints) {
|
|
|
247
238
|
}
|
|
248
239
|
// Report any emit diagnostics
|
|
249
240
|
if (emitResult.diagnostics.length > 0) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
241
|
+
const emitErrors = emitResult.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error);
|
|
242
|
+
const emitWarnings = emitResult.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Warning);
|
|
243
|
+
console.error(`❌ Found ${emitErrors.length} error(s) and ${emitWarnings.length} warning(s) during emit:`);
|
|
244
|
+
console.log();
|
|
245
|
+
const formatHost = {
|
|
246
|
+
getCurrentDirectory: () => process.cwd(),
|
|
247
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
248
|
+
getNewLine: () => ts.sys.newLine,
|
|
249
|
+
};
|
|
250
|
+
// Keep errors and warnings intermixed in their original order
|
|
251
|
+
const relevantEmitDiagnostics = emitResult.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error ||
|
|
252
|
+
d.category === ts.DiagnosticCategory.Warning);
|
|
253
|
+
if (relevantEmitDiagnostics.length > 0) {
|
|
254
|
+
console.log(ts.formatDiagnosticsWithColorAndContext(relevantEmitDiagnostics, formatHost));
|
|
257
255
|
}
|
|
258
256
|
}
|
|
259
257
|
}
|
package/out/utils.js
CHANGED
|
@@ -19,22 +19,27 @@ export async function getEntryPoints(patterns) {
|
|
|
19
19
|
export function readTsconfig(tsconfigPath) {
|
|
20
20
|
// Read and parse tsconfig.json
|
|
21
21
|
const configPath = path.resolve(tsconfigPath);
|
|
22
|
+
const configDir = path.dirname(configPath);
|
|
22
23
|
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
23
24
|
if (configFile.error) {
|
|
24
25
|
console.error("Error reading tsconfig.json:", ts.formatDiagnostic(configFile.error, {
|
|
25
|
-
getCurrentDirectory: () =>
|
|
26
|
+
getCurrentDirectory: () => configDir,
|
|
26
27
|
getCanonicalFileName: (fileName) => fileName,
|
|
27
28
|
getNewLine: () => ts.sys.newLine,
|
|
28
29
|
}));
|
|
29
30
|
process.exit(1);
|
|
30
31
|
}
|
|
31
|
-
// Parse the config
|
|
32
|
-
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config,
|
|
32
|
+
// Parse the config with explicit base path
|
|
33
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, {
|
|
34
|
+
...ts.sys,
|
|
35
|
+
// Override getCurrentDirectory to use the tsconfig directory
|
|
36
|
+
getCurrentDirectory: () => configDir,
|
|
37
|
+
}, configDir);
|
|
33
38
|
if (parsedConfig.errors.length > 0) {
|
|
34
39
|
console.error("❌ Error parsing tsconfig.json:");
|
|
35
40
|
for (const error of parsedConfig.errors) {
|
|
36
41
|
console.error(ts.formatDiagnostic(error, {
|
|
37
|
-
getCurrentDirectory: () =>
|
|
42
|
+
getCurrentDirectory: () => configDir,
|
|
38
43
|
getCanonicalFileName: (fileName) => fileName,
|
|
39
44
|
getNewLine: () => ts.sys.newLine,
|
|
40
45
|
}));
|
|
@@ -47,18 +52,6 @@ export function readTsconfig(tsconfigPath) {
|
|
|
47
52
|
return parsedConfig.options;
|
|
48
53
|
}
|
|
49
54
|
export async function compileProject(config, entryPoints) {
|
|
50
|
-
const exts = [];
|
|
51
|
-
// exts.push(config.jsExtension ?? ".js");
|
|
52
|
-
// exts.push(config.dtsExtension ?? ".d.ts");
|
|
53
|
-
// console.log(
|
|
54
|
-
// `🧱 Building${
|
|
55
|
-
// config.mode === "ts"
|
|
56
|
-
// ? ".js/.d.ts"
|
|
57
|
-
// : config.mode === "mts"
|
|
58
|
-
// ? ".mjs/.d.ts"
|
|
59
|
-
// : ".cjs/.d.ts"
|
|
60
|
-
// }...`,
|
|
61
|
-
// );
|
|
62
55
|
// Create compiler host
|
|
63
56
|
const host = ts.createCompilerHost(config.compilerOptions);
|
|
64
57
|
const originalWriteFile = host.writeFile;
|
|
@@ -174,23 +167,21 @@ export async function compileProject(config, entryPoints) {
|
|
|
174
167
|
if (diagnostics.length > 0) {
|
|
175
168
|
const errorCount = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error).length;
|
|
176
169
|
const warningCount = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Warning).length;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
console.log(`... and ${errorCount - 5} more errors`);
|
|
193
|
-
}
|
|
170
|
+
if (errorCount > 0 || warningCount > 0) {
|
|
171
|
+
console.log(`⚠️ Found ${errorCount} error(s) and ${warningCount} warning(s)`);
|
|
172
|
+
console.log();
|
|
173
|
+
}
|
|
174
|
+
// Format diagnostics with color and context like tsc, keeping original order
|
|
175
|
+
const formatHost = {
|
|
176
|
+
getCurrentDirectory: () => process.cwd(),
|
|
177
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
178
|
+
getNewLine: () => ts.sys.newLine,
|
|
179
|
+
};
|
|
180
|
+
// Keep errors and warnings intermixed in their original order
|
|
181
|
+
const relevantDiagnostics = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error ||
|
|
182
|
+
d.category === ts.DiagnosticCategory.Warning);
|
|
183
|
+
if (relevantDiagnostics.length > 0) {
|
|
184
|
+
console.log(ts.formatDiagnosticsWithColorAndContext(relevantDiagnostics, formatHost));
|
|
194
185
|
}
|
|
195
186
|
}
|
|
196
187
|
// emit the files
|
|
@@ -209,13 +200,20 @@ export async function compileProject(config, entryPoints) {
|
|
|
209
200
|
}
|
|
210
201
|
// Report any emit diagnostics
|
|
211
202
|
if (emitResult.diagnostics.length > 0) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
203
|
+
const emitErrors = emitResult.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error);
|
|
204
|
+
const emitWarnings = emitResult.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Warning);
|
|
205
|
+
console.error(`❌ Found ${emitErrors.length} error(s) and ${emitWarnings.length} warning(s) during emit:`);
|
|
206
|
+
console.log();
|
|
207
|
+
const formatHost = {
|
|
208
|
+
getCurrentDirectory: () => process.cwd(),
|
|
209
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
210
|
+
getNewLine: () => ts.sys.newLine,
|
|
211
|
+
};
|
|
212
|
+
// Keep errors and warnings intermixed in their original order
|
|
213
|
+
const relevantEmitDiagnostics = emitResult.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error ||
|
|
214
|
+
d.category === ts.DiagnosticCategory.Warning);
|
|
215
|
+
if (relevantEmitDiagnostics.length > 0) {
|
|
216
|
+
console.log(ts.formatDiagnosticsWithColorAndContext(relevantEmitDiagnostics, formatHost));
|
|
219
217
|
}
|
|
220
218
|
}
|
|
221
219
|
}
|