ftown-bridge 0.30.6 → 0.30.7
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.
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** The exact managed block: BEGIN marker, the PATH export, END marker. */
|
|
2
2
|
export declare function buildManagedBlock(): string;
|
|
3
|
+
/**
|
|
4
|
+
* Fish-flavoured managed block. The BEGIN/END markers are `#` comments in fish
|
|
5
|
+
* too, so the same upsert logic applies; only the PATH assignment differs
|
|
6
|
+
* (fish uses `set -gx`, not `export`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildFishManagedBlock(): string;
|
|
3
9
|
/**
|
|
4
10
|
* PURE. Upsert the managed `block` into `existing` shell-profile content.
|
|
5
11
|
*
|
|
@@ -15,11 +21,20 @@ export declare function upsertManagedBlock(existing: string, block: string): {
|
|
|
15
21
|
/**
|
|
16
22
|
* Ensure ~/.ftown is on PATH via the user's shell profiles.
|
|
17
23
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
24
|
+
* Targets, all created if missing and all idempotent across calls:
|
|
25
|
+
* - ~/.zshenv (zsh, read by both login and non-login shells).
|
|
26
|
+
* - Bash: ~/.bashrc when it exists (interactive non-login shells, which most
|
|
27
|
+
* login profiles source). When it does NOT exist, a login shell instead
|
|
28
|
+
* reads the first of ~/.bash_profile, ~/.bash_login or ~/.profile, so we
|
|
29
|
+
* target ~/.bash_profile if present and otherwise ~/.profile. This keeps
|
|
30
|
+
* login semantics correct: writing only ~/.profile would be ignored when a
|
|
31
|
+
* ~/.bash_profile exists.
|
|
32
|
+
* - ~/.config/fish/conf.d/ftown.fish (sourced by every fish shell), using fish
|
|
33
|
+
* syntax rather than `export`.
|
|
34
|
+
*
|
|
35
|
+
* Honors `FTOWN_SKIP_PATH_SETUP` as a boolean kill-switch (unset or one of
|
|
21
36
|
* 0/false/no/off -> not skipped; any other value -> no-op). Returns the
|
|
22
|
-
* profiles actually written
|
|
37
|
+
* profiles actually written.
|
|
23
38
|
*/
|
|
24
39
|
export declare function ensureFtownOnPath(opts?: {
|
|
25
40
|
home?: string;
|
|
@@ -6,15 +6,23 @@
|
|
|
6
6
|
* clearly-fenced block in the user's shell profiles, never touching content
|
|
7
7
|
* outside its BEGIN..END markers, and runs only during explicit ftown setup.
|
|
8
8
|
*/
|
|
9
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
10
10
|
import { homedir } from 'node:os';
|
|
11
|
-
import { join } from 'node:path';
|
|
11
|
+
import { dirname, join } from 'node:path';
|
|
12
12
|
const BEGIN = '# >>> ftown (managed by ftown-bridge) >>>';
|
|
13
13
|
const END = '# <<< ftown (managed by ftown-bridge) <<<';
|
|
14
14
|
/** The exact managed block: BEGIN marker, the PATH export, END marker. */
|
|
15
15
|
export function buildManagedBlock() {
|
|
16
16
|
return `${BEGIN}\nexport PATH="$HOME/.ftown:$PATH"\n${END}`;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Fish-flavoured managed block. The BEGIN/END markers are `#` comments in fish
|
|
20
|
+
* too, so the same upsert logic applies; only the PATH assignment differs
|
|
21
|
+
* (fish uses `set -gx`, not `export`).
|
|
22
|
+
*/
|
|
23
|
+
export function buildFishManagedBlock() {
|
|
24
|
+
return `${BEGIN}\nset -gx PATH "$HOME/.ftown" $PATH\n${END}`;
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* PURE. Upsert the managed `block` into `existing` shell-profile content.
|
|
20
28
|
*
|
|
@@ -42,8 +50,10 @@ export function upsertManagedBlock(existing, block) {
|
|
|
42
50
|
function writeIfChanged(path, block) {
|
|
43
51
|
const existing = existsSync(path) ? readFileSync(path, 'utf8') : '';
|
|
44
52
|
const { content, changed } = upsertManagedBlock(existing, block);
|
|
45
|
-
if (changed)
|
|
53
|
+
if (changed) {
|
|
54
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
46
55
|
writeFileSync(path, content, { mode: 0o644 });
|
|
56
|
+
}
|
|
47
57
|
return changed;
|
|
48
58
|
}
|
|
49
59
|
/** Boolean env-flag convention: unset / 0 / false / no / off are all "not set". */
|
|
@@ -55,11 +65,20 @@ function isTruthyFlag(value) {
|
|
|
55
65
|
/**
|
|
56
66
|
* Ensure ~/.ftown is on PATH via the user's shell profiles.
|
|
57
67
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
68
|
+
* Targets, all created if missing and all idempotent across calls:
|
|
69
|
+
* - ~/.zshenv (zsh, read by both login and non-login shells).
|
|
70
|
+
* - Bash: ~/.bashrc when it exists (interactive non-login shells, which most
|
|
71
|
+
* login profiles source). When it does NOT exist, a login shell instead
|
|
72
|
+
* reads the first of ~/.bash_profile, ~/.bash_login or ~/.profile, so we
|
|
73
|
+
* target ~/.bash_profile if present and otherwise ~/.profile. This keeps
|
|
74
|
+
* login semantics correct: writing only ~/.profile would be ignored when a
|
|
75
|
+
* ~/.bash_profile exists.
|
|
76
|
+
* - ~/.config/fish/conf.d/ftown.fish (sourced by every fish shell), using fish
|
|
77
|
+
* syntax rather than `export`.
|
|
78
|
+
*
|
|
79
|
+
* Honors `FTOWN_SKIP_PATH_SETUP` as a boolean kill-switch (unset or one of
|
|
61
80
|
* 0/false/no/off -> not skipped; any other value -> no-op). Returns the
|
|
62
|
-
* profiles actually written
|
|
81
|
+
* profiles actually written.
|
|
63
82
|
*/
|
|
64
83
|
export function ensureFtownOnPath(opts) {
|
|
65
84
|
const env = opts?.env ?? process.env;
|
|
@@ -72,8 +91,22 @@ export function ensureFtownOnPath(opts) {
|
|
|
72
91
|
if (writeIfChanged(zshenv, block))
|
|
73
92
|
updated.push(zshenv);
|
|
74
93
|
const bashrc = join(home, '.bashrc');
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
const bashProfile = join(home, '.bash_profile');
|
|
95
|
+
const profile = join(home, '.profile');
|
|
96
|
+
if (existsSync(bashrc)) {
|
|
97
|
+
if (writeIfChanged(bashrc, block))
|
|
98
|
+
updated.push(bashrc);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// No .bashrc: the only way a bash shell sees us is via a login file, and
|
|
102
|
+
// bash reads .bash_profile in preference to .profile.
|
|
103
|
+
const loginProfile = existsSync(bashProfile) ? bashProfile : profile;
|
|
104
|
+
if (writeIfChanged(loginProfile, block))
|
|
105
|
+
updated.push(loginProfile);
|
|
106
|
+
}
|
|
107
|
+
const fishConf = join(home, '.config', 'fish', 'conf.d', 'ftown.fish');
|
|
108
|
+
if (writeIfChanged(fishConf, buildFishManagedBlock()))
|
|
109
|
+
updated.push(fishConf);
|
|
77
110
|
return { updated, skipped: false };
|
|
78
111
|
}
|
|
79
112
|
//# sourceMappingURL=ensure-ftown-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-ftown-path.js","sourceRoot":"","sources":["../src/ensure-ftown-path.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ensure-ftown-path.js","sourceRoot":"","sources":["../src/ensure-ftown-path.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,KAAK,GAAG,2CAA2C,CAAC;AAC1D,MAAM,GAAG,GAAG,2CAA2C,CAAC;AAExD,0EAA0E;AAC1E,MAAM,UAAU,iBAAiB;IAC/B,OAAO,GAAG,KAAK,uCAAuC,GAAG,EAAE,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,M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AE,SAAS,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,yEAAyE;QACzE,sDAAsD;QACtD,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC;QACrE,IAAI,cAAc,CAAC,YAAY,EAAE,KAAK,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACvE,IAAI,cAAc,CAAC,QAAQ,EAAE,qBAAqB,EAAE,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE9E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ftown-bridge",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.7",
|
|
4
4
|
"description": "CLI bridge for ftown — generic PTY-over-Centrifugo relay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"overrides": {
|
|
74
74
|
"qs": "6.16.1"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "af2fecca2ab156a4af22423b84eecac44fa57d1f"
|
|
77
77
|
}
|