sprint-es 0.0.93 → 0.0.94

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.
@@ -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", "sprint.config.ts"] : ["sprint.config.ts", "sprint.config.js"];
106
+ const configFiles = isProd ? ["sprint.config.js", "dist/sprint.config.js"] : ["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,27 +271,32 @@ class Sprint {
271
271
  }
272
272
  async init() {
273
273
  const callerDir = process.cwd();
274
- const basePath = isProd ? "dist" : "src";
275
- path.join(callerDir, basePath, "middlewares");
276
- path.join(callerDir, basePath, "routes");
277
- path.join(callerDir, basePath, "cronjobs");
274
+ const normalizePath = (p) => {
275
+ if (path.isAbsolute(p)) return p;
276
+ return isProd ? p.replace(/\bsrc\b/, "dist") : p.replace(/\bdist\b/, "src");
277
+ };
278
+ const middlewaresCandidate = normalizePath(this.middlewaresPath);
279
+ const routesCandidate = normalizePath(this.routesPath);
280
+ const cronjobsCandidate = normalizePath(this.cronjobsPath);
281
+ const resolve = (p) => path.isAbsolute(p) ? p : path.join(callerDir, p);
278
282
  try {
279
- const middlewaresCandidate = path.isAbsolute(this.middlewaresPath) ? this.middlewaresPath : path.join(callerDir, this.middlewaresPath.replace("./src/", `./${basePath}/`).replace("./dist/", `./${basePath}/`));
280
- if (fs.existsSync(middlewaresCandidate) && fs.statSync(middlewaresCandidate).isDirectory()) await this.loadMiddlewares(middlewaresCandidate);
281
- else if (isVerbose) console.log(`[Sprint] Middlewares folder not found at: ${middlewaresCandidate}, skipping.`);
283
+ const fullPath = resolve(middlewaresCandidate);
284
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) await this.loadMiddlewares(fullPath);
285
+ else if (isVerbose) console.log(`[Sprint] Middlewares folder not found at: ${fullPath}, skipping.`);
282
286
  } catch (err) {
283
287
  console.error("[Sprint] Failed to load middlewares:", err);
284
288
  }
285
289
  try {
286
- const routesCandidate = path.isAbsolute(this.routesPath) ? this.routesPath : path.join(callerDir, this.routesPath.replace("./src/", `./${basePath}/`).replace("./dist/", `./${basePath}/`));
287
- if (fs.existsSync(routesCandidate) && fs.statSync(routesCandidate).isDirectory()) await this.loadRoutes(routesCandidate);
290
+ const fullPath = resolve(routesCandidate);
291
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) await this.loadRoutes(fullPath);
292
+ else console.warn(`[Sprint] Routes folder not found at: ${fullPath}`);
288
293
  } catch (err) {
289
294
  console.error("[Sprint] Failed to load routes:", err);
290
295
  }
291
296
  try {
292
- const cronjobsCandidate = path.isAbsolute(this.cronjobsPath) ? this.cronjobsPath : path.join(callerDir, this.cronjobsPath.replace("./src/", `./${basePath}/`).replace("./dist/", `./${basePath}/`));
293
- if (fs.existsSync(cronjobsCandidate) && fs.statSync(cronjobsCandidate).isDirectory()) await this.loadCronJobs(cronjobsCandidate);
294
- else if (isVerbose) console.log(`[Sprint] Cronjobs folder not found at: ${cronjobsCandidate}, skipping.`);
297
+ const fullPath = resolve(cronjobsCandidate);
298
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) await this.loadCronJobs(fullPath);
299
+ else if (isVerbose) console.log(`[Sprint] Cronjobs folder not found at: ${fullPath}, skipping.`);
295
300
  } catch (err) {
296
301
  console.error("[Sprint] Failed to load cronjobs:", err);
297
302
  }
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", "sprint.config.ts"] : ["sprint.config.ts", "sprint.config.js"];
81
+ const configFiles = isProd ? ["sprint.config.js", "dist/sprint.config.js"] : ["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,27 +246,32 @@ class Sprint {
246
246
  }
