sprint-es 0.0.121 → 0.0.123

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
@@ -5,7 +5,6 @@ const fs = require("fs");
5
5
  const crypto = require("crypto");
6
6
  const path = require("path");
7
7
  const child_process = require("child_process");
8
- const module$1 = require("module");
9
8
  function _interopNamespaceDefault(e) {
10
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
11
10
  if (e) {
@@ -176,42 +175,6 @@ function runCommand(cmd, envVars) {
176
175
  });
177
176
  });
178
177
  }
179
- function collectEntryPoints(dir) {
180
- const entries = [];
181
- if (!fs.existsSync(dir)) return entries;
182
- for (const file of fs.readdirSync(dir)) {
183
- const fullPath = path.join(dir, file);
184
- if (fs.statSync(fullPath).isDirectory()) {
185
- entries.push(...collectEntryPoints(fullPath));
186
- } else if (file.endsWith(".ts") && !file.endsWith(".d.ts")) {
187
- entries.push(fullPath);
188
- }
189
- }
190
- return entries;
191
- }
192
- async function buildWithEsbuild(srcPath, distPath, external) {
193
- const requireFromProject = module$1.createRequire(path.join(projectRoot, "package.json"));
194
- const esbuild = requireFromProject("esbuild");
195
- const entryPoints = collectEntryPoints(srcPath);
196
- const forceExternalPlugin = {
197
- name: "force-external",
198
- setup(build) {
199
- build.onResolve({ filter: /^[^./]/ }, (args2) => {
200
- return { path: args2.path, external: true };
201
- });
202
- }
203
- };
204
- await esbuild.build({
205
- entryPoints,
206
- outdir: distPath,
207
- outbase: srcPath,
208
- platform: "node",
209
- format: "cjs",
210
- bundle: true,
211
- sourcemap: true,
212
- plugins: [forceExternalPlugin]
213
- });
214
- }
215
178
  function generateJWTSecret() {
216
179
  const chars = crypto__namespace.randomBytes(24).toString("hex").split("");
217
180
  const positions = /* @__PURE__ */ new Set();
@@ -438,40 +401,25 @@ async function main() {
438
401
  console.log("🚀 Building for production...");
439
402
  const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
440
403
  const distPath = path.join(projectRoot, "dist");
441
- const srcPath = path.join(projectRoot, "src");
442
404
  const tsconfigPath = path.join(projectRoot, "tsconfig.json");
443
405
  console.log("[Sprint] Cleaning dist...");
444
406
  fs.rmSync(distPath, { recursive: true, force: true });
445
407
  console.log("[Sprint] dist cleaned ✓");
446
- const packageJson = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf-8"));
447
- const external = [
448
- ...Object.keys(packageJson.dependencies ?? {}),
449
- ...Object.keys(packageJson.devDependencies ?? {}),
450
- ...Object.keys(packageJson.optionalDependencies ?? {}),
451
- ...Object.keys(packageJson.peerDependencies ?? {})
452
- ];
453
- console.log("[Sprint] Compiling with esbuild...");
454
- await buildWithEsbuild(srcPath, distPath);
455
- console.log("[Sprint] Compilation completed ✓");
408
+ const entryFile = fs.existsSync(path.join(projectRoot, "src/app.ts")) ? "src/app.ts" : fs.existsSync(path.join(projectRoot, "src/index.ts")) ? "src/index.ts" : fs.existsSync(path.join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
409
+ console.log(`[Sprint] Entry point: ${entryFile}`);
456
410
  console.log("[Sprint] Type checking...");
457
411
  await runCommand(`tsc --project "${tsconfigPath}" --noEmit`, { NODE_ENV: "production" });
458
412
  console.log("[Sprint] Type check completed ✓");
459
- console.log("[Sprint] Resolving aliases...");
460
- const aliasConfigPath = path.join(projectRoot, "tsconfig.alias.json");
461
- fs.writeFileSync(aliasConfigPath, JSON.stringify({
462
- extends: "./tsconfig.json",
463
- compilerOptions: { outDir: "./dist", noEmit: false }
464
- }, null, 4));
465
- try {
466
- await runCommand(`tsc-alias --project "${aliasConfigPath}"`, { NODE_ENV: "production" });
467
- console.log("[Sprint] Aliases resolved ✓");
468
- } finally {
469
- fs.rmSync(aliasConfigPath, { force: true });
470
- }
413
+ console.log("[Sprint] Compiling with tsup...");
414
+ await runCommand(
415
+ `tsup "${entryFile}" --outDir "${distPath}" --format cjs --target es2022 --sourcemap --clean --skipNodeModulesBundle --tsconfig "${tsconfigPath}"`,
416
+ { NODE_ENV: "production" }
417
+ );
418
+ console.log("[Sprint] Compilation completed ✓");
471
419
  if (isTS) {
472
420
  console.log("[Sprint] Compiling sprint.config.ts...");
473
421
  await runCommand(
474
- `esbuild "${path.join(projectRoot, "sprint.config.ts")}" --outfile="${path.join(projectRoot, "dist/sprint.config.js")}" --platform=node --format=cjs --bundle=true ${external.map((e) => `--external:${e}`).join(" ")}`,
422
+ `tsup sprint.config.ts --outDir "${distPath}" --format cjs --skipNodeModulesBundle --tsconfig "${tsconfigPath}"`,
475
423
  { NODE_ENV: "production" }
476
424
  );
477
425
  console.log("[Sprint] sprint.config.js generated ✓");
package/dist/esm/cli.js CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, rmSync, readFileSync, writeFileSync, readdirSync, statSync } from "fs";
2
+ import { existsSync, rmSync, readFileSync, readdirSync, statSync } from "fs";
3
3
  import * as crypto from "crypto";
4
4
  import { resolve, join } from "path";
5
5
  import { spawn } from "child_process";
6
- import { createRequire } from "module";
7
6
  const args = process.argv.slice(2);
8
7
  const command = args[0];
9
8
  const pc = {
@@ -157,42 +156,6 @@ function runCommand(cmd, envVars) {
157
156
  });
158
157
  });
159
158
  }
