@stacksjs/path 0.74.28 → 0.74.31
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.d.ts +3 -5
- package/dist/index.js +51 -45
- package/dist/project.d.ts +5 -0
- package/dist/project.js +38 -0
- package/package.json +7 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appPath, frameworkPath, projectPath, storagePath } from './project';
|
|
1
2
|
import { basename, delimiter, dirname, extname, isAbsolute, join, normalize, parse, relative, resolve, sep, toNamespacedPath } from 'node:path';
|
|
2
3
|
import type { ParsedPath } from 'node:path';
|
|
3
4
|
/**
|
|
@@ -248,7 +249,6 @@ export declare function arraysPath(path?: string): string;
|
|
|
248
249
|
* console.log(appPath('Actions/DummyAction.ts')) // Outputs the absolute path to 'Actions/DummyAction.ts' within the app directory.
|
|
249
250
|
* ```
|
|
250
251
|
*/
|
|
251
|
-
export declare function appPath(path?: string, options?: { relative?: boolean, cwd?: string }): string;
|
|
252
252
|
/**
|
|
253
253
|
* Returns the path to the defaults `app` directory within the framework directory.
|
|
254
254
|
* This is where default Actions, Controllers, etc. are stored.
|
|
@@ -531,7 +531,6 @@ export declare function fakerPath(path?: string): string;
|
|
|
531
531
|
* @param options.cwd - Specifies a custom working directory.
|
|
532
532
|
* @returns The absolute or relative path to the specified file or directory within the framework directory.
|
|
533
533
|
*/
|
|
534
|
-
export declare function frameworkPath(path?: string, options?: { relative?: boolean, cwd?: string }): string;
|
|
535
534
|
/**
|
|
536
535
|
* Returns the path to the `frontend` directory within the core directory.
|
|
537
536
|
*
|
|
@@ -700,7 +699,6 @@ export declare function paymentsPath(path?: string): string;
|
|
|
700
699
|
* @param filePath - The relative path to append to the project path. Defaults to an empty string.
|
|
701
700
|
* @returns The absolute path to the specified file or directory within the project directory.
|
|
702
701
|
*/
|
|
703
|
-
export declare function projectPath(filePath?: string, options?: { relative: boolean }): string;
|
|
704
702
|
/**
|
|
705
703
|
* Finds and returns the absolute path of a specified project by name.
|
|
706
704
|
*
|
|
@@ -722,7 +720,6 @@ export declare function projectConfigPath(path?: string): string;
|
|
|
722
720
|
* @param path - The relative path to the file or directory within the storage directory.
|
|
723
721
|
* @returns The absolute path to the specified file or directory within the storage directory.
|
|
724
722
|
*/
|
|
725
|
-
export declare function storagePath(path?: string): string;
|
|
726
723
|
/**
|
|
727
724
|
* Returns the path to the `public` directory within the project directory.
|
|
728
725
|
*
|
|
@@ -1018,7 +1015,7 @@ export declare function frameworkRuntimePath(path?: string): string;
|
|
|
1018
1015
|
/**
|
|
1019
1016
|
* Returns the path to stx's build cache and generated route manifest.
|
|
1020
1017
|
*
|
|
1021
|
-
* stx writes its compiled-template cache,
|
|
1018
|
+
* stx writes its compiled-template cache, ts-css CSS cache, client-script
|
|
1022
1019
|
* bundles and `routes.ts` manifest here. It used to be `./.stx` in the project
|
|
1023
1020
|
* root; stx now takes the location from its own `stateDir` config option, which
|
|
1024
1021
|
* `config/ui.ts` sets to this directory and {@link runtimeDirectoryEnv} exports
|
|
@@ -1299,4 +1296,5 @@ export declare interface Path {
|
|
|
1299
1296
|
* comparison can say whether it is current.
|
|
1300
1297
|
*/
|
|
1301
1298
|
export type DefaultsProvenance = 'not-applicable' | 'current' | 'stale' | 'unstamped';
|
|
1299
|
+
export { appPath, frameworkPath, projectPath, storagePath } from './project';
|
|
1302
1300
|
export { basename, delimiter, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep, toNamespacedPath };
|
package/dist/index.js
CHANGED
|
@@ -22,12 +22,46 @@ import {
|
|
|
22
22
|
join,
|
|
23
23
|
normalize,
|
|
24
24
|
parse,
|
|
25
|
-
relative,
|
|
26
|
-
resolve,
|
|
25
|
+
relative as relative2,
|
|
26
|
+
resolve as resolve2,
|
|
27
27
|
sep,
|
|
28
28
|
toNamespacedPath
|
|
29
29
|
} from "path";
|
|
30
|
+
import process2 from "process";
|
|
31
|
+
|
|
32
|
+
// src/project.ts
|
|
33
|
+
import { relative, resolve } from "path";
|
|
30
34
|
import process from "process";
|
|
35
|
+
function projectPath(filePath = "", options) {
|
|
36
|
+
let path = process.cwd();
|
|
37
|
+
while (path.includes("storage")) {
|
|
38
|
+
const parent = resolve(path, "..");
|
|
39
|
+
if (parent === path)
|
|
40
|
+
break;
|
|
41
|
+
path = parent;
|
|
42
|
+
}
|
|
43
|
+
const finalPath = resolve(path, filePath);
|
|
44
|
+
if (options?.relative)
|
|
45
|
+
return relative(process.cwd(), finalPath);
|
|
46
|
+
return finalPath;
|
|
47
|
+
}
|
|
48
|
+
function appPath(path, options) {
|
|
49
|
+
const absolutePath = projectPath(`app/${path || ""}`);
|
|
50
|
+
if (options?.relative)
|
|
51
|
+
return relative(options.cwd || process.cwd(), absolutePath);
|
|
52
|
+
return absolutePath;
|
|
53
|
+
}
|
|
54
|
+
function storagePath(path) {
|
|
55
|
+
return projectPath(`storage/${path || ""}`);
|
|
56
|
+
}
|
|
57
|
+
function frameworkPath(path, options) {
|
|
58
|
+
const absolutePath = storagePath(`framework/${path || ""}`);
|
|
59
|
+
if (options?.relative)
|
|
60
|
+
return relative(options.cwd || process.cwd(), absolutePath);
|
|
61
|
+
return absolutePath;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/index.ts
|
|
31
65
|
async function debugLog(message) {
|
|
32
66
|
try {
|
|
33
67
|
const loggingPackage = "@stacksjs/" + "logging";
|
|
@@ -41,18 +75,18 @@ function actionsPath(path) {
|
|
|
41
75
|
return corePath(`actions/${path || ""}`);
|
|
42
76
|
}
|
|
43
77
|
function relativeActionsPath(path) {
|
|
44
|
-
return
|
|
78
|
+
return relative2(projectPath(), actionsPath(path));
|
|
45
79
|
}
|
|
46
80
|
function userActionsPath(path, options) {
|
|
47
81
|
const absolutePath = appPath(`Actions/${path || ""}`);
|
|
48
82
|
if (options?.relative)
|
|
49
|
-
return
|
|
83
|
+
return relative2(process2.cwd(), absolutePath);
|
|
50
84
|
return absolutePath;
|
|
51
85
|
}
|
|
52
86
|
function builtUserActionsPath(path, options) {
|
|
53
87
|
const absolutePath = frameworkPath(`actions/${path || ""}`);
|
|
54
88
|
if (options?.relative)
|
|
55
|
-
return
|
|
89
|
+
return relative2(process2.cwd(), absolutePath);
|
|
56
90
|
return absolutePath;
|
|
57
91
|
}
|
|
58
92
|
function userComponentsPath(path) {
|
|
@@ -112,7 +146,7 @@ function aliasPath() {
|
|
|
112
146
|
function buddyPath(path, options) {
|
|
113
147
|
const absolutePath = corePath(`buddy/${path || ""}`);
|
|
114
148
|
if (options?.relative)
|
|
115
|
-
return
|
|
149
|
+
return relative2(process2.cwd(), absolutePath);
|
|
116
150
|
return absolutePath;
|
|
117
151
|
}
|
|
118
152
|
function runtimePath(path) {
|
|
@@ -124,12 +158,6 @@ function analyticsPath(path) {
|
|
|
124
158
|
function arraysPath(path) {
|
|
125
159
|
return corePath(`arrays/${path || ""}`);
|
|
126
160
|
}
|
|
127
|
-
function appPath(path, options) {
|
|
128
|
-
const absolutePath = projectPath(`app/${path || ""}`);
|
|
129
|
-
if (options?.relative)
|
|
130
|
-
return relative(options.cwd || process.cwd(), absolutePath);
|
|
131
|
-
return absolutePath;
|
|
132
|
-
}
|
|
133
161
|
function defaultsAppPath(path) {
|
|
134
162
|
return frameworkPath(`defaults/app/${path || ""}`);
|
|
135
163
|
}
|
|
@@ -242,12 +270,6 @@ function examplesPath(type) {
|
|
|
242
270
|
function fakerPath(path) {
|
|
243
271
|
return corePath(`faker/${path || ""}`);
|
|
244
272
|
}
|
|
245
|
-
function frameworkPath(path, options) {
|
|
246
|
-
const absolutePath = storagePath(`framework/${path || ""}`);
|
|
247
|
-
if (options?.relative)
|
|
248
|
-
return relative(options.cwd || process.cwd(), absolutePath);
|
|
249
|
-
return absolutePath;
|
|
250
|
-
}
|
|
251
273
|
function browserPath(path) {
|
|
252
274
|
return corePath(`browser/${path || ""}`);
|
|
253
275
|
}
|
|
@@ -270,7 +292,7 @@ function layoutsPath(path, options) {
|
|
|
270
292
|
else
|
|
271
293
|
absolutePath = resourcesPath(`layouts/${path || ""}`);
|
|
272
294
|
if (options?.relative)
|
|
273
|
-
return
|
|
295
|
+
return relative2(process2.cwd(), absolutePath);
|
|
274
296
|
return absolutePath;
|
|
275
297
|
}
|
|
276
298
|
function libraryPackagePath(slug, path) {
|
|
@@ -321,19 +343,6 @@ function pathPath(path) {
|
|
|
321
343
|
function paymentsPath(path) {
|
|
322
344
|
return corePath(`payments/${path || ""}`);
|
|
323
345
|
}
|
|
324
|
-
function projectPath(filePath = "", options) {
|
|
325
|
-
let path = process.cwd();
|
|
326
|
-
while (path.includes("storage")) {
|
|
327
|
-
const parent = resolve(path, "..");
|
|
328
|
-
if (parent === path)
|
|
329
|
-
break;
|
|
330
|
-
path = parent;
|
|
331
|
-
}
|
|
332
|
-
const finalPath = resolve(path, filePath);
|
|
333
|
-
if (options?.relative)
|
|
334
|
-
return relative(process.cwd(), finalPath);
|
|
335
|
-
return finalPath;
|
|
336
|
-
}
|
|
337
346
|
async function findProjectPath(project) {
|
|
338
347
|
const projectList = Bun.spawnSync(["buddy", "projects:list", "--quiet"]).stdout.toString();
|
|
339
348
|
await debugLog(`ProjectList in findProjectPath ${projectList}`);
|
|
@@ -348,9 +357,6 @@ async function findProjectPath(project) {
|
|
|
348
357
|
function projectConfigPath(path) {
|
|
349
358
|
return projectPath(`config/${path || ""}`);
|
|
350
359
|
}
|
|
351
|
-
function storagePath(path) {
|
|
352
|
-
return projectPath(`storage/${path || ""}`);
|
|
353
|
-
}
|
|
354
360
|
function publicPath(path) {
|
|
355
361
|
return projectPath(`public/${path || ""}`);
|
|
356
362
|
}
|
|
@@ -422,7 +428,7 @@ function realtimePath(path) {
|
|
|
422
428
|
function resourcesPath(path, options) {
|
|
423
429
|
if (options?.relative) {
|
|
424
430
|
const absolutePath = projectPath(`resources/${path || ""}`);
|
|
425
|
-
return
|
|
431
|
+
return relative2(process2.cwd(), absolutePath);
|
|
426
432
|
}
|
|
427
433
|
return projectPath(`resources/${path || ""}`);
|
|
428
434
|
}
|
|
@@ -435,7 +441,7 @@ function routerPath(path) {
|
|
|
435
441
|
function routesPath(path, options) {
|
|
436
442
|
const absolutePath = resourcesPath(`routes/${path || ""}`);
|
|
437
443
|
if (options?.relative)
|
|
438
|
-
return
|
|
444
|
+
return relative2(process2.cwd(), absolutePath);
|
|
439
445
|
return projectPath(`routes/${path || ""}`);
|
|
440
446
|
}
|
|
441
447
|
function searchEnginePath(path) {
|
|
@@ -519,7 +525,7 @@ function typesPath(path) {
|
|
|
519
525
|
function uiPath(path, options) {
|
|
520
526
|
const absolutePath = corePath(`ui/${path || ""}`);
|
|
521
527
|
if (options?.relative)
|
|
522
|
-
return
|
|
528
|
+
return relative2(process2.cwd(), absolutePath);
|
|
523
529
|
return absolutePath;
|
|
524
530
|
}
|
|
525
531
|
function utilsPath(path) {
|
|
@@ -550,8 +556,8 @@ function runtimeDirectoryEnv() {
|
|
|
550
556
|
}
|
|
551
557
|
function applyRuntimeDirectoryEnv() {
|
|
552
558
|
for (const [key, value] of Object.entries(runtimeDirectoryEnv())) {
|
|
553
|
-
if (!
|
|
554
|
-
|
|
559
|
+
if (!process2.env[key]?.trim())
|
|
560
|
+
process2.env[key] = value;
|
|
555
561
|
}
|
|
556
562
|
}
|
|
557
563
|
function mergeDirectoryInto(from, to) {
|
|
@@ -584,7 +590,7 @@ function ensureRuntimeDirectories() {
|
|
|
584
590
|
continue;
|
|
585
591
|
}
|
|
586
592
|
if (stats.isSymbolicLink()) {
|
|
587
|
-
const pointsAtTarget =
|
|
593
|
+
const pointsAtTarget = resolve2(dirname(legacyPath), readlinkSync(legacyPath)) === resolve2(targetPath);
|
|
588
594
|
if (!pointsAtTarget) {
|
|
589
595
|
results.push({ legacy: legacyPath, target: targetPath, cleared: false });
|
|
590
596
|
continue;
|
|
@@ -755,8 +761,8 @@ var path = {
|
|
|
755
761
|
isAbsolute,
|
|
756
762
|
join,
|
|
757
763
|
normalize,
|
|
758
|
-
relative,
|
|
759
|
-
resolve,
|
|
764
|
+
relative: relative2,
|
|
765
|
+
resolve: resolve2,
|
|
760
766
|
parse,
|
|
761
767
|
sep: () => sep,
|
|
762
768
|
toNamespacedPath
|
|
@@ -859,10 +865,10 @@ export {
|
|
|
859
865
|
queryBuilderPath,
|
|
860
866
|
queuePath,
|
|
861
867
|
realtimePath,
|
|
862
|
-
relative,
|
|
868
|
+
relative2 as relative,
|
|
863
869
|
relativeActionsPath,
|
|
864
870
|
replPath,
|
|
865
|
-
resolve,
|
|
871
|
+
resolve2 as resolve,
|
|
866
872
|
resolveUserLibBase,
|
|
867
873
|
resourcesPath,
|
|
868
874
|
routerPath,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
export declare function projectPath(filePath?: string, options?: { relative: boolean }): string;
|
|
3
|
+
export declare function appPath(path?: string, options?: { relative?: boolean, cwd?: string }): string;
|
|
4
|
+
export declare function storagePath(path?: string): string;
|
|
5
|
+
export declare function frameworkPath(path?: string, options?: { relative?: boolean, cwd?: string }): string;
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/project.ts
|
|
3
|
+
import { relative, resolve } from "path";
|
|
4
|
+
import process from "process";
|
|
5
|
+
function projectPath(filePath = "", options) {
|
|
6
|
+
let path = process.cwd();
|
|
7
|
+
while (path.includes("storage")) {
|
|
8
|
+
const parent = resolve(path, "..");
|
|
9
|
+
if (parent === path)
|
|
10
|
+
break;
|
|
11
|
+
path = parent;
|
|
12
|
+
}
|
|
13
|
+
const finalPath = resolve(path, filePath);
|
|
14
|
+
if (options?.relative)
|
|
15
|
+
return relative(process.cwd(), finalPath);
|
|
16
|
+
return finalPath;
|
|
17
|
+
}
|
|
18
|
+
function appPath(path, options) {
|
|
19
|
+
const absolutePath = projectPath(`app/${path || ""}`);
|
|
20
|
+
if (options?.relative)
|
|
21
|
+
return relative(options.cwd || process.cwd(), absolutePath);
|
|
22
|
+
return absolutePath;
|
|
23
|
+
}
|
|
24
|
+
function storagePath(path) {
|
|
25
|
+
return projectPath(`storage/${path || ""}`);
|
|
26
|
+
}
|
|
27
|
+
function frameworkPath(path, options) {
|
|
28
|
+
const absolutePath = storagePath(`framework/${path || ""}`);
|
|
29
|
+
if (options?.relative)
|
|
30
|
+
return relative(options.cwd || process.cwd(), absolutePath);
|
|
31
|
+
return absolutePath;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
appPath,
|
|
35
|
+
frameworkPath,
|
|
36
|
+
projectPath,
|
|
37
|
+
storagePath
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/path",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.74.
|
|
4
|
+
"version": "0.74.31",
|
|
5
5
|
"description": "The Stacks path.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
"bun": "./dist/index.js",
|
|
32
32
|
"import": "./dist/index.js",
|
|
33
33
|
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./project": {
|
|
36
|
+
"types": "./dist/project.d.ts",
|
|
37
|
+
"bun": "./dist/project.js",
|
|
38
|
+
"import": "./dist/project.js",
|
|
39
|
+
"default": "./dist/project.js"
|
|
34
40
|
}
|
|
35
41
|
},
|
|
36
42
|
"module": "dist/index.js",
|