rolldown-license-plugin 2.2.3 → 2.2.5
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/README.md +11 -5
- package/dist/index.js +15 -13
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -12,9 +12,15 @@ import {licensePlugin} from "rolldown-license-plugin";
|
|
|
12
12
|
export default {
|
|
13
13
|
plugins: [
|
|
14
14
|
licensePlugin({
|
|
15
|
-
done(deps) {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
done(deps, context) {
|
|
16
|
+
const content = deps.map(({name, version, license, licenseText}) => (
|
|
17
|
+
`${name} ${version} (${license})\n${licenseText}`
|
|
18
|
+
)).join("\n\n");
|
|
19
|
+
context.emitFile({
|
|
20
|
+
type: "asset",
|
|
21
|
+
fileName: "licenses.txt",
|
|
22
|
+
source: content,
|
|
23
|
+
});
|
|
18
24
|
},
|
|
19
25
|
}),
|
|
20
26
|
],
|
|
@@ -71,8 +77,8 @@ Throw a build error when a dependency does not specify any license.
|
|
|
71
77
|
```typescript
|
|
72
78
|
type LicenseInfo = {
|
|
73
79
|
name: string; // package name
|
|
74
|
-
version: string; // package version
|
|
75
|
-
license: string; // SPDX license identifier from package.json
|
|
80
|
+
version: string; // package version, or ""
|
|
81
|
+
license: string; // SPDX license identifier from package.json, or ""
|
|
76
82
|
licenseText: string; // contents of LICENSE/COPYING file, or ""
|
|
77
83
|
};
|
|
78
84
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join, sep } from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region index.ts
|
|
@@ -70,32 +70,34 @@ const licensePlugin = ({ done, match = defaultMatch, wrapText, allow, failOnViol
|
|
|
70
70
|
}
|
|
71
71
|
const seen = /* @__PURE__ */ new Set();
|
|
72
72
|
const licenses = [];
|
|
73
|
-
|
|
73
|
+
for (const dir of roots) {
|
|
74
74
|
let pkgJson;
|
|
75
75
|
try {
|
|
76
|
-
pkgJson = JSON.parse(
|
|
76
|
+
pkgJson = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
77
77
|
} catch {
|
|
78
|
-
|
|
78
|
+
continue;
|
|
79
79
|
}
|
|
80
|
-
if (!pkgJson.name)
|
|
80
|
+
if (!pkgJson.name) continue;
|
|
81
81
|
const key = `${pkgJson.name}@${pkgJson.version ?? ""}`;
|
|
82
|
-
if (seen.has(key))
|
|
82
|
+
if (seen.has(key)) continue;
|
|
83
83
|
seen.add(key);
|
|
84
84
|
let licenseText = "";
|
|
85
85
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
licenseText = readFileSync(join(dir, "LICENSE"), "utf8");
|
|
87
|
+
} catch {
|
|
88
|
+
try {
|
|
89
|
+
const licenseFile = readdirSync(dir).find((entry) => match.test(entry));
|
|
90
|
+
if (licenseFile) licenseText = readFileSync(join(dir, licenseFile), "utf8");
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
93
|
+
if (wrapText && licenseText) licenseText = wrap(licenseText, wrapText).trim();
|
|
92
94
|
licenses.push({
|
|
93
95
|
name: pkgJson.name,
|
|
94
96
|
version: pkgJson.version ?? "",
|
|
95
97
|
license: parseLicense(pkgJson),
|
|
96
98
|
licenseText
|
|
97
99
|
});
|
|
98
|
-
}
|
|
100
|
+
}
|
|
99
101
|
licenses.sort((a, b) => a.name.localeCompare(b.name));
|
|
100
102
|
if (allow) {
|
|
101
103
|
const errors = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-license-plugin",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Rolldown plugin to extract dependency licenses",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/rolldown-license-plugin",
|
|
@@ -19,19 +19,20 @@
|
|
|
19
19
|
"rolldown": "*"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/node": "25.
|
|
23
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
22
|
+
"@types/node": "25.6.0",
|
|
23
|
+
"@typescript/native-preview": "7.0.0-dev.20260410.1",
|
|
24
24
|
"eslint": "10.2.0",
|
|
25
|
-
"eslint-config-silverwind": "131.0.
|
|
25
|
+
"eslint-config-silverwind": "131.0.4",
|
|
26
26
|
"jest-extended": "7.0.0",
|
|
27
27
|
"rolldown": "1.0.0-rc.15",
|
|
28
28
|
"tsdown": "0.21.7",
|
|
29
29
|
"tsdown-config-silverwind": "2.0.5",
|
|
30
|
-
"typescript": "
|
|
30
|
+
"typescript": "6.0.2",
|
|
31
31
|
"typescript-config-silverwind": "17.0.0",
|
|
32
32
|
"updates": "17.14.0",
|
|
33
|
-
"updates-config-silverwind": "2.0
|
|
33
|
+
"updates-config-silverwind": "2.1.0",
|
|
34
34
|
"versions": "14.2.7",
|
|
35
|
+
"vite": "8.0.8",
|
|
35
36
|
"vitest": "4.1.4",
|
|
36
37
|
"vitest-config-silverwind": "11.1.4"
|
|
37
38
|
}
|