@ac-kit/app-system 0.1.2 → 0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @ac-kit/app-system
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [235ec3c]
8
+ - @ac-kit/core@0.5.0
9
+ - @ac-kit/app-report@0.1.4
10
+ - @ac-kit/async@0.1.4
11
+ - @ac-kit/crypto-hash@0.1.4
12
+ - @ac-kit/data@0.1.4
13
+ - @ac-kit/format-ansi@0.1.4
14
+ - @ac-kit/format-shell@0.1.3
15
+ - @ac-kit/node@0.3.2
16
+
17
+ ## 0.2.0
18
+
19
+ ### Minor Changes
20
+
21
+ - 6cce28a: `getXdgBaseDirectories` resolves the XDG Base Directory specification's data,
22
+ configuration, state, cache, executable and runtime directories and search
23
+ lists, ignoring the empty and relative values the specification rules out.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [aca1cb1]
28
+ - @ac-kit/core@0.4.0
29
+ - @ac-kit/app-report@0.1.3
30
+ - @ac-kit/async@0.1.3
31
+ - @ac-kit/crypto-hash@0.1.3
32
+ - @ac-kit/data@0.1.3
33
+ - @ac-kit/format-ansi@0.1.3
34
+ - @ac-kit/format-shell@0.1.2
35
+ - @ac-kit/node@0.3.1
36
+
3
37
  ## 0.1.2
4
38
 
5
39
  ### Patch Changes
package/README.md CHANGED
@@ -33,7 +33,8 @@ teardown order is declared rather than implied by registration order.
33
33
  - **Process inspection** — `ps` with filters, `getProcessesSnapshot`,
34
34
  `hostMetrics`, and `sysfs` readers.
35
35
  - **Files** — `rotateLogFiles`, `RotatingFileSink` (optionally gzip-compressed),
36
- and an artifact cache.
36
+ an artifact cache, and `getXdgBaseDirectories` for where an application keeps
37
+ its data, configuration, state and cache.
37
38
  - **Locks** — `FileLock` and `UdpBindLock`, for single-instance enforcement.
38
39
  - **Terminal and text** — `nodeTerminal`, the Node adapter for
39
40
  `@ac-kit/app-terminal`'s `Terminal`, plus charset encode/decode streams.
@@ -41,5 +42,5 @@ teardown order is declared rather than implied by registration order.
41
42
  Node only, by definition: this is the host-bound layer.
42
43
 
43
44
  See the
44
- [generated API docs](https://anthochamp.github.io/node-essentials/api/app-system/)
45
+ [generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/app-system/)
45
46
  for the full reference.
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./os/process-kill-by-pid-file.js";
9
9
  export * from "./os/process-wait-pid.js";
10
10
  export * from "./os/ps.js";
11
11
  export * from "./os/sysfs.js";
12
+ export * from "./os/xdg-base-directories.js";
12
13
  export * from "./process/child-process-message-sink.js";
13
14
  export * from "./process/error-listeners.js";
14
15
  export * from "./process/exit-manager.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,yCAAyC,CAAC;AACxD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yCAAyC,CAAC;AACxD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC"}
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ export * from "./os/process-kill-by-pid-file.js";
9
9
  export * from "./os/process-wait-pid.js";
10
10
  export * from "./os/ps.js";
11
11
  export * from "./os/sysfs.js";
12
+ export * from "./os/xdg-base-directories.js";
12
13
  export * from "./process/child-process-message-sink.js";
13
14
  export * from "./process/error-listeners.js";
14
15
  export * from "./process/exit-manager.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,yCAAyC,CAAC;AACxD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yCAAyC,CAAC;AACxD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Where an application keeps its files, per the XDG Base Directory
