dsh-home-hosted 0.4.2 → 0.4.4
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/docs/DESIGN.md +4 -1
- package/lib/index.js +15 -2
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/docs/DESIGN.md
CHANGED
|
@@ -95,7 +95,10 @@ explicit `$HHOSTED_HOME` still wins, and a panel already living at
|
|
|
95
95
|
every server look like it vanished), but otherwise the root is the instance's own
|
|
96
96
|
`<stateDir>/panel`. Only a root with a `servers.config.json` counts, or a
|
|
97
97
|
`run.json` whose pid is alive — a killed panel leaves a runtime file behind, and
|
|
98
|
-
adopting on that would point a fresh install at somebody's dead root.
|
|
98
|
+
adopting on that would point a fresh install at somebody's dead root. Adoption is
|
|
99
|
+
also limited to an instance that already exists: the machine's own harness home,
|
|
100
|
+
or a state dir that already holds settings. A scratch `DSH_HOME` or a test
|
|
101
|
+
project must not reach over and drive the panel some other install owns.
|
|
99
102
|
|
|
100
103
|
The boot artifact name follows the state root too, but keyed on the *machine*
|
|
101
104
|
default: `home-hosted` only for `~/.dsh/dsh-home-hosted`, `home-hosted-<hash>`
|
package/lib/index.js
CHANGED
|
@@ -1989,10 +1989,23 @@ function resolveHomeHostedHome(stateDir, env = process.env, homeDir = os3.homedi
|
|
|
1989
1989
|
const configured = env.HHOSTED_HOME?.trim();
|
|
1990
1990
|
if (configured)
|
|
1991
1991
|
return { home: resolveUnder(configured, homeDir), source: "env" };
|
|
1992
|
+
const state = resolveUnder(stateDir, homeDir);
|
|
1993
|
+
const own = path6.join(state, "panel");
|
|
1994
|
+
if (fs7.existsSync(own))
|
|
1995
|
+
return { home: own, source: "instance" };
|
|
1992
1996
|
const legacy = path6.join(homeDir, ".home-hosted");
|
|
1993
|
-
if (hasLivePanel(legacy))
|
|
1997
|
+
if (isEstablishedInstance(state, homeDir) && hasLivePanel(legacy))
|
|
1994
1998
|
return { home: legacy, source: "legacy" };
|
|
1995
|
-
return { home:
|
|
1999
|
+
return { home: own, source: "instance" };
|
|
2000
|
+
}
|
|
2001
|
+
function isEstablishedInstance(stateDir, homeDir) {
|
|
2002
|
+
if (stateDir === path6.join(homeDir, ".dsh", "dsh-home-hosted"))
|
|
2003
|
+
return true;
|
|
2004
|
+
try {
|
|
2005
|
+
return fs7.statSync(path6.join(stateDir, "settings.json")).isFile();
|
|
2006
|
+
} catch {
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
1996
2009
|
}
|
|
1997
2010
|
function hasLivePanel(home) {
|
|
1998
2011
|
try {
|