spec-spine 0.1.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 +202 -0
- package/README.md +75 -0
- package/bin/spec-spine.js +35 -0
- package/lib/platform.js +122 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 The spec-spine Authors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# spec-spine (npm)
|
|
2
|
+
|
|
3
|
+
**The [`spec-spine`](https://github.com/bartekus/spec-spine) CLI, distributed as a
|
|
4
|
+
prebuilt binary through npm. No Rust toolchain required.**
|
|
5
|
+
|
|
6
|
+
spec-spine turns a markdown spec corpus into a deterministic, hash-verifiable
|
|
7
|
+
authority ledger and refuses code that drifts from its owning spec at PR time.
|
|
8
|
+
This package lets a TypeScript/JS repo install and run the CLI like any other dev
|
|
9
|
+
tool.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i -D spec-spine
|
|
13
|
+
npx spec-spine --version
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx spec-spine init # scaffold a spec corpus
|
|
18
|
+
npx spec-spine compile # specs/*/spec.md -> registry.json
|
|
19
|
+
npx spec-spine index # codebase index
|
|
20
|
+
npx spec-spine lint --fail-on-warn # corpus conformance
|
|
21
|
+
npx spec-spine couple --base origin/main --head HEAD # the PR-time drift gate
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Add it to your CI / package scripts like any other binary CLI:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"scripts": {
|
|
29
|
+
"spec:check": "spec-spine compile && spec-spine index check && spec-spine lint --fail-on-warn"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## How it works
|
|
35
|
+
|
|
36
|
+
This is a **binary-distribution shim, not a native (napi) addon**. The package's
|
|
37
|
+
`bin` is a tiny Node launcher that resolves the one prebuilt binary matching your
|
|
38
|
+
platform and runs it as a child process, forwarding arguments and the exit code.
|
|
39
|
+
|
|
40
|
+
The binaries ship as **optional dependencies** (`@spec-spine/cli-<os>-<cpu>`),
|
|
41
|
+
each gated by npm's `os`/`cpu` fields so only the one for your machine is
|
|
42
|
+
installed. There is **no `postinstall` script, no network access at install time,
|
|
43
|
+
and no archive extraction**, so it works under `npm ci --ignore-scripts` and
|
|
44
|
+
fully offline (from a warm cache or a private mirror).
|
|
45
|
+
|
|
46
|
+
## Supported platforms
|
|
47
|
+
|
|
48
|
+
| OS | Arch | Notes |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| macOS | arm64, x64 | |
|
|
51
|
+
| Linux | x64, arm64 | **glibc only** (see below) |
|
|
52
|
+
| Windows | x64 | |
|
|
53
|
+
|
|
54
|
+
**Linux binaries are glibc, not musl.** On **Alpine** or any musl host the
|
|
55
|
+
launcher refuses with a clear message: use a glibc-based image, or install from
|
|
56
|
+
source with `cargo install spec-spine-cli`. The same applies to any platform
|
|
57
|
+
without a prebuilt binary (Windows on ARM, 32-bit, …).
|
|
58
|
+
|
|
59
|
+
## Versioning
|
|
60
|
+
|
|
61
|
+
The npm version equals the binary release tag it ships: `spec-spine@0.1.0` runs
|
|
62
|
+
the binary built from `v0.1.0`. There is no floating range, so a pinned npm
|
|
63
|
+
version always runs a known binary.
|
|
64
|
+
|
|
65
|
+
## Alternatives (no npm)
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
cargo install spec-spine-cli # from crates.io
|
|
69
|
+
curl -fsSL https://raw.githubusercontent.com/bartekus/spec-spine/main/install.sh | sh
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
Apache-2.0. See the [repository](https://github.com/bartekus/spec-spine) for full
|
|
75
|
+
documentation, the Rust library API, and the design docs.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Spec: specs/007-distribution/spec.md
|
|
5
|
+
//
|
|
6
|
+
// The launcher. Resolves the prebuilt binary for this host (see lib/platform.js)
|
|
7
|
+
// and exec's it, forwarding argv and the child's exit code. It is a pure
|
|
8
|
+
// translation layer: no flags added, no arguments rewritten, nothing printed on
|
|
9
|
+
// the success path. `spec-spine <args>` through npm is identical to the native
|
|
10
|
+
// binary. NOT a native addon; the Rust engine runs as a child process.
|
|
11
|
+
|
|
12
|
+
const { execFileSync } = require('node:child_process');
|
|
13
|
+
const { resolveBinaryPath } = require('../lib/platform.js');
|
|
14
|
+
|
|
15
|
+
let binPath;
|
|
16
|
+
try {
|
|
17
|
+
binPath = resolveBinaryPath();
|
|
18
|
+
} catch (err) {
|
|
19
|
+
process.stderr.write(`${err.message}\n`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
execFileSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
25
|
+
} catch (err) {
|
|
26
|
+
if (typeof err.status === 'number') {
|
|
27
|
+
process.exit(err.status); // forward the binary's own exit code
|
|
28
|
+
}
|
|
29
|
+
if (err.signal) {
|
|
30
|
+
process.stderr.write(`spec-spine: binary terminated by signal ${err.signal}\n`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
process.stderr.write(`spec-spine: failed to run binary: ${err.message}\n`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
package/lib/platform.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Spec: specs/007-distribution/spec.md
|
|
4
|
+
//
|
|
5
|
+
// The pure (process.platform, process.arch) -> platform-package mapping behind
|
|
6
|
+
// the launcher (bin/spec-spine.js). No I/O on the mapping path, so it is
|
|
7
|
+
// unit-tested directly (test/platform.test.js). Resolution of the installed
|
|
8
|
+
// binary is the one filesystem touch, and it takes injectable seams so the
|
|
9
|
+
// tests stay network- and disk-free.
|
|
10
|
+
|
|
11
|
+
const path = require('node:path');
|
|
12
|
+
|
|
13
|
+
// The five supported (platform-arch) targets. This table is one fact shared
|
|
14
|
+
// with release.yml's build matrix and install.sh's detection; keep all three in
|
|
15
|
+
// lockstep (specs/007-distribution/spec.md sec 3.2).
|
|
16
|
+
const SUPPORTED = {
|
|
17
|
+
'darwin-arm64': '@spec-spine/cli-darwin-arm64',
|
|
18
|
+
'darwin-x64': '@spec-spine/cli-darwin-x64',
|
|
19
|
+
'linux-x64': '@spec-spine/cli-linux-x64',
|
|
20
|
+
'linux-arm64': '@spec-spine/cli-linux-arm64',
|
|
21
|
+
'win32-x64': '@spec-spine/cli-win32-x64',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
class UnsupportedPlatformError extends Error {
|
|
25
|
+
constructor(message) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'UnsupportedPlatformError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// The in-archive binary name: `.exe` on Windows, bare elsewhere (matches the
|
|
32
|
+
// names release.yml stages into each archive).
|
|
33
|
+
function binaryName(platform) {
|
|
34
|
+
return platform === 'win32' ? 'spec-spine.exe' : 'spec-spine';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Pure resolution: (platform, arch, { muslLinux }) -> { key, packageName, binaryName }.
|
|
38
|
+
// Throws UnsupportedPlatformError on any host without a prebuilt binary.
|
|
39
|
+
function targetFor(platform, arch, opts = {}) {
|
|
40
|
+
if (platform === 'linux' && opts.muslLinux === true) {
|
|
41
|
+
throw new UnsupportedPlatformError(unsupportedMessage(platform, arch, 'musl'));
|
|
42
|
+
}
|
|
43
|
+
const key = `${platform}-${arch}`;
|
|
44
|
+
const packageName = SUPPORTED[key];
|
|
45
|
+
if (!packageName) {
|
|
46
|
+
throw new UnsupportedPlatformError(unsupportedMessage(platform, arch));
|
|
47
|
+
}
|
|
48
|
+
return { key, packageName, binaryName: binaryName(platform) };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function unsupportedMessage(platform, arch, reason) {
|
|
52
|
+
const host = reason === 'musl' ? `${platform}-${arch} (musl libc)` : `${platform}-${arch}`;
|
|
53
|
+
const lines = [
|
|
54
|
+
`spec-spine: no prebuilt binary for ${host}.`,
|
|
55
|
+
'Prebuilt binaries cover darwin-arm64, darwin-x64, linux-x64 (glibc),',
|
|
56
|
+
'linux-arm64 (glibc), and win32-x64. Install from source instead:',
|
|
57
|
+
' cargo install spec-spine-cli',
|
|
58
|
+
];
|
|
59
|
+
if (reason === 'musl') {
|
|
60
|
+
lines.push('(Alpine/musl: use a glibc-based image, or cargo install spec-spine-cli.)');
|
|
61
|
+
}
|
|
62
|
+
return lines.join('\n');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function missingPackageMessage(packageName) {
|
|
66
|
+
return [
|
|
67
|
+
`spec-spine: the prebuilt binary package '${packageName}' is not installed.`,
|
|
68
|
+
'It is an optional dependency, so this happens with `npm install --no-optional`,',
|
|
69
|
+
'on an unsupported platform, or when its download failed.',
|
|
70
|
+
'Reinstall without --no-optional, or install from source:',
|
|
71
|
+
' cargo install spec-spine-cli',
|
|
72
|
+
].join('\n');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Detect a musl (non-glibc) Linux. Returns false off Linux. Uses process.report's
|
|
76
|
+
// glibcVersionRuntime, which is present on glibc and absent on musl. Permissive
|
|
77
|
+
// on error: if we cannot tell, assume glibc and let resolution fail loudly later.
|
|
78
|
+
function isMuslLinux(proc = process) {
|
|
79
|
+
if (proc.platform !== 'linux') {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
if (!proc.report || typeof proc.report.getReport !== 'function') {
|
|
84
|
+
return false; // cannot tell; assume glibc and let resolution fail loudly if wrong
|
|
85
|
+
}
|
|
86
|
+
const report = proc.report.getReport();
|
|
87
|
+
const glibc = report && report.header ? report.header.glibcVersionRuntime : undefined;
|
|
88
|
+
return !glibc; // report present but no glibc runtime => musl
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Resolve the absolute path to the platform binary on this host. `process` and
|
|
95
|
+
// `resolve` are injectable for tests; `resolve` defaults to this module's
|
|
96
|
+
// require.resolve so optional platform packages are found from the main package.
|
|
97
|
+
// Throws UnsupportedPlatformError when the matching optional package is absent.
|
|
98
|
+
function resolveBinaryPath(opts = {}) {
|
|
99
|
+
const proc = opts.process || process;
|
|
100
|
+
const resolve = opts.resolve || ((request) => require.resolve(request));
|
|
101
|
+
const { packageName, binaryName: bin } = targetFor(proc.platform, proc.arch, {
|
|
102
|
+
muslLinux: isMuslLinux(proc),
|
|
103
|
+
});
|
|
104
|
+
let manifest;
|
|
105
|
+
try {
|
|
106
|
+
manifest = resolve(`${packageName}/package.json`);
|
|
107
|
+
} catch {
|
|
108
|
+
throw new UnsupportedPlatformError(missingPackageMessage(packageName));
|
|
109
|
+
}
|
|
110
|
+
return path.join(path.dirname(manifest), 'bin', bin);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = {
|
|
114
|
+
SUPPORTED,
|
|
115
|
+
UnsupportedPlatformError,
|
|
116
|
+
binaryName,
|
|
117
|
+
targetFor,
|
|
118
|
+
unsupportedMessage,
|
|
119
|
+
missingPackageMessage,
|
|
120
|
+
isMuslLinux,
|
|
121
|
+
resolveBinaryPath,
|
|
122
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "spec-spine",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The spec-spine CLI: compile a markdown spec corpus into a deterministic authority ledger and refuse code that drifts from its owning spec. Ships the prebuilt binary; no Rust toolchain required.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"spec",
|
|
7
|
+
"specification",
|
|
8
|
+
"authority",
|
|
9
|
+
"governance",
|
|
10
|
+
"coupling",
|
|
11
|
+
"cli",
|
|
12
|
+
"rust",
|
|
13
|
+
"deterministic"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/bartekus/spec-spine#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/bartekus/spec-spine.git",
|
|
19
|
+
"directory": "npm"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/bartekus/spec-spine/issues"
|
|
23
|
+
},
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"author": "The spec-spine Authors",
|
|
26
|
+
"type": "commonjs",
|
|
27
|
+
"bin": {
|
|
28
|
+
"spec-spine": "bin/spec-spine.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin/",
|
|
32
|
+
"lib/",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"test": "node --test test/*.test.js",
|
|
41
|
+
"generate": "node scripts/generate-platform-packages.js",
|
|
42
|
+
"smoke": "scripts/smoke-test.sh"
|
|
43
|
+
},
|
|
44
|
+
"optionalDependencies": {
|
|
45
|
+
"@spec-spine/cli-darwin-arm64": "0.1.0",
|
|
46
|
+
"@spec-spine/cli-darwin-x64": "0.1.0",
|
|
47
|
+
"@spec-spine/cli-linux-x64": "0.1.0",
|
|
48
|
+
"@spec-spine/cli-linux-arm64": "0.1.0",
|
|
49
|
+
"@spec-spine/cli-win32-x64": "0.1.0"
|
|
50
|
+
},
|
|
51
|
+
"spec-spine": {
|
|
52
|
+
"spec": "007-distribution"
|
|
53
|
+
}
|
|
54
|
+
}
|