@feds01/zenith 0.0.0-stage → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexander Fedotov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # zenith
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An architecture linter for TypeScript and JavaScript codebases, built for
4
+ monorepos. Zenith enforces *contracts* about which parts of a codebase may
5
+ import which other parts, declared in `zenith.toml`, and `zenith check` fails
6
+ when the code breaks them.
7
+
8
+ ```sh
9
+ npm install --save-dev @feds01/zenith
10
+ npx zenith check
11
+ ```
12
+
13
+ See the [user guide](https://feds01.github.io/zenith/) for the contracts, the
14
+ configuration and the command line.
15
+
16
+ ## How it is installed
17
+
18
+ Zenith is a native binary. This package has none itself, nor any install
19
+ script: the binary for each platform is in a package of its own, which this
20
+ one lists as an optional dependency, and the package manager installs only
21
+ the one for your platform:
22
+
23
+ | Package | Platform |
24
+ |---|---|
25
+ | `@feds01/zenith-darwin-arm64` | macOS, Apple silicon |
26
+ | `@feds01/zenith-darwin-x64` | macOS, Intel |
27
+ | `@feds01/zenith-linux-arm64` | Linux, ARM64 (static, any libc) |
28
+ | `@feds01/zenith-linux-x64` | Linux, x86-64 (static, any libc) |
29
+ | `@feds01/zenith-win32-x64` | Windows, x86-64 |
30
+
31
+ So it installs offline from a package manager's cache, the lockfile's
32
+ integrity hashes cover the binary, and bun needs no `trustedDependencies`
33
+ entry for it. Don't leave optional dependencies out of the install, e.g. with
34
+ `npm install --omit=optional`, or the `zenith` command has no binary to run.
35
+
36
+ On another platform, build zenith from source with
37
+ `cargo install --locked --git https://github.com/feds01/zenith zenith`, and
38
+ set `ZENITH_BINARY` to the path of the binary.
39
+
40
+ ## Licence
41
+
42
+ MIT
package/bin/zenith.js ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+ // The `zenith` command of the npm package. It runs the binary from the
3
+ // package for this platform, e.g. `@feds01/zenith-darwin-arm64`, which the
4
+ // package manager installed as one of its optional dependencies. The binary
5
+ // gets the arguments, stdin, stdout and stderr, and the command exits as the
6
+ // binary does.
7
+
8
+ "use strict";
9
+
10
+ const { spawn } = require("child_process");
11
+ const path = require("path");
12
+
13
+ const { name: main, version, optionalDependencies } = require("../package.json");
14
+
15
+ /** The exit code of a usage or internal error, as zenith's own. */
16
+ const ERROR_EXIT_CODE = 2;
17
+
18
+ /** The signals that are passed on to the binary, as when the launcher is stopped on its own. */
19
+ const FORWARDED_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
20
+
21
+ /** Print `message` to stderr, and exit with an error. */
22
+ function fail(message) {
23
+ process.stderr.write(`error: ${message}\n`);
24
+ process.exit(ERROR_EXIT_CODE);
25
+ }
26
+
27
+ /** The path of the binary to run. */
28
+ function binaryPath() {
29
+ // 1. A binary of the user's own, e.g. one built from source for a
30
+ // platform without a package.
31
+ const override = process.env.ZENITH_BINARY;
32
+ if (override) {
33
+ return override;
34
+ }
35
+
36
+ // 2. The package for this platform, which must be one that is published.
37
+ const target = `${process.platform}-${process.arch}`;
38
+ const platformPackage = `${main}-${target}`;
39
+ if (!Object.prototype.hasOwnProperty.call(optionalDependencies, platformPackage)) {
40
+ const supported = Object.keys(optionalDependencies)
41
+ .map((name) => name.slice(main.length + 1))
42
+ .join(", ");
43
+ fail(
44
+ `${main} has no binary for this platform, ${target}; it has binaries for ${supported}.\n` +
45
+ "Build zenith from source with " +
46
+ "`cargo install --locked --git https://github.com/feds01/zenith zenith`,\n" +
47
+ "and set ZENITH_BINARY to the path of the binary.",
48
+ );
49
+ }
50
+
51
+ // 3. Where the package manager installed it.
52
+ let manifest;
53
+ try {
54
+ manifest = require.resolve(`${platformPackage}/package.json`);
55
+ } catch {
56
+ fail(
57
+ `${platformPackage}, which has the binary for this platform, isn't installed.\n` +
58
+ `It is an optional dependency of ${main}, so it is left out when optional dependencies are,\n` +
59
+ "e.g. with `npm install --omit=optional`. Install again without leaving them out,\n" +
60
+ `or add ${platformPackage}@${version} to your dependencies.`,
61
+ );
62
+ }
63
+ return path.join(path.dirname(manifest), process.platform === "win32" ? "zenith.exe" : "zenith");
64
+ }
65
+
66
+ // 1. Run the binary with the launcher's arguments and streams.
67
+ const binary = binaryPath();
68
+ const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
69
+
70
+ // 2. Pass on the signals that would stop the launcher alone, so that the
71
+ // binary stops with it rather than running on.
72
+ const forward = (signal) => child.kill(signal);
73
+ for (const signal of FORWARDED_SIGNALS) {
74
+ process.on(signal, forward);
75
+ }
76
+
77
+ child.on("error", (error) => fail(`could not run ${binary}: ${error.message}`));
78
+
79
+ // 3. Exit as the binary did: with its exit code, or by the signal that
80
+ // stopped it.
81
+ child.on("exit", (code, signal) => {
82
+ for (const forwarded of FORWARDED_SIGNALS) {
83
+ process.removeListener(forwarded, forward);
84
+ }
85
+ if (signal) {
86
+ process.kill(process.pid, signal);
87
+ } else {
88
+ process.exit(code);
89
+ }
90
+ });
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@feds01/zenith",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "An architecture linter for TypeScript and JavaScript codebases",
5
+ "keywords": [
6
+ "architecture",
7
+ "linter",
8
+ "imports",
9
+ "monorepo",
10
+ "typescript",
11
+ "javascript"
12
+ ],
13
+ "homepage": "https://feds01.github.io/zenith/",
14
+ "bugs": "https://github.com/feds01/zenith/issues",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/feds01/zenith.git"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Alexander Fedotov <alexander.fedotov.uk@gmail.com>",
21
+ "bin": {
22
+ "zenith": "bin/zenith.js"
23
+ },
24
+ "files": [
25
+ "bin"
26
+ ],
27
+ "engines": {
28
+ "node": ">=14"
29
+ },
30
+ "optionalDependencies": {
31
+ "@feds01/zenith-darwin-arm64": "0.2.0",
32
+ "@feds01/zenith-darwin-x64": "0.2.0",
33
+ "@feds01/zenith-linux-arm64": "0.2.0",
34
+ "@feds01/zenith-linux-x64": "0.2.0",
35
+ "@feds01/zenith-win32-x64": "0.2.0"
36
+ }
37
+ }