@ac-tool/notices 0.0.0-stage → 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/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # @ac-tool/notices
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 065cf8d: New package, under the new `@ac-tool` scope: third-party notices and licence checks for a JavaScript package or workspace.
8
+
9
+ - `collectProductionDependencies(directory, { isFirstParty, platform, signal })` walks the production dependency tree the way Node.js resolves it — `dependencies`, installable `optionalDependencies`, and the `peerDependencies` of every package reached, each resolved from its dependent; pnpm layouts and Yarn's `mocked` placeholders included — and answers `{ packages, missingPeerDependencies }`. A package is judged by its manifest name and real path (`ResolvedPackage`), so an npm alias is audited as the package it installs. Every installed copy is read; copies of one name and version are one `ThirdPartyPackage` (with their `directories`) only when licence and texts agree. Missing optional dependencies and optional peers are skipped, a missing required dependency throws, a missing required peer is reported. Ordered by name in code point order, then SemVer precedence.
10
+ - `findDisallowedPackages(packages, policy)` reports a package with no licence, a licence that is not an SPDX expression, or one the policy's licences and exceptions cannot satisfy; `renderNotices(name, packages)` writes `THIRD-PARTY-NOTICES.md`, each text in a code fence no line of it can close; `runNotices(targets, { check, … })` does both for several packages, a missing required peer being a problem too.
11
+ - The `ac-notices` command (`--check`, `--root`, `--config`) takes workspaces from `pnpm-workspace.yaml` when it exists, else from the root's `workspaces`, refuses a Yarn Plug'n'Play install, treats the root and its workspaces as first party by real path, and reads a `notices.config.{js,mjs,ts,mts}` module (`defineNoticesConfig`, `loadNoticesConfig`) whose `policyFor(workspace)` gives each workspace's policy, or `null` for one that is not distributed; `runNoticesCli(args, { cwd, stdout, stderr, signal })` is the command as a function.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [065cf8d]
16
+ - Updated dependencies [065cf8d]
17
+ - Updated dependencies [065cf8d]
18
+ - Updated dependencies [065cf8d]
19
+ - Updated dependencies [065cf8d]
20
+ - Updated dependencies [065cf8d]
21
+ - Updated dependencies [065cf8d]
22
+ - Updated dependencies [065cf8d]
23
+ - @ac-kit/core@0.11.0
24
+ - @ac-kit/format-semver@0.1.0
25
+ - @ac-kit/format-spdx@0.1.0
26
+ - @ac-kit/node@0.10.0
27
+ - @ac-kit/format-markdown@0.2.1
28
+ - @ac-kit/format-yaml@0.2.8
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,3 +1,101 @@
1
- # Temporary Holding Version
1
+ # @ac-tool/notices
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
+ Third-party notices for a JavaScript package or workspace. For each package
4
+ you distribute, it walks the production dependency tree the way Node.js
5
+ resolves it — so pnpm and Yarn's pnpm linker work as well as a flat
6
+ `node_modules` — collects each third-party package's licence, notice and
7
+ copying files, writes them to `THIRD-PARTY-NOTICES.md`, and reports every
8
+ licence the package's policy does not allow.
9
+
10
+ ## Command line
11
+
12
+ ```sh
13
+ npx --package=@ac-tool/notices ac-notices # write THIRD-PARTY-NOTICES.md, report problems
14
+ npx --package=@ac-tool/notices ac-notices --check # report only, write nothing (for CI)
15
+ ```
16
+
17
+ Or add `@ac-tool/notices` as a devDependency and run `ac-notices` from a
18
+ script; the configuration below imports it anyway.
19
+
20
+ Options: `--root <directory>` (default: the current directory),
21
+ `--config <file>`, `--help`. The exit code is `0` when every licence is
22
+ allowed, `1` when one is not or the run fails, `2` on a usage error.
23
+
24
+ The configuration is a module in the root — `notices.config.js`, `.mjs`, `.ts`
25
+ or `.mts` (TypeScript needs a Node.js that strips types) — whose default export
26
+ says which licences each package may ship:
27
+
28
+ ```ts
29
+ // notices.config.mjs
30
+ import { defineNoticesConfig } from "@ac-tool/notices";
31
+
32
+ const permissive = ["MIT", "ISC", "BSD-2-Clause", "BSD-3-Clause", "Apache-2.0"];
33
+
34
+ export default defineNoticesConfig({
35
+ policyFor: (workspace) =>
36
+ workspace.name === "@acme/server"
37
+ ? null // not distributed: no notices file, no check
38
+ : { licenses: permissive, exceptions: ["LLVM-exception"] },
39
+ });
40
+ ```
41
+
42
+ `policyFor` is called with each workspace — those `pnpm-workspace.yaml`'s
43
+ `packages` lists when that file exists, those the root manifest's `workspaces`
44
+ field declares otherwise (with npm's glob and `!` semantics) — or with the root
45
+ package itself when there is none, and may be asynchronous. A licence is checked as an SPDX expression: `MIT OR GPL-3.0-only`
46
+ is allowed when MIT is, `X+` and `X-or-later` when `X` or `X-only` is, and a
47
+ `WITH` exception only when listed too. A package with no licence, or one that
48
+ is not an SPDX expression (`SEE LICENSE IN …`), is reported.
49
+
50
+ ## What is audited
51
+
52
+ Every package Node.js would load at run time, as installed: the target's
53
+ `dependencies` and installable `optionalDependencies`, then those of every
54
+ package reached and its `peerDependencies`, each peer resolved from its
55
+ dependent's directory. The target's own peers are its consumer's to provide.
56
+ A missing optional dependency or optional peer (`peerDependenciesMeta`) is
57
+ skipped; a missing required peer is reported as a problem, since what is not
58
+ installed cannot be audited. A Yarn placeholder with `mocked: true` counts
59
+ as not installed. An npm alias (`"x": "npm:y@1"`) is audited as `y`. Each
60
+ installed copy is read: copies of one version that declare different licences
61
+ or ship different texts are listed (and checked) separately.
62
+
63
+ Supported layouts: a flat `node_modules`, pnpm's, and Yarn's `node-modules` and
64
+ `pnpm` linkers. A Yarn Plug'n'Play install (`.pnp.cjs`) has no `node_modules`
65
+ to walk and is refused with an error.
66
+
67
+ ## Other settings
68
+
69
+ `isFirstParty(dependency)` — the project's own packages, walked through and
70
+ never listed, told the package's manifest name and real path (default: the
71
+ packages whose real path is the root's or a workspace's) — and
72
+ `platform` — the `os`, `cpu` and `libc` optional dependencies must suit
73
+ (default: the current machine's), since the notices list what is actually
74
+ installed for a platform.
75
+
76
+ ## Programmatic API
77
+
78
+ ```ts
79
+ import {
80
+ collectProductionDependencies,
81
+ findDisallowedPackages,
82
+ renderNotices,
83
+ runNotices,
84
+ } from "@ac-tool/notices";
85
+
86
+ const { packages, missingPeerDependencies } =
87
+ await collectProductionDependencies("packages/app", {
88
+ isFirstParty: (dependency) => dependency.name.startsWith("@acme/"),
89
+ });
90
+ const problems = findDisallowedPackages(packages, { licenses: ["MIT", "ISC"] });
91
+ const markdown = renderNotices("@acme/app", packages);
92
+ ```
93
+
94
+ `runNotices(targets, options)` does all three for several packages, writing
95
+ each file atomically, and `runNoticesCli(args, options)` is the command itself,
96
+ with its output routed to your own functions. Every function that reads files
97
+ takes a `signal`.
98
+
99
+ The SPDX evaluation is `@ac-kit/format-spdx`, the version ordering
100
+ `@ac-kit/format-semver`, and the workspace listing and platform matching
101
+ `@ac-kit/node` — use those directly for anything else.
package/bin/notices.js ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+
3
+ import packageJson from "../package.json" with { type: "json" };
4
+
5
+ const entryPath = packageJson.exports["./cli"];
6
+
7
+ // In this repository the entry point is TypeScript source; once published it
8
+ // is the compiled `dist/cli.js`.
9
+ if (entryPath.endsWith(".ts")) {
10
+ const { register } = await import("tsx/esm/api");
11
+ register();
12
+ }
13
+
14
+ await import(new URL(entryPath, new URL("../", import.meta.url)).href);
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ import { runNoticesCli } from "./run-notices-cli.js";
2
+ process.exitCode = await runNoticesCli(process.argv.slice(2));
3
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,CAAC,QAAQ,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { type Predicate } from "@ac-kit/core";
2
+ import { type NpmPlatform, type PackageManifest } from "@ac-kit/node";
3
+ /** A licence, notice or copying file found at the root of a package. */
4
+ export type LicenseFile = {
5
+ /** Its file name. */
6
+ readonly name: string;
7
+ readonly text: string;
8
+ };
9
+ /**
10
+ * One third-party package of a production dependency tree: every installed copy
11
+ * of a name and version that declares the same licence and ships the same
12
+ * licence files. Copies that differ are separate entries.
13
+ */
14
+ export type ThirdPartyPackage = {
15
+ /** The `name` of its manifest, whatever name it was installed under. */
16
+ readonly name: string;
17
+ /** `0.0.0` when its manifest has none. */
18
+ readonly version: string;
19
+ /**
20
+ * Its `license` field, or its legacy `license.type` or `licenses[].type`
21
+ * (joined with `OR`); `undefined` when it declares none.
22
+ */
23
+ readonly license: string | undefined;
24
+ /** Ordered by name. */
25
+ readonly files: readonly LicenseFile[];
26
+ /** The real path of each copy, in code point order. */
27
+ readonly directories: readonly string[];
28
+ };
29
+ /** A package found while walking, before it is classified. */
30
+ export type ResolvedPackage = {
31
+ /** The `name` of its manifest, or the dependency key when it has none. */
32
+ readonly name: string;
33
+ /** Its real path. */
34
+ readonly directory: string;
35
+ readonly manifest: PackageManifest;
36
+ };
37
+ /** A required peer dependency that is not installed where its dependent is. */
38
+ export type MissingPeerDependency = {
39
+ /** The peer's name. */
40
+ readonly name: string;
41
+ /** `name@version` of the package that declares it. */
42
+ readonly dependent: string;
43
+ };
44
+ export type CollectedDependencies = {
45
+ /**
46
+ * Ordered by name (code point order), version (SemVer precedence), licence
47
+ * and texts.
48
+ */
49
+ readonly packages: readonly ThirdPartyPackage[];
50
+ /** Ordered by dependent, then name. */
51
+ readonly missingPeerDependencies: readonly MissingPeerDependency[];
52
+ };
53
+ export type CollectDependenciesOptions = {
54
+ /**
55
+ * Packages of the project itself, walked through and never listed. Told the
56
+ * package's own name and real path, not the key it was installed under, so an
57
+ * npm alias (`"x": "npm:y@1"`) is judged as `y`.
58
+ */
59
+ readonly isFirstParty: Predicate<[dependency: ResolvedPackage]>;
60
+ /**
61
+ * The platform optional dependencies must suit, as npm decides. Default: this
62
+ * process's, {@link currentNpmPlatform}.
63
+ */
64
+ readonly platform?: NpmPlatform | null;
65
+ readonly signal?: AbortSignal | null;
66
+ };
67
+ /**
68
+ * The third-party packages a directory's production dependency tree resolves
69
+ * to, found the way Node.js resolves them, up the `node_modules` directories,
70
+ * so that isolated layouts (pnpm, Yarn's pnpm linker) work. The tree is the
71
+ * directory's `dependencies` and `optionalDependencies`, then those and the
72
+ * `peerDependencies` of every package reached, each peer resolved from its
73
+ * dependent's directory as Node.js resolves it at run time. The directory's own
74
+ * peers are not walked: whoever installs it provides them.
75
+ *
76
+ * Every installed copy is read, so two copies of one name and version that
77
+ * declare different licences or ship different texts are two entries; copies
78
+ * that agree are one, listing their directories. Yarn Plug'n'Play installs,
79
+ * which have no `node_modules`, are not supported.
80
+ *
81
+ * Skipped, each with what lies behind it: an optional dependency or an optional
82
+ * peer (`peerDependenciesMeta`) that is not installed, an optional dependency
83
+ * whose `os`, `cpu` or `libc` excludes the platform. Yarn placeholders with
84
+ * `mocked: true` are treated as not installed. A required peer that is not
85
+ * installed is reported in `missingPeerDependencies` rather than thrown:
86
+ * package managers only warn about it, and the caller decides.
87
+ *
88
+ * @throws {Error} When a required dependency cannot be resolved from its
89
+ * dependent.
90
+ * @throws The error reading a manifest or a licence file, or the signal's
91
+ * reason once it aborts.
92
+ */
93
+ export declare function collectProductionDependencies(directory: string, options: CollectDependenciesOptions): Promise<CollectedDependencies>;
94
+ //# sourceMappingURL=collect-dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect-dependencies.d.ts","sourceRoot":"","sources":["../src/collect-dependencies.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAIN,KAAK,WAAW,EAChB,KAAK,eAAe,EAGpB,MAAM,cAAc,CAAC;AAEtB,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG;IACzB,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAI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ACrC,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,6BAA6B,CAClD,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,0BAA0B,GACjC,OAAO,CAAC,qBAAqB,CAAC,CAqEhC"}
@@ -0,0 +1,231 @@
1
+ import { readFile, realpath } from "node:fs/promises";
2
+ import { basename, dirname, join } from "node:path";
3
+ import { compareCodePoints, isObject } from "@ac-kit/core";
4
+ import { compareSemVer, tryParseSemVer } from "@ac-kit/format-semver";
5
+ import { currentNpmPlatform, isFileAsync, isPackageInstallableOn, readPackageManifest, walkPaths, } from "@ac-kit/node";
6
+ const LICENSE_FILE_NAME_ = /^(licen[sc]e|notice|copying)([-._][^/]*)?$/i;
7
+ /**
8
+ * The third-party packages a directory's production dependency tree resolves
9
+ * to, found the way Node.js resolves them, up the `node_modules` directories,
10
+ * so that isolated layouts (pnpm, Yarn's pnpm linker) work. The tree is the
11
+ * directory's `dependencies` and `optionalDependencies`, then those and the
12
+ * `peerDependencies` of every package reached, each peer resolved from its
13
+ * dependent's directory as Node.js resolves it at run time. The directory's own
14
+ * peers are not walked: whoever installs it provides them.
15
+ *
16
+ * Every installed copy is read, so two copies of one name and version that
17
+ * declare different licences or ship different texts are two entries; copies
18
+ * that agree are one, listing their directories. Yarn Plug'n'Play installs,
19
+ * which have no `node_modules`, are not supported.
20
+ *
21
+ * Skipped, each with what lies behind it: an optional dependency or an optional
22
+ * peer (`peerDependenciesMeta`) that is not installed, an optional dependency
23
+ * whose `os`, `cpu` or `libc` excludes the platform. Yarn placeholders with
24
+ * `mocked: true` are treated as not installed. A required peer that is not
25
+ * installed is reported in `missingPeerDependencies` rather than thrown:
26
+ * package managers only warn about it, and the caller decides.
27
+ *
28
+ * @throws {Error} When a required dependency cannot be resolved from its
29
+ * dependent.
30
+ * @throws The error reading a manifest or a licence file, or the signal's
31
+ * reason once it aborts.
32
+ */
33
+ export async function collectProductionDependencies(directory, options) {
34
+ const signal = options.signal ?? null;
35
+ const platform = options.platform ?? currentNpmPlatform();
36
+ const root = await realpath(directory);
37
+ const visited = new Set();
38
+ // Every resolved path is classified once, however many dependents reach it.
39
+ const classified = new Set([root]);
40
+ const copies = [];
41
+ const copyDirectories = [];
42
+ const missingPeerDependencies = [];
43
+ const pending = [root];
44
+ for (let next = pending.pop(); next !== undefined; next = pending.pop()) {
45
+ if (visited.has(next)) {
46
+ continue;
47
+ }
48
+ visited.add(next);
49
+ const manifest = await readPackageManifest(next, { signal });
50
+ for (const [key, edge] of edgesOf_(manifest, next === root)) {
51
+ signal?.throwIfAborted();
52
+ const resolvedPackage = await resolveDependency_(next, key, signal);
53
+ if (resolvedPackage === undefined) {
54
+ if (edge === "dependency") {
55
+ throw new Error(`Cannot resolve ${key}, a dependency of ${manifest.name ?? next}`);
56
+ }
57
+ if (edge === "peer") {
58
+ missingPeerDependencies.push({
59
+ name: key,
60
+ dependent: `${manifest.name ?? next}@${manifest.version ?? "0.0.0"}`,
61
+ });
62
+ }
63
+ continue;
64
+ }
65
+ const { directory: resolved, manifest: dependency } = resolvedPackage;
66
+ if (edge === "optional" &&
67
+ !isPackageInstallableOn(dependency, platform)) {
68
+ continue;
69
+ }
70
+ if (!classified.has(resolved)) {
71
+ classified.add(resolved);
72
+ if (!options.isFirstParty(resolvedPackage)) {
73
+ copies.push({
74
+ name: resolvedPackage.name,
75
+ version: dependency.version ?? "0.0.0",
76
+ license: licenseOf_(dependency),
77
+ files: await readLicenseFiles_(resolved, signal),
78
+ });
79
+ copyDirectories.push(resolved);
80
+ }
81
+ }
82
+ pending.push(resolved);
83
+ }
84
+ }
85
+ return {
86
+ packages: mergeCopies_(copies, copyDirectories),
87
+ missingPeerDependencies: missingPeerDependencies.sort((left, right) => compareCodePoints(left.dependent, right.dependent) ||
88
+ compareCodePoints(left.name, right.name)),
89
+ };
90
+ }
91
+ /**
92
+ * The names a package needs, each once: a dependency over an optional one over
93
+ * a peer, as a package manager installs it.
94
+ */
95
+ function edgesOf_(manifest, isRoot) {
96
+ const edges = new Map();
97
+ if (!isRoot) {
98
+ const meta = isObject(manifest["peerDependenciesMeta"])
99
+ ? manifest["peerDependenciesMeta"]
100
+ : {};
101
+ for (const name of Object.keys(manifest.peerDependencies ?? {})) {
102
+ const entry = Object.hasOwn(meta, name) ? meta[name] : undefined;
103
+ const optional = isObject(entry) && entry.optional === true;
104
+ edges.set(name, optional ? "optional-peer" : "peer");
105
+ }
106
+ }
107
+ for (const name of Object.keys(manifest.optionalDependencies ?? {})) {
108
+ edges.set(name, "optional");
109
+ }
110
+ for (const name of Object.keys(manifest.dependencies ?? {})) {
111
+ if (!Object.hasOwn(manifest.optionalDependencies ?? {}, name)) {
112
+ edges.set(name, "dependency");
113
+ }
114
+ }
115
+ return edges;
116
+ }
117
+ /** Copies of one name and version that agree on licence and texts, as one. */
118
+ function mergeCopies_(copies, directories) {
119
+ const merged = new Map();
120
+ for (let index = 0; index < copies.length; index++) {
121
+ const copy = copies[index];
122
+ const key = JSON.stringify([
123
+ copy.name,
124
+ copy.version,
125
+ copy.license ?? null,
126
+ copy.files.map((file) => [file.name, file.text]),
127
+ ]);
128
+ const existing = merged.get(key);
129
+ if (existing === undefined) {
130
+ merged.set(key, { entry: copy, directories: [directories[index]] });
131
+ }
132
+ else {
133
+ existing.directories.push(directories[index]);
134
+ }
135
+ }
136
+ return [...merged.values()]
137
+ .map(({ entry, directories: paths }) => ({
138
+ ...entry,
139
+ directories: paths.sort(compareCodePoints),
140
+ }))
141
+ .sort(comparePackages_);
142
+ }
143
+ async function resolveDependency_(fromDirectory, name, signal) {
144
+ let directory = fromDirectory;
145
+ for (;;) {
146
+ const candidate = basename(directory) === "node_modules"
147
+ ? join(directory, name)
148
+ : join(directory, "node_modules", name);
149
+ if (await isFileAsync(join(candidate, "package.json"))) {
150
+ const resolved = await realpath(candidate);
151
+ const manifest = await readPackageManifest(resolved, { signal });
152
+ return manifest.mocked === true
153
+ ? undefined
154
+ : { name: manifest.name ?? name, directory: resolved, manifest };
155
+ }
156
+ const parent = dirname(directory);
157
+ if (parent === directory) {
158
+ return undefined;
159
+ }
160
+ directory = parent;
161
+ }
162
+ }
163
+ function licenseOf_(manifest) {
164
+ const { license, licenses } = manifest;
165
+ if (typeof license === "string") {
166
+ return license;
167
+ }
168
+ if (isObject(license)) {
169
+ const { type } = license;
170
+ if (typeof type === "string") {
171
+ return type;
172
+ }
173
+ }
174
+ if (Array.isArray(licenses)) {
175
+ const types = licenses.flatMap((entry) => {
176
+ const type = isObject(entry) ? entry.type : null;
177
+ return typeof type === "string" ? [type] : [];
178
+ });
179
+ if (types.length > 0) {
180
+ return `(${types.join(" OR ")})`;
181
+ }
182
+ }
183
+ return undefined;
184
+ }
185
+ async function readLicenseFiles_(directory, signal) {
186
+ const files = [];
187
+ for await (const walked of walkPaths({
188
+ root: directory,
189
+ include: LICENSE_FILE_NAME_,
190
+ descend: false,
191
+ signal,
192
+ })) {
193
+ if (walked.entry.isFile() || walked.entry.isSymbolicLink()) {
194
+ const text = await readFile(join(directory, walked.path), {
195
+ encoding: "utf8",
196
+ signal: signal ?? undefined,
197
+ });
198
+ files.push({ name: walked.path, text });
199
+ }
200
+ }
201
+ return files.sort((left, right) => compareCodePoints(left.name, right.name));
202
+ }
203
+ /**
204
+ * Name, then version — a valid SemVer before anything else, by precedence then
205
+ * by its text (build metadata), and other text by code point — then licence and
206
+ * texts, so differing copies of one version keep a stable order.
207
+ */
208
+ function comparePackages_(left, right) {
209
+ const byName = compareCodePoints(left.name, right.name);
210
+ if (byName !== 0) {
211
+ return byName;
212
+ }
213
+ const leftVersion = tryParseSemVer(left.version);
214
+ const rightVersion = tryParseSemVer(right.version);
215
+ if (leftVersion !== null && rightVersion !== null) {
216
+ const byPrecedence = compareSemVer(leftVersion, rightVersion);
217
+ if (byPrecedence !== 0) {
218
+ return byPrecedence;
219
+ }
220
+ }
221
+ else if (leftVersion !== null || rightVersion !== null) {
222
+ return leftVersion !== null ? -1 : 1;
223
+ }
224
+ return (compareCodePoints(left.version, right.version) ||
225
+ compareCodePoints(left.license ?? "", right.license ?? "") ||
226
+ compareCodePoints(textsOf_(left), textsOf_(right)));
227
+ }
228
+ function textsOf_(entry) {
229
+ return entry.files.map((file) => `${file.name}\0${file.text}`).join("\0");
230
+ }
231
+ //# sourceMappingURL=collect-dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect-dependencies.js","sourceRoot":"","sources":["../src/collect-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EACN,kBAAkB,EAClB,WAAW,EACX,sBAAsB,EAGtB,mBAAmB,EACnB,SAAS,GACT,MAAM,cAAc,CAAC;AA0EtB,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,SAAiB,EACjB,OAAmC;IAEnC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,kBAAkB,EAAE,CAAC;IAC1D,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,4EAA4E;IAC5E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,MAAM,MAAM,GAA6C,EAAE,CAAC;IAC5D,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,u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,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { type MaybeAsyncCallable, type Predicate } from "@ac-kit/core";
2
+ import type { NpmPlatform, Workspace } from "@ac-kit/node";
3
+ import type { ResolvedPackage } from "./collect-dependencies.js";
4
+ import type { NoticesPolicy } from "./render-notices.js";
5
+ /** What `ac-notices` reads from `notices.config.*`. */
6
+ export type NoticesConfig = {
7
+ /**
8
+ * The licences a package's production dependencies may carry, or `null` for a
9
+ * package that is not distributed, which gets no notices file and no check.
10
+ * Called once per workspace — from the root manifest's `workspaces`, or from
11
+ * `pnpm-workspace.yaml`'s `packages` when that file exists — or once for the
12
+ * root package when there is none.
13
+ */
14
+ readonly policyFor: MaybeAsyncCallable<[
15
+ workspace: Workspace
16
+ ], NoticesPolicy | null>;
17
+ /**
18
+ * Packages of the project itself, walked through and never listed. Default:
19
+ * the packages whose real path is the root's or one of its workspaces'.
20
+ */
21
+ readonly isFirstParty?: Predicate<[dependency: ResolvedPackage]> | null;
22
+ /** The platform optional dependencies must suit. Default: this process's. */
23
+ readonly platform?: NpmPlatform | null;
24
+ };
25
+ /** The file names `ac-notices` looks for in the root, in this order. */
26
+ export declare const NOTICES_CONFIG_FILE_NAMES: readonly string[];
27
+ /** Types a configuration module's default export; returns it unchanged. */
28
+ export declare function defineNoticesConfig(config: NoticesConfig): NoticesConfig;
29
+ /**
30
+ * Imports a configuration module and checks its default export. A TypeScript
31
+ * module needs a Node.js that strips types (22.18, 23.6 and later).
32
+ *
33
+ * @param path The module, or `null` for the first of
34
+ * {@link NOTICES_CONFIG_FILE_NAMES} found in `root`.
35
+ * @throws {Error} When no configuration file is found.
36
+ * @throws {TypeError} When the default export is not a configuration.
37
+ */
38
+ export declare function loadNoticesConfig(root: string, path?: string | null): Promise<NoticesConfig>;
39
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,uDAAuD;AACvD,MAAM,MAAM,aAAa,GAAG;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CACrC;QAAC,SAAS,EAAE,SAAS;KAAC,EACtB,aAAa,GAAG,IAAI,CACpB,CAAC;IACF;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,GAAG,IAAI,CAAC;IACxE,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAKtD,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAExE;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAClB,OAAO,CAAC,aAAa,CAAC,CAyBxB"}
package/dist/config.js ADDED
@@ -0,0 +1,40 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import { isObject, } from "@ac-kit/core";
5
+ /** The file names `ac-notices` looks for in the root, in this order. */
6
+ export const NOTICES_CONFIG_FILE_NAMES = [
7
+ "notices.config.js",
8
+ "notices.config.mjs",
9
+ "notices.config.ts",
10
+ "notices.config.mts",
11
+ ];
12
+ /** Types a configuration module's default export; returns it unchanged. */
13
+ export function defineNoticesConfig(config) {
14
+ return config;
15
+ }
16
+ /**
17
+ * Imports a configuration module and checks its default export. A TypeScript
18
+ * module needs a Node.js that strips types (22.18, 23.6 and later).
19
+ *
20
+ * @param path The module, or `null` for the first of
21
+ * {@link NOTICES_CONFIG_FILE_NAMES} found in `root`.
22
+ * @throws {Error} When no configuration file is found.
23
+ * @throws {TypeError} When the default export is not a configuration.
24
+ */
25
+ export async function loadNoticesConfig(root, path) {
26
+ const file = path === undefined || path === null
27
+ ? NOTICES_CONFIG_FILE_NAMES.map((name) => join(root, name)).find((candidate) => existsSync(candidate))
28
+ : resolve(root, path);
29
+ if (file === undefined) {
30
+ throw new Error(`No configuration in ${root}: create one of ${NOTICES_CONFIG_FILE_NAMES.join(", ")}`);
31
+ }
32
+ const module = (await import(pathToFileURL(file).href));
33
+ const config = module.default;
34
+ if (!isObject(config) ||
35
+ typeof config.policyFor !== "function") {
36
+ throw new TypeError(`${file} must export a configuration with a policyFor function as its default`);
37
+ }
38
+ return config;
39
+ }
40
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACN,QAAQ,GAGR,MAAM,cAAc,CAAC;AA4BtB,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC3D,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;IACnB,oBAAoB;CACpB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,UAAU,mBAAmB,CAAC,MAAqB;IACxD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,IAAY,EACZ,IAAoB;IAEpB,MAAM,IAAI,GACT,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI;QAClC,CAAC,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAC9D,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CACpC;QACF,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACd,uBAAuB,IAAI,mBAAmB,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpF,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAErD,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;IAC9B,IACC,CAAC,QAAQ,CAAC,MAAM,CAAC;QACjB,OAAQ,MAAkC,CAAC,SAAS,KAAK,UAAU,EAClE,CAAC;QACF,MAAM,IAAI,SAAS,CAClB,GAAG,IAAI,uEAAuE,CAC9E,CAAC;IACH,CAAC;IACD,OAAO,MAAuB,CAAC;AAChC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./collect-dependencies.js";
2
+ export * from "./config.js";
3
+ export * from "./render-notices.js";
4
+ export * from "./run-notices.js";
5
+ export * from "./run-notices-cli.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./collect-dependencies.js";
2
+ export * from "./config.js";
3
+ export * from "./render-notices.js";
4
+ export * from "./run-notices.js";
5
+ export * from "./run-notices-cli.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { ThirdPartyPackage } from "./collect-dependencies.js";
2
+ /** The licences a distribution may ship, as SPDX identifiers. */
3
+ export type NoticesPolicy = {
4
+ /** Licence identifiers and `LicenseRef-` references accepted. */
5
+ readonly licenses: Iterable<string>;
6
+ /** Exceptions accepted after `WITH`. Default: none. */
7
+ readonly exceptions?: Iterable<string> | null;
8
+ };
9
+ /**
10
+ * The packages whose licence the policy does not allow: one with no licence,
11
+ * one whose licence is not an SPDX expression (`SEE LICENSE IN …`), and one
12
+ * whose expression cannot be complied with using allowed licences, as
13
+ * `isSpdxExpressionAllowed` (`@ac-kit/format-spdx`) decides.
14
+ */
15
+ export declare function findDisallowedPackages(packages: readonly ThirdPartyPackage[], policy: NoticesPolicy): readonly ThirdPartyPackage[];
16
+ /**
17
+ * The `THIRD-PARTY-NOTICES.md` content of one distribution: a section per
18
+ * package — numbered `(copy n)` when copies of one version differ — with its
19
+ * licence and the text of each of its licence files in a code block (line
20
+ * endings normalised to `\n`, outer blank lines trimmed).
21
+ */
22
+ export declare function renderNotices(distributionName: string, packages: readonly ThirdPartyPackage[]): string;
23
+ //# sourceMappingURL=render-notices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-notices.d.ts","sourceRoot":"","sources":["../src/render-notices.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,uDAAuD;IACvD,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,MAAM,EAAE,aAAa,GACnB,SAAS,iBAAiB,EAAE,CAW9B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC5B,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,SAAS,iBAAiB,EAAE,GACpC,MAAM,CAiCR"}
@@ -0,0 +1,54 @@
1
+ import { markdownCodeFence } from "@ac-kit/format-markdown";
2
+ import { isSpdxExpressionAllowed, SpdxAllowList, tryParseSpdxExpression, } from "@ac-kit/format-spdx";
3
+ /**
4
+ * The packages whose licence the policy does not allow: one with no licence,
5
+ * one whose licence is not an SPDX expression (`SEE LICENSE IN …`), and one
6
+ * whose expression cannot be complied with using allowed licences, as
7
+ * `isSpdxExpressionAllowed` (`@ac-kit/format-spdx`) decides.
8
+ */
9
+ export function findDisallowedPackages(packages, policy) {
10
+ const allowList = new SpdxAllowList(policy);
11
+ return packages.filter((entry) => {
12
+ if (entry.license === undefined) {
13
+ return true;
14
+ }
15
+ const expression = tryParseSpdxExpression(entry.license);
16
+ return (expression === null || !isSpdxExpressionAllowed(expression, allowList));
17
+ });
18
+ }
19
+ /**
20
+ * The `THIRD-PARTY-NOTICES.md` content of one distribution: a section per
21
+ * package — numbered `(copy n)` when copies of one version differ — with its
22
+ * licence and the text of each of its licence files in a code block (line
23
+ * endings normalised to `\n`, outer blank lines trimmed).
24
+ */
25
+ export function renderNotices(distributionName, packages) {
26
+ const lines = [
27
+ "# Third-party notices",
28
+ "",
29
+ `${distributionName} includes the following third-party packages.`,
30
+ "",
31
+ ];
32
+ if (packages.length === 0) {
33
+ lines.push("It has no third-party production dependency.", "");
34
+ }
35
+ const counts = new Map();
36
+ for (const entry of packages) {
37
+ const id = `${entry.name}@${entry.version}`;
38
+ counts.set(id, (counts.get(id) ?? 0) + 1);
39
+ }
40
+ const seen = new Map();
41
+ for (const entry of packages) {
42
+ const id = `${entry.name}@${entry.version}`;
43
+ const ordinal = (seen.get(id) ?? 0) + 1;
44
+ seen.set(id, ordinal);
45
+ lines.push(counts.get(id) === 1 ? `## ${id}` : `## ${id} (copy ${ordinal})`, "", `License: ${entry.license ?? "UNKNOWN"}`, "");
46
+ for (const file of entry.files) {
47
+ const text = file.text.replaceAll("\r\n", "\n").trim();
48
+ const fence = markdownCodeFence(text);
49
+ lines.push(`### ${file.name}`, "", fence, text, fence, "");
50
+ }
51
+ }
52
+ return `${lines.join("\n").trimEnd()}\n`;
53
+ }
54
+ //# sourceMappingURL=render-notices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-notices.js","sourceRoot":"","sources":["../src/render-notices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACN,uBAAuB,EACvB,aAAa,EACb,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAY7B;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACrC,QAAsC,EACtC,MAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzD,OAAO,CACN,UAAU,KAAK,IAAI,IAAI,CAAC,uBAAuB,CAA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CAAC,OAAO,IAAI,SAAS,EAAE,EACxC,EAAE,CACF,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YACvD,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type Callable } from "@ac-kit/core";
2
+ export type RunNoticesCliOptions = {
3
+ /** The directory relative paths start from. Default: `process.cwd()`. */
4
+ readonly cwd?: string | null;
5
+ /** Receives each line of normal output. Default: `console.log`. */
6
+ readonly stdout?: Callable<[line: string]> | null;
7
+ /** Receives each line of error output. Default: `console.error`. */
8
+ readonly stderr?: Callable<[line: string]> | null;
9
+ readonly signal?: AbortSignal | null;
10
+ };
11
+ /**
12
+ * Runs the `ac-notices` command: reads the configuration, lists the root's
13
+ * workspaces — from `pnpm-workspace.yaml` when it exists, from the manifest's
14
+ * `workspaces` otherwise, or the root package alone when there is none — asks
15
+ * the configuration for each one's policy, then runs `runNotices`. A Yarn
16
+ * Plug'n'Play install (`.pnp.cjs`) is refused.
17
+ *
18
+ * @param args The arguments after the command name.
19
+ * @returns The exit code: `0` on success, `1` when a licence is not allowed, a
20
+ * required peer dependency is missing or the run fails (an abort included),
21
+ * `2` on a usage error.
22
+ */
23
+ export declare function runNoticesCli(args: readonly string[], options?: RunNoticesCliOptions | null): Promise<number>;
24
+ //# sourceMappingURL=run-notices-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-notices-cli.d.ts","sourceRoot":"","sources":["../src/run-notices-cli.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAyB,MAAM,cAAc,CAAC;AAapE,MAAM,MAAM,oBAAoB,GAAG;IAClC,yEAAyE;IACzE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IAClD,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACrC,CAAC;AAgBF;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAClC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,GACnC,OAAO,CAAC,MAAM,CAAC,CA4FjB"}
@@ -0,0 +1,146 @@
1
+ import { realpath } from "node:fs/promises";
2
+ import { join, resolve } from "node:path";
3
+ import { parseArgs } from "node:util";
4
+ import { formatError, isObject } from "@ac-kit/core";
5
+ import { parseYaml } from "@ac-kit/format-yaml";
6
+ import { isFileAsync, listWorkspaces, readFileOrNull, readPackageManifest, } from "@ac-kit/node";
7
+ import { loadNoticesConfig } from "./config.js";
8
+ import { runNotices } from "./run-notices.js";
9
+ const USAGE_ = `Usage: ac-notices [--check] [--root <directory>] [--config <file>]
10
+
11
+ Writes THIRD-PARTY-NOTICES.md beside each distributed package of the workspace
12
+ at <directory> (default: the current directory), and reports every
13
+ third-party licence its policy does not allow.
14
+
15
+ --check report only, write nothing
16
+ --root <dir> the root package's directory
17
+ --config <file> the configuration module (default: notices.config.{js,mjs,ts,mts} in the root)
18
+ --help print this help`;
19
+ const PNPM_WORKSPACE_FILE_ = "pnpm-workspace.yaml";
20
+ const YARN_PNP_FILE_ = ".pnp.cjs";
21
+ /**
22
+ * Runs the `ac-notices` command: reads the configuration, lists the root's
23
+ * workspaces — from `pnpm-workspace.yaml` when it exists, from the manifest's
24
+ * `workspaces` otherwise, or the root package alone when there is none — asks
25
+ * the configuration for each one's policy, then runs `runNotices`. A Yarn
26
+ * Plug'n'Play install (`.pnp.cjs`) is refused.
27
+ *
28
+ * @param args The arguments after the command name.
29
+ * @returns The exit code: `0` on success, `1` when a licence is not allowed, a
30
+ * required peer dependency is missing or the run fails (an abort included),
31
+ * `2` on a usage error.
32
+ */
33
+ export async function runNoticesCli(args, options) {
34
+ const stdout = options?.stdout ?? console.log;
35
+ const stderr = options?.stderr ?? console.error;
36
+ const signal = options?.signal ?? null;
37
+ let values;
38
+ try {
39
+ ({ values } = parseArgs({
40
+ args: [...args],
41
+ options: {
42
+ check: { type: "boolean" },
43
+ root: { type: "string" },
44
+ config: { type: "string" },
45
+ help: { type: "boolean" },
46
+ },
47
+ }));
48
+ }
49
+ catch (error) {
50
+ stderr(error.message);
51
+ stderr(USAGE_);
52
+ return 2;
53
+ }
54
+ if (values.help === true) {
55
+ stdout(USAGE_);
56
+ return 0;
57
+ }
58
+ try {
59
+ const check = values.check === true;
60
+ const root = resolve(options?.cwd ?? process.cwd(), values.root ?? ".");
61
+ signal?.throwIfAborted();
62
+ const config = await loadNoticesConfig(root, values.config);
63
+ const rootManifest = await readPackageManifest(root, { signal });
64
+ const workspaces = await listRootWorkspaces_(root, signal);
65
+ const packages = workspaces.length > 0
66
+ ? workspaces
67
+ : [
68
+ {
69
+ name: rootManifest.name ?? root,
70
+ directory: root,
71
+ manifest: rootManifest,
72
+ },
73
+ ];
74
+ const ownDirectories = new Set([
75
+ await realpath(root),
76
+ ...(await Promise.all(packages.map((workspace) => realpath(workspace.directory)))),
77
+ ]);
78
+ const targets = [];
79
+ for (const workspace of packages) {
80
+ signal?.throwIfAborted();
81
+ const policy = await config.policyFor(workspace);
82
+ signal?.throwIfAborted();
83
+ if (policy !== null) {
84
+ targets.push({
85
+ name: workspace.name,
86
+ directory: workspace.directory,
87
+ policy,
88
+ });
89
+ }
90
+ }
91
+ const problems = await runNotices(targets, {
92
+ check,
93
+ isFirstParty: config.isFirstParty ??
94
+ ((dependency) => ownDirectories.has(dependency.directory)),
95
+ platform: config.platform,
96
+ signal,
97
+ });
98
+ signal?.throwIfAborted();
99
+ for (const problem of problems) {
100
+ stderr(`${problem.workspace}: ${problem.message}`);
101
+ }
102
+ if (problems.length > 0) {
103
+ return 1;
104
+ }
105
+ stdout(`${targets.length} ${targets.length === 1 ? "package" : "packages"} ${check ? "checked" : "written"}`);
106
+ return 0;
107
+ }
108
+ catch (error) {
109
+ stderr(formatError(error));
110
+ return 1;
111
+ }
112
+ }
113
+ /**
114
+ * The root's workspaces: `pnpm-workspace.yaml`'s `packages` when that file
115
+ * exists (pnpm ignores the manifest's `workspaces`), the manifest's
116
+ * `workspaces` otherwise.
117
+ *
118
+ * @throws {Error} For a Yarn Plug'n'Play install, which has no `node_modules`
119
+ * to walk.
120
+ * @throws {TypeError} For a `pnpm-workspace.yaml` whose `packages` is not a
121
+ * list of strings.
122
+ */
123
+ async function listRootWorkspaces_(root, signal) {
124
+ if (await isFileAsync(join(root, YARN_PNP_FILE_))) {
125
+ throw new Error(`${root} is a Yarn Plug'n'Play install (${YARN_PNP_FILE_}), which has no node_modules to walk: set nodeLinker to node-modules or pnpm`);
126
+ }
127
+ const path = join(root, PNPM_WORKSPACE_FILE_);
128
+ const text = await readFileOrNull(path, { encoding: "utf8", signal });
129
+ if (text === null) {
130
+ return listWorkspaces(root, { signal });
131
+ }
132
+ const parsed = parseYaml(text);
133
+ let packages = [];
134
+ if (isObject(parsed)) {
135
+ packages = parsed.packages ?? [];
136
+ }
137
+ else if (parsed !== null && parsed !== undefined) {
138
+ packages = null;
139
+ }
140
+ if (!Array.isArray(packages) ||
141
+ !packages.every((pattern) => typeof pattern === "string")) {
142
+ throw new TypeError(`${path}: "packages" is not a list of strings`);
143
+ }
144
+ return listWorkspaces(root, { patterns: packages, signal });
145
+ }
146
+ //# sourceMappingURL=run-notices-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-notices-cli.js","sourceRoot":"","sources":["../src/run-notices-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAiB,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EACN,WAAW,EACX,cAAc,EACd,cAAc,EACd,mBAAmB,GAEnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAsB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAYlE,MAAM,MAAM,GAAG;;;;;;;;;mCASoB,CAAC;AAEpC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AACnD,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,IAAuB,EACvB,OAAqC;IAErC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;IAC9C,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC;IAChD,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC;IAEvC,IAAI,MAKH,CAAC;IACF,IAAI,CAAC;QACJ,CAAC,EAAE,MAAM,EAAE,GAAG,S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S,EAAE,CAAC;QACpD,QAAQ,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IACC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,EACxD,CAAC;QACF,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,cAAc,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAoB,EAAE,MAAM,EAAE,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type CollectDependenciesOptions } from "./collect-dependencies.js";
2
+ import { type NoticesPolicy } from "./render-notices.js";
3
+ /** The name of the file {@link runNotices} writes in each target directory. */
4
+ export declare const NOTICES_FILE_NAME = "THIRD-PARTY-NOTICES.md";
5
+ /**
6
+ * A licence one target's policy does not allow, or a required peer dependency
7
+ * of one of its packages that is not installed — an error rather than a
8
+ * warning, since what is not installed cannot be audited.
9
+ */
10
+ export type NoticesProblem = {
11
+ /** The target's name. */
12
+ readonly workspace: string;
13
+ readonly message: string;
14
+ };
15
+ /** A distributed package: its directory, and the licences it may ship. */
16
+ export type NoticesTarget = {
17
+ readonly name: string;
18
+ readonly directory: string;
19
+ readonly policy: NoticesPolicy;
20
+ };
21
+ export type RunNoticesOptions = CollectDependenciesOptions & {
22
+ /** Reports problems only, writing no file. */
23
+ readonly check: boolean;
24
+ };
25
+ /**
26
+ * Collects each target's production dependencies, reports every licence its
27
+ * policy does not allow and every required peer dependency missing and, unless
28
+ * checking, writes its {@link NOTICES_FILE_NAME} (atomically, whatever the
29
+ * problems).
30
+ *
31
+ * @returns The problems of every target, in target order then package order.
32
+ */
33
+ export declare function runNotices(targets: readonly NoticesTarget[], options: RunNoticesOptions): Promise<readonly NoticesProblem[]>;
34
+ //# sourceMappingURL=run-notices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-notices.d.ts","sourceRoot":"","sources":["../src/run-notices.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,0BAA0B,EAE/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,KAAK,aAAa,EAElB,MAAM,qBAAqB,CAAC;AAE7B,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,GAAG;IAC5D,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC/B,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,OAAO,EAAE,iBAAiB,GACxB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAgCpC"}
@@ -0,0 +1,44 @@
1
+ import { join } from "node:path";
2
+ import { writeFileAtomic } from "@ac-kit/node";
3
+ import { collectProductionDependencies, } from "./collect-dependencies.js";
4
+ import { findDisallowedPackages, renderNotices, } from "./render-notices.js";
5
+ /** The name of the file {@link runNotices} writes in each target directory. */
6
+ export const NOTICES_FILE_NAME = "THIRD-PARTY-NOTICES.md";
7
+ /**
8
+ * Collects each target's production dependencies, reports every licence its
9
+ * policy does not allow and every required peer dependency missing and, unless
10
+ * checking, writes its {@link NOTICES_FILE_NAME} (atomically, whatever the
11
+ * problems).
12
+ *
13
+ * @returns The problems of every target, in target order then package order.
14
+ */
15
+ export async function runNotices(targets, options) {
16
+ const problems = [];
17
+ for (const target of targets) {
18
+ const { packages, missingPeerDependencies } = await collectProductionDependencies(target.directory, options);
19
+ for (const peer of missingPeerDependencies) {
20
+ problems.push({
21
+ workspace: target.name,
22
+ message: `${peer.dependent} needs the peer dependency ${peer.name}, which is not installed`,
23
+ });
24
+ }
25
+ for (const entry of findDisallowedPackages(packages, target.policy)) {
26
+ problems.push({
27
+ workspace: target.name,
28
+ message: `${entry.name}@${entry.version} has the licence ${entry.license ?? "UNKNOWN"}, which its policy does not allow`,
29
+ });
30
+ }
31
+ if (!options.check) {
32
+ try {
33
+ await writeFileAtomic(join(target.directory, NOTICES_FILE_NAME), renderNotices(target.name, packages), { signal: options.signal ?? null });
34
+ }
35
+ catch (error) {
36
+ // `writeFile` rejects with its own `AbortError`, not the reason.
37
+ options.signal?.throwIfAborted();
38
+ throw error;
39
+ }
40
+ }
41
+ }
42
+ return problems;
43
+ }
44
+ //# sourceMappingURL=run-notices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-notices.js","sourceRoot":"","sources":["../src/run-notices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAEN,6BAA6B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,sBAAsB,EAEtB,aAAa,GACb,MAAM,qBAAqB,CAAC;AAE7B,+EAA+E;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAyB1D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC/B,OAAiC,EACjC,OAA0B;IAE1B,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,EAAE,QAAQ,EAAE,uBAAuB,EAAE,GAC1C,MAAM,6BAA6B,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChE,KAAK,MAAM,IAAI,IAAI,uBAAuB,EAAE,CAAC;YAC5C,QAAQ,CAAC,IAAI,CAAC;gBACb,SAAS,EAAE,MAAM,CAAC,IAAI;gBACtB,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,8BAA8B,IAAI,CAAC,IAAI,0BAA0B;aAC3F,CAAC,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACrE,QAAQ,CAAC,IAAI,CAAC;gBACb,SAAS,EAAE,MAAM,CAAC,IAAI;gBACtB,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,oBAAoB,KAAK,CAAC,OAAO,IAAI,SAAS,mCAAmC;aACxH,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACpB,IAAI,CAAC;gBACJ,MAAM,eAAe,CACpB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,CAAC,EACzC,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,EACpC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,CAClC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,iEAAiE;gBACjE,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;gBACjC,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@ac-tool/notices",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Third-party notices for a JavaScript workspace: walks each package's production dependencies, collects their licence texts, writes THIRD-PARTY-NOTICES.md and checks every licence against an allow-list.",
5
+ "keywords": [
6
+ "license",
7
+ "notices",
8
+ "spdx",
9
+ "third-party"
10
+ ],
11
+ "homepage": "https://git.grenadine.io/anthochamp/node-essentials/src/branch/main/tools/notices#readme",
12
+ "bugs": {
13
+ "url": "https://git.grenadine.io/anthochamp/node-essentials/issues"
14
+ },
15
+ "license": "BSD-3-Clause",
16
+ "author": "Anthony Champagne <dev@anthonychampagne.fr>",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://git.grenadine.io/anthochamp/node-essentials.git",
20
+ "directory": "tools/notices"
21
+ },
22
+ "bin": {
23
+ "ac-notices": "./bin/notices.js"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "bin"
28
+ ],
29
+ "type": "module",
30
+ "sideEffects": false,
31
+ "main": "./dist/index.js",
32
+ "exports": {
33
+ ".": "./dist/index.js",
34
+ "./cli": "./dist/cli.js"
35
+ },
36
+ "publishConfig": {
37
+ "main": "./dist/index.js",
38
+ "exports": {
39
+ ".": "./dist/index.js",
40
+ "./cli": "./dist/cli.js"
41
+ },
42
+ "access": "public"
43
+ },
44
+ "scripts": {
45
+ "compile": "tsc -p ./tsconfig.build.json --outDir dist",
46
+ "compile:check": "tsc -noEmit -p ./tsconfig.json",
47
+ "clean": "rimraf dist",
48
+ "build": "yarn clean && yarn compile",
49
+ "test": "yarn run -T vitest run",
50
+ "prepack": "yarn build"
51
+ },
52
+ "dependencies": {
53
+ "@ac-kit/core": "^0.11.0",
54
+ "@ac-kit/format-markdown": "^0.2.1",
55
+ "@ac-kit/format-semver": "^0.1.0",
56
+ "@ac-kit/format-spdx": "^0.1.0",
57
+ "@ac-kit/format-yaml": "^0.2.8",
58
+ "@ac-kit/node": "^0.10.0",
59
+ "@types/node": "^26.5.1"
60
+ },
61
+ "devDependencies": {
62
+ "@ac-kit/integration-test-util": "0.5.0",
63
+ "@ac-kit/tsconfig": "0.1.0",
64
+ "@ac-kit/typedoc-config": "0.1.0",
65
+ "@ac-kit/vitest-config": "0.1.1",
66
+ "@typescript/native": "typescript@7.0.2",
67
+ "rimraf": "6.1.4",
68
+ "tsx": "4.23.15",
69
+ "typedoc": "0.28.20",
70
+ "typescript": "@typescript/typescript6@6.0.2"
71
+ },
72
+ "engines": {
73
+ "node": ">=24"
74
+ }
6
75
  }