@stacksjs/path 0.58.73 → 0.59.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/path",
3
3
  "type": "module",
4
- "version": "0.58.73",
4
+ "version": "0.59.2",
5
5
  "description": "The Stacks path.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -17,7 +17,6 @@
17
17
  },
18
18
  "keywords": [
19
19
  "path",
20
- "pathe",
21
20
  "paths",
22
21
  "utilities",
23
22
  "functions",
@@ -46,8 +45,8 @@
46
45
  "prepublishOnly": "bun --bun run build"
47
46
  },
48
47
  "dependencies": {
49
- "@stacksjs/validation": "latest",
50
- "pathe": "^1.1.2"
48
+ "@stacksjs/logging": "latest",
49
+ "@stacksjs/validation": "latest"
51
50
  },
52
51
  "devDependencies": {
53
52
  "@stacksjs/development": "latest"
package/src/index.ts CHANGED
@@ -1,632 +1,5 @@
1
- import process from 'node:process'
2
- import os from 'node:os'
3
- import { basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath } from 'pathe'
1
+ import { path } from './paths'
4
2
 
5
- /**
6
- * Returns the path to the `actions` directory. The actions directory
7
- * contains the core Stacks' actions. An action
8
- *
9
- * @param path - relative path to the file or directory
10
- * @returns string - absolute path to the file or directory
11
- * @example
12
- * ```ts
13
- * import { buildPath } from '@stacks/paths'
14
- *
15
- * buildPath('functions.stx')
16
- * buildPath('any-path.ts')
17
- * ```
18
- */
19
- export function actionsPath(path?: string) {
20
- return corePath(`actions/src/${path || ''}`)
21
- }
3
+ export * from './paths'
22
4
 
23
- export function relativeActionsPath(path?: string) {
24
- return relative(projectPath(), actionsPath(path))
25
- }
26
-
27
- export function userActionsPath(path?: string) {
28
- return appPath(`Actions/${path || ''}`)
29
- }
30
-
31
- export function userJobsPath(path?: string) {
32
- return appPath(`Jobs/${path || ''}`)
33
- }
34
-
35
- export function userListenersPath(path?: string) {
36
- return appPath(`Listeners/${path || ''}`)
37
- }
38
-
39
- export function userMiddlewarePath(path?: string) {
40
- return appPath(`Middleware/${path || ''}`)
41
- }
42
-
43
- export function userModelsPath(path?: string) {
44
- return appPath(`Models/${path || ''}`)
45
- }
46
-
47
- export function userNotificationsPath(path?: string) {
48
- return appPath(`Notifications/${path || ''}`)
49
- }
50
-
51
- export function userEventsPath() {
52
- return appPath(`Events.ts`)
53
- }
54
-
55
- /**
56
- * Returns the path to the `ai` directory. The AI directory
57
- * contains the core Stacks' AI logic which currently
58
- * is a wrapper of the OpenAI API.
59
- *
60
- * @param path - relative path to the file or directory
61
- * @returns string - absolute path to the file or directory
62
- *
63
- * @example
64
- * ```ts
65
- * import { aiPath } from '@stacks/paths'
66
- *
67
- * console.log('path is', aiPath())
68
- * // path is /Users/chrisbreuer/Code/stacks/storage/stacks/src/ai
69
- * ```
70
- */
71
- export function aiPath(path?: string) {
72
- return corePath(`ai/${path || ''}`)
73
- }
74
-
75
- export function assetsPath(path?: string) {
76
- return resourcesPath(`assets/${path || ''}`)
77
- }
78
-
79
- export function aliasPath() {
80
- return corePath('alias/src/index.ts')
81
- }
82
-
83
- export function buddyPath(path?: string, options?: { relative?: boolean }) {
84
- const absolutePath = corePath(`buddy/${path || ''}`)
85
-
86
- if (options?.relative)
87
- return relative(process.cwd(), absolutePath)
88
-
89
- return absolutePath
90
- }
91
-
92
- export function runtimePath(path?: string) {
93
- return frameworkPath(`buddy/${path || ''}`)
94
- }
95
-
96
- export function analyticsPath(path?: string) {
97
- return corePath(`analytics/${path || ''}`)
98
- }
99
-
100
- export function arraysPath(path?: string) {
101
- return corePath(`arrays/${path || ''}`)
102
- }
103
-
104
- export function appPath(path?: string) {
105
- return projectPath(`app/${path || ''}`)
106
- }
107
-
108
- export function authPath(path?: string) {
109
- return corePath(`auth/${path || ''}`)
110
- }
111
-
112
- /**
113
- * Returns the path to the build directory. The build directory
114
- * contains Stacks' build engine & its tooling integrations.
115
- *
116
- * @param path string - relative path to the file or directory
117
- * @returns string - absolute path to the file or directory
118
- * @example
119
- * ```ts
120
- * buildPath('functions.stx')
121
- * buildPath('components.ts')
122
- * ```
123
- */
124
- export function buildPath(path?: string) {
125
- return corePath(`build/${path || ''}`)
126
- }
127
-
128
- export function buildEnginePath(path?: string) {
129
- return buildPath(`${path || ''}`)
130
- }
131
-
132
- export function libsPath(path?: string) {
133
- return frameworkPath(`libs/${path || ''}`)
134
- }
135
-
136
- export function libsEntriesPath(path?: string) {
137
- return libsPath(`entries/${path || ''}`)
138
- }
139
-
140
- export function cachePath(path?: string) {
141
- return corePath(`cache/${path || ''}`)
142
- }
143
-
144
- export function chatPath(path?: string) {
145
- return corePath(`chat/${path || ''}`)
146
- }
147
-
148
- export function cliPath(path?: string) {
149
- return corePath(`cli/${path || ''}`)
150
- }
151
-
152
- export function cloudPath(path?: string) {
153
- return corePath(`cloud/${path || ''}`)
154
- }
155
-
156
- export function frameworkCloudPath(path?: string) {
157
- return frameworkPath(`cloud/${path || ''}`)
158
- }
159
-
160
- export function collectionsPath(path?: string) {
161
- return corePath(`collections/${path || ''}`)
162
- }
163
-
164
- export function commandsPath(path?: string) {
165
- return appPath(`Commands/${path || ''}`)
166
- }
167
-
168
- export function componentsPath(path?: string) {
169
- return resourcesPath(`components/${path || ''}`)
170
- }
171
-
172
- export function configPath(path?: string) {
173
- return corePath(`config/${path || ''}`)
174
- }
175
-
176
- export function corePath(path?: string) {
177
- return frameworkPath(`core/${path || ''}`)
178
- }
179
-
180
- export function customElementsDataPath() {
181
- return frameworkPath('core/custom-elements.json')
182
- }
183
-
184
- export function databasePath(path?: string) {
185
- return corePath(`database/${path || ''}`)
186
- }
187
-
188
- export function datetimePath(path?: string) {
189
- return corePath(`datetime/${path || ''}`)
190
- }
191
-
192
- export function developmentPath(path?: string) {
193
- return corePath(`development/${path || ''}`)
194
- }
195
-
196
- export function desktopPath(path?: string) {
197
- return corePath(`desktop/${path || ''}`)
198
- }
199
-
200
- export function docsPath(path?: string) {
201
- return corePath(`docs/${path || ''}`)
202
- }
203
-
204
- export function dnsPath(path?: string) {
205
- return corePath(`domains/${path || ''}`)
206
- }
207
-
208
- export function emailPath(path?: string) {
209
- return notificationsPath(`email/${path || ''}`)
210
- }
211
-
212
- export function enumsPath(path?: string) {
213
- return corePath(`enums/${path || ''}`)
214
- }
215
-
216
- export function errorHandlingPath(path?: string) {
217
- return corePath(`error-handling/${path || ''}`)
218
- }
219
-
220
- export function eventsPath(path?: string) {
221
- return corePath(`events/${path || ''}`)
222
- }
223
-
224
- export function coreEnvPath(path?: string) {
225
- return corePath(`env/${path || ''}`)
226
- }
227
-
228
- export function examplesPath(type: 'vue-components' | 'web-components') {
229
- return frameworkPath(`examples/${type || ''}`)
230
- }
231
-
232
- export function fakerPath(path?: string) {
233
- return corePath(`faker/${path || ''}`)
234
- }
235
-
236
- export function frameworkPath(path?: string, options?: { relative?: boolean, cwd?: string }) {
237
- const absolutePath = projectStoragePath(`framework/${path || ''}`)
238
-
239
- if (options?.relative)
240
- return relative(options.cwd || process.cwd(), absolutePath)
241
-
242
- return absolutePath
243
- }
244
-
245
- export function healthPath(path?: string) {
246
- return corePath(`health/${path || ''}`)
247
- }
248
-
249
- export function functionsPath(path?: string) {
250
- return resourcesPath(`functions/${path || ''}`)
251
- }
252
-
253
- export function gitPath(path?: string) {
254
- return corePath(`git/${path || ''}`)
255
- }
256
-
257
- export function langPath(path?: string) {
258
- return projectPath(`lang/${path || ''}`)
259
- }
260
-
261
- export function layoutsPath(path?: string, options?: { relative?: boolean }) {
262
- const absolutePath = resourcesPath(`layouts/${path || ''}`)
263
-
264
- if (options?.relative)
265
- return relative(process.cwd(), absolutePath)
266
-
267
- return absolutePath
268
- }
269
-
270
- export type LibraryType = 'vue-components' | 'web-components' | 'functions'
271
- export function libraryEntryPath(type: LibraryType) {
272
- return libsEntriesPath(`${type}.ts`)
273
- }
274
-
275
- export function lintPath(path?: string) {
276
- return corePath(`lint/${path || ''}`)
277
- }
278
-
279
- export function listenersPath(path?: string) {
280
- return appPath(`Listeners/${path || ''}`)
281
- }
282
-
283
- export function eslintPath(path?: string) {
284
- return lintPath(`eslint/${path || ''}`)
285
- }
286
-
287
- export function jobsPath(path?: string) {
288
- return appPath(`Jobs/${path || ''}`)
289
- }
290
-
291
- export function loggingPath(path?: string) {
292
- return corePath(`logging/${path || ''}`)
293
- }
294
-
295
- export function logsPath(path?: string) {
296
- return projectStoragePath(`logs/${path || ''}`)
297
- }
298
-
299
- export function modelsPath(path?: string) {
300
- return appPath(`models/${path || ''}`)
301
- }
302
-
303
- export function modulesPath(path?: string) {
304
- return resourcesPath(`modules/${path || ''}`)
305
- }
306
-
307
- export function notificationsPath(path?: string) {
308
- return corePath(`notifications/${path || ''}`)
309
- }
310
-
311
- export function ormPath(path?: string) {
312
- return corePath(`orm/${path || ''}`)
313
- }
314
-
315
- export function objectsPath(path?: string) {
316
- return corePath(`objects/${path || ''}`)
317
- }
318
-
319
- export function onboardingPath(path?: string) {
320
- return projectPath(`${path || 'views/dashboard/onboarding'}`)
321
- }
322
-
323
- export function packageJsonPath(type: 'vue-components' | 'web-components' | 'functions') {
324
- if (type === 'vue-components')
325
- return frameworkPath('libs/components/vue/package.json')
326
-
327
- if (type === 'web-components')
328
- return frameworkPath('libs/components/web/package.json')
329
-
330
- return frameworkPath(`libs/${type}/package.json`)
331
- }
332
-
333
- export function viewsPath(path?: string) {
334
- return resourcesPath(`views/${path || ''}`)
335
- }
336
-
337
- export function pathPath(path?: string) {
338
- return corePath(`path/${path || ''}`)
339
- }
340
-
341
- export function paymentsPath(path?: string) {
342
- return corePath(`payments/${path || ''}`)
343
- }
344
-
345
- // all paths ultimately build on the projectPath
346
- export function projectPath(filePath = '') {
347
- let path = process.cwd()
348
-
349
- // need to also account for this being called in the ./storage/framework folder
350
- while (path.includes('storage'))
351
- path = resolve(path, '..')
352
-
353
- return resolve(path, filePath)
354
- }
355
-
356
- export function projectConfigPath(path?: string) {
357
- return projectPath(`config/${path || ''}`)
358
- }
359
-
360
- export function projectStoragePath(path?: string): string {
361
- return projectPath(`storage/${path || ''}`)
362
- }
363
-
364
- export function publicPath(path?: string) {
365
- return projectPath(`public/${path || ''}`)
366
- }
367
-
368
- export function pushPath(path?: string) {
369
- return notificationsPath(`push/${path || ''}`)
370
- }
371
-
372
- export function queryBuilderPath(path?: string) {
373
- return corePath(`query-builder/${path || ''}`)
374
- }
375
-
376
- export function queuePath(path?: string) {
377
- return corePath(`queue/${path || ''}`)
378
- }
379
-
380
- export function realtimePath(path?: string) {
381
- return corePath(`realtime/${path || ''}`)
382
- }
383
-
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
-
390
- return projectPath(`resources/${path || ''}`)
391
- }
392
-
393
- export function replPath(path?: string) {
394
- return corePath(`repl/${path || ''}`)
395
- }
396
-
397
- export function routerPath(path?: string) {
398
- return corePath(`router/${path || ''}`)
399
- }
400
-
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
-
407
- return projectPath(`routes/${path || ''}`)
408
- }
409
-
410
- export function searchEnginePath(path?: string) {
411
- return corePath(`search-engine/${path || ''}`)
412
- }
413
-
414
- export function settingsPath(path?: string) {
415
- return projectPath(`${path || 'views/dashboard/settings'}`)
416
- }
417
-
418
- export function scriptsPath(path?: string) {
419
- return frameworkPath(`scripts/${path || ''}`)
420
- }
421
-
422
- export function schedulerPath(path?: string) {
423
- return corePath(`scheduler/${path || ''}`)
424
- }
425
-
426
- export function signalsPath(path?: string) {
427
- return corePath(`signals/${path || ''}`)
428
- }
429
-
430
- export function slugPath(path?: string) {
431
- return corePath(`slug/${path || ''}`)
432
- }
433
-
434
- export function smsPath(path?: string) {
435
- return notificationsPath(`sms/${path || ''}`)
436
- }
437
-
438
- export function storagePath(path?: string) {
439
- return corePath(`storage/${path || ''}`)
440
- }
441
-
442
- export function storesPath(path?: string) {
443
- return resourcesPath(`stores/${path || ''}`)
444
- }
445
-
446
- export function securityPath(path?: string) {
447
- return corePath(`security/${path || ''}`)
448
- }
449
-
450
- export function serverPath(path?: string) {
451
- return corePath(`server/${path || ''}`)
452
- }
453
-
454
- export function serverlessPath(path?: string) {
455
- return corePath(`serverless/${path || ''}`)
456
- }
457
-
458
- export function stacksPath(path?: string) {
459
- return frameworkPath(`src/${path || ''}`)
460
- }
461
-
462
- export function shellPath(path?: string) {
463
- return corePath(`shell/${path || ''}`)
464
- }
465
-
466
- export function stringsPath(path?: string) {
467
- return corePath(`strings/${path || ''}`)
468
- }
469
-
470
- export function testingPath(path?: string) {
471
- return corePath(`testing/${path || ''}`)
472
- }
473
-
474
- export function tinkerPath(path?: string) {
475
- return corePath(`tinker/${path || ''}`)
476
- }
477
-
478
- export function testsPath(path?: string) {
479
- return frameworkPath(`tests/${path || ''}`)
480
- }
481
-
482
- export function typesPath(path?: string) {
483
- return corePath(`types/${path || ''}`)
484
- }
485
-
486
- export function uiPath(path?: string) {
487
- return corePath(`ui/${path || ''}`)
488
- }
489
-
490
- export function utilsPath(path?: string) {
491
- return corePath(`utils/${path || ''}`)
492
- }
493
-
494
- export function validationPath(path?: string) {
495
- return corePath(`validation/${path || ''}`)
496
- }
497
-
498
- export function vitePath(path?: string) {
499
- return corePath(`vite/${path || ''}`)
500
- }
501
-
502
- export function xRayPath(path?: string) {
503
- return frameworkPath(`stacks/x-ray/${path || ''}`)
504
- }
505
-
506
- export function homeDir(path?: string) {
507
- return os.homedir() + (path ? (path.startsWith('/') ? '' : '/') + path : '~')
508
- }
509
-
510
- export const path = {
511
- actionsPath,
512
- userActionsPath,
513
- aiPath,
514
- assetsPath,
515
- relativeActionsPath,
516
- aliasPath,
517
- analyticsPath,
518
- arraysPath,
519
- appPath,
520
- authPath,
521
- buddyPath,
522
- buildEnginePath,
523
- libsEntriesPath,
524
- buildPath,
525
- cachePath,
526
- chatPath,
527
- cliPath,
528
- cloudPath,
529
- frameworkCloudPath,
530
- collectionsPath,
531
- commandsPath,
532
- componentsPath,
533
- configPath,
534
- projectConfigPath,
535
- corePath,
536
- customElementsDataPath,
537
- databasePath,
538
- datetimePath,
539
- developmentPath,
540
- desktopPath,
541
- docsPath,
542
- dnsPath,
543
- emailPath,
544
- enumsPath,
545
- errorHandlingPath,
546
- eventsPath,
547
- coreEnvPath,
548
- healthPath,
549
- examplesPath,
550
- fakerPath,
551
- frameworkPath,
552
- storagePath,
553
- functionsPath,
554
- gitPath,
555
- langPath,
556
- layoutsPath,
557
- libsPath,
558
- libraryEntryPath,
559
- lintPath,
560
- listenersPath,
561
- loggingPath,
562
- jobsPath,
563
- modulesPath,
564
- ormPath,
565
- objectsPath,
566
- onboardingPath,
567
- notificationsPath,
568
- packageJsonPath,
569
- viewsPath,
570
- pathPath,
571
- paymentsPath,
572
- projectPath,
573
- projectStoragePath,
574
- publicPath,
575
- pushPath,
576
- queryBuilderPath,
577
- queuePath,
578
- realtimePath,
579
- resourcesPath,
580
- replPath,
581
- routerPath,
582
- routesPath,
583
- runtimePath,
584
- searchEnginePath,
585
- schedulerPath,
586
- settingsPath,
587
- smsPath,
588
- signalsPath,
589
- slugPath,
590
- scriptsPath,
591
- securityPath,
592
- serverPath,
593
- serverlessPath,
594
- stacksPath,
595
- stringsPath,
596
- shellPath,
597
- storesPath,
598
- testingPath,
599
- testsPath,
600
- tinkerPath,
601
- typesPath,
602
- uiPath,
603
- userEventsPath,
604
- userJobsPath,
605
- userListenersPath,
606
- userMiddlewarePath,
607
- userModelsPath,
608
- userNotificationsPath,
609
- utilsPath,
610
- validationPath,
611
- vitePath,
612
- xRayPath,
613
- homeDir,
614
-
615
- // path utils
616
- basename,
617
- delimiter,
618
- dirname,
619
- extname,
620
- format,
621
- isAbsolute,
622
- join,
623
- normalize,
624
- normalizeString,
625
- parse,
626
- relative,
627
- resolve,
628
- sep,
629
- toNamespacedPath,
630
- }
631
-
632
- export { basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath }
5
+ export default path