rolldown-license-plugin 1.3.1 → 1.4.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/README.md +6 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,12 @@ Type: `number`
|
|
|
46
46
|
|
|
47
47
|
When set, word-wrap `licenseText` to this column width.
|
|
48
48
|
|
|
49
|
+
#### `opts.allow`
|
|
50
|
+
|
|
51
|
+
Type: `(license: LicenseInfo) => boolean`
|
|
52
|
+
|
|
53
|
+
Validate each dependency's license. Return `false` to throw a build error.
|
|
54
|
+
|
|
49
55
|
### `LicenseInfo`
|
|
50
56
|
|
|
51
57
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -5741,7 +5741,8 @@ type LicenseInfo = {
|
|
|
5741
5741
|
type RolldownLicensePluginOpts = {
|
|
5742
5742
|
/** Called during `generateBundle` with the collected license data, sorted by name */onDone: (licenses: LicenseInfo[]) => void; /** Regex to match license filenames. Default: `/^((UN)?LICEN(S|C)E|COPYING).*$/i` */
|
|
5743
5743
|
match?: RegExp; /** When set, word-wrap `licenseText` to this column width */
|
|
5744
|
-
wrapText?: number;
|
|
5744
|
+
wrapText?: number; /** Validate each dependency's license. Return `false` to throw a build error */
|
|
5745
|
+
allow?: (license: LicenseInfo) => boolean;
|
|
5745
5746
|
};
|
|
5746
5747
|
/** Word-wrap plain text to a specified column width */
|
|
5747
5748
|
declare function wrap(text: string, width: number): string;
|
|
@@ -5749,7 +5750,8 @@ declare function wrap(text: string, width: number): string;
|
|
|
5749
5750
|
declare const licensePlugin: ({
|
|
5750
5751
|
onDone,
|
|
5751
5752
|
match,
|
|
5752
|
-
wrapText
|
|
5753
|
+
wrapText,
|
|
5754
|
+
allow
|
|
5753
5755
|
}: RolldownLicensePluginOpts) => Plugin;
|
|
5754
5756
|
//#endregion
|
|
5755
5757
|
export { LicenseInfo, RolldownLicensePluginOpts, licensePlugin, wrap };
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ function parseLicense(pkgJson) {
|
|
|
40
40
|
return "";
|
|
41
41
|
}
|
|
42
42
|
/** Rolldown plugin that extracts license information from bundled dependencies */
|
|
43
|
-
const licensePlugin = ({ onDone, match = defaultMatch, wrapText }) => ({
|
|
43
|
+
const licensePlugin = ({ onDone, match = defaultMatch, wrapText, allow }) => ({
|
|
44
44
|
name: "rolldown-license-plugin",
|
|
45
45
|
async generateBundle(_opts, bundle) {
|
|
46
46
|
const pkgJsonCache = /* @__PURE__ */ new Map();
|
|
@@ -106,6 +106,10 @@ const licensePlugin = ({ onDone, match = defaultMatch, wrapText }) => ({
|
|
|
106
106
|
};
|
|
107
107
|
}));
|
|
108
108
|
licenses.sort((a, b) => a.name.localeCompare(b.name));
|
|
109
|
+
if (allow) {
|
|
110
|
+
const violations = licenses.filter((entry) => !allow(entry));
|
|
111
|
+
if (violations.length) throw new Error(`License violation in: ${violations.map((entry) => `${entry.name}@${entry.version} (${entry.license || "unlicensed"})`).join(", ")}`);
|
|
112
|
+
}
|
|
109
113
|
onDone(licenses);
|
|
110
114
|
}
|
|
111
115
|
});
|
package/package.json
CHANGED