160
- function collectEntryPoints(dir) {
161
- const entries = [];
162
- if (!existsSync(dir)) return entries;
163
- for (const file of readdirSync(dir)) {
164
- const fullPath = join(dir, file);
165
- if (statSync(fullPath).isDirectory()) {
166
- entries.push(...collectEntryPoints(fullPath));
167
- } else if (file.endsWith(".ts") && !file.endsWith(".d.ts")) {
168
- entries.push(fullPath);
169
- }
170
- }
171
- return entries;
172
- }
173
- async function buildWithEsbuild(srcPath, distPath, external) {
174
- const requireFromProject = createRequire(join(projectRoot, "package.json"));
175
- const esbuild = requireFromProject("esbuild");
176
- const entryPoints = collectEntryPoints(srcPath);
177
- const forceExternalPlugin = {
178
- name: "force-external",
179
- setup(build) {
180
- build.onResolve({ filter: /^[^./]/ }, (args2) => {
181
- return { path: args2.path, external: true };
182
- });
183
- }
184
- };
185
- await esbuild.build({
186
- entryPoints,
187
- outdir: distPath,
188
- outbase: srcPath,
189
- platform: "node",
190
- format: "cjs",
191
- bundle: true,
192
- sourcemap: true,
193
- plugins: [forceExternalPlugin]
194
- });
195
- }
196
159
  function generateJWTSecret() {
197
160
  const chars = crypto.randomBytes(24).toString("hex").split("");
198
161
  const positions = /* @__PURE__ */ new Set();
@@ -419,40 +382,25 @@ async function main() {
419
382
  console.log("🚀 Building for production...");
420
383
  const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
421
384
  const distPath = join(projectRoot, "dist");
422
- const srcPath = join(projectRoot, "src");
423
385
  const tsconfigPath = join(projectRoot, "tsconfig.json");
424
386
  console.log("[Sprint] Cleaning dist...");
425
387
  rmSync(distPath, { recursive: true, force: true });
426
388
  console.log("[Sprint] dist cleaned ✓");
427
- const packageJson = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf-8"));
428
- const external = [
429
- ...Object.keys(packageJson.dependencies ?? {}),
430
- ...Object.keys(packageJson.devDependencies ?? {}),
431
- ...Object.keys(packageJson.optionalDependencies ?? {}),
432
- ...Object.keys(packageJson.peerDependencies ?? {})
433
- ];
434
- console.log("[Sprint] Compiling with esbuild...");
435
- await buildWithEsbuild(srcPath, distPath);
436
- console.log("[Sprint] Compilation completed ✓");
389
+ const entryFile = existsSync(join(projectRoot, "src/app.ts")) ? "src/app.ts" : existsSync(join(projectRoot, "src/index.ts")) ? "src/index.ts" : existsSync(join(projectRoot, "src/app.js")) ? "src/app.js" : "src/index.js";
390
+ console.log(`[Sprint] Entry point: ${entryFile}`);
437
391
  console.log("[Sprint] Type checking...");
438
392
  await runCommand(`tsc --project "${tsconfigPath}" --noEmit`, { NODE_ENV: "production" });
439
393
  console.log("[Sprint] Type check completed ✓");
440
- console.log("[Sprint] Resolving aliases...");
441
- const aliasConfigPath = join(projectRoot, "tsconfig.alias.json");
442
- writeFileSync(aliasConfigPath, JSON.stringify({
443
- extends: "./tsconfig.json",
444
- compilerOptions: { outDir: "./dist", noEmit: false }
445
- }, null, 4));
446
- try {
447
- await runCommand(`tsc-alias --project "${aliasConfigPath}"`, { NODE_ENV: "production" });
448
- console.log("[Sprint] Aliases resolved ✓");
449
- } finally {
450
- rmSync(aliasConfigPath, { force: true });
451
- }
394
+ console.log("[Sprint] Compiling with tsup...");
395
+ await runCommand(
396
+ `tsup "${entryFile}" --outDir "${distPath}" --format cjs --target es2022 --sourcemap --clean --skipNodeModulesBundle --tsconfig "${tsconfigPath}"`,
397
+ { NODE_ENV: "production" }
398
+ );
399
+ console.log("[Sprint] Compilation completed ✓");
452
400
  if (isTS) {
453
401
  console.log("[Sprint] Compiling sprint.config.ts...");
454
402
  await runCommand(
455
- `esbuild "${join(projectRoot, "sprint.config.ts")}" --outfile="${join(projectRoot, "dist/sprint.config.js")}" --platform=node --format=cjs --bundle=true ${external.map((e) => `--external:${e}`).join(" ")}`,
403
+ `tsup sprint.config.ts --outDir "${distPath}" --format cjs --skipNodeModulesBundle --tsconfig "${tsconfigPath}"`,
456
404
  { NODE_ENV: "production" }
457
405
  );
458
406
  console.log("[Sprint] sprint.config.js generated ✓");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprint-es",
3
- "version": "0.0.121",
3
+ "version": "0.0.123",
4
4
  "description": "Sprint - Quickly API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",