Skip to content

Commit 26c6fe9

Browse files
authored
Merge pull request #642 from TobyAndToby/ts/docs-v4
Update the docs to include major version 4
2 parents 5cfebc1 + a336279 commit 26c6fe9

File tree

18 files changed

+1279
-23
lines changed

18 files changed

+1279
-23
lines changed

website/docs/v3-to-v4.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Migrate from V3 to V4
3+
---
4+
5+
import Tabs from "@theme/Tabs";
6+
import TabItem from "@theme/TabItem";
7+
8+
## Breaking Changes
9+
10+
### Dropped Support for Node.js 18
11+
12+
Generate-license-file now requires Node.js 20 or later.

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const sidebars = {
4747
label: "Migration Guides",
4848
collapsed: false,
4949
items: [
50+
{ type: "doc", id: "v3-to-v4", label: "V3 to V4" },
5051
{ type: "doc", id: "v2-to-v3", label: "V2 to V3" },
5152
{ type: "doc", id: "v1-to-v2", label: "V1 to V2" },
5253
],

website/versioned_docs/version-1.3.0/library/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ a detailed spec on the method signatures and types, please read the [API spec](.
1212

1313
## Generate and write a license file to disk
1414

15-
To programatically run the generate license file program you can use the `generateLicenseFile` method.
15+
To programmatically run the generate license file program you can use the `generateLicenseFile` method.
1616
Like the CLI, this method requires a path to a package.json, an output file path, and can be given
17-
an optional line ending paramter. It will produce the same result as running the command via the CLI.
17+
an optional line ending parameter. It will produce the same result as running the command via the CLI.
1818

1919
<Tabs groupId="library-page">
2020
<TabItem value="ts" label="TypeScript">

website/versioned_docs/version-2.0.0/library/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ a detailed spec on the method signatures and types, please read the [API spec](.
1212

1313
## Generate and write a license file to disk
1414

15-
To programatically run the generate license file program you can use the `generateLicenseFile` method.
15+
To programmatically run the generate license file program you can use the `generateLicenseFile` method.
1616
Like the CLI, this method requires a path to a package.json, an output file path, and can be given
17-
an optional line ending paramter. It will produce the same result as running the command via the CLI.
17+
an optional line ending parameter. It will produce the same result as running the command via the CLI.
1818

1919
<Tabs groupId="library-page">
2020
<TabItem value="ts" label="TypeScript">

website/versioned_docs/version-3.0.0/cli/config-file.mdx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: Config File
33
description: Overview and example usages of the generate license file CLI config file
4-
toc_max_heading_level: 4
54
---
65

76
import Tabs from "@theme/Tabs";
@@ -82,11 +81,9 @@ module.exports = {
8281

8382
:::
8483

85-
### Advanced Options
84+
The more advanced features that a config file can contain allow you to edit the contents of the generated output file.
8685

87-
The config file also allows for more complex configurations that are not available as CLI flags.
88-
89-
#### Append
86+
### Append
9087

9188
The append option allows you to append files to the end of the generated output file. This is useful if your project
9289
contains other types of licensed material other than node_modules dependencies that you want to include like fonts or images.
@@ -122,7 +119,7 @@ module.exports = {
122119
</TabItem>
123120
</Tabs>
124121

125-
#### Replace
122+
### Replace
126123

127124
The replace option allows you to replace the license content for a specific dependency. This is useful in situations like:
128125

@@ -134,7 +131,7 @@ Packages can be specified using the format `package@version` or `package`, where
134131

135132
:::info
136133

137-
While it might be more convenient to use the package name without the version, it is recommended to use the version where possible to guarentee you always know exactly which package you are replacing the license for.
134+
While it might be more convenient to use the package name without the version, it is recommended to use the version where possible to guarantee you always know exactly which package you are replacing the license for.
138135

139136
:::
140137

@@ -208,19 +205,17 @@ module.exports = {
208205
</div>
209206
</details>
210207

211-
#### Exclude
208+
### Exclude
212209

213-
The exclude option allows you to exclude dependencies from the generated output file. This is useful for cases like when a dependency
210+
The exclude option allows you to exclude a dependency from the generated output file. This is useful if a dependency
214211
accidentally lists one of it's own dev-dependencies as a normal dependency and you want to exclude that dev-dependency.
215212

216-
Values can be specified using the format `package@version` or `package`, where the latter will match all versions of a given package. You can also use regular expressions by wrapping the expression in forward slashes `/.../` and adding any relevant flags after the closing slash.
217-
218213
<Tabs groupId="file-formats">
219214
<TabItem value="json" label="JSON" default>
220215

221216
```json
222217
{
223-
"exclude": ["lodash", "lodash@1.2.0", "/lodash-.*/i"]
218+
"exclude": ["[email protected].3"]
224219
}
225220
```
226221

@@ -230,9 +225,7 @@ Values can be specified using the format `package@version` or `package`, where t
230225

231226
```yaml
232227
exclude:
233-
- lodash
234-
235-
- /lodash-.*/i
228+
236229
```
237230
238231
</TabItem>
@@ -241,7 +234,7 @@ exclude:
241234
242235
```js
243236
module.exports = {
244-
exclude: ["lodash", "lodash@1.2.0", "/lodash-.*/i"],
237+
exclude: ["[email protected].3"],
245238
};
246239
```
247240

website/versioned_docs/version-3.0.0/library/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ a detailed spec on the method signatures and types, please read the [API spec](.
1212

1313
## Generate and write a license file to disk
1414

15-
To programatically run the generate license file program you can use the `generateLicenseFile` method.
15+
To programmatically run the generate license file program you can use the `generateLicenseFile` method.
1616
Like the CLI, this method requires a path to a package.json, an output file path, and can be given
17-
an optional line ending paramter. It will produce the same result as running the command via the CLI.
17+
an optional line ending parameter. It will produce the same result as running the command via the CLI.
1818

1919
<Tabs groupId="library-page">
2020
<TabItem value="ts" label="TypeScript">
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
---
2+
title: Config File
3+
description: Overview and example usages of the generate license file CLI config file
4+
toc_max_heading_level: 4
5+
---
6+
7+
import Tabs from "@theme/Tabs";
8+
import TabItem from "@theme/TabItem";
9+
10+
The generate-license-file CLI can be configured using a config file so that you don't need to re-enter the same
11+
config options every time. The config file also allows you to specify additional more complex options that are not
12+
available as CLI flags.
13+
14+
## File Formats
15+
16+
Config files can be called either `.glf` or `.generatelicensefile` and can be customised using the following options:
17+
18+
- File name can optionally end with `rc`
19+
- Can be in a `./.config` directory (no longer needs the `.` prefix on the file name)
20+
- Have the following file extensions: `.json`, `jsonc`, `.json5`, `.yaml`, `.yml`, `.js`, `.cjs`
21+
22+
E.g. `.glf.json`, `.glfrc.yml`, `.generatelicensefile.jsonc`, `.config/glf.js`, and more.
23+
24+
## Config Options
25+
26+
The file can contain all of the options that are [available as CLI flags](./).
27+
28+
<Tabs groupId="file-formats">
29+
<TabItem value="json" label="JSON" default>
30+
31+
```json
32+
{
33+
"inputs": ["./package.json"],
34+
"output": "./THIRD-PARTY-LICENSES.txt",
35+
"overwrite": true,
36+
"eol": "lf",
37+
"ci": true,
38+
"no-spinner": true
39+
}
40+
```
41+
42+
</TabItem>
43+
44+
<TabItem value="yaml" label="YAML">
45+
46+
```yaml
47+
inputs:
48+
- ./package.json
49+
output: ./THIRD-PARTY-LICENSES.txt
50+
overwrite: true
51+
eol: lf
52+
ci: true
53+
no-spinner: true
54+
```
55+
56+
</TabItem>
57+
58+
<TabItem value="js" label="JavaScript">
59+
60+
```js
61+
module.exports = {
62+
inputs: ["./package.json"],
63+
output: "./THIRD-PARTY-LICENSES.txt",
64+
overwrite: true,
65+
eol: "lf",
66+
ci: true,
67+
noSpinner: true,
68+
};
69+
```
70+
71+
</TabItem>
72+
</Tabs>
73+
74+
:::tip
75+
JavaScript allows for more dynamic usages
76+
77+
```js
78+
module.exports = {
79+
ci: process.env.CI === "true",
80+
};
81+
```
82+
83+
:::
84+
85+
### Advanced Options
86+
87+
The config file also allows for more complex configurations that are not available as CLI flags.
88+
89+
#### Append
90+
91+
The append option allows you to append files to the end of the generated output file. This is useful if your project
92+
contains other types of licensed material other than node_modules dependencies that you want to include like fonts or images.
93+
94+
<Tabs groupId="file-formats">
95+
<TabItem value="json" label="JSON" default>
96+
97+
```json
98+
{
99+
"append": ["./extra-licenses.txt"]
100+
}
101+
```
102+
103+
</TabItem>
104+
105+
<TabItem value="yaml" label="YAML">
106+
107+
```yaml
108+
append:
109+
- ./extra-licenses.txt
110+
```
111+
112+
</TabItem>
113+
114+
<TabItem value="js" label="JavaScript">
115+
116+
```js
117+
module.exports = {
118+
append: ["./extra-licenses.txt"],
119+
};
120+
```
121+
122+
</TabItem>
123+
</Tabs>
124+
125+
#### Replace
126+
127+
The replace option allows you to replace the license content for a specific dependency. This is useful in situations like:
128+
129+
- A dependency does not have its license file included in the published package
130+
- The license file is not in a standard format
131+
- The published package contains multiple license files and you want to pick a specific one
132+
133+
Packages can be specified using the format `package@version` or `package`, where the latter will match all versions of a given package. If both are specified, then the configuration with a matching version will take precedence.
134+
135+
:::info
136+
137+
While it might be more convenient to use the package name without the version, it is recommended to use the version where possible to guarantee you always know exactly which package you are replacing the license for.
138+
139+
:::
140+
141+
The replacement value can be:
142+
143+
- A relative or absolute file path to a location on disk
144+
- A URL to a remote file on the internet
145+
146+
:::tip
147+
148+
An advantage to using a file path over a URL is that the generated output will always be the same for any given commit.
149+
150+
:::
151+
152+
<Tabs groupId="file-formats">
153+
<TabItem value="json" label="JSON" default>
154+
155+
```json
156+
{
157+
"replace": {
158+
"[email protected]": "./licenses/lodash.txt",
159+
"[email protected]": "./node_modules/react/LICENSE",
160+
"axios": "./node_modules/axios/LICENSE",
161+
"express": "https://spdx.org/licenses/MIT.txt"
162+
}
163+
}
164+
```
165+
166+
</TabItem>
167+
168+
<TabItem value="yaml" label="YAML">
169+
170+
```yaml
171+
replace:
172+
[email protected]: ./licenses/lodash.txt
173+
[email protected]: ./node_modules/react/LICENSE
174+
axios: ./node_modules/axios/LICENSE
175+
express: https://spdx.org/licenses/MIT.txt
176+
```
177+
178+
</TabItem>
179+
180+
<TabItem value="js" label="JavaScript">
181+
182+
```js
183+
module.exports = {
184+
replace: {
185+
"[email protected]": "./licenses/lodash.txt",
186+
"[email protected]": "./node_modules/react/LICENSE",
187+
axios: "./node_modules/axios/LICENSE",
188+
express: "https://spdx.org/licenses/MIT.txt",
189+
},
190+
};
191+
```
192+
193+
</TabItem>
194+
</Tabs>
195+
196+
<details>
197+
<summary>When using pnpm, the way to reference a file in a node_module can look a little different</summary>
198+
<div>
199+
200+
```json
201+
{
202+
"replace": {
203+
"[email protected]": "node_modules/.pnpm/[email protected]/node_modules/react/LICENSE"
204+
}
205+
}
206+
```
207+
208+
</div>
209+
</details>
210+
211+
#### Exclude
212+
213+
The exclude option allows you to exclude dependencies from the generated output file. This is useful for cases like when a dependency
214+
accidentally lists one of it's own dev-dependencies as a normal dependency and you want to exclude that dev-dependency.
215+
216+
Values can be specified using the format `package@version` or `package`, where the latter will match all versions of a given package. You can also use regular expressions by wrapping the expression in forward slashes `/.../` and adding any relevant flags after the closing slash.
217+
218+
<Tabs groupId="file-formats">
219+
<TabItem value="json" label="JSON" default>
220+
221+
```json
222+
{
223+
"exclude": ["lodash", "[email protected]", "/lodash-.*/i"]
224+
}
225+
```
226+
227+
</TabItem>
228+
229+
<TabItem value="yaml" label="YAML">
230+
231+
```yaml
232+
exclude:
233+
- lodash
234+
235+
- /lodash-.*/i
236+
```
237+
238+
</TabItem>
239+
240+
<TabItem value="js" label="JavaScript">
241+
242+
```js
243+
module.exports = {
244+
exclude: ["lodash", "[email protected]", "/lodash-.*/i"],
245+
};
246+
```
247+
248+
</TabItem>
249+
</Tabs>
250+
251+
## File Location
252+
253+
If you want to keep your config file in a different location to the current working directory (or a `./.config` directory)
254+
then you can specify the location of the config file using the `--config` CLI flag.
255+
256+
```bash
257+
generate-license-file --config ./path/to/config.json
258+
```

0 commit comments

Comments
 (0)