247
247
  async init() {
248
248
  const callerDir = process.cwd();
249
- const basePath = isProd ? "dist" : "src";
250
- path.join(callerDir, basePath, "middlewares");
251
- path.join(callerDir, basePath, "routes");
252
- path.join(callerDir, basePath, "cronjobs");
249
+ const normalizePath = (p) => {
250
+ if (path.isAbsolute(p)) return p;
251
+ return isProd ? p.replace(/\bsrc\b/, "dist") : p.replace(/\bdist\b/, "src");
252
+ };
253
+ const middlewaresCandidate = normalizePath(this.middlewaresPath);
254
+ const routesCandidate = normalizePath(this.routesPath);
255
+ const cronjobsCandidate = normalizePath(this.cronjobsPath);
256
+ const resolve = (p) => path.isAbsolute(p) ? p : path.join(callerDir, p);
253
257
  try {
254
- const middlewaresCandidate = path.isAbsolute(this.middlewaresPath) ? this.middlewaresPath : path.join(callerDir, this.middlewaresPath.replace("./src/", `./${basePath}/`).replace("./dist/", `./${basePath}/`));
255
- if (fs.existsSync(middlewaresCandidate) && fs.statSync(middlewaresCandidate).isDirectory()) await this.loadMiddlewares(middlewaresCandidate);
256
- else if (isVerbose) console.log(`[Sprint] Middlewares folder not found at: ${middlewaresCandidate}, skipping.`);
258
+ const fullPath = resolve(middlewaresCandidate);
259
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) await this.loadMiddlewares(fullPath);
260
+ else if (isVerbose) console.log(`[Sprint] Middlewares folder not found at: ${fullPath}, skipping.`);
257
261
  } catch (err) {
258
262
  console.error("[Sprint] Failed to load middlewares:", err);
259
263
  }
260
264
  try {
261
- const routesCandidate = path.isAbsolute(this.routesPath) ? this.routesPath : path.join(callerDir, this.routesPath.replace("./src/", `./${basePath}/`).replace("./dist/", `./${basePath}/`));
262
- if (fs.existsSync(routesCandidate) && fs.statSync(routesCandidate).isDirectory()) await this.loadRoutes(routesCandidate);
265
+ const fullPath = resolve(routesCandidate);
266
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) await this.loadRoutes(fullPath);
267
+ else console.warn(`[Sprint] Routes folder not found at: ${fullPath}`);
263
268
  } catch (err) {
264
269
  console.error("[Sprint] Failed to load routes:", err);
265
270
  }
266
271
  try {
267
- const cronjobsCandidate = path.isAbsolute(this.cronjobsPath) ? this.cronjobsPath : path.join(callerDir, this.cronjobsPath.replace("./src/", `./${basePath}/`).replace("./dist/", `./${basePath}/`));
268
- if (fs.existsSync(cronjobsCandidate) && fs.statSync(cronjobsCandidate).isDirectory()) await this.loadCronJobs(cronjobsCandidate);
269
- else if (isVerbose) console.log(`[Sprint] Cronjobs folder not found at: ${cronjobsCandidate}, skipping.`);
272
+ const fullPath = resolve(cronjobsCandidate);
273
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) await this.loadCronJobs(fullPath);
274
+ else if (isVerbose) console.log(`[Sprint] Cronjobs folder not found at: ${fullPath}, skipping.`);
270
275
  } catch (err) {
271
276
  console.error("[Sprint] Failed to load cronjobs:", err);
272
277
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAA+B,gBAAgB,EAAoB,MAAM,SAAS,CAAC;AACnG,OAAO,OAAO,EAAE,EAAE,WAAW,EAAoD,MAAM,SAAS,CAAC;AAejG,eAAO,MAAM,aAAa,SAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;AAoDnC,qBAAa,MAAM;IACR,GAAG,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,IAAI,CAAwD;IACpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,S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,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACrC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACpC,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,EAAE,YAAY,CAAC,EAAE,OAAO;IAY9E,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAIvC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;CA8DzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprint-es",
3
- "version": "0.0.93",
3
+ "version": "0.0.94",
4
4
  "description": "Sprint - Quickly API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",