sprint-es 0.0.133 → 0.0.134
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/index.cjs +14 -8
- package/dist/esm/index.js +14 -8
- package/dist/types/sprint.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -103,7 +103,7 @@ async function loadSprintConfig() {
|
|
|
103
103
|
const callerDir = process.cwd();
|
|
104
104
|
const projectRoot = await findProjectRoot(callerDir);
|
|
105
105
|
if (!projectRoot) return null;
|
|
106
|
-
const configFiles = isProd ? ["sprint.config.js", "dist/sprint.config.
|
|
106
|
+
const configFiles = isProd ? ["dist/sprint.config.js", "sprint.config.js", "dist/sprint.config.mjs"] : ["sprint.config.ts", "sprint.config.js"];
|
|
107
107
|
for (const configFile of configFiles) {
|
|
108
108
|
const configPath = path.join(projectRoot, configFile);
|
|
109
109
|
if (!fs.existsSync(configPath)) continue;
|
|
@@ -271,10 +271,16 @@ class Sprint {
|
|
|
271
271
|
}
|
|
272
272
|
async init() {
|
|
273
273
|
const callerDir = process.cwd();
|
|
274
|
-
console.log("CWD:", process.cwd());
|
|
275
274
|
const normalizePath = (p) => {
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
const clean = p.replace(/^\.\//, "");
|
|
276
|
+
if (isProd) {
|
|
277
|
+
if (clean.startsWith("dist/")) return clean;
|
|
278
|
+
const callerDir2 = process.cwd();
|
|
279
|
+
const isTsProject = fs.existsSync(path.join(callerDir2, "tsconfig.json")) || fs.existsSync(path.join(callerDir2, "sprint.config.ts"));
|
|
280
|
+
if (isTsProject && clean.startsWith("src/")) return clean.replace("src/", "dist/");
|
|
281
|
+
if (isTsProject && !clean.includes("/")) return path.join("dist", clean);
|
|
282
|
+
}
|
|
283
|
+
return clean;
|
|
278
284
|
};
|
|
279
285
|
const middlewaresCandidate = normalizePath(this.middlewaresPath);
|
|
280
286
|
const routesCandidate = normalizePath(this.routesPath);
|
|
@@ -370,7 +376,7 @@ class Sprint {
|
|
|
370
376
|
* Load all middleware files from the middlewares folder
|
|
371
377
|
*/
|
|
372
378
|
async loadMiddlewares(middlewaresPath) {
|
|
373
|
-
const fileExtensions = isProd ? [".
|
|
379
|
+
const fileExtensions = isProd ? [".mjs", ".js"] : [".ts"];
|
|
374
380
|
const files = await fs.promises.readdir(middlewaresPath);
|
|
375
381
|
for (const file of files) {
|
|
376
382
|
const filePath = path.join(middlewaresPath, file);
|
|
@@ -409,7 +415,7 @@ class Sprint {
|
|
|
409
415
|
});
|
|
410
416
|
}
|
|
411
417
|
async loadRoutes(routesPath) {
|
|
412
|
-
const fileExtensions = isProd ? [".
|
|
418
|
+
const fileExtensions = isProd ? [".mjs", ".js"] : [".ts"];
|
|
413
419
|
const walkDir = async (dir) => {
|
|
414
420
|
const files = await fs.promises.readdir(dir);
|
|
415
421
|
for (const file of files) {
|
|
@@ -422,7 +428,7 @@ class Sprint {
|
|
|
422
428
|
const module2 = await import(moduleUrl);
|
|
423
429
|
const router = module2.default || module2.router;
|
|
424
430
|
if (router && typeof router === "function" && router.stack && Array.isArray(router.stack)) {
|
|
425
|
-
let routePath = "/" + path.relative(routesPath, filePath).replace(/\.(ts|js)$/, "").replace(/\\/g, "/");
|
|
431
|
+
let routePath = "/" + path.relative(routesPath, filePath).replace(/\.(ts|js|mjs)$/, "").replace(/\\/g, "/");
|
|
426
432
|
routePath = stripRouteGroups(routePath);
|
|
427
433
|
if (routePath.endsWith("/index")) routePath = routePath.slice(0, -6) || "/";
|
|
428
434
|
const fullRoute = this.prefix + (routePath === "/" ? "" : routePath);
|
|
@@ -468,7 +474,7 @@ class Sprint {
|
|
|
468
474
|
await walkDir(routesPath);
|
|
469
475
|
}
|
|
470
476
|
async loadCronJobs(cronjobsPath) {
|
|
471
|
-
const fileExtensions = isProd ? [".
|
|
477
|
+
const fileExtensions = isProd ? [".mjs", ".js"] : [".ts"];
|
|
472
478
|
const files = await fs.promises.readdir(cronjobsPath);
|
|
473
479
|
for (const file of files) {
|
|
474
480
|
const filePath = path.join(cronjobsPath, file);
|
package/dist/esm/index.js
CHANGED
|
@@ -78,7 +78,7 @@ async function loadSprintConfig() {
|
|
|
78
78
|
const callerDir = process.cwd();
|
|
79
79
|
const projectRoot = await findProjectRoot(callerDir);
|
|
80
80
|
if (!projectRoot) return null;
|
|
81
|
-
const configFiles = isProd ? ["sprint.config.js", "dist/sprint.config.
|
|
81
|
+
const configFiles = isProd ? ["dist/sprint.config.js", "sprint.config.js", "dist/sprint.config.mjs"] : ["sprint.config.ts", "sprint.config.js"];
|
|
82
82
|
for (const configFile of configFiles) {
|
|
83
83
|
const configPath = path.join(projectRoot, configFile);
|
|
84
84
|
if (!fs.existsSync(configPath)) continue;
|
|
@@ -246,10 +246,16 @@ class Sprint {
|
|
|
246
246
|
}
|
|
247
247
|
async init() {
|
|
248
248
|
const callerDir = process.cwd();
|
|
249
|
-
console.log("CWD:", process.cwd());
|
|
250
249
|
const normalizePath = (p) => {
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
const clean = p.replace(/^\.\//, "");
|
|
251
|
+
if (isProd) {
|
|
252
|
+
if (clean.startsWith("dist/")) return clean;
|
|
253
|
+
const callerDir2 = process.cwd();
|
|
254
|
+
const isTsProject = fs.existsSync(path.join(callerDir2, "tsconfig.json")) || fs.existsSync(path.join(callerDir2, "sprint.config.ts"));
|
|
255
|
+
if (isTsProject && clean.startsWith("src/")) return clean.replace("src/", "dist/");
|
|
256
|
+
if (isTsProject && !clean.includes("/")) return path.join("dist", clean);
|
|
257
|
+
}
|
|
258
|
+
return clean;
|
|
253
259
|
};
|
|
254
260
|
const middlewaresCandidate = normalizePath(this.middlewaresPath);
|
|
255
261
|
const routesCandidate = normalizePath(this.routesPath);
|
|
@@ -345,7 +351,7 @@ class Sprint {
|
|
|
345
351
|
* Load all middleware files from the middlewares folder
|
|
346
352
|
*/
|
|
347
353
|
async loadMiddlewares(middlewaresPath) {
|
|
348
|
-
const fileExtensions = isProd ? [".
|
|
354
|
+
const fileExtensions = isProd ? [".mjs", ".js"] : [".ts"];
|
|
349
355
|
const files = await fs.promises.readdir(middlewaresPath);
|
|
350
356
|
for (const file of files) {
|
|
351
357
|
const filePath = path.join(middlewaresPath, file);
|
|
@@ -384,7 +390,7 @@ class Sprint {
|
|
|
384
390
|
});
|
|
385
391
|
}
|
|
386
392
|
async loadRoutes(routesPath) {
|
|
387
|
-
const fileExtensions = isProd ? [".
|
|
393
|
+
const fileExtensions = isProd ? [".mjs", ".js"] : [".ts"];
|
|
388
394
|
const walkDir = async (dir) => {
|
|
389
395
|
const files = await fs.promises.readdir(dir);
|
|
390
396
|
for (const file of files) {
|
|
@@ -397,7 +403,7 @@ class Sprint {
|
|
|
397
403
|
const module = await import(moduleUrl);
|
|
398
404
|
const router = module.default || module.router;
|
|
399
405
|
if (router && typeof router === "function" && router.stack && Array.isArray(router.stack)) {
|
|
400
|
-
let routePath = "/" + path.relative(routesPath, filePath).replace(/\.(ts|js)$/, "").replace(/\\/g, "/");
|
|
406
|
+
let routePath = "/" + path.relative(routesPath, filePath).replace(/\.(ts|js|mjs)$/, "").replace(/\\/g, "/");
|
|
401
407
|
routePath = stripRouteGroups(routePath);
|
|
402
408
|
if (routePath.endsWith("/index")) routePath = routePath.slice(0, -6) || "/";
|
|
403
409
|
const fullRoute = this.prefix + (routePath === "/" ? "" : routePath);
|
|
@@ -443,7 +449,7 @@ class Sprint {
|
|
|
443
449
|
await walkDir(routesPath);
|
|
444
450
|
}
|
|
445
451
|
async loadCronJobs(cronjobsPath) {
|
|
446
|
-
const fileExtensions = isProd ? [".
|
|
452
|
+
const fileExtensions = isProd ? [".mjs", ".js"] : [".ts"];
|
|
447
453
|
const files = await fs.promises.readdir(cronjobsPath);
|
|
448
454
|
for (const file of files) {
|
|
449
455
|
const filePath = path.join(cronjobsPath, file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint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