sprint-es 0.0.122 → 0.0.124

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,43 +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
- if (!args2.importer) return null;
201
- return { path: args2.path, external: true };
202
- });
203
- }
204
- };
205
- await esbuild.build({
206
- entryPoints,
207
- outdir: distPath,
208
- outbase: srcPath,
209
- platform: "node",
210
- format: "cjs",
211
- bundle: true,
212
- sourcemap: true,
213
- plugins: [forceExternalPlugin]
214
- });
215
- }
216
178
  function generateJWTSecret() {
217
179
  const chars = crypto__namespace.randomBytes(24).toString("hex").split("");
218
180
  const positions = /* @__PURE__ */ new Set();
@@ -439,40 +401,25 @@ async function main() {
439
401
  console.log("🚀 Building for production...");
440
402
  const isTS = fs.existsSync(path.join(projectRoot, "sprint.config.ts"));
441
403
  const distPath = path.join(projectRoot, "dist");
442
- const srcPath = path.join(projectRoot, "src");
443
404
  const tsconfigPath = path.join(projectRoot, "tsconfig.json");
444
405
  console.log("[Sprint] Cleaning dist...");
445
406
  fs.rmSync(distPath, { recursive: true, force: true });
446
407
  console.log("[Sprint] dist cleaned ✓");
447
- const packageJson = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf-8"));
448
- const external = [
449
- ...Object.keys(packageJson.dependencies ?? {}),
450
- ...Object.keys(packageJson.devDependencies ?? {}),
451
- ...Object.keys(packageJson.optionalDependencies ?? {}),
452
- ...Object.keys(packageJson.peerDependencies ?? {})
453
- ];
454
- console.log("[Sprint] Compiling with esbuild...");
455
- await buildWithEsbuild(srcPath, distPath);
456
- 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}`);
457
410
  console.log("[Sprint] Type checking...");
458
411
  await runCommand(`tsc --project "${tsconfigPath}" --noEmit`, { NODE_ENV: "production" });
459
412
  console.log("[Sprint] Type check completed ✓");
460
- console.log("[Sprint] Resolving aliases...");
461
- const aliasConfigPath = path.join(projectRoot, "tsconfig.alias.json");
462
- fs.writeFileSync(aliasConfigPath, JSON.stringify({
463
- extends: "./tsconfig.json",
464
- compilerOptions: { outDir: "./dist", noEmit: false }
465
- }, null, 4));
466
- try {
467
- await runCommand(`tsc-alias --project "${aliasConfigPath}"`, { NODE_ENV: "production" });
468
- console.log("[Sprint] Aliases resolved ✓");
469
- } finally {
470
- fs.rmSync(aliasConfigPath, { force: true });
471
- }
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 ✓");
472
419
  if (isTS) {
473
420
  console.log("[Sprint] Compiling sprint.config.ts...");
474
421
  await runCommand(
475
- `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}"`,
476
423
  { NODE_ENV: "production" }
477
424
  );
478
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,43 +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
- if (!args2.importer) return null;
182
- return { path: args2.path, external: true };
183
- });
184
- }
185
- };
186
- await esbuild.build({
187
- entryPoints,
188
- outdir: distPath,
189
- outbase: srcPath,
190
- platform: "node",
191
- format: "cjs",
192
- bundle: true,
193
- sourcemap: true,
194
- plugins: [forceExternalPlugin]
195
- });
196
- }
197
159
  function generateJWTSecret() {
198
160
  const chars = crypto.randomBytes(24).toString("hex").split("");
199
161
  const positions = /* @__PURE__ */ new Set();
@@ -420,40 +382,25 @@ async function main() {
420
382
  console.log("🚀 Building for production...");
421
383
  const isTS = existsSync(join(projectRoot, "sprint.config.ts"));
422
384
  const distPath = join(projectRoot, "dist");
423
- const srcPath = join(projectRoot, "src");
424
385
  const tsconfigPath = join(projectRoot, "tsconfig.json");
425
386
  console.log("[Sprint] Cleaning dist...");
426
387
  rmSync(distPath, { recursive: true, force: true });
427
388
  console.log("[Sprint] dist cleaned ✓");
428
- const packageJson = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf-8"));
429
- const external = [
430
- ...Object.keys(packageJson.dependencies ?? {}),
431
- ...Object.keys(packageJson.devDependencies ?? {}),
432
- ...Object.keys(packageJson.optionalDependencies ?? {}),
433
- ...Object.keys(packageJson.peerDependencies ?? {})
434
- ];
435
- console.log("[Sprint] Compiling with esbuild...");
436
- await buildWithEsbuild(srcPath, distPath);
437
- 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}`);
438
391
  console.log("[Sprint] Type checking...");
439
392
  await runCommand(`tsc --project "${tsconfigPath}" --noEmit`, { NODE_ENV: "production" });
440
393
  console.log("[Sprint] Type check completed ✓");
441
- console.log("[Sprint] Resolving aliases...");
442
- const aliasConfigPath = join(projectRoot, "tsconfig.alias.json");
443
- writeFileSync(aliasConfigPath, JSON.stringify({
444
- extends: "./tsconfig.json",
445
- compilerOptions: { outDir: "./dist", noEmit: false }
446
- }, null, 4));
447
- try {
448
- await runCommand(`tsc-alias --project "${aliasConfigPath}"`, { NODE_ENV: "production" });
449
- console.log("[Sprint] Aliases resolved ✓");
450
- } finally {
451
- rmSync(aliasConfigPath, { force: true });
452
- }
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 ✓");
453
400
  if (isTS) {
454
401
  console.log("[Sprint] Compiling sprint.config.ts...");
455
402
  await runCommand(
456
- `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}"`,
457
404
  { NODE_ENV: "production" }
458
405
  );
459
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.122",
3
+ "version": "0.0.124",
4
4
  "description": "Sprint - Quickly API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",