From 65c62e1ff0090a047acfbd5607e3ad92b44fcb39 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 30 Mar 2020 08:30:08 -0700 Subject: [PATCH] feat(docs): add docs for copyright generator --- docs/site/Copyright-generator.md | 79 +++++++++++++++++++ docs/site/sidebars/lb4_sidebar.yml | 4 + docs/site/tables/lb4-artifact-commands.html | 6 -- docs/site/tables/lb4-project-commands.html | 12 +++ .../copyright-monorepo.integration.js | 2 +- .../generators/copyright.integration.js | 2 +- 6 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 docs/site/Copyright-generator.md diff --git a/docs/site/Copyright-generator.md b/docs/site/Copyright-generator.md new file mode 100644 index 000000000000..1900f6ee001f --- /dev/null +++ b/docs/site/Copyright-generator.md @@ -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 (.) +``` diff --git a/docs/site/sidebars/lb4_sidebar.yml b/docs/site/sidebars/lb4_sidebar.yml index 7507800198f8..dd2826604b9a 100644 --- a/docs/site/sidebars/lb4_sidebar.yml +++ b/docs/site/sidebars/lb4_sidebar.yml @@ -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' diff --git a/docs/site/tables/lb4-artifact-commands.html b/docs/site/tables/lb4-artifact-commands.html index 4ac835692e23..c8a02a383181 100644 --- a/docs/site/tables/lb4-artifact-commands.html +++ b/docs/site/tables/lb4-artifact-commands.html @@ -76,12 +76,6 @@ Global interceptor generator - - lb4 update - Check and/or update project dependencies of LoopBack modules - Project dependency update - - lb4 rest-crud Generate rest configs for model endpoints diff --git a/docs/site/tables/lb4-project-commands.html b/docs/site/tables/lb4-project-commands.html index c4abe5bf28e6..a76922625637 100644 --- a/docs/site/tables/lb4-project-commands.html +++ b/docs/site/tables/lb4-project-commands.html @@ -33,6 +33,18 @@ + + lb4 update + Check and/or update project dependencies of LoopBack modules + Project dependency update + + + + lb4 copyright + Add or update copyright/license header for JavaScript/TypeScript files + Copyright generator + + lb4 example diff --git a/packages/cli/test/integration/generators/copyright-monorepo.integration.js b/packages/cli/test/integration/generators/copyright-monorepo.integration.js index 62aae3acc48e..9c930a68ec6a 100644 --- a/packages/cli/test/integration/generators/copyright-monorepo.integration.js +++ b/packages/cli/test/integration/generators/copyright-monorepo.integration.js @@ -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); diff --git a/packages/cli/test/integration/generators/copyright.integration.js b/packages/cli/test/integration/generators/copyright.integration.js index 618e57c201b5..fb031e0c9e8f 100644 --- a/packages/cli/test/integration/generators/copyright.integration.js +++ b/packages/cli/test/integration/generators/copyright.integration.js @@ -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);