@stacksjs/path 0.75.207 → 0.75.210
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 +1 -0
- package/dist/index.js +30 -13
- package/dist/module-resolution.d.ts +2 -0
- package/dist/module-resolution.js +20 -0
- package/package.json +7 -1
package/dist/index.d.ts
CHANGED
|
@@ -1320,4 +1320,5 @@ export declare interface Path {
|
|
|
1320
1320
|
*/
|
|
1321
1321
|
export type DefaultsProvenance = 'not-applicable' | 'current' | 'stale' | 'unstamped';
|
|
1322
1322
|
export { appPath, frameworkPath, isCompiledBinary, projectPath, storagePath } from './project';
|
|
1323
|
+
export { resolveModulePath } from './module-resolution';
|
|
1323
1324
|
export { basename, delimiter, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep, toNamespacedPath };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/index.ts
|
|
3
3
|
import {
|
|
4
|
-
existsSync as
|
|
4
|
+
existsSync as existsSync3,
|
|
5
5
|
lstatSync,
|
|
6
6
|
mkdirSync,
|
|
7
7
|
readFileSync,
|
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
delimiter,
|
|
19
19
|
dirname,
|
|
20
20
|
extname,
|
|
21
|
-
isAbsolute,
|
|
21
|
+
isAbsolute as isAbsolute2,
|
|
22
22
|
join as join2,
|
|
23
23
|
normalize,
|
|
24
24
|
parse,
|
|
25
25
|
relative as relative2,
|
|
26
|
-
resolve as
|
|
26
|
+
resolve as resolve3,
|
|
27
27
|
sep as sep2,
|
|
28
28
|
toNamespacedPath
|
|
29
29
|
} from "path";
|
|
@@ -82,6 +82,22 @@ function frameworkPath(path, options) {
|
|
|
82
82
|
return relative(options.cwd || process.cwd(), absolutePath);
|
|
83
83
|
return absolutePath;
|
|
84
84
|
}
|
|
85
|
+
// src/module-resolution.ts
|
|
86
|
+
import { existsSync as existsSync2 } from "fs";
|
|
87
|
+
import { isAbsolute, resolve as resolve2 } from "path";
|
|
88
|
+
import { fileURLToPath } from "url";
|
|
89
|
+
function resolveModulePath(specifier, importerDirectory) {
|
|
90
|
+
if (specifier.startsWith("file:"))
|
|
91
|
+
return fileURLToPath(specifier);
|
|
92
|
+
if (specifier.startsWith(".") || isAbsolute(specifier))
|
|
93
|
+
return resolve2(importerDirectory, specifier);
|
|
94
|
+
if (specifier.startsWith("@"))
|
|
95
|
+
return Bun.resolveSync(specifier, importerDirectory);
|
|
96
|
+
const local = resolve2(importerDirectory, specifier);
|
|
97
|
+
if (existsSync2(local))
|
|
98
|
+
return local;
|
|
99
|
+
return Bun.resolveSync(specifier, importerDirectory);
|
|
100
|
+
}
|
|
85
101
|
|
|
86
102
|
// src/index.ts
|
|
87
103
|
async function debugLog(message) {
|
|
@@ -120,7 +136,7 @@ function userViewsPath(path) {
|
|
|
120
136
|
function userFunctionsPath(path) {
|
|
121
137
|
return `${resolveUserLibBase(projectPath("functions"), resourcesPath("functions"))}/${path || ""}`;
|
|
122
138
|
}
|
|
123
|
-
function resolveUserLibBase(rootDir, resourcesDir, exists =
|
|
139
|
+
function resolveUserLibBase(rootDir, resourcesDir, exists = existsSync3) {
|
|
124
140
|
return exists(rootDir) ? rootDir : resourcesDir;
|
|
125
141
|
}
|
|
126
142
|
function userJobsPath(path) {
|
|
@@ -239,7 +255,7 @@ function configPath(path) {
|
|
|
239
255
|
}
|
|
240
256
|
function siteConfigPath(root = projectPath()) {
|
|
241
257
|
const configured = join2(root, "config/site.ts");
|
|
242
|
-
return
|
|
258
|
+
return existsSync3(configured) ? configured : join2(root, "site.config.ts");
|
|
243
259
|
}
|
|
244
260
|
function corePath(path) {
|
|
245
261
|
return frameworkPath(`core/${path || ""}`);
|
|
@@ -407,9 +423,9 @@ function isInside(child, parent) {
|
|
|
407
423
|
function inspectDefaultsProvenance(projectRoot = projectPath()) {
|
|
408
424
|
const targetDefaults = join2(projectRoot, "storage/framework/defaults");
|
|
409
425
|
const packageRoot = defaultsPackagePath(projectRoot);
|
|
410
|
-
if (!
|
|
426
|
+
if (!existsSync3(targetDefaults) || !existsSync3(join2(packageRoot, "package.json")))
|
|
411
427
|
return notApplicable();
|
|
412
|
-
if (
|
|
428
|
+
if (existsSync3(join2(projectRoot, "storage/framework/core/buddy/package.json")))
|
|
413
429
|
return notApplicable();
|
|
414
430
|
try {
|
|
415
431
|
if (!isInside(packageRoot, join2(realpathSync(projectRoot), "node_modules")))
|
|
@@ -587,7 +603,7 @@ function mergeDirectoryInto(from, to) {
|
|
|
587
603
|
for (const entry of readdirSync(from)) {
|
|
588
604
|
const source = join2(from, entry);
|
|
589
605
|
const destination = join2(to, entry);
|
|
590
|
-
if (!
|
|
606
|
+
if (!existsSync3(destination)) {
|
|
591
607
|
renameSync(source, destination);
|
|
592
608
|
continue;
|
|
593
609
|
}
|
|
@@ -612,7 +628,7 @@ function ensureRuntimeDirectories() {
|
|
|
612
628
|
}
|
|
613
629
|
mkdirSync(targetPath, { recursive: true });
|
|
614
630
|
if (stats.isSymbolicLink()) {
|
|
615
|
-
const pointsAtTarget =
|
|
631
|
+
const pointsAtTarget = resolve3(dirname(legacyPath), readlinkSync(legacyPath)) === resolve3(targetPath);
|
|
616
632
|
if (!pointsAtTarget) {
|
|
617
633
|
results.push({ legacy: legacyPath, target: targetPath, cleared: false });
|
|
618
634
|
continue;
|
|
@@ -780,11 +796,11 @@ var path = {
|
|
|
780
796
|
delimiter: () => delimiter,
|
|
781
797
|
dirname,
|
|
782
798
|
extname,
|
|
783
|
-
isAbsolute,
|
|
799
|
+
isAbsolute: isAbsolute2,
|
|
784
800
|
join: join2,
|
|
785
801
|
normalize,
|
|
786
802
|
relative: relative2,
|
|
787
|
-
resolve:
|
|
803
|
+
resolve: resolve3,
|
|
788
804
|
parse,
|
|
789
805
|
sep: () => sep2,
|
|
790
806
|
toNamespacedPath
|
|
@@ -854,7 +870,7 @@ export {
|
|
|
854
870
|
homeDir,
|
|
855
871
|
inspectDefaultsProvenance,
|
|
856
872
|
installedDefaultsVersion,
|
|
857
|
-
isAbsolute,
|
|
873
|
+
isAbsolute2 as isAbsolute,
|
|
858
874
|
isCompiledBinary,
|
|
859
875
|
jobsPath,
|
|
860
876
|
join2 as join,
|
|
@@ -891,7 +907,8 @@ export {
|
|
|
891
907
|
relative2 as relative,
|
|
892
908
|
relativeActionsPath,
|
|
893
909
|
replPath,
|
|
894
|
-
|
|
910
|
+
resolve3 as resolve,
|
|
911
|
+
resolveModulePath,
|
|
895
912
|
resolveUserLibBase,
|
|
896
913
|
resourcesPath,
|
|
897
914
|
routerPath,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/module-resolution.ts
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { isAbsolute, resolve } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
function resolveModulePath(specifier, importerDirectory) {
|
|
7
|
+
if (specifier.startsWith("file:"))
|
|
8
|
+
return fileURLToPath(specifier);
|
|
9
|
+
if (specifier.startsWith(".") || isAbsolute(specifier))
|
|
10
|
+
return resolve(importerDirectory, specifier);
|
|
11
|
+
if (specifier.startsWith("@"))
|
|
12
|
+
return Bun.resolveSync(specifier, importerDirectory);
|
|
13
|
+
const local = resolve(importerDirectory, specifier);
|
|
14
|
+
if (existsSync(local))
|
|
15
|
+
return local;
|
|
16
|
+
return Bun.resolveSync(specifier, importerDirectory);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
resolveModulePath
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/path",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.75.
|
|
4
|
+
"version": "0.75.210",
|
|
5
5
|
"description": "The Stacks path.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -37,6 +37,12 @@
|
|
|
37
37
|
"bun": "./dist/project.js",
|
|
38
38
|
"import": "./dist/project.js",
|
|
39
39
|
"default": "./dist/project.js"
|
|
40
|
+
},
|
|
41
|
+
"./module-resolution": {
|
|
42
|
+
"types": "./dist/module-resolution.d.ts",
|
|
43
|
+
"bun": "./dist/module-resolution.js",
|
|
44
|
+
"import": "./dist/module-resolution.js",
|
|
45
|
+
"default": "./dist/module-resolution.js"
|
|
40
46
|
}
|
|
41
47
|
},
|
|
42
48
|
"module": "dist/index.js",
|