@stacksjs/path 0.70.23 → 0.70.25
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/README.md +2 -2
- package/dist/index.js +61 -20
- package/dist/src/index.d.ts +1061 -0
- package/package.json +20 -6
- package/dist/index.d.ts +0 -119
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Easily work with file paths.
|
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
bun install -d @stacksjs/path
|
|
16
|
-
# if stacks is installed, you can also use
|
|
16
|
+
# if stacks is installed, you can also use
|
|
17
17
|
# import path from 'stacks/path'
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -25,7 +25,7 @@ import { filename, normalizeAliases, resolve, resolveAlias } from '@stacksjs/pat
|
|
|
25
25
|
// and more...
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
To view the full documentation, please visit [https://stacksjs.
|
|
28
|
+
To view the full documentation, please visit [<https://stacksjs.com/pat>h](https://stacksjs.com/path).
|
|
29
29
|
|
|
30
30
|
## 🧪 Testing
|
|
31
31
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
3
|
+
|
|
2
4
|
// src/index.ts
|
|
3
|
-
import os from "
|
|
5
|
+
import os from "os";
|
|
4
6
|
import {
|
|
5
7
|
basename,
|
|
6
8
|
delimiter,
|
|
@@ -14,9 +16,16 @@ import {
|
|
|
14
16
|
resolve,
|
|
15
17
|
sep,
|
|
16
18
|
toNamespacedPath
|
|
17
|
-
} from "
|
|
18
|
-
import process from "
|
|
19
|
-
|
|
19
|
+
} from "path";
|
|
20
|
+
import process from "process";
|
|
21
|
+
async function debugLog(message) {
|
|
22
|
+
try {
|
|
23
|
+
const { log } = await import("@stacksjs/logging");
|
|
24
|
+
log.debug(message);
|
|
25
|
+
} catch {
|
|
26
|
+
console.debug(message);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
20
29
|
function actionsPath(path) {
|
|
21
30
|
return corePath(`actions/${path || ""}`);
|
|
22
31
|
}
|
|
@@ -47,6 +56,9 @@ function userFunctionsPath(path) {
|
|
|
47
56
|
function userJobsPath(path) {
|
|
48
57
|
return appPath(`Jobs/${path || ""}`);
|
|
49
58
|
}
|
|
59
|
+
function userControllersPath(path) {
|
|
60
|
+
return appPath(`Controllers/${path || ""}`);
|
|
61
|
+
}
|
|
50
62
|
function userListenersPath(path) {
|
|
51
63
|
return appPath(`Listeners/${path || ""}`);
|
|
52
64
|
}
|
|
@@ -98,6 +110,12 @@ function appPath(path, options) {
|
|
|
98
110
|
return relative(options.cwd || process.cwd(), absolutePath);
|
|
99
111
|
return absolutePath;
|
|
100
112
|
}
|
|
113
|
+
function defaultsAppPath(path) {
|
|
114
|
+
return frameworkPath(`defaults/app/${path || ""}`);
|
|
115
|
+
}
|
|
116
|
+
function defaultsResourcesPath(path) {
|
|
117
|
+
return frameworkPath(`defaults/resources/${path || ""}`);
|
|
118
|
+
}
|
|
101
119
|
function authPath(path) {
|
|
102
120
|
return corePath(`auth/${path || ""}`);
|
|
103
121
|
}
|
|
@@ -125,6 +143,9 @@ function cachePath(path) {
|
|
|
125
143
|
function chatPath(path) {
|
|
126
144
|
return corePath(`chat/${path || ""}`);
|
|
127
145
|
}
|
|
146
|
+
function chartsPath(path) {
|
|
147
|
+
return corePath(`charts/${path || ""}`);
|
|
148
|
+
}
|
|
128
149
|
function cliPath(path) {
|
|
129
150
|
return corePath(`cli/${path || ""}`);
|
|
130
151
|
}
|
|
@@ -218,7 +239,7 @@ function langPath(path) {
|
|
|
218
239
|
function layoutsPath(path, options) {
|
|
219
240
|
let absolutePath;
|
|
220
241
|
if (options?.defaults)
|
|
221
|
-
absolutePath = frameworkPath(`defaults/layouts/${path || ""}`);
|
|
242
|
+
absolutePath = frameworkPath(`defaults/resources/layouts/${path || ""}`);
|
|
222
243
|
else
|
|
223
244
|
absolutePath = resourcesPath(`layouts/${path || ""}`);
|
|
224
245
|
if (options?.relative)
|
|
@@ -252,6 +273,9 @@ function modulesPath(path) {
|
|
|
252
273
|
function notificationsPath(path) {
|
|
253
274
|
return corePath(`notifications/${path || ""}`);
|
|
254
275
|
}
|
|
276
|
+
function newsletterPath(path) {
|
|
277
|
+
return corePath(`newsletter/${path || ""}`);
|
|
278
|
+
}
|
|
255
279
|
function ormPath(path) {
|
|
256
280
|
return corePath(`orm/${path || ""}`);
|
|
257
281
|
}
|
|
@@ -262,8 +286,6 @@ function onboardingPath(path) {
|
|
|
262
286
|
return projectPath(`${path || "views/dashboard/onboarding"}`);
|
|
263
287
|
}
|
|
264
288
|
function packageJsonPath(type) {
|
|
265
|
-
if (type === "vue-components")
|
|
266
|
-
return frameworkPath("libs/components/vue/package.json");
|
|
267
289
|
if (type === "web-components")
|
|
268
290
|
return frameworkPath("libs/components/web/package.json");
|
|
269
291
|
return frameworkPath(`libs/${type}/package.json`);
|
|
@@ -279,8 +301,12 @@ function paymentsPath(path) {
|
|
|
279
301
|
}
|
|
280
302
|
function projectPath(filePath = "", options) {
|
|
281
303
|
let path = process.cwd();
|
|
282
|
-
while (path.includes("storage"))
|
|
283
|
-
|
|
304
|
+
while (path.includes("storage")) {
|
|
305
|
+
const parent = resolve(path, "..");
|
|
306
|
+
if (parent === path)
|
|
307
|
+
break;
|
|
308
|
+
path = parent;
|
|
309
|
+
}
|
|
284
310
|
const finalPath = resolve(path, filePath);
|
|
285
311
|
if (options?.relative)
|
|
286
312
|
return relative(process.cwd(), finalPath);
|
|
@@ -288,10 +314,10 @@ function projectPath(filePath = "", options) {
|
|
|
288
314
|
}
|
|
289
315
|
async function findProjectPath(project) {
|
|
290
316
|
const projectList = Bun.spawnSync(["buddy", "projects:list", "--quiet"]).stdout.toString();
|
|
291
|
-
|
|
317
|
+
await debugLog(`ProjectList in findProjectPath ${projectList}`);
|
|
292
318
|
const projects = projectList.split(`
|
|
293
319
|
`).filter((line) => line.startsWith(" - ")).map((line) => line.trim().substring(4));
|
|
294
|
-
|
|
320
|
+
await debugLog(`Projects in findProjectPath ${projects}`);
|
|
295
321
|
const projectPath2 = projects.find((proj) => proj.includes(project));
|
|
296
322
|
if (!projectPath2)
|
|
297
323
|
throw new Error(`Could not find project with name: ${project}`);
|
|
@@ -376,6 +402,12 @@ function serverlessPath(path) {
|
|
|
376
402
|
function stacksPath(path) {
|
|
377
403
|
return frameworkPath(`src/${path || ""}`);
|
|
378
404
|
}
|
|
405
|
+
function stacksLockPath() {
|
|
406
|
+
return storagePath("framework/stacks.lock.json");
|
|
407
|
+
}
|
|
408
|
+
function stacksBackupPath(stackName) {
|
|
409
|
+
return storagePath(`framework/stacks/backups/${stackName || ""}`);
|
|
410
|
+
}
|
|
379
411
|
function shellPath(path) {
|
|
380
412
|
return corePath(`shell/${path || ""}`);
|
|
381
413
|
}
|
|
@@ -406,11 +438,8 @@ function utilsPath(path) {
|
|
|
406
438
|
function validationPath(path) {
|
|
407
439
|
return corePath(`validation/${path || ""}`);
|
|
408
440
|
}
|
|
409
|
-
function
|
|
410
|
-
return corePath(`
|
|
411
|
-
}
|
|
412
|
-
function vitePluginPath(path) {
|
|
413
|
-
return corePath(`vite-plugin/${path || ""}`);
|
|
441
|
+
function socialsPath(path) {
|
|
442
|
+
return corePath(`socials/${path || ""}`);
|
|
414
443
|
}
|
|
415
444
|
function xRayPath(path) {
|
|
416
445
|
return frameworkPath(`stacks/x-ray/${path || ""}`);
|
|
@@ -432,6 +461,8 @@ var path = {
|
|
|
432
461
|
analyticsPath,
|
|
433
462
|
arraysPath,
|
|
434
463
|
appPath,
|
|
464
|
+
defaultsAppPath,
|
|
465
|
+
defaultsResourcesPath,
|
|
435
466
|
authPath,
|
|
436
467
|
coreApiPath,
|
|
437
468
|
buddyPath,
|
|
@@ -439,6 +470,7 @@ var path = {
|
|
|
439
470
|
libsEntriesPath,
|
|
440
471
|
buildPath,
|
|
441
472
|
cachePath,
|
|
473
|
+
chartsPath,
|
|
442
474
|
chatPath,
|
|
443
475
|
cliPath,
|
|
444
476
|
cloudPath,
|
|
@@ -485,6 +517,7 @@ var path = {
|
|
|
485
517
|
objectsPath,
|
|
486
518
|
onboardingPath,
|
|
487
519
|
notificationsPath,
|
|
520
|
+
newsletterPath,
|
|
488
521
|
packageJsonPath,
|
|
489
522
|
viewsPath,
|
|
490
523
|
pathPath,
|
|
@@ -513,8 +546,11 @@ var path = {
|
|
|
513
546
|
userServerPath,
|
|
514
547
|
serverlessPath,
|
|
515
548
|
stacksPath,
|
|
549
|
+
stacksLockPath,
|
|
550
|
+
stacksBackupPath,
|
|
516
551
|
stringsPath,
|
|
517
552
|
shellPath,
|
|
553
|
+
socialsPath,
|
|
518
554
|
storesPath,
|
|
519
555
|
testingPath,
|
|
520
556
|
testsPath,
|
|
@@ -525,14 +561,13 @@ var path = {
|
|
|
525
561
|
userMigrationsPath,
|
|
526
562
|
userEventsPath,
|
|
527
563
|
userJobsPath,
|
|
564
|
+
userControllersPath,
|
|
528
565
|
userListenersPath,
|
|
529
566
|
userMiddlewarePath,
|
|
530
567
|
userModelsPath,
|
|
531
568
|
userNotificationsPath,
|
|
532
569
|
utilsPath,
|
|
533
570
|
validationPath,
|
|
534
|
-
viteConfigPath,
|
|
535
|
-
vitePluginPath,
|
|
536
571
|
xRayPath,
|
|
537
572
|
homeDir,
|
|
538
573
|
basename,
|
|
@@ -550,8 +585,6 @@ var path = {
|
|
|
550
585
|
};
|
|
551
586
|
export {
|
|
552
587
|
xRayPath,
|
|
553
|
-
vitePluginPath,
|
|
554
|
-
viteConfigPath,
|
|
555
588
|
viewsPath,
|
|
556
589
|
validationPath,
|
|
557
590
|
utilsPath,
|
|
@@ -567,6 +600,7 @@ export {
|
|
|
567
600
|
userFunctionsPath,
|
|
568
601
|
userEventsPath,
|
|
569
602
|
userDatabasePath,
|
|
603
|
+
userControllersPath,
|
|
570
604
|
userComponentsPath,
|
|
571
605
|
userActionsPath,
|
|
572
606
|
uiPath,
|
|
@@ -579,6 +613,9 @@ export {
|
|
|
579
613
|
storesPath,
|
|
580
614
|
storagePath,
|
|
581
615
|
stacksPath,
|
|
616
|
+
stacksLockPath,
|
|
617
|
+
stacksBackupPath,
|
|
618
|
+
socialsPath,
|
|
582
619
|
smsPath,
|
|
583
620
|
slugPath,
|
|
584
621
|
shellPath,
|
|
@@ -614,6 +651,7 @@ export {
|
|
|
614
651
|
objectsPath,
|
|
615
652
|
notificationsPath,
|
|
616
653
|
normalize,
|
|
654
|
+
newsletterPath,
|
|
617
655
|
modulesPath,
|
|
618
656
|
modelsPath,
|
|
619
657
|
logsPath,
|
|
@@ -649,6 +687,8 @@ export {
|
|
|
649
687
|
developmentPath,
|
|
650
688
|
desktopPath,
|
|
651
689
|
delimiter,
|
|
690
|
+
defaultsResourcesPath,
|
|
691
|
+
defaultsAppPath,
|
|
652
692
|
datetimePath,
|
|
653
693
|
databasePath,
|
|
654
694
|
customElementsDataPath,
|
|
@@ -663,6 +703,7 @@ export {
|
|
|
663
703
|
cloudPath,
|
|
664
704
|
cliPath,
|
|
665
705
|
chatPath,
|
|
706
|
+
chartsPath,
|
|
666
707
|
cachePath,
|
|
667
708
|
builtUserActionsPath,
|
|
668
709
|
buildPath,
|