@ugudlado1/backlog 2.2.0 → 2.2.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/package.json +8 -6
- package/postinstall.cjs +62 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ugudlado1/backlog",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"module": "src/cli.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"cli.js",
|
|
7
7
|
"resolveBinary.cjs",
|
|
8
8
|
"postuninstall.cjs",
|
|
9
|
+
"postinstall.cjs",
|
|
9
10
|
"package.json",
|
|
10
11
|
"README.md",
|
|
11
12
|
"LICENSE"
|
|
@@ -14,13 +15,14 @@
|
|
|
14
15
|
"backlog": "cli.js"
|
|
15
16
|
},
|
|
16
17
|
"optionalDependencies": {
|
|
17
|
-
"@ugudlado1/backlog-linux-x64": "2.2.
|
|
18
|
-
"@ugudlado1/backlog-linux-arm64": "2.2.
|
|
19
|
-
"@ugudlado1/backlog-darwin-x64": "2.2.
|
|
20
|
-
"@ugudlado1/backlog-darwin-arm64": "2.2.
|
|
21
|
-
"@ugudlado1/backlog-windows-x64": "2.2.
|
|
18
|
+
"@ugudlado1/backlog-linux-x64": "2.2.1",
|
|
19
|
+
"@ugudlado1/backlog-linux-arm64": "2.2.1",
|
|
20
|
+
"@ugudlado1/backlog-darwin-x64": "2.2.1",
|
|
21
|
+
"@ugudlado1/backlog-darwin-arm64": "2.2.1",
|
|
22
|
+
"@ugudlado1/backlog-windows-x64": "2.2.1"
|
|
22
23
|
},
|
|
23
24
|
"scripts": {
|
|
25
|
+
"postinstall": "node postinstall.cjs",
|
|
24
26
|
"postuninstall": "node postuninstall.cjs"
|
|
25
27
|
},
|
|
26
28
|
"lint-staged": {
|
package/postinstall.cjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Guarded auto-(re)start of the backlog web UI launchd service on `npm i -g`.
|
|
4
|
+
//
|
|
5
|
+
// This runs on EVERY install, including CI, Docker, project-dependency installs,
|
|
6
|
+
// and other users' machines, so it must stay a strict no-op unless it's clearly
|
|
7
|
+
// safe and wanted:
|
|
8
|
+
// - Global installs only (npm_config_global) — never when added as a project
|
|
9
|
+
// dependency, where the postinstall would fire on every `npm install`.
|
|
10
|
+
// - macOS only (the `service` command is launchd-only).
|
|
11
|
+
// - Never in CI / Docker.
|
|
12
|
+
// - If the service is already installed -> restart it so the upgrade takes
|
|
13
|
+
// effect. This is the common "I upgraded and want the new binary" case and
|
|
14
|
+
// must NOT depend on a TTY: npm pipes script stdio, so an interactive
|
|
15
|
+
// `npm i -g` reports no TTY. npm_config_global is the deterministic signal.
|
|
16
|
+
// - If NOT installed, only start it when the user explicitly opts in with
|
|
17
|
+
// BACKLOG_AUTO_SERVICE=1. A fresh install does NOT silently spawn a daemon.
|
|
18
|
+
//
|
|
19
|
+
// Any failure is swallowed: a postinstall must never break `npm i`.
|
|
20
|
+
|
|
21
|
+
const { existsSync } = require("node:fs");
|
|
22
|
+
const { spawnSync } = require("node:child_process");
|
|
23
|
+
const { join } = require("node:path");
|
|
24
|
+
const os = require("node:os");
|
|
25
|
+
|
|
26
|
+
function skip(reason) {
|
|
27
|
+
// Quiet by default; one line so an interested user can see why nothing happened.
|
|
28
|
+
if (process.env.BACKLOG_DEBUG) console.log(`[backlog postinstall] skipped: ${reason}`);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
// Global installs only — a project dependency must never spawn a daemon.
|
|
34
|
+
if (process.env.npm_config_global !== "true") skip("not a global install");
|
|
35
|
+
if (process.platform !== "darwin") skip("not macOS");
|
|
36
|
+
// CI / container: never touch services.
|
|
37
|
+
if (process.env.CI) skip("CI");
|
|
38
|
+
if (existsSync("/.dockerenv")) skip("docker");
|
|
39
|
+
|
|
40
|
+
const plist = join(os.homedir(), "Library", "LaunchAgents", "md.backlog.browser.plist");
|
|
41
|
+
const installed = existsSync(plist);
|
|
42
|
+
|
|
43
|
+
// Refresh an existing service unconditionally (no TTY/opt-in needed); only a
|
|
44
|
+
// FRESH install requires explicit opt-in to avoid a surprise background daemon.
|
|
45
|
+
if (!installed && process.env.BACKLOG_AUTO_SERVICE !== "1") {
|
|
46
|
+
console.log("backlog: run `backlog service start` to run the web UI as a background service.");
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// `service start` is idempotent — installs if absent, restarts if present,
|
|
51
|
+
// either way the freshly-installed binary is what gets loaded.
|
|
52
|
+
const cli = join(__dirname, "cli.js");
|
|
53
|
+
const entry = existsSync(cli) ? cli : join(__dirname, "cli.cjs"); // cli.js in npm shim, cli.cjs in repo
|
|
54
|
+
const res = spawnSync(process.execPath, [entry, "service", "start"], { stdio: "inherit" });
|
|
55
|
+
if (res.status !== 0) {
|
|
56
|
+
console.log("backlog: could not auto-start the service; run `backlog service start` manually.");
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
if (process.env.BACKLOG_DEBUG) console.error("[backlog postinstall]", err);
|
|
60
|
+
// Never fail the install.
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|