Skip to content

Commit

Permalink
feat(docs): add docs for copyright generator
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Apr 1, 2020
1 parent b0d66e5 commit 65c62e1
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 8 deletions.
79 changes: 79 additions & 0 deletions docs/site/Copyright-generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
lang: en
title: 'Generate copyright/license header for JavaScript/TypeScript files'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/Copyright-generator.html
---

### Synopsis

The `lb4 copyright` command runs inside a Node.js project with `package.json` to
add or update copyright/license header for JavaScript and TypeScript files based
on `package.json` and git history.

The command also supports [lerna](https://github.com/lerna/lerna) monorepos. It
traverses all packages within the monorepo and apply copyright/license headers.

```sh
lb4 copyright [options]
```

The following is an example of such headers.

```js
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
```

The year(s) is built from the git history of the file and `Node module` is read
from the `name` property in `package.json`.

Please note the command expects `git` is installed.

### Options

`--owner` : _(Optional)_ The owner of the copyright, such as `IBM Corp.`.

`--license` : _(Optional)_ The name of the license, such as `MIT`.

`--gitOnly` : _(Optional)_ A flag to control if only git tracked files are
updated. Default to `true`.

### Interactive Prompts

The command prompts you for:

1. The copyright owner. The default value is read from `copyright.owner` or
`author` in the `package.json`.

2. The license name. The default value is read from `license` in the
`package.json`.

The default owner is `IBM Corp.` and license is `MIT` with the following
`package.json`.

```json
{
"name": "@loopback/boot",
"version": "2.0.2",
"author": "IBM Corp.",
"copyright.owner": "IBM Corp.",
"license": "MIT"
}
```

### Output

The following output is captured when `lb4 copyright` is run against
[`loopback4-example-shopping`](https://github.com/strongloop/loopback4-example-shopping).

```
? Copyright owner: IBM Corp.
? License name: MIT
Updating project loopback4-example-recommender (packages/recommender)
Updating project loopback4-example-shopping (packages/shopping)
Updating project loopback4-example-shopping-monorepo (.)
```
4 changes: 4 additions & 0 deletions docs/site/sidebars/lb4_sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ children:
url: Update-generator.html
output: 'web, pdf'

- title: 'Generate copyright/license headers'
url: Copyright-generator.html
output: 'web, pdf'

- title: 'Connectors reference'
url: Connectors-reference.html
output: 'web'
Expand Down
6 changes: 0 additions & 6 deletions docs/site/tables/lb4-artifact-commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@
<td><a href="Interceptor-generator.html">Global interceptor generator</a></td>
</tr>

<tr>
<td><code>lb4 update</code></td>
<td>Check and/or update project dependencies of LoopBack modules</td>
<td><a href="Update-generator.html">Project dependency update</a></td>
</tr>

<tr>
<td><code>lb4 rest-crud</code></td>
<td>Generate rest configs for model endpoints</td>
Expand Down
12 changes: 12 additions & 0 deletions docs/site/tables/lb4-project-commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
</td>
</tr>

<tr>
<td><code>lb4 update</code></td>
<td>Check and/or update project dependencies of LoopBack modules</td>
<td><a href="Update-generator.html">Project dependency update</a></td>
</tr>

<tr>
<td><code>lb4 copyright</code></td>
<td>Add or update copyright/license header for JavaScript/TypeScript files</td>
<td><a href="Copyright-generator.html">Copyright generator</a></td>
</tr>

<tr>
<td>
<code>lb4 example</code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const sandbox = new TestSandbox(SANDBOX_PATH);

const year = new Date().getFullYear();

describe('lb4 copyright for monorepo', function() {
describe('lb4 copyright for monorepo', function () {
// eslint-disable-next-line no-invalid-this
this.timeout(30000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const sandbox = new TestSandbox(SANDBOX_PATH);

const year = new Date().getFullYear();

describe('lb4 copyright', function() {
describe('lb4 copyright', function () {
// eslint-disable-next-line no-invalid-this
this.timeout(30000);

Expand Down

0 comments on commit 65c62e1

Please sign in to comment.