Skip to content

Commit 652e2f8

Browse files
committed
feat(docs): add docs for lb4 copyright command
1 parent 9ed6e7a commit 652e2f8

File tree

4 files changed

+100
-6
lines changed

4 files changed

+100
-6
lines changed

docs/site/Copyright-generator.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
lang: en
3+
title: 'Generate copyright/license header for JavaScript/TypeScript files'
4+
keywords: LoopBack 4.0, LoopBack 4
5+
sidebar: lb4_sidebar
6+
permalink: /doc/en/lb4/Copyright-generator.html
7+
---
8+
9+
### Synopsis
10+
11+
The `lb4 copyright` command runs inside a Node.js project with `package.json` to
12+
add or update copyright/license header for JavaScript and TypeScript files based
13+
on `package.json` and git history.
14+
15+
The command also supports [lerna](https://github.com/lerna/lerna) monorepos. It
16+
traverses all packages within the monorepo and apply copyright/license headers.
17+
18+
```sh
19+
lb4 copyright [options]
20+
```
21+
22+
The following is an example of such headers.
23+
24+
```js
25+
// Copyright IBM Corp. 2020. All Rights Reserved.
26+
// Node module: @loopback/cli
27+
// This file is licensed under the MIT License.
28+
// License text available at https://opensource.org/licenses/MIT
29+
```
30+
31+
The year(s) is built from the git history of the file and `Node module` is read
32+
from the `name` property in `package.json`.
33+
34+
Please note the command expects `git` is installed.
35+
36+
### Options
37+
38+
`--owner` : _(Optional)_ The owner of the copyright, such as `IBM Corp.`.
39+
40+
`--license` : _(Optional)_ The name of the license, such as `MIT`.
41+
42+
`--gitOnly` : _(Optional)_ A flag to control if only git tracked files are
43+
updated. Default to `true`.
44+
45+
### Interactive Prompts
46+
47+
The command prompts you for:
48+
49+
1. The copyright owner. The default value is read from `copyright.owner` or
50+
`author` in the `package.json`.
51+
52+
2. The license name. The default value is read from `license` in the
53+
`package.json`.
54+
55+
The default owner is `IBM Corp.` and license is `MIT` with the following
56+
`package.json`.
57+
58+
```json
59+
{
60+
"name": "@loopback/boot",
61+
"version": "2.0.2",
62+
"author": "IBM Corp.",
63+
"copyright.owner": "IBM Corp.",
64+
"license": "MIT"
65+
}
66+
```
67+
68+
### Output
69+
70+
The following output is captured when `lb4 copyright` is run against
71+
[`loopback4-example-shopping`](https://github.com/strongloop/loopback4-example-shopping).
72+
73+
```
74+
? Copyright owner: IBM Corp.
75+
? License name: (Use arrow keys or type to search)
76+
❯ MIT (MIT License)
77+
ISC (ISC License)
78+
Artistic-2.0 (Artistic License 2.0)
79+
Apache-2.0 (Apache License 2.0)
80+
...
81+
Updating project loopback4-example-recommender (packages/recommender)
82+
Updating project loopback4-example-shopping (packages/shopping)
83+
Updating project loopback4-example-shopping-monorepo (.)
84+
```

docs/site/sidebars/lb4_sidebar.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ children:
559559
url: Update-generator.html
560560
output: 'web, pdf'
561561

562+
- title: 'Generate copyright/license headers'
563+
url: Copyright-generator.html
564+
output: 'web, pdf'
565+
562566
- title: 'Connectors reference'
563567
url: Connectors-reference.html
564568
output: 'web'

docs/site/tables/lb4-artifact-commands.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@
7676
<td><a href="Interceptor-generator.html">Global interceptor generator</a></td>
7777
</tr>
7878

79-
<tr>
80-
<td><code>lb4 update</code></td>
81-
<td>Check and/or update project dependencies of LoopBack modules</td>
82-
<td><a href="Update-generator.html">Project dependency update</a></td>
83-
</tr>
84-
8579
<tr>
8680
<td><code>lb4 rest-crud</code></td>
8781
<td>Generate rest configs for model endpoints</td>

docs/site/tables/lb4-project-commands.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
</td>
3434
</tr>
3535

36+
<tr>
37+
<td><code>lb4 update</code></td>
38+
<td>Check and/or update project dependencies of LoopBack modules</td>
39+
<td><a href="Update-generator.html">Project dependency update</a></td>
40+
</tr>
41+
42+
<tr>
43+
<td><code>lb4 copyright</code></td>
44+
<td>Add or update copyright/license header for JavaScript/TypeScript files</td>
45+
<td><a href="Copyright-generator.html">Copyright generator</a></td>
46+
</tr>
47+
3648
<tr>
3749
<td>
3850
<code>lb4 example</code>

0 commit comments

Comments
 (0)