zshy 0.0.3 → 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.cjs +6 -15
- package/out/index.js +6 -15
- package/out/utils.cjs +39 -41
- package/out/utils.js +39 -41
- package/package.json +3 -2
package/out/index.cjs
CHANGED
|
@@ -62,10 +62,8 @@ async function main() {
|
|
|
62
62
|
let args;
|
|
63
63
|
try {
|
|
64
64
|
args = (0, arg_1.default)({
|
|
65
|
-
"--project": String,
|
|
66
65
|
"--help": Boolean,
|
|
67
66
|
// Aliases
|
|
68
|
-
"-p": "--project",
|
|
69
67
|
"-h": "--help",
|
|
70
68
|
});
|
|
71
69
|
}
|
|
@@ -82,20 +80,13 @@ async function main() {
|
|
|
82
80
|
Usage: zshy [options]
|
|
83
81
|
|
|
84
82
|
Options:
|
|
85
|
-
-p, --project <path> Path to tsconfig.json file
|
|
86
83
|
-h, --help Show this help message
|
|
87
84
|
|
|
88
85
|
Examples:
|
|
89
|
-
zshy
|
|
90
|
-
zshy -p ./tsconfig.build.json # Use specific tsconfig file
|
|
91
|
-
zshy --project ./tsconfig.prod.json
|
|
86
|
+
zshy # Use ./tsconfig.json or package.json#zshy.tsconfig
|
|
92
87
|
`);
|
|
93
88
|
process.exit(0);
|
|
94
89
|
}
|
|
95
|
-
const projectPath = args["--project"];
|
|
96
|
-
if (projectPath) {
|
|
97
|
-
console.log(`⚙️ Using custom project path: ${projectPath}`);
|
|
98
|
-
}
|
|
99
90
|
///////////////////////////////////
|
|
100
91
|
/// find and read pkg json ///
|
|
101
92
|
///////////////////////////////////
|
|
@@ -166,12 +157,12 @@ Examples:
|
|
|
166
157
|
///////////////////////////
|
|
167
158
|
// Determine tsconfig.json path
|
|
168
159
|
let tsconfigPath;
|
|
169
|
-
if (
|
|
170
|
-
// Resolve the provided
|
|
171
|
-
const resolvedProjectPath = path.resolve(
|
|
160
|
+
if (config.tsconfig) {
|
|
161
|
+
// Resolve the provided tsconfig path against package.json directory
|
|
162
|
+
const resolvedProjectPath = path.resolve(pkgJsonDir, config.tsconfig);
|
|
172
163
|
if (fs.existsSync(resolvedProjectPath)) {
|
|
173
164
|
if (fs.statSync(resolvedProjectPath).isDirectory()) {
|
|
174
|
-
console.error(`❌
|
|
165
|
+
console.error(`❌ zshy.tsconfig must point to a tsconfig.json file, not a directory: ${resolvedProjectPath}`);
|
|
175
166
|
process.exit(1);
|
|
176
167
|
}
|
|
177
168
|
else {
|
|
@@ -180,7 +171,7 @@ Examples:
|
|
|
180
171
|
}
|
|
181
172
|
}
|
|
182
173
|
else {
|
|
183
|
-
console.error(`❌
|
|
174
|
+
console.error(`❌ Tsconfig file not found: ${resolvedProjectPath}`);
|
|
184
175
|
process.exit(1);
|
|
185
176
|
}
|
|
186
177
|
}
|
package/out/index.js
CHANGED
|
@@ -24,10 +24,8 @@ async function main() {
|
|
|
24
24
|
let args;
|
|
25
25
|
try {
|
|
26
26
|
args = parseArgs({
|
|
27
|
-
"--project": String,
|
|
28
27
|
"--help": Boolean,
|
|
29
28
|
// Aliases
|
|
30
|
-
"-p": "--project",
|
|
31
29
|
"-h": "--help",
|
|
32
30
|
});
|
|
33
31
|
}
|
|
@@ -44,20 +42,13 @@ async function main() {
|
|
|
44
42
|
Usage: zshy [options]
|
|
45
43
|
|
|
46
44
|
Options:
|
|
47
|
-
-p, --project <path> Path to tsconfig.json file
|
|
48
45
|
-h, --help Show this help message
|
|
49
46
|
|
|
50
47
|
Examples:
|
|
51
|
-
zshy
|
|
52
|
-
zshy -p ./tsconfig.build.json # Use specific tsconfig file
|
|
53
|
-
zshy --project ./tsconfig.prod.json
|
|
48
|
+
zshy # Use ./tsconfig.json or package.json#zshy.tsconfig
|
|
54
49
|
`);
|
|
55
50
|
process.exit(0);
|
|
56
51
|
}
|
|
57
|
-
const projectPath = args["--project"];
|
|
58
|
-
if (projectPath) {
|
|
59
|
-
console.log(`⚙️ Using custom project path: ${projectPath}`);
|
|
60
|
-
}
|
|
61
52
|
///////////////////////////////////
|
|
62
53
|
/// find and read pkg json ///
|
|
63
54
|
///////////////////////////////////
|
|
@@ -128,12 +119,12 @@ Examples:
|
|
|
128
119
|
///////////////////////////
|
|
129
120
|
// Determine tsconfig.json path
|
|
130
121
|
let tsconfigPath;
|
|
131
|
-
if (
|
|
132
|
-
// Resolve the provided
|
|
133
|
-
const resolvedProjectPath = path.resolve(
|
|
122
|
+
if (config.tsconfig) {
|
|
123
|
+
// Resolve the provided tsconfig path against package.json directory
|
|
124
|
+
const resolvedProjectPath = path.resolve(pkgJsonDir, config.tsconfig);
|
|
134
125
|
if (fs.existsSync(resolvedProjectPath)) {
|
|
135
126
|
if (fs.statSync(resolvedProjectPath).isDirectory()) {
|
|
136
|
-
console.error(`❌
|
|
127
|
+
console.error(`❌ zshy.tsconfig must point to a tsconfig.json file, not a directory: ${resolvedProjectPath}`);
|
|
137
128
|
process.exit(1);
|
|
138
129
|
}
|
|
139
130
|
else {
|
|
@@ -142,7 +133,7 @@ Examples:
|
|
|
142
133
|
}
|
|
143
134
|
}
|
|
144
135
|
else {
|
|
145
|
-
console.error(`❌
|
|
136
|
+
console.error(`❌ Tsconfig file not found: ${resolvedProjectPath}`);
|
|
146
137
|
process.exit(1);
|
|
147
138
|
}
|
|
148
139
|
}
|
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
|
-
console.error("Error parsing tsconfig.json:");
|
|
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
|
-
console.error("Error parsing tsconfig.json:");
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zshy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Gold-standard build tool for TypeScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"sourceDialects": [
|
|
65
65
|
"@zod/source"
|
|
66
|
-
]
|
|
66
|
+
],
|
|
67
|
+
"tsconfig": "./tsconfig.build.json"
|
|
67
68
|
},
|
|
68
69
|
"main": "./out/index.cjs",
|
|
69
70
|
"types": "./out/index.d.cts",
|