sprint-es 0.0.102 → 0.0.105

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