3
+ * specification.
4
+ */
5
+ export type XdgBaseDirectories = {
6
+ /** `$XDG_DATA_HOME`: user data files, `~/.local/share` by default. */
7
+ dataHome: string;
8
+ /** `$XDG_CONFIG_HOME`: user configuration, `~/.config` by default. */
9
+ configHome: string;
10
+ /**
11
+ * `$XDG_STATE_HOME`: state worth keeping across restarts but not backing up —
12
+ * logs, history — `~/.local/state` by default.
13
+ */
14
+ stateHome: string;
15
+ /** `$XDG_CACHE_HOME`: non-essential cached data, `~/.cache` by default. */
16
+ cacheHome: string;
17
+ /**
18
+ * `~/.local/bin`: user executables. The specification names no variable for
19
+ * it.
20
+ */
21
+ binHome: string;
22
+ /**
23
+ * `$XDG_RUNTIME_DIR`: sockets, pipes and other runtime files, owned by the
24
+ * user and removed at logout. `undefined` when unset, since the specification
25
+ * gives it no default: the application picks its own fallback.
26
+ */
27
+ runtimeDir: string | undefined;
28
+ /** `$XDG_DATA_DIRS`: data directories to search after `dataHome`, in order. */
29
+ dataDirs: string[];
30
+ /**
31
+ * `$XDG_CONFIG_DIRS`: configuration directories to search after `configHome`,
32
+ * in order.
33
+ */
34
+ configDirs: string[];
35
+ };
36
+ /** Options of {@link getXdgBaseDirectories}. */
37
+ export type GetXdgBaseDirectoriesOptions = {
38
+ /** The environment to read, `process.env` by default. */
39
+ env?: Readonly<Record<string, string | undefined>>;
40
+ /** The home directory, `os.homedir()` by default. */
41
+ home?: string;
42
+ };
43
+ /**
44
+ * Resolves the XDG base directories (specification 0.8): where an application
45
+ * should read and write its data, configuration, state, cache and runtime files
46
+ * on Linux and other freedesktop.org systems.
47
+ *
48
+ * Append the application's own directory name to the one it needs:
49
+ * `join(getXdgBaseDirectories().dataHome, "myapp")`. Nothing is created.
50
+ *
51
+ * A variable that is unset, empty or holds a relative path falls back to its
52
+ * default, as the specification requires; in a list, relative entries are
53
+ * dropped, and a list left empty falls back too.
54
+ *
55
+ * Time complexity: O(n) in the length of the variables read. Memory: O(n).
56
+ *
57
+ * @example
58
+ * getXdgBaseDirectories({ env: {}, home: "/home/ada" }).dataHome;
59
+ * // "/home/ada/.local/share"
60
+ *
61
+ * @param options - The environment and home directory to read.
62
+ * @returns The directories, as absolute paths.
63
+ */
64
+ export declare function getXdgBaseDirectories(options?: GetXdgBaseDirectoriesOptions): XdgBaseDirectories;
65
+ //# sourceMappingURL=xdg-base-directories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xdg-base-directories.d.ts","sourceRoot":"","sources":["../../src/os/xdg-base-directories.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,4BAA4B,GAAG;IAC1C,yDAAyD;IACzD,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACnD,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,CAAC,EAAE,4BAA4B,GACpC,kBAAkB,CA8BpB"}
@@ -0,0 +1,51 @@
1
+ import { homedir } from "node:os";
2
+ import { isAbsolute, join } from "node:path";
3
+ /**
4
+ * Resolves the XDG base directories (specification 0.8): where an application
5
+ * should read and write its data, configuration, state, cache and runtime files
6
+ * on Linux and other freedesktop.org systems.
7
+ *
8
+ * Append the application's own directory name to the one it needs:
9
+ * `join(getXdgBaseDirectories().dataHome, "myapp")`. Nothing is created.
10
+ *
11
+ * A variable that is unset, empty or holds a relative path falls back to its
12
+ * default, as the specification requires; in a list, relative entries are
13
+ * dropped, and a list left empty falls back too.
14
+ *
15
+ * Time complexity: O(n) in the length of the variables read. Memory: O(n).
16
+ *
17
+ * @example
18
+ * getXdgBaseDirectories({ env: {}, home: "/home/ada" }).dataHome;
19
+ * // "/home/ada/.local/share"
20
+ *
21
+ * @param options - The environment and home directory to read.
22
+ * @returns The directories, as absolute paths.
23
+ */
24
+ export function getXdgBaseDirectories(options) {
25
+ const env = options?.env ?? process.env;
26
+ const home = options?.home ?? homedir();
27
+ const single = (name, fallback) => {
28
+ const value = env[name];
29
+ return value !== undefined && isAbsolute(value) ? value : fallback;
30
+ };
31
+ const list = (name, fallback) => {
32
+ const values = (env[name] ?? "")
33
+ .split(":")
34
+ .filter((value) => isAbsolute(value));
35
+ return values.length > 0 ? values : fallback;
36
+ };
37
+ const runtimeDir = env["XDG_RUNTIME_DIR"];
38
+ return {
39
+ dataHome: single("XDG_DATA_HOME", join(home, ".local", "share")),
40
+ configHome: single("XDG_CONFIG_HOME", join(home, ".config")),
41
+ stateHome: single("XDG_STATE_HOME", join(home, ".local", "state")),
42
+ cacheHome: single("XDG_CACHE_HOME", join(home, ".cache")),
43
+ binHome: join(home, ".local", "bin"),
44
+ runtimeDir: runtimeDir !== undefined && isAbsolute(runtimeDir)
45
+ ? runtimeDir
46
+ : undefined,
47
+ dataDirs: list("XDG_DATA_DIRS", ["/usr/local/share", "/usr/share"]),
48
+ configDirs: list("XDG_CONFIG_DIRS", ["/etc/xdg"]),
49
+ };
50
+ }
51
+ //# sourceMappingURL=xdg-base-directories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xdg-base-directories.js","sourceRoot":"","sources":["../../src/os/xdg-base-directories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA8C7C;;;;;;;;;;;;;;;;;;;;GAoBG;A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;QACzD,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC;QACpC,UAAU,EACT,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,UAAU,CAAC;YACjD,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,SAAS;QACb,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;QACnE,UAAU,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,UAAU,CAAC,CAAC;KACjD,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ac-kit/app-system",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "Process lifecycle helpers: PID files, process inspection, log rotation and command execution.",
5
5
  "keywords": [
6
6
  "log-rotation",
@@ -9,15 +9,15 @@
9
9
  "process",
10
10
  "system"
11
11
  ],
