@gajae-code/utils 0.4.5 → 0.5.1
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/types/dirs.d.ts +16 -0
- package/package.json +2 -2
- package/src/dirs.ts +52 -0
- package/src/env.ts +20 -0
package/dist/types/dirs.d.ts
CHANGED
|
@@ -18,6 +18,22 @@ export declare const CONFIG_DIR_NAME: string;
|
|
|
18
18
|
export declare const VERSION: string;
|
|
19
19
|
/** Minimum Bun version */
|
|
20
20
|
export declare const MIN_BUN_VERSION: string;
|
|
21
|
+
/**
|
|
22
|
+
* Build the diagnostic shown when the Bun runtime executing `gjc` is older
|
|
23
|
+
* than {@link MIN_BUN_VERSION}. This is the most common Windows native-install
|
|
24
|
+
* failure (issue #525): `bun install -g gajae-code` probes a recent Bun while
|
|
25
|
+
* the `gjc` launcher resolves an older Bun still on PATH. The message names the
|
|
26
|
+
* exact detected runtime path and gives a platform-specific upgrade + PATH fix
|
|
27
|
+
* instead of a bare `bun upgrade`.
|
|
28
|
+
*
|
|
29
|
+
* Pure and platform-parameterized so it can be unit-tested cross-platform.
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatBunRuntimeError(opts: {
|
|
32
|
+
currentVersion: string;
|
|
33
|
+
minVersion: string;
|
|
34
|
+
execPath?: string;
|
|
35
|
+
platform?: NodeJS.Platform;
|
|
36
|
+
}): string;
|
|
21
37
|
export declare function resolveEquivalentPath(inputPath: string): string;
|
|
22
38
|
export declare function normalizePathForComparison(inputPath: string): string;
|
|
23
39
|
export declare function pathIsWithin(root: string, candidate: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/utils",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://gaebal-gajae.dev",
|
|
7
7
|
"author": "Yeachan-Heo",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fmt": "biome format --write ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@gajae-code/natives": "0.
|
|
34
|
+
"@gajae-code/natives": "0.5.1",
|
|
35
35
|
"beautiful-mermaid": "^1.1.3",
|
|
36
36
|
"handlebars": "^4.7.9",
|
|
37
37
|
"winston": "^3.19.0",
|
package/src/dirs.ts
CHANGED
|
@@ -28,6 +28,58 @@ export const VERSION: string = version;
|
|
|
28
28
|
/** Minimum Bun version */
|
|
29
29
|
export const MIN_BUN_VERSION: string = engines.bun.replace(/[^0-9.]/g, "");
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Build the diagnostic shown when the Bun runtime executing `gjc` is older
|
|
33
|
+
* than {@link MIN_BUN_VERSION}. This is the most common Windows native-install
|
|
34
|
+
* failure (issue #525): `bun install -g gajae-code` probes a recent Bun while
|
|
35
|
+
* the `gjc` launcher resolves an older Bun still on PATH. The message names the
|
|
36
|
+
* exact detected runtime path and gives a platform-specific upgrade + PATH fix
|
|
37
|
+
* instead of a bare `bun upgrade`.
|
|
38
|
+
*
|
|
39
|
+
* Pure and platform-parameterized so it can be unit-tested cross-platform.
|
|
40
|
+
*/
|
|
41
|
+
export function formatBunRuntimeError(opts: {
|
|
42
|
+
currentVersion: string;
|
|
43
|
+
minVersion: string;
|
|
44
|
+
execPath?: string;
|
|
45
|
+
platform?: NodeJS.Platform;
|
|
46
|
+
}): string {
|
|
47
|
+
const platform = opts.platform ?? process.platform;
|
|
48
|
+
const lines = [
|
|
49
|
+
`error: ${APP_NAME} requires Bun >= ${opts.minVersion}, but the running Bun is v${opts.currentVersion}.`,
|
|
50
|
+
];
|
|
51
|
+
if (opts.execPath) {
|
|
52
|
+
lines.push(` detected Bun runtime: ${opts.execPath}`);
|
|
53
|
+
}
|
|
54
|
+
if (platform === "win32") {
|
|
55
|
+
lines.push(
|
|
56
|
+
"",
|
|
57
|
+
"The 'gjc' launcher is using an older Bun than the one used to install it.",
|
|
58
|
+
"Upgrade Bun, then restart your terminal so PATH and the runtime refresh:",
|
|
59
|
+
"",
|
|
60
|
+
' powershell -c "irm bun.sh/install.ps1|iex"',
|
|
61
|
+
"",
|
|
62
|
+
"After restarting the terminal, verify both versions match:",
|
|
63
|
+
" bun --version",
|
|
64
|
+
" gjc --version",
|
|
65
|
+
"",
|
|
66
|
+
"If 'gjc' still loads the old runtime, make sure %USERPROFILE%\\.bun\\bin is",
|
|
67
|
+
"first on PATH and remove any stale Bun installs shadowing it.",
|
|
68
|
+
);
|
|
69
|
+
} else {
|
|
70
|
+
lines.push(
|
|
71
|
+
"",
|
|
72
|
+
"Upgrade Bun, then restart your terminal:",
|
|
73
|
+
" bun upgrade",
|
|
74
|
+
"",
|
|
75
|
+
"Then verify:",
|
|
76
|
+
" bun --version",
|
|
77
|
+
" gjc --version",
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return `${lines.join("\n")}\n`;
|
|
81
|
+
}
|
|
82
|
+
|
|
31
83
|
// =============================================================================
|
|
32
84
|
// Project directory
|
|
33
85
|
// =============================================================================
|
package/src/env.ts
CHANGED
|
@@ -180,6 +180,25 @@ export function $inheritedEnv(name: string): string | undefined {
|
|
|
180
180
|
return resolveFileEnvValue(inheritedEnv, name);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
function resolveLiveCredentialEnvValue(name: string): string | undefined {
|
|
184
|
+
if (!isSafeEnvName(name)) return undefined;
|
|
185
|
+
const value = Bun.env[name];
|
|
186
|
+
if (value === undefined || !isSafeEnvValue(value)) return undefined;
|
|
187
|
+
const trimmed = value.trim();
|
|
188
|
+
if (trimmed.length === 0) return undefined;
|
|
189
|
+
|
|
190
|
+
const projectValue = resolveFileEnvValue(projectEnv, name);
|
|
191
|
+
if (
|
|
192
|
+
projectValue !== undefined &&
|
|
193
|
+
projectValue === trimmed &&
|
|
194
|
+
resolveFileEnvValue(inheritedEnv, name) === undefined
|
|
195
|
+
) {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return trimmed;
|
|
200
|
+
}
|
|
201
|
+
|
|
183
202
|
for (const file of [projectEnv, agentEnv, piEnv, homeEnv, homeShellEnv]) {
|
|
184
203
|
for (const key in file) {
|
|
185
204
|
if (!Bun.env[key]) {
|
|
@@ -224,6 +243,7 @@ export function $pickenv(...keys: string[]): string | undefined {
|
|
|
224
243
|
export function $credentialEnv(name: string): string | undefined {
|
|
225
244
|
return (
|
|
226
245
|
$inheritedEnv(name) ??
|
|
246
|
+
resolveLiveCredentialEnvValue(name) ??
|
|
227
247
|
resolveFileEnvValue(agentEnv, name) ??
|
|
228
248
|
resolveFileEnvValue(piEnv, name) ??
|
|
229
249
|
resolveFileEnvValue(homeEnv, name) ??
|