@stacksjs/path 0.75.245 → 0.75.246
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 -1
- package/dist/index.js +15 -2
- package/dist/project.d.ts +12 -3
- package/dist/project.js +15 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1321,6 +1321,6 @@ export declare interface Path {
|
|
|
1321
1321
|
* comparison can say whether it is current.
|
|
1322
1322
|
*/
|
|
1323
1323
|
export type DefaultsProvenance = 'not-applicable' | 'current' | 'stale' | 'unstamped';
|
|
1324
|
-
export { appPath, frameworkDefaultsRoot, frameworkPath, isCompiledBinary, linkPackagedDefaults, packagedDefaultsRoot, projectPath, storagePath, usesVendoredDefaults } from './project';
|
|
1324
|
+
export { appPath, frameworkDefaultsRoot, frameworkPath, isCompiledBinary, isInstalledDefaultsRoot, linkPackagedDefaults, packagedDefaultsRoot, projectPath, storagePath, usesVendoredDefaults } from './project';
|
|
1325
1325
|
export { resolveModulePath } from './module-resolution';
|
|
1326
1326
|
export { basename, delimiter, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep, toNamespacedPath };
|
package/dist/index.js
CHANGED
|
@@ -75,14 +75,26 @@ function appPath(path, options) {
|
|
|
75
75
|
}
|
|
76
76
|
var VENDORED_DEFAULTS = "framework/defaults";
|
|
77
77
|
var packagedDefaultsRoots = new Map;
|
|
78
|
+
function isInstalledDefaultsRoot(path) {
|
|
79
|
+
return /[/\\]@stacksjs[/\\]defaults$/.test(path) && !/[/\\]install[/\\]cache[/\\]/.test(path);
|
|
80
|
+
}
|
|
78
81
|
function packagedDefaultsRoot(projectRoot = projectPath()) {
|
|
79
82
|
const cached = packagedDefaultsRoots.get(projectRoot);
|
|
80
|
-
if (cached
|
|
83
|
+
if (cached)
|
|
81
84
|
return cached;
|
|
85
|
+
for (const dir of ["node_modules", "pantry"]) {
|
|
86
|
+
const candidate = join(projectRoot, dir, "@stacksjs", "defaults");
|
|
87
|
+
if (existsSync(join(candidate, "package.json"))) {
|
|
88
|
+
packagedDefaultsRoots.set(projectRoot, candidate);
|
|
89
|
+
return candidate;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (cached === null)
|
|
93
|
+
return null;
|
|
82
94
|
let root = null;
|
|
83
95
|
try {
|
|
84
96
|
const resolved = dirname(Bun.resolveSync("@stacksjs/defaults/package.json", projectRoot));
|
|
85
|
-
if (
|
|
97
|
+
if (isInstalledDefaultsRoot(resolved))
|
|
86
98
|
root = resolved;
|
|
87
99
|
} catch {}
|
|
88
100
|
packagedDefaultsRoots.set(projectRoot, root);
|
|
@@ -932,6 +944,7 @@ export {
|
|
|
932
944
|
installedDefaultsVersion,
|
|
933
945
|
isAbsolute2 as isAbsolute,
|
|
934
946
|
isCompiledBinary,
|
|
947
|
+
isInstalledDefaultsRoot,
|
|
935
948
|
jobsPath,
|
|
936
949
|
join2 as join,
|
|
937
950
|
langPath,
|
package/dist/project.d.ts
CHANGED
|
@@ -2,12 +2,21 @@ import { relative } from 'node:path';
|
|
|
2
2
|
export declare function isCompiledBinary(main?: string | undefined): boolean;
|
|
3
3
|
export declare function projectPath(filePath?: string, options?: { relative: boolean }): string;
|
|
4
4
|
export declare function appPath(path?: string, options?: { relative?: boolean, cwd?: string }): string;
|
|
5
|
+
/**
|
|
6
|
+
* Whether a resolved `@stacksjs/defaults` is a copy the project installed.
|
|
7
|
+
*
|
|
8
|
+
* With none installed, Bun answers from its own auto-install cache
|
|
9
|
+
* (`~/.bun/install/cache/@stacksjs/defaults@x@@@1`, or
|
|
10
|
+
* `<repo>/pantry/install/cache/...` on CI): a release nobody declared. A test
|
|
11
|
+
* running in a temp directory then loaded that release's models.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isInstalledDefaultsRoot(path: string): boolean;
|
|
5
14
|
/**
|
|
6
15
|
* Where the installed `@stacksjs/defaults` lives for a project, or null when
|
|
7
16
|
* it is not installed. Resolved through `package.json` because the package
|
|
8
|
-
* publishes no `.` export, and memoised per project root: it
|
|
9
|
-
* without a reinstall, and this sits under every `storagePath()`
|
|
10
|
-
* names the defaults tree.
|
|
17
|
+
* publishes no `.` export, and memoised per project root once found: it
|
|
18
|
+
* cannot move without a reinstall, and this sits under every `storagePath()`
|
|
19
|
+
* call that names the defaults tree.
|
|
11
20
|
*/
|
|
12
21
|
export declare function packagedDefaultsRoot(projectRoot?: string): string | null;
|
|
13
22
|
/**
|
package/dist/project.js
CHANGED
|
@@ -45,14 +45,26 @@ function appPath(path, options) {
|
|
|
45
45
|
}
|
|
46
46
|
var VENDORED_DEFAULTS = "framework/defaults";
|
|
47
47
|
var packagedDefaultsRoots = new Map;
|
|
48
|
+
function isInstalledDefaultsRoot(path) {
|
|
49
|
+
return /[/\\]@stacksjs[/\\]defaults$/.test(path) && !/[/\\]install[/\\]cache[/\\]/.test(path);
|
|
50
|
+
}
|
|
48
51
|
function packagedDefaultsRoot(projectRoot = projectPath()) {
|
|
49
52
|
const cached = packagedDefaultsRoots.get(projectRoot);
|
|
50
|
-
if (cached
|
|
53
|
+
if (cached)
|
|
51
54
|
return cached;
|
|
55
|
+
for (const dir of ["node_modules", "pantry"]) {
|
|
56
|
+
const candidate = join(projectRoot, dir, "@stacksjs", "defaults");
|
|
57
|
+
if (existsSync(join(candidate, "package.json"))) {
|
|
58
|
+
packagedDefaultsRoots.set(projectRoot, candidate);
|
|
59
|
+
return candidate;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (cached === null)
|
|
63
|
+
return null;
|
|
52
64
|
let root = null;
|
|
53
65
|
try {
|
|
54
66
|
const resolved = dirname(Bun.resolveSync("@stacksjs/defaults/package.json", projectRoot));
|
|
55
|
-
if (
|
|
67
|
+
if (isInstalledDefaultsRoot(resolved))
|
|
56
68
|
root = resolved;
|
|
57
69
|
} catch {}
|
|
58
70
|
packagedDefaultsRoots.set(projectRoot, root);
|
|
@@ -112,6 +124,7 @@ export {
|
|
|
112
124
|
frameworkDefaultsRoot,
|
|
113
125
|
frameworkPath,
|
|
114
126
|
isCompiledBinary,
|
|
127
|
+
isInstalledDefaultsRoot,
|
|
115
128
|
linkPackagedDefaults,
|
|
116
129
|
packagedDefaultsRoot,
|
|
117
130
|
projectPath,
|