sprint-es 0.0.102 → 0.0.104

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 CHANGED
@@ -162,14 +162,17 @@ function getProjectRoot() {
162
162
  }
163
163
  const projectRoot = getProjectRoot();
164
164
  function runCommand(cmd, envVars) {
165
- const child = child_process.spawn(cmd, [], {
166
- cwd: projectRoot,
167
- stdio: "inherit",
168
- shell: true,
169
- env: { ...process.env, ...envVars }
170
- });
171
- child.on("exit", (code) => {
172
- process.exit(code || 0);
165
+ return new Promise((resolve2, reject) => {
166
+ const child = child_process.spawn(cmd, [], {
167
+ cwd: projectRoot,
168
+ stdio: "inherit",
169
+ shell: true,
170
+ env: { ...process.env, ...envVars }
171
+ });
172
+ child.on("exit", (code) => {
173
+ if (code === 0 || code === null) resolve2();
174
+ else reject(new Error(`Command failed with exit code ${code}`));
175
+ });
173
176
  });
174
177
  }
175
178
  function generateJWTSecret() {
@@ -384,66 +387,72 @@ async function runDoctor() {
384
387
  }
385
388
  logger.break();
386
389
  }
387
- switch (command) {
388
- case "dev": {
389
- console.log("šŸš€ Starting development server with hot reload...");
390
- const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
391
- const srcFile = isTS ? fs.existsSync(path.join(projectRoot, "src/app.ts")) ? "src/app.ts" : "src/index.ts" : fs.existsSync(path.join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
392
- const devCmd = isTS ? `tsx --watch ${srcFile}` : `node --watch ${srcFile}`;
393
- runCommand(devCmd, { NODE_ENV: "development" });
394
- break;
395
- }
396
- case "build": {
397
- console.log("šŸš€ Building for production...");
398
- const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
399
- const buildCmd = "tsc && tsc-esm-fix --src=dist --ext=.js && tsc-alias";
400
- if (isTS) {
401
- const tsconfigPath = path.join(projectRoot, "tsconfig.json");
402
- const tsconfig = JSON.parse(stripJsonComments(fs.readFileSync(tsconfigPath, "utf-8")));
403
- const originalInclude = tsconfig.include ?? [];
404
- const patched = originalInclude.filter((p) => !p.includes("sprint.config"));
405
- if (patched.length !== originalInclude.length) {
406
- fs.writeFileSync(tsconfigPath, JSON.stringify({ ...tsconfig, include: patched }, null, 4));
407
- try {
408
- runCommand(buildCmd, { NODE_ENV: "production" });
409
- } finally {
410
- fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
411
- }
412
- } else runCommand(buildCmd, { NODE_ENV: "production" });
413
- runCommand(
414
- "esbuild sprint.config.ts --outfile=dist/sprint.config.js --platform=node --format=esm --bundle=false",
415
- { NODE_ENV: "production" }
416
- );
417
- } else runCommand(buildCmd, { NODE_ENV: "production" });
418
- break;
419
- }
420
- case "start": {
421
- console.log("šŸš€ Starting production server...");
422
- const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
423
- const entryFile = isTS ? fs.existsSync(path.join(projectRoot, "dist/app.js")) ? "dist/app.js" : "dist/index.js" : fs.existsSync(path.join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
424
- runCommand(`node ${entryFile}`, { NODE_ENV: "production" });
425
- break;
426
- }
427
- case "doctor":
428
- runDoctor();
429
- break;
430
- case "generate-keys": {
431
- const { publicKey, privateKey } = crypto__namespace.generateKeyPairSync("rsa", {
432
- modulusLength: 2048,
433
- publicKeyEncoding: { type: "spki", format: "pem" },
434
- privateKeyEncoding: { type: "pkcs8", format: "pem" }
435
- });
436
- console.log("\nšŸ”‘ Generating JWT keys...\n");
437
- console.log("JWT_PUBLIC_KEY='" + publicKey + "'");
438
- console.log("\nJWT_PRIVATE_KEY='" + privateKey + "'");
439
- console.log("\nJWT_ENCRYPTION_SECRET=" + generateJWTSecret());
440
- console.log("\nšŸ“ Add these to your .env file (use single quotes for multiline values):\n");
441
- process.exit(0);
442
- break;
390
+ async function main() {
391
+ switch (command) {
392
+ case "dev": {
393
+ console.log("šŸš€ Starting development server with hot reload...");
394
+ const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
395
+ const srcFile = isTS ? fs.existsSync(path.join(projectRoot, "src/app.ts")) ? "src/app.ts" : "src/index.ts" : fs.existsSync(path.join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
396
+ const devCmd = isTS ? `tsx --watch ${srcFile}` : `node --watch ${srcFile}`;
397
+ await runCommand(devCmd, { NODE_ENV: "development" });
398
+ break;
399
+ }
400
+ case "build": {
401
+ console.log("šŸš€ Building for production...");
402
+ const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
403
+ const buildCmd = "tsc && tsc-esm-fix --src=dist --ext=.js && tsc-alias";
404
+ if (isTS) {
405
+ const tsconfigPath = path.join(projectRoot, "tsconfig.json");
406
+ const tsconfig = JSON.parse(stripJsonComments(fs.readFileSync(tsconfigPath, "utf-8")));
407
+ const originalInclude = tsconfig.include ?? [];
408
+ const patched = originalInclude.filter((p) => !p.includes("sprint.config"));
409
+ if (patched.length !== originalInclude.length) {
410
+ fs.writeFileSync(tsconfigPath, JSON.stringify({ ...tsconfig, include: patched }, null, 4));
411
+ try {
412
+ await runCommand(buildCmd, { NODE_ENV: "production" });
413
+ } finally {
414
+ fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
415
+ }
416
+ } else await runCommand(buildCmd, { NODE_ENV: "production" });
417
+ await runCommand(
418
+ "esbuild sprint.config.ts --outfile=dist/sprint.config.js --platform=node --format=esm --bundle=false",
419
+ { NODE_ENV: "production" }
420
+ );
421
+ } else await runCommand(buildCmd, { NODE_ENV: "production" });
422
+ break;
423
+ }
424
+ case "start": {
425
+ console.log("šŸš€ Starting production server...");
426
+ const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
427
+ const entryFile = isTS ? fs.existsSync(path.join(projectRoot, "dist/app.js")) ? "dist/app.js" : "dist/index.js" : fs.existsSync(path.join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
428
+ await runCommand(`node ${entryFile}`, { NODE_ENV: "production" });
429
+ break;
430
+ }
431
+ case "doctor":
432
+ runDoctor();
433
+ break;
434
+ case "generate-keys": {
435
+ const { publicKey, privateKey } = crypto__namespace.generateKeyPairSync("rsa", {
436
+ modulusLength: 2048,
437
+ publicKeyEncoding: { type: "spki", format: "pem" },
438
+ privateKeyEncoding: { type: "pkcs8", format: "pem" }
439
+ });
440
+ console.log("\nšŸ”‘ Generating JWT keys...\n");
441
+ console.log("JWT_PUBLIC_KEY='" + publicKey + "'");
442
+ console.log("\nJWT_PRIVATE_KEY='" + privateKey + "'");
443
+ console.log("\nJWT_ENCRYPTION_SECRET=" + generateJWTSecret());
444
+ console.log("\nšŸ“ Add these to your .env file (use single quotes for multiline values):\n");
445
+ process.exit(0);
446
+ break;
447
+ }
448
+ default:
449
+ console.error(`Unknown command: ${command}`);
450
+ console.log("Use --help for usage information");
451
+ process.exit(1);
443
452
  }
444
- default:
445
- console.error(`Unknown command: ${command}`);
446
- console.log("Use --help for usage information");
447
- process.exit(1);
448
453
  }
454
+ main().catch((err) => {
455
+ console.error(err);
456
+ process.exit(1);
457
+ });
449
458
  exports.default = stripJsonComments;
package/dist/esm/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, readFileSync, writeFileSync, readdirSync, statSync } from "fs";
3
3
  import * as crypto from "crypto";
4
- import { join, resolve } from "path";
4
+ import { resolve, join } from "path";
5
5
  import { spawn } from "child_process";
6
6
  const args = process.argv.slice(2);
7
7
  const command = args[0];
@@ -143,14 +143,17 @@ function getProjectRoot() {
143
143
  }
144
144
  const projectRoot = getProjectRoot();
145
145
  function runCommand(cmd, envVars) {
146
- const child = spawn(cmd, [], {
147
- cwd: projectRoot,
148
- stdio: "inherit",
149
- shell: true,
150
- env: { ...process.env, ...envVars }
151
- });
152
- child.on("exit", (code) => {
153
- process.exit(code || 0);
146
+ return new Promise((resolve2, reject) => {
147
+ const child = spawn(cmd, [], {
148
+ cwd: projectRoot,
149
+ stdio: "inherit",
150
+ shell: true,
151
+ env: { ...process.env, ...envVars }
152
+ });
153
+ child.on("exit", (code) => {
154
+ if (code === 0 || code === null) resolve2();
155
+ else reject(new Error(`Command failed with exit code ${code}`));
156
+ });
154
157
  });
155
158
  }
156
159
  function generateJWTSecret() {
@@ -365,68 +368,74 @@ async function runDoctor() {
365
368
  }
366
369
  logger.break();
367
370
  }
368
- switch (command) {
369
- case "dev": {
370
- console.log("šŸš€ Starting development server with hot reload...");
371
- const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
372
- const srcFile = isTS ? existsSync(join(projectRoot, "src/app.ts")) ? "src/app.ts" : "src/index.ts" : existsSync(join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
373
- const devCmd = isTS ? `tsx --watch ${srcFile}` : `node --watch ${srcFile}`;
374
- runCommand(devCmd, { NODE_ENV: "development" });
375
- break;
376
- }
377
- case "build": {
378
- console.log("šŸš€ Building for production...");
379
- const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
380
- const buildCmd = "tsc && tsc-esm-fix --src=dist --ext=.js && tsc-alias";
381
- if (isTS) {
382
- const tsconfigPath = join(projectRoot, "tsconfig.json");
383
- const tsconfig = JSON.parse(stripJsonComments(readFileSync(tsconfigPath, "utf-8")));
384
- const originalInclude = tsconfig.include ?? [];
385
- const patched = originalInclude.filter((p) => !p.includes("sprint.config"));
386
- if (patched.length !== originalInclude.length) {
387
- writeFileSync(tsconfigPath, JSON.stringify({ ...tsconfig, include: patched }, null, 4));
388
- try {
389
- runCommand(buildCmd, { NODE_ENV: "production" });
390
- } finally {
391
- writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
392
- }
393
- } else runCommand(buildCmd, { NODE_ENV: "production" });
394
- runCommand(
395
- "esbuild sprint.config.ts --outfile=dist/sprint.config.js --platform=node --format=esm --bundle=false",
396
- { NODE_ENV: "production" }
397
- );
398
- } else runCommand(buildCmd, { NODE_ENV: "production" });
399
- break;
400
- }
401
- case "start": {
402
- console.log("šŸš€ Starting production server...");
403
- const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
404
- const entryFile = isTS ? existsSync(join(projectRoot, "dist/app.js")) ? "dist/app.js" : "dist/index.js" : existsSync(join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
405
- runCommand(`node ${entryFile}`, { NODE_ENV: "production" });
406
- break;
407
- }
408
- case "doctor":
409
- runDoctor();
410
- break;
411
- case "generate-keys": {
412
- const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
413
- modulusLength: 2048,
414
- publicKeyEncoding: { type: "spki", format: "pem" },
415
- privateKeyEncoding: { type: "pkcs8", format: "pem" }
416
- });
417
- console.log("\nšŸ”‘ Generating JWT keys...\n");
418
- console.log("JWT_PUBLIC_KEY='" + publicKey + "'");
419
- console.log("\nJWT_PRIVATE_KEY='" + privateKey + "'");
420
- console.log("\nJWT_ENCRYPTION_SECRET=" + generateJWTSecret());
421
- console.log("\nšŸ“ Add these to your .env file (use single quotes for multiline values):\n");
422
- process.exit(0);
423
- break;
371
+ async function main() {
372
+ switch (command) {
373
+ case "dev": {
374
+ console.log("šŸš€ Starting development server with hot reload...");
375
+ const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
376
+ const srcFile = isTS ? existsSync(join(projectRoot, "src/app.ts")) ? "src/app.ts" : "src/index.ts" : existsSync(join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
377
+ const devCmd = isTS ? `tsx --watch ${srcFile}` : `node --watch ${srcFile}`;
378
+ await runCommand(devCmd, { NODE_ENV: "development" });
379
+ break;
380
+ }
381
+ case "build": {
382
+ console.log("šŸš€ Building for production...");
383
+ const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
384
+ const buildCmd = "tsc && tsc-esm-fix --src=dist --ext=.js && tsc-alias";
385
+ if (isTS) {
386
+ const tsconfigPath = join(projectRoot, "tsconfig.json");
387
+ const tsconfig = JSON.parse(stripJsonComments(readFileSync(tsconfigPath, "utf-8")));
388
+ const originalInclude = tsconfig.include ?? [];
389
+ const patched = originalInclude.filter((p) => !p.includes("sprint.config"));
390
+ if (patched.length !== originalInclude.length) {
391
+ writeFileSync(tsconfigPath, JSON.stringify({ ...tsconfig, include: patched }, null, 4));
392
+ try {
393
+ await runCommand(buildCmd, { NODE_ENV: "production" });
394
+ } finally {
395
+ writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
396
+ }
397
+ } else await runCommand(buildCmd, { NODE_ENV: "production" });
398
+ await runCommand(
399
+ "esbuild sprint.config.ts --outfile=dist/sprint.config.js --platform=node --format=esm --bundle=false",
400
+ { NODE_ENV: "production" }
401
+ );
402
+ } else await runCommand(buildCmd, { NODE_ENV: "production" });
403
+ break;
404
+ }
405
+ case "start": {
406
+ console.log("šŸš€ Starting production server...");
407
+ const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
408
+ const entryFile = isTS ? existsSync(join(projectRoot, "dist/app.js")) ? "dist/app.js" : "dist/index.js" : existsSync(join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
409
+ await runCommand(`node ${entryFile}`, { NODE_ENV: "production" });
410
+ break;
411
+ }
412
+ case "doctor":
413
+ runDoctor();
414
+ break;
415
+ case "generate-keys": {
416
+ const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
417
+ modulusLength: 2048,
418
+ publicKeyEncoding: { type: "spki", format: "pem" },
419
+ privateKeyEncoding: { type: "pkcs8", format: "pem" }
420
+ });
421
+ console.log("\nšŸ”‘ Generating JWT keys...\n");
422
+ console.log("JWT_PUBLIC_KEY='" + publicKey + "'");
423
+ console.log("\nJWT_PRIVATE_KEY='" + privateKey + "'");
424
+ console.log("\nJWT_ENCRYPTION_SECRET=" + generateJWTSecret());
425
+ console.log("\nšŸ“ Add these to your .env file (use single quotes for multiline values):\n");
426
+ process.exit(0);
427
+ break;
428
+ }
429
+ default:
430
+ console.error(`Unknown command: ${command}`);
431
+ console.log("Use --help for usage information");
432
+ process.exit(1);
424
433
  }
425
- default:
426
- console.error(`Unknown command: ${command}`);
427
- console.log("Use --help for usage information");
428
- process.exit(1);
429
434
  }
435
+ main().catch((err) => {
436
+ console.error(err);
437
+ process.exit(1);
438
+ });
430
439
  export {
431
440
  stripJsonComments as default
432
441
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprint-es",
3
- "version": "0.0.102",
3
+ "version": "0.0.104",
4
4
  "description": "Sprint - Quickly API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",