@stacksjs/path 0.59.11 → 0.61.0

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,5 @@
1
1
  // @bun
2
2
  // src/paths.ts
3
- import process from "process";
4
3
  import os from "os";
5
4
  import {
6
5
  basename,
@@ -16,6 +15,7 @@ resolve,
16
15
  sep,
17
16
  toNamespacedPath
18
17
  } from "path";
18
+ import process from "process";
19
19
  import {runCommandSync} from "@stacksjs/cli";
20
20
  import {log} from "@stacksjs/logging";
21
21
  function actionsPath(path) {
@@ -27,6 +27,15 @@ function relativeActionsPath(path) {
27
27
  function userActionsPath(path) {
28
28
  return appPath(`Actions/${path || ""}`);
29
29
  }
30
+ function userComponentsPath(path) {
31
+ return libsPath(`components/${path || ""}`);
32
+ }
33
+ function userViewsPath(path) {
34
+ return resourcesPath(`views/${path || ""}`);
35
+ }
36
+ function userFunctionsPath(path) {
37
+ return resourcesPath(`views/${path || ""}`);
38
+ }
30
39
  function userJobsPath(path) {
31
40
  return appPath(`Jobs/${path || ""}`);
32
41
  }
@@ -42,6 +51,12 @@ function userModelsPath(path) {
42
51
  function userNotificationsPath(path) {
43
52
  return appPath(`Notifications/${path || ""}`);
44
53
  }
54
+ function userDatabasePath(path) {
55
+ return projectPath(`database/${path || ""}`);
56
+ }
57
+ function userMigrationsPath(path) {
58
+ return userDatabasePath(`migrations/${path || ""}`);
59
+ }
45
60
  function userEventsPath() {
46
61
  return appPath(`Events.ts`);
47
62
  }
@@ -84,6 +99,9 @@ function buildEnginePath(path) {
84
99
  function libsPath(path) {
85
100
  return frameworkPath(`libs/${path || ""}`);
86
101
  }
102
+ function userLibsPath(path) {
103
+ return projectPath(`libs/${path || ""}`);
104
+ }
87
105
  function libsEntriesPath(path) {
88
106
  return libsPath(`entries/${path || ""}`);
89
107
  }
@@ -109,7 +127,7 @@ function commandsPath(path) {
109
127
  return appPath(`Commands/${path || ""}`);
110
128
  }
111
129
  function componentsPath(path) {
112
- return resourcesPath(`components/${path || ""}`);
130
+ return userLibsPath(`components/${path || ""}`);
113
131
  }
114
132
  function configPath(path) {
115
133
  return corePath(`config/${path || ""}`);
@@ -169,13 +187,13 @@ function healthPath(path) {
169
187
  return corePath(`health/${path || ""}`);
170
188
  }
171
189
  function functionsPath(path) {
172
- return resourcesPath(`functions/${path || ""}`);
190
+ return userLibsPath(`functions/${path || ""}`);
173
191
  }
174
192
  function gitPath(path) {
175
193
  return corePath(`git/${path || ""}`);
176
194
  }
177
195
  function langPath(path) {
178
- return projectPath(`lang/${path || ""}`);
196
+ return resourcesPath(`lang/${path || ""}`);
179
197
  }
180
198
  function layoutsPath(path, options) {
181
199
  const absolutePath = resourcesPath(`layouts/${path || ""}`);
@@ -192,9 +210,6 @@ function lintPath(path) {
192
210
  function listenersPath(path) {
193
211
  return appPath(`Listeners/${path || ""}`);
194
212
  }
195
- function eslintPath(path) {
196
- return lintPath(`eslint/${path || ""}`);
197
- }
198
213
  function jobsPath(path) {
199
214
  return appPath(`Jobs/${path || ""}`);
200
215
  }
@@ -359,8 +374,11 @@ function utilsPath(path) {
359
374
  function validationPath(path) {
360
375
  return corePath(`validation/${path || ""}`);
361
376
  }
362
- function vitePath(path) {
363
- return corePath(`vite/${path || ""}`);
377
+ function viteConfigPath(path) {
378
+ return corePath(`vite-config/${path || ""}`);
379
+ }
380
+ function vitePluginPath(path) {
381
+ return corePath(`vite-plugin/${path || ""}`);
364
382
  }
365
383
  function xRayPath(path) {
366
384
  return frameworkPath(`stacks/x-ray/${path || ""}`);
@@ -371,6 +389,9 @@ function homeDir(path) {
371
389
  var path = {
372
390
  actionsPath,
373
391
  userActionsPath,
392
+ userComponentsPath,
393
+ userViewsPath,
394
+ userFunctionsPath,
374
395
  aiPath,
375
396
  assetsPath,
376
397
  relativeActionsPath,
@@ -416,10 +437,12 @@ var path = {
416
437
  langPath,
417
438
  layoutsPath,
418
439
  libsPath,
440
+ userLibsPath,
419
441
  libraryEntryPath,
420
442
  lintPath,
421
443
  listenersPath,
422
444
  loggingPath,
445
+ logsPath,
423
446
  jobsPath,
424
447
  modulesPath,
425
448
  ormPath,
@@ -461,6 +484,8 @@ var path = {
461
484
  tinkerPath,
462
485
  typesPath,
463
486
  uiPath,
487
+ userDatabasePath,
488
+ userMigrationsPath,
464
489
  userEventsPath,
465
490
  userJobsPath,
466
491
  userListenersPath,
@@ -469,7 +494,8 @@ var path = {
469
494
  userNotificationsPath,
470
495
  utilsPath,
471
496
  validationPath,
472
- vitePath,
497
+ viteConfigPath,
498
+ vitePluginPath,
473
499
  xRayPath,
474
500
  homeDir,
475
501
  basename,
@@ -490,16 +516,23 @@ var path = {
490
516
  var src_default = path;
491
517
  export {
492
518
  xRayPath,
493
- vitePath,
519
+ vitePluginPath,
520
+ viteConfigPath,
494
521
  viewsPath,
495
522
  validationPath,
496
523
  utilsPath,
524
+ userViewsPath,
497
525
  userNotificationsPath,
498
526
  userModelsPath,
527
+ userMigrationsPath,
499
528
  userMiddlewarePath,
500
529
  userListenersPath,
530
+ userLibsPath,
501
531
  userJobsPath,
532
+ userFunctionsPath,
502
533
  userEventsPath,
534
+ userDatabasePath,
535
+ userComponentsPath,
503
536
  userActionsPath,
504
537
  uiPath,
505
538
  typesPath,
@@ -572,7 +605,6 @@ export {
572
605
  extname,
573
606
  examplesPath,
574
607
  eventsPath,
575
- eslintPath,
576
608
  errorHandlingPath,
577
609
  enumsPath,
578
610
  emailPath,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/path",
3
3
  "type": "module",
4
- "version": "0.59.11",
4
+ "version": "0.61.0",
5
5
  "description": "The Stacks path.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
package/src/paths.ts CHANGED
@@ -1,4 +1,3 @@
1
- import process from 'node:process'
2
1
  import os from 'node:os'
3
2
  import {
4
3
  basename,
@@ -14,6 +13,7 @@ import {
14
13
  sep,
15
14
  toNamespacedPath,
16
15
  } from 'node:path'
16
+ import process from 'node:process'
17
17
  import { runCommandSync } from '@stacksjs/cli'
18
18
  import { log } from '@stacksjs/logging'
19
19
 
@@ -42,6 +42,18 @@ export function userActionsPath(path?: string) {
42
42
  return appPath(`Actions/${path || ''}`)
43
43
  }
44
44
 
45
+ export function userComponentsPath(path?: string) {
46
+ return libsPath(`components/${path || ''}`)
47
+ }
48
+
49
+ export function userViewsPath(path?: string) {
50
+ return resourcesPath(`views/${path || ''}`)
51
+ }
52
+
53
+ export function userFunctionsPath(path?: string) {
54
+ return resourcesPath(`views/${path || ''}`)
55
+ }
56
+
45
57
  /**
46
58
  * Returns the path to the user-defined `Jobs` directory.
47
59
  *
@@ -122,6 +134,14 @@ export function userNotificationsPath(path?: string) {
122
134
  return appPath(`Notifications/${path || ''}`)
123
135
  }
124
136
 
137
+ export function userDatabasePath(path?: string) {
138
+ return projectPath(`database/${path || ''}`)
139
+ }
140
+
141
+ export function userMigrationsPath(path?: string) {
142
+ return userDatabasePath(`migrations/${path || ''}`)
143
+ }
144
+
125
145
  /**
126
146
  * Returns the path to the user-defined `Events.ts` file.
127
147
  *
@@ -205,8 +225,7 @@ export function aliasPath() {
205
225
  export function buddyPath(path?: string, options?: { relative?: boolean }) {
206
226
  const absolutePath = corePath(`buddy/${path || ''}`)
207
227
 
208
- if (options?.relative)
209
- return relative(process.cwd(), absolutePath)
228
+ if (options?.relative) return relative(process.cwd(), absolutePath)
210
229
 
211
230
  return absolutePath
212
231
  }
@@ -327,6 +346,16 @@ export function libsPath(path?: string): string {
327
346
  return frameworkPath(`libs/${path || ''}`)
328
347
  }
329
348
 
349
+ /**
350
+ * Returns the path to the user `libs` directory within the root project directory.
351
+ *
352
+ * @param path - The relative path to the file or directory within the `libs` directory.
353
+ * @returns The absolute path to the specified file or directory within the `libs` directory.
354
+ */
355
+ export function userLibsPath(path?: string): string {
356
+ return projectPath(`libs/${path || ''}`)
357
+ }
358
+
330
359
  /**
331
360
  * Returns the path to the `entries` directory within the `libs` directory.
332
361
  *
@@ -414,7 +443,7 @@ export function commandsPath(path?: string): string {
414
443
  * @returns The absolute path to the specified file or directory within the `components` directory.
415
444
  */
416
445
  export function componentsPath(path?: string): string {
417
- return resourcesPath(`components/${path || ''}`)
446
+ return userLibsPath(`components/${path || ''}`)
418
447
  }
419
448
 
420
449
  /**
@@ -562,9 +591,7 @@ export function coreEnvPath(path?: string): string {
562
591
  * @param type - The type of examples to filter by ('vue-components' or 'web-components').
563
592
  * @returns The absolute path to the specified type of examples within the `examples` directory.
564
593
  */
565
- export function examplesPath(
566
- type: 'vue-components' | 'web-components',
567
- ): string {
594
+ export function examplesPath(type: 'vue-components' | 'web-components'): string {
568
595
  return frameworkPath(`examples/${type || ''}`)
569
596
  }
570
597
 
@@ -587,14 +614,10 @@ export function fakerPath(path?: string): string {
587
614
  * @param options.cwd - Specifies a custom working directory.
588
615
  * @returns The absolute or relative path to the specified file or directory within the framework directory.
589
616
  */
590
- export function frameworkPath(
591
- path?: string,
592
- options?: { relative?: boolean, cwd?: string },
593
- ): string {
617
+ export function frameworkPath(path?: string, options?: { relative?: boolean; cwd?: string }): string {
594
618
  const absolutePath = projectStoragePath(`framework/${path || ''}`)
595
619
 
596
- if (options?.relative)
597
- return relative(options.cwd || process.cwd(), absolutePath)
620
+ if (options?.relative) return relative(options.cwd || process.cwd(), absolutePath)
598
621
 
599
622
  return absolutePath
600
623
  }
@@ -616,7 +639,7 @@ export function healthPath(path?: string): string {
616
639
  * @returns The absolute path to the specified file or directory within the `functions` directory.
617
640
  */
618
641
  export function functionsPath(path?: string): string {
619
- return resourcesPath(`functions/${path || ''}`)
642
+ return userLibsPath(`functions/${path || ''}`)
620
643
  }
621
644
 
622
645
  /**
@@ -636,7 +659,7 @@ export function gitPath(path?: string): string {
636
659
  * @returns The absolute path to the specified file or directory within the lang directory.
637
660
  */
638
661
  export function langPath(path?: string): string {
639
- return projectPath(`lang/${path || ''}`)
662
+ return resourcesPath(`lang/${path || ''}`)
640
663
  }
641
664
 
642
665
  /**
@@ -647,14 +670,10 @@ export function langPath(path?: string): string {
647
670
  * @param options.relative - If true, returns the path relative to the current working directory.
648
671
  * @returns The absolute or relative path to the specified file or directory within the `layouts` directory.
649
672
  */
650
- export function layoutsPath(
651
- path?: string,
652
- options?: { relative?: boolean },
653
- ): string {
673
+ export function layoutsPath(path?: string, options?: { relative?: boolean }): string {
654
674
  const absolutePath = resourcesPath(`layouts/${path || ''}`)
655
675
 
656
- if (options?.relative)
657
- return relative(process.cwd(), absolutePath)
676
+ if (options?.relative) return relative(process.cwd(), absolutePath)
658
677
 
659
678
  return absolutePath
660
679
  }
@@ -690,16 +709,6 @@ export function listenersPath(path?: string): string {
690
709
  return appPath(`Listeners/${path || ''}`)
691
710
  }
692
711
 
693
- /**
694
- * Returns the path to the `eslint` directory within the lint directory.
695
- *
696
- * @param path - The relative path to the file or directory within the eslint directory.
697
- * @returns The absolute path to the specified file or directory within the eslint directory.
698
- */
699
- export function eslintPath(path?: string): string {
700
- return lintPath(`eslint/${path || ''}`)
701
- }
702
-
703
712
  /**
704
713
  * Returns the path to the `jobs` directory within the app directory.
705
714
  *
@@ -796,14 +805,10 @@ export function onboardingPath(path?: string): string {
796
805
  * @param type - The type of the library ('vue-components', 'web-components', or 'functions') for which to return the package.json path.
797
806
  * @returns The absolute path to the specified package.json file within the framework directory.
798
807
  */
799
- export function packageJsonPath(
800
- type: 'vue-components' | 'web-components' | 'functions',
801
- ): string {
802
- if (type === 'vue-components')
803
- return frameworkPath('libs/components/vue/package.json')
808
+ export function packageJsonPath(type: 'vue-components' | 'web-components' | 'functions'): string {
809
+ if (type === 'vue-components') return frameworkPath('libs/components/vue/package.json')
804
810
 
805
- if (type === 'web-components')
806
- return frameworkPath('libs/components/web/package.json')
811
+ if (type === 'web-components') return frameworkPath('libs/components/web/package.json')
807
812
 
808
813
  return frameworkPath(`libs/${type}/package.json`)
809
814
  }
@@ -852,8 +857,7 @@ export function projectPath(filePath = '', options?: { relative: boolean }): str
852
857
  const finalPath = resolve(path, filePath)
853
858
 
854
859
  // If the `relative` option is true, return the path relative to the current working directory
855
- if (options?.relative)
856
- return relative(process.cwd(), finalPath)
860
+ if (options?.relative) return relative(process.cwd(), finalPath)
857
861
 
858
862
  return finalPath
859
863
  }
@@ -879,8 +883,7 @@ export async function findProjectPath(project: string): Promise<string> {
879
883
  // since we are targeting a specific project, find its path
880
884
  const projectPath = projects.find((proj: string) => proj.includes(project))
881
885
 
882
- if (!projectPath)
883
- throw new Error(`Could not find project with name: ${project}`)
886
+ if (!projectPath) throw new Error(`Could not find project with name: ${project}`)
884
887
 
885
888
  return projectPath.startsWith('/') ? projectPath : `/${projectPath}`
886
889
  }
@@ -966,8 +969,7 @@ export function realtimePath(path?: string) {
966
969
  export function resourcesPath(path?: string, options?: { relative?: boolean }) {
967
970
  const absolutePath = projectStoragePath(`resources/${path || ''}`)
968
971
 
969
- if (options?.relative)
970
- return relative(process.cwd(), absolutePath)
972
+ if (options?.relative) return relative(process.cwd(), absolutePath)
971
973
 
972
974
  return projectPath(`resources/${path || ''}`)
973
975
  }
@@ -1003,8 +1005,7 @@ export function routerPath(path?: string) {
1003
1005
  export function routesPath(path?: string, options?: { relative?: boolean }) {
1004
1006
  const absolutePath = resourcesPath(`routes/${path || ''}`)
1005
1007
 
1006
- if (options?.relative)
1007
- return relative(process.cwd(), absolutePath)
1008
+ if (options?.relative) return relative(process.cwd(), absolutePath)
1008
1009
 
1009
1010
  return projectPath(`routes/${path || ''}`)
1010
1011
  }
@@ -1220,13 +1221,23 @@ export function validationPath(path?: string) {
1220
1221
  }
1221
1222
 
1222
1223
  /**
1223
- * Returns the path to the `vite` directory within the core directory.
1224
+ * Returns the path to the `vite-config` directory within the core directory.
1225
+ *
1226
+ * @param path - The relative path to the file or directory within the vite-config directory.
1227
+ * @returns The absolute path to the specified file or directory within the vite-config directory.
1228
+ */
1229
+ export function viteConfigPath(path?: string) {
1230
+ return corePath(`vite-config/${path || ''}`)
1231
+ }
1232
+
1233
+ /**
1234
+ * Returns the path to the `vite-plugin` directory within the core directory.
1224
1235
  *
1225
1236
  * @param path - The relative path to the file or directory within the vite directory.
1226
1237
  * @returns The absolute path to the specified file or directory within the vite directory.
1227
1238
  */
1228
- export function vitePath(path?: string) {
1229
- return corePath(`vite/${path || ''}`)
1239
+ export function vitePluginPath(path?: string) {
1240
+ return corePath(`vite-plugin/${path || ''}`)
1230
1241
  }
1231
1242
 
1232
1243
  /**
@@ -1252,6 +1263,9 @@ export function homeDir(path?: string) {
1252
1263
  export const path = {
1253
1264
  actionsPath,
1254
1265
  userActionsPath,
1266
+ userComponentsPath,
1267
+ userViewsPath,
1268
+ userFunctionsPath,
1255
1269
  aiPath,
1256
1270
  assetsPath,
1257
1271
  relativeActionsPath,
@@ -1297,10 +1311,12 @@ export const path = {
1297
1311
  langPath,
1298
1312
  layoutsPath,
1299
1313
  libsPath,
1314
+ userLibsPath,
1300
1315
  libraryEntryPath,
1301
1316
  lintPath,
1302
1317
  listenersPath,
1303
1318
  loggingPath,
1319
+ logsPath,
1304
1320
  jobsPath,
1305
1321
  modulesPath,
1306
1322
  ormPath,
@@ -1342,6 +1358,8 @@ export const path = {
1342
1358
  tinkerPath,
1343
1359
  typesPath,
1344
1360
  uiPath,
1361
+ userDatabasePath,
1362
+ userMigrationsPath,
1345
1363
  userEventsPath,
1346
1364
  userJobsPath,
1347
1365
  userListenersPath,
@@ -1350,7 +1368,8 @@ export const path = {
1350
1368
  userNotificationsPath,
1351
1369
  utilsPath,
1352
1370
  validationPath,
1353
- vitePath,
1371
+ viteConfigPath,
1372
+ vitePluginPath,
1354
1373
  xRayPath,
1355
1374
  homeDir,
1356
1375
 
@@ -1369,16 +1388,4 @@ export const path = {
1369
1388
  toNamespacedPath,
1370
1389
  }
1371
1390
 
1372
- export {
1373
- basename,
1374
- delimiter,
1375
- dirname,
1376
- extname,
1377
- isAbsolute,
1378
- join,
1379
- normalize,
1380
- relative,
1381
- resolve,
1382
- sep,
1383
- toNamespacedPath,
1384
- }
1391
+ export { basename, delimiter, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep, toNamespacedPath }
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { path } from './paths';
2
- export * from './paths';
3
- export default path;