@stacksjs/path 0.58.71 → 0.58.73

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/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // @bun
2
2
  // src/index.ts
3
3
  import process from "process";
4
+ import os from "os";
4
5
  import {basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath} from "pathe";
5
6
  function actionsPath(path) {
6
7
  return corePath(`actions/src/${path || ""}`);
@@ -249,7 +250,10 @@ function queuePath(path) {
249
250
  function realtimePath(path) {
250
251
  return corePath(`realtime/${path || ""}`);
251
252
  }
252
- function resourcesPath(path) {
253
+ function resourcesPath(path, options) {
254
+ const absolutePath = projectStoragePath(`resources/${path || ""}`);
255
+ if (options?.relative)
256
+ return relative(process.cwd(), absolutePath);
253
257
  return projectPath(`resources/${path || ""}`);
254
258
  }
255
259
  function replPath(path) {
@@ -258,7 +262,10 @@ function replPath(path) {
258
262
  function routerPath(path) {
259
263
  return corePath(`router/${path || ""}`);
260
264
  }
261
- function routesPath(path) {
265
+ function routesPath(path, options) {
266
+ const absolutePath = resourcesPath(`routes/${path || ""}`);
267
+ if (options?.relative)
268
+ return relative(process.cwd(), absolutePath);
262
269
  return projectPath(`routes/${path || ""}`);
263
270
  }
264
271
  function searchEnginePath(path) {
@@ -300,6 +307,9 @@ function serverlessPath(path) {
300
307
  function stacksPath(path) {
301
308
  return frameworkPath(`src/${path || ""}`);
302
309
  }
310
+ function shellPath(path) {
311
+ return corePath(`shell/${path || ""}`);
312
+ }
303
313
  function stringsPath(path) {
304
314
  return corePath(`strings/${path || ""}`);
305
315
  }
@@ -330,6 +340,9 @@ function vitePath(path) {
330
340
  function xRayPath(path) {
331
341
  return frameworkPath(`stacks/x-ray/${path || ""}`);
332
342
  }
343
+ function homeDir(path) {
344
+ return os.homedir() + (path ? (path.startsWith("/") ? "" : "/") + path : "~");
345
+ }
333
346
  var path = {
334
347
  actionsPath,
335
348
  userActionsPath,
@@ -416,6 +429,7 @@ var path = {
416
429
  serverlessPath,
417
430
  stacksPath,
418
431
  stringsPath,
432
+ shellPath,
419
433
  storesPath,
420
434
  testingPath,
421
435
  testsPath,
@@ -432,6 +446,7 @@ var path = {
432
446
  validationPath,
433
447
  vitePath,
434
448
  xRayPath,
449
+ homeDir,
435
450
  basename,
436
451
  delimiter,
437
452
  dirname,
@@ -473,6 +488,7 @@ export {
473
488
  smsPath,
474
489
  slugPath,
475
490
  signalsPath,
491
+ shellPath,
476
492
  settingsPath,
477
493
  serverlessPath,
478
494
  serverPath,
@@ -522,6 +538,7 @@ export {
522
538
  join,
523
539
  jobsPath,
524
540
  isAbsolute,
541
+ homeDir,
525
542
  healthPath,
526
543
  gitPath,
527
544
  functionsPath,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/path",
3
3
  "type": "module",
4
- "version": "0.58.71",
4
+ "version": "0.58.73",
5
5
  "description": "The Stacks path.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import process from 'node:process'
2
+ import os from 'node:os'
2
3
  import { basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath } from 'pathe'
3
4
 
4
5
  /**
@@ -259,6 +260,7 @@ export function langPath(path?: string) {
259
260
 
260
261
  export function layoutsPath(path?: string, options?: { relative?: boolean }) {
261
262
  const absolutePath = resourcesPath(`layouts/${path || ''}`)
263
+
262
264
  if (options?.relative)
263
265
  return relative(process.cwd(), absolutePath)
264
266
 
@@ -379,7 +381,12 @@ export function realtimePath(path?: string) {
379
381
  return corePath(`realtime/${path || ''}`)
380
382
  }
381
383
 
382
- export function resourcesPath(path?: string) {
384
+ export function resourcesPath(path?: string, options?: { relative?: boolean }) {
385
+ const absolutePath = projectStoragePath(`resources/${path || ''}`)
386
+
387
+ if (options?.relative)
388
+ return relative(process.cwd(), absolutePath)
389
+
383
390
  return projectPath(`resources/${path || ''}`)
384
391
  }
385
392
 
@@ -391,7 +398,12 @@ export function routerPath(path?: string) {
391
398
  return corePath(`router/${path || ''}`)
392
399
  }
393
400
 
394
- export function routesPath(path?: string) {
401
+ export function routesPath(path?: string, options?: { relative?: boolean }) {
402
+ const absolutePath = resourcesPath(`routes/${path || ''}`)
403
+
404
+ if (options?.relative)
405
+ return relative(process.cwd(), absolutePath)
406
+
395
407
  return projectPath(`routes/${path || ''}`)
396
408
  }
397
409
 
@@ -447,6 +459,10 @@ export function stacksPath(path?: string) {
447
459
  return frameworkPath(`src/${path || ''}`)
448
460
  }
449
461
 
462
+ export function shellPath(path?: string) {
463
+ return corePath(`shell/${path || ''}`)
464
+ }
465
+
450
466
  export function stringsPath(path?: string) {
451
467
  return corePath(`strings/${path || ''}`)
452
468
  }
@@ -487,6 +503,10 @@ export function xRayPath(path?: string) {
487
503
  return frameworkPath(`stacks/x-ray/${path || ''}`)
488
504
  }
489
505
 
506
+ export function homeDir(path?: string) {
507
+ return os.homedir() + (path ? (path.startsWith('/') ? '' : '/') + path : '~')
508
+ }
509
+
490
510
  export const path = {
491
511
  actionsPath,
492
512
  userActionsPath,
@@ -573,6 +593,7 @@ export const path = {
573
593
  serverlessPath,
574
594
  stacksPath,
575
595
  stringsPath,
596
+ shellPath,
576
597
  storesPath,
577
598
  testingPath,
578
599
  testsPath,
@@ -589,6 +610,7 @@ export const path = {
589
610
  validationPath,
590
611
  vitePath,
591
612
  xRayPath,
613
+ homeDir,
592
614
 
593
615
  // path utils
594
616
  basename,