12
- "homepage": "https://anthochamp.github.io/node-essentials/api/app-system/",
12
+ "homepage": "https://anthochamp.pages.grenadine.io/node-essentials/api/app-system/",
13
13
  "bugs": {
14
- "url": "https://github.com/anthochamp/node-essentials/issues"
14
+ "url": "https://git.grenadine.io/anthochamp/node-essentials/issues"
15
15
  },
16
16
  "license": "BSD-3-Clause",
17
17
  "author": "Anthony Champagne <dev@anthonychampagne.fr>",
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "git+https://github.com/anthochamp/node-essentials.git",
20
+ "url": "git+https://git.grenadine.io/anthochamp/node-essentials.git",
21
21
  "directory": "packages/app-system"
22
22
  },
23
23
  "files": [
@@ -39,15 +39,15 @@
39
39
  "prepack": "yarn build"
40
40
  },
41
41
  "dependencies": {
42
- "@ac-kit/app-report": "^0.1.2",
42
+ "@ac-kit/app-report": "^0.1.4",
43
43
  "@ac-kit/app-terminal": "^0.1.0",
44
- "@ac-kit/async": "^0.1.2",
45
- "@ac-kit/core": "0.3.0",
46
- "@ac-kit/crypto-hash": "^0.1.2",
47
- "@ac-kit/data": "^0.1.2",
48
- "@ac-kit/format-ansi": "^0.1.2",
49
- "@ac-kit/format-shell": "^0.1.1",
50
- "@ac-kit/node": "0.3.0",
44
+ "@ac-kit/async": "^0.1.4",
45
+ "@ac-kit/core": "0.5.0",
46
+ "@ac-kit/crypto-hash": "^0.1.4",
47
+ "@ac-kit/data": "^0.1.4",
48
+ "@ac-kit/format-ansi": "^0.1.4",
49
+ "@ac-kit/format-shell": "^0.1.3",
50
+ "@ac-kit/node": "0.3.2",
51
51
  "@types/node": "^26.5.1",
52
52
  "type-fest": "^5.8.0"
53
53
  },
@@ -58,7 +58,7 @@
58
58
  "@typescript/native": "typescript@7.0.2",
59
59
  "iconv-lite": "0.7.3",
60
60
  "rimraf": "6.1.3",
61
- "tsx": "4.23.12",
61
+ "tsx": "4.23.15",
62
62
  "typedoc": "0.28.20",
63
63
  "typescript": "@typescript/typescript6@6.0.2"
64
64
  },