sprint-es 0.0.95 ā 0.0.98
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/dist/cjs/cli.cjs +20 -2
- package/dist/esm/cli.js +21 -3
- package/package.json +1 -1
package/dist/cjs/cli.cjs
CHANGED
|
@@ -39,6 +39,10 @@ const logger = {
|
|
|
39
39
|
dim: (...args2) => console.log(pc.dim(args2.join(" "))),
|
|
40
40
|
break: () => console.log("")
|
|
41
41
|
};
|
|
42
|
+
function parseJsonc(content) {
|
|
43
|
+
const stripped = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "").replace(/,\s*([}\]])/g, "$1");
|
|
44
|
+
return JSON.parse(stripped);
|
|
45
|
+
}
|
|
42
46
|
if (!command) {
|
|
43
47
|
console.log("\nš Sprint CLI\n");
|
|
44
48
|
console.log("Usage: sprint-es <command>");
|
|
@@ -308,8 +312,22 @@ switch (command) {
|
|
|
308
312
|
console.log("š Building for production...");
|
|
309
313
|
const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
|
|
310
314
|
if (isTS) {
|
|
311
|
-
|
|
312
|
-
|
|
315
|
+
const tsconfigPath = path.join(projectRoot, "tsconfig.json");
|
|
316
|
+
const tsconfig = parseJsonc(fs.readFileSync(tsconfigPath, "utf-8"));
|
|
317
|
+
const originalInclude = tsconfig.include ?? [];
|
|
318
|
+
const patched = originalInclude.filter((p) => !p.includes("sprint.config"));
|
|
319
|
+
if (patched.length !== originalInclude.length) {
|
|
320
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify({ ...tsconfig, include: patched }, null, 4));
|
|
321
|
+
try {
|
|
322
|
+
runCommand("tsc && tsc-alias", { NODE_ENV: "production" });
|
|
323
|
+
} finally {
|
|
324
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
|
|
325
|
+
}
|
|
326
|
+
} else runCommand("tsc && tsc-alias", { NODE_ENV: "production" });
|
|
327
|
+
runCommand(
|
|
328
|
+
"esbuild sprint.config.ts --outfile=dist/sprint.config.js --platform=node --format=cjs --bundle=false",
|
|
329
|
+
{ NODE_ENV: "production" }
|
|
330
|
+
);
|
|
313
331
|
} else runCommand("tsc && tsc-alias", { NODE_ENV: "production" });
|
|
314
332
|
break;
|
|
315
333
|
}
|
package/dist/esm/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, readdirSync, statSync } from "fs";
|
|
3
3
|
import * as crypto from "crypto";
|
|
4
4
|
import { join, resolve } from "path";
|
|
5
5
|
import { spawn } from "child_process";
|
|
@@ -21,6 +21,10 @@ const logger = {
|
|
|
21
21
|
dim: (...args2) => console.log(pc.dim(args2.join(" "))),
|
|
22
22
|
break: () => console.log("")
|
|
23
23
|
};
|
|
24
|
+
function parseJsonc(content) {
|
|
25
|
+
const stripped = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "").replace(/,\s*([}\]])/g, "$1");
|
|
26
|
+
return JSON.parse(stripped);
|
|
27
|
+
}
|
|
24
28
|
if (!command) {
|
|
25
29
|
console.log("\nš Sprint CLI\n");
|
|
26
30
|
console.log("Usage: sprint-es <command>");
|
|
@@ -290,8 +294,22 @@ switch (command) {
|
|
|
290
294
|
console.log("š Building for production...");
|
|
291
295
|
const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
|
|
292
296
|
if (isTS) {
|
|
293
|
-
|
|
294
|
-
|
|
297
|
+
const tsconfigPath = join(projectRoot, "tsconfig.json");
|
|
298
|
+
const tsconfig = parseJsonc(readFileSync(tsconfigPath, "utf-8"));
|
|
299
|
+
const originalInclude = tsconfig.include ?? [];
|
|
300
|
+
const patched = originalInclude.filter((p) => !p.includes("sprint.config"));
|
|
301
|
+
if (patched.length !== originalInclude.length) {
|
|
302
|
+
writeFileSync(tsconfigPath, JSON.stringify({ ...tsconfig, include: patched }, null, 4));
|
|
303
|
+
try {
|
|
304
|
+
runCommand("tsc && tsc-alias", { NODE_ENV: "production" });
|
|
305
|
+
} finally {
|
|
306
|
+
writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
|
|
307
|
+
}
|
|
308
|
+
} else runCommand("tsc && tsc-alias", { NODE_ENV: "production" });
|
|
309
|
+
runCommand(
|
|
310
|
+
"esbuild sprint.config.ts --outfile=dist/sprint.config.js --platform=node --format=cjs --bundle=false",
|
|
311
|
+
{ NODE_ENV: "production" }
|
|
312
|
+
);
|
|
295
313
|
} else runCommand("tsc && tsc-alias", { NODE_ENV: "production" });
|
|
296
314
|
break;
|
|
297
315
|
}
|