@aws/nx-plugin 0.2.1 → 0.3.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/LICENSE-THIRD-PARTY +22 -1
- package/generators.json +11 -0
- package/package.json +5 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/license/README.md +255 -0
- package/src/license/__snapshots__/config.spec.ts.snap +89 -0
- package/src/license/config-types.d.ts +107 -0
- package/src/license/config-types.js +3 -0
- package/src/license/config-types.js.map +1 -0
- package/src/license/config.d.ts +25 -0
- package/src/license/config.js +174 -0
- package/src/license/config.js.map +1 -0
- package/src/license/files/licenses/ASL/LICENSE.template +96 -0
- package/src/license/files/licenses/Apache-2.0/LICENSE.template +175 -0
- package/src/license/files/licenses/MIT/LICENSE.template +21 -0
- package/src/license/generator.d.ts +8 -0
- package/src/license/generator.js +32 -0
- package/src/license/generator.js.map +1 -0
- package/src/license/schema.d.ts +17 -0
- package/src/license/schema.json +23 -0
- package/src/license/sync/generator.d.ts +9 -0
- package/src/license/sync/generator.js +307 -0
- package/src/license/sync/generator.js.map +1 -0
- package/src/license/sync/schema.json +9 -0
- package/src/ts/lib/eslint.js +4 -8
- package/src/ts/lib/eslint.js.map +1 -1
- package/src/utils/ast.d.ts +5 -1
- package/src/utils/ast.js +35 -1
- package/src/utils/ast.js.map +1 -1
- package/src/utils/config/__snapshots__/utils.spec.ts.snap +16 -0
- package/src/utils/config/files/aws-nx-plugin.config.mts.template +5 -0
- package/src/utils/config/index.d.ts +15 -0
- package/src/utils/config/index.js +5 -0
- package/src/utils/config/index.js.map +1 -0
- package/src/utils/config/utils.d.ts +20 -0
- package/src/utils/config/utils.js +71 -0
- package/src/utils/config/utils.js.map +1 -0
- package/src/utils/git.d.ts +9 -0
- package/src/utils/git.js +27 -0
- package/src/utils/git.js.map +1 -0
- package/src/utils/js.d.ts +8 -0
- package/src/utils/js.js +34 -0
- package/src/utils/js.js.map +1 -0
package/LICENSE-THIRD-PARTY
CHANGED
|
@@ -10801,7 +10801,7 @@ THE SOFTWARE.
|
|
|
10801
10801
|
|
|
10802
10802
|
---
|
|
10803
10803
|
|
|
10804
|
-
The following software may be included in this product: fast-glob (3.3.
|
|
10804
|
+
The following software may be included in this product: fast-glob (3.3.3)
|
|
10805
10805
|
This software contains the following license and notice below:
|
|
10806
10806
|
|
|
10807
10807
|
The MIT License (MIT)
|
|
@@ -38984,6 +38984,27 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
38984
38984
|
|
|
38985
38985
|
---
|
|
38986
38986
|
|
|
38987
|
+
The following software may be included in this product: minimatch (10.0.1)
|
|
38988
|
+
This software contains the following license and notice below:
|
|
38989
|
+
|
|
38990
|
+
The ISC License
|
|
38991
|
+
|
|
38992
|
+
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
|
|
38993
|
+
|
|
38994
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
38995
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
38996
|
+
copyright notice and this permission notice appear in all copies.
|
|
38997
|
+
|
|
38998
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
38999
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
39000
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
39001
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
39002
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
39003
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
39004
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
39005
|
+
|
|
39006
|
+
---
|
|
39007
|
+
|
|
38987
39008
|
The following software may be included in this product: minipass (7.1.2)
|
|
38988
39009
|
This software contains the following license and notice below:
|
|
38989
39010
|
|
package/generators.json
CHANGED
|
@@ -38,6 +38,17 @@
|
|
|
38
38
|
"factory": "./src/trpc/react/generator",
|
|
39
39
|
"schema": "./src/trpc/react/schema.json",
|
|
40
40
|
"description": "provides React integration to a React website"
|
|
41
|
+
},
|
|
42
|
+
"license": {
|
|
43
|
+
"factory": "./src/license/generator",
|
|
44
|
+
"schema": "./src/license/schema.json",
|
|
45
|
+
"description": "Add LICENSE files and configure source code licence headers"
|
|
46
|
+
},
|
|
47
|
+
"license#sync": {
|
|
48
|
+
"factory": "./src/license/sync/generator",
|
|
49
|
+
"schema": "./src/license/sync/schema.json",
|
|
50
|
+
"description": "Sync generator for writing licence headers and subproject LICENSE files",
|
|
51
|
+
"hidden": true
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws/nx-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"generators": "./generators.json",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"prettier": "^3.4.2"
|
|
14
|
+
"prettier": "^3.4.2",
|
|
15
|
+
"nx": "20.4.0"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@nx/devkit": "^20.4.0",
|
|
@@ -20,7 +21,9 @@
|
|
|
20
21
|
"@nx/react": "^20.4.0",
|
|
21
22
|
"@nx/vite": "^20.4.0",
|
|
22
23
|
"@phenomnomnominal/tsquery": "6.1.3",
|
|
24
|
+
"fast-glob": "^3.3.3",
|
|
23
25
|
"lodash.kebabcase": "4.1.1",
|
|
26
|
+
"minimatch": "^10.0.1",
|
|
24
27
|
"typescript": "~5.5.4",
|
|
25
28
|
"vite": "^5.4.0",
|
|
26
29
|
"vitest": "^1.6.0"
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
1
4
|
/**
|
|
2
5
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
6
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
7
|
*/
|
|
8
|
+
tslib_1.__exportStar(require("./utils/config"), exports);
|
|
5
9
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nx-plugin/src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nx-plugin/src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,yDAA+B"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# License Generator
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This generator configures `LICENSE` files and source file headers for your project. After you run this generator, a [sync generator](https://nx.dev/concepts/sync-generators) is registered to execute as part of your `lint` targets which will ensure that your source files conform to the desired license content and format, as well as ensuring that all projects in your workspace contain a copy of the root `LICENSE` file.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
You can run the generator in two ways:
|
|
10
|
+
|
|
11
|
+
### 1. Using VSCode IDE
|
|
12
|
+
|
|
13
|
+
First, install the NX Console extension for VSCode:
|
|
14
|
+
|
|
15
|
+
1. Open VSCode
|
|
16
|
+
2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
|
|
17
|
+
3. Search for "Nx Console"
|
|
18
|
+
4. Install [Nx Console](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console)
|
|
19
|
+
|
|
20
|
+
Then generate your API:
|
|
21
|
+
|
|
22
|
+
1. Open the NX Console in VSCode
|
|
23
|
+
2. Click on "Generate"
|
|
24
|
+
3. Search for "license"
|
|
25
|
+
4. Fill in the required parameters in the form
|
|
26
|
+
5. Click "Run"
|
|
27
|
+
|
|
28
|
+
### 2. Using CLI
|
|
29
|
+
|
|
30
|
+
Generate the API:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
nx g @aws/nx-plugin:license my-api --copyrightHolder="My Company, Inc." --license=MIT
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You can also perform a dry-run to see what files would be generated or updated without actually creating them:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
nx g @aws/nx-plugin:license my-api --copyrightHolder="My Company, Inc." --license=MIT --dry-run
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Both methods will create a root `LICENSE` file based on your selected license and copyright holder, as well as configuring the sync generator to ensure that source files specify the correct license header.
|
|
43
|
+
|
|
44
|
+
## Input Parameters
|
|
45
|
+
|
|
46
|
+
| Parameter | Type | Default | Description |
|
|
47
|
+
| --------------- | ------ | ------------------------------------ | -------------------------------------------------------------------------------------- |
|
|
48
|
+
| license | string | "Apache-2.0" | The SPDX license identifier for your chosen license. |
|
|
49
|
+
| copyrightHolder | string | "Amazon.com, Inc. or its affiliates" | The copyright holder, included in the LICENSE file and source file headers by default. |
|
|
50
|
+
|
|
51
|
+
## Expected Output
|
|
52
|
+
|
|
53
|
+
The generator will create or update the following files:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
└── LICENSE # The content is written based on the selected license
|
|
57
|
+
└── package.json # The "license" field is updated with the selected license
|
|
58
|
+
└── nx.json # The "lint" target is configured to sync LICENSE files and source file headers
|
|
59
|
+
└── aws-nx-plugin.config.mts # Configuration for the license sync, such as customising the license header content and format for different languages
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Some default configuration for license header content and format is added to `aws-nx-plugin.config.mts` to write appropriate headers for a handful of file types. You may wish to customise this further; please see the [configuration section](#configuration) below.
|
|
63
|
+
|
|
64
|
+
## License Sync Behaviour
|
|
65
|
+
|
|
66
|
+
The license sync generator performs two main tasks:
|
|
67
|
+
|
|
68
|
+
### 1. Synchronise Source File License Headers
|
|
69
|
+
|
|
70
|
+
When the sync generator is run, it will ensure that all source code files in your workspace (based on your configuration) contain the appropriate license header. The header is written as the first block comment or consecutive series of line comments in the file (besides the shebang/hashbang if present in a file).
|
|
71
|
+
|
|
72
|
+
You can update the configuration at any time to change which files should be included or excluded, as well as the content or format of license headers for different file types. For more details, please see the [configuration section](#configuration) below.
|
|
73
|
+
|
|
74
|
+
### 2. Synchronise LICENSE Files
|
|
75
|
+
|
|
76
|
+
When the sync generator is run, it will ensure that all projects in your workspace contain the same `LICENSE` file as the `LICENSE` file in the root of your workspace. If your workspace does not have a root LICENSE file, this is skipped.
|
|
77
|
+
|
|
78
|
+
You can exclude projects in the configuration if required. For more details, please see the [configuration section](#configuration) below.
|
|
79
|
+
|
|
80
|
+
## Configuration
|
|
81
|
+
|
|
82
|
+
Configuration is defined in the `aws-nx-plugin.config.mts` file in the root of your workspace.
|
|
83
|
+
|
|
84
|
+
### License header content
|
|
85
|
+
|
|
86
|
+
The license header content can be configured in two ways:
|
|
87
|
+
|
|
88
|
+
1. Using inline content:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
{
|
|
92
|
+
license: {
|
|
93
|
+
header: {
|
|
94
|
+
content: {
|
|
95
|
+
lines: ['Copyright My Company, Inc.', 'Licensed under MIT License', 'All rights reserved'];
|
|
96
|
+
}
|
|
97
|
+
// ... format configuration
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
2. Loading from a file:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
{
|
|
107
|
+
license: {
|
|
108
|
+
header: {
|
|
109
|
+
content: {
|
|
110
|
+
filePath: 'license-header.txt'; // relative to workspace root
|
|
111
|
+
}
|
|
112
|
+
// ... format configuration
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Including files and specifying a format
|
|
119
|
+
|
|
120
|
+
You can specify how license headers should be formatted for different file types using glob patterns. The format configuration supports line comments, block comments, or a combination of both:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
{
|
|
124
|
+
license: {
|
|
125
|
+
header: {
|
|
126
|
+
content: {
|
|
127
|
+
lines: ['Copyright notice here']
|
|
128
|
+
},
|
|
129
|
+
format: {
|
|
130
|
+
// Line comments
|
|
131
|
+
'**/*.ts': {
|
|
132
|
+
lineStart: '// '
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Block comments
|
|
136
|
+
'**/*.css': {
|
|
137
|
+
blockStart: '/*',
|
|
138
|
+
blockEnd: '*/'
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
// Block comments with line prefixes
|
|
142
|
+
'**/*.java': {
|
|
143
|
+
blockStart: '/*',
|
|
144
|
+
lineStart: ' * ',
|
|
145
|
+
blockEnd: ' */'
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
// Line comments with header/footer
|
|
149
|
+
'**/*.py': {
|
|
150
|
+
blockStart: '# ------------',
|
|
151
|
+
lineStart: '# ',
|
|
152
|
+
blockEnd: '# ------------'
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The format configuration supports:
|
|
161
|
+
|
|
162
|
+
- `blockStart`: Text written before the license content (e.g., to start a block comment)
|
|
163
|
+
- `lineStart`: Text prepended to each line of the license content
|
|
164
|
+
- `lineEnd`: Text appended to each line of the license content
|
|
165
|
+
- `blockEnd`: Text written after the license content (e.g., to end a block comment)
|
|
166
|
+
|
|
167
|
+
### Custom comment syntax
|
|
168
|
+
|
|
169
|
+
For file types that aren't natively supported, you can specify custom comment syntax:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
{
|
|
173
|
+
license: {
|
|
174
|
+
header: {
|
|
175
|
+
content: {
|
|
176
|
+
lines: ['My license header']
|
|
177
|
+
},
|
|
178
|
+
format: {
|
|
179
|
+
'**/*.xyz': {
|
|
180
|
+
lineStart: '## '
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
commentSyntax: {
|
|
184
|
+
xyz: {
|
|
185
|
+
line: '##' // Define line comment syntax
|
|
186
|
+
},
|
|
187
|
+
abc: {
|
|
188
|
+
block: { // Define block comment syntax
|
|
189
|
+
start: '<!--',
|
|
190
|
+
end: '-->'
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
This tells the sync generator how to identify existing license headers in these file types. The `commentSyntax` configuration supports:
|
|
200
|
+
|
|
201
|
+
- `line`: Characters that start a line comment
|
|
202
|
+
- `block`: Characters that start and end a block comment
|
|
203
|
+
|
|
204
|
+
### Excluding files
|
|
205
|
+
|
|
206
|
+
By default, in a git repository, all `.gitignore` files are honored to ensure that only files managed by version control are synchronized. In non-git repositories, all files are considered unless explicitly excluded in configuration.
|
|
207
|
+
|
|
208
|
+
You can exclude additional files from license header synchronization using glob patterns:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
{
|
|
212
|
+
license: {
|
|
213
|
+
header: {
|
|
214
|
+
content: {
|
|
215
|
+
lines: ['My license header']
|
|
216
|
+
},
|
|
217
|
+
format: {
|
|
218
|
+
'**/*.ts': {
|
|
219
|
+
lineStart: '// '
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
exclude: [
|
|
223
|
+
'**/generated/**',
|
|
224
|
+
'**/dist/**',
|
|
225
|
+
'some-specific-file.ts'
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Excluding projects from LICENSE file sync
|
|
233
|
+
|
|
234
|
+
You can exclude specific projects from LICENSE file synchronization using glob patterns:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
{
|
|
238
|
+
license: {
|
|
239
|
+
files: {
|
|
240
|
+
exclude: ['packages/excluded-project', 'apps/internal-*'];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
When excluded, these projects will not receive a copy of the root LICENSE file during synchronization.
|
|
247
|
+
|
|
248
|
+
## Disabling license sync
|
|
249
|
+
|
|
250
|
+
To disable the license sync generator:
|
|
251
|
+
|
|
252
|
+
1. Remove the `license` section from your configuration in `aws-nx-plugin.config.mts` (or remove the `aws-nx-plugin.config.mts` file)
|
|
253
|
+
2. Remove the `@aws/nx-plugin:license#sync` generator from `targetDefaults.lint.syncGenerators`
|
|
254
|
+
|
|
255
|
+
To re-enable license sync, simply run the `license` generator again.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`license config > defaultLicenseConfig > should generate default license config for ASL 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"header": {
|
|
6
|
+
"content": {
|
|
7
|
+
"lines": [
|
|
8
|
+
"Copyright Test Inc. or its affiliates. All Rights Reserved. ",
|
|
9
|
+
" ",
|
|
10
|
+
"Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance ",
|
|
11
|
+
"with the License. A copy of the License is located at ",
|
|
12
|
+
" ",
|
|
13
|
+
" https://aws.amazon.com/asl/ ",
|
|
14
|
+
" ",
|
|
15
|
+
"or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES",
|
|
16
|
+
"OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions ",
|
|
17
|
+
"and limitations under the License. ",
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
"exclude": [],
|
|
21
|
+
"format": {
|
|
22
|
+
"**/*.{js,ts}": {
|
|
23
|
+
"blockEnd": " **********************************************************************************************************************/",
|
|
24
|
+
"blockStart": "/**********************************************************************************************************************",
|
|
25
|
+
"lineEnd": " *",
|
|
26
|
+
"lineStart": " * ",
|
|
27
|
+
},
|
|
28
|
+
"**/*.{py,sh}": {
|
|
29
|
+
"blockEnd": "######################################################################################################################",
|
|
30
|
+
"blockStart": "######################################################################################################################",
|
|
31
|
+
"lineEnd": " #",
|
|
32
|
+
"lineStart": "# ",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`license config > defaultLicenseConfig > should generate default license config for Apache-2.0 1`] = `
|
|
40
|
+
{
|
|
41
|
+
"header": {
|
|
42
|
+
"content": {
|
|
43
|
+
"lines": [
|
|
44
|
+
"Copyright Test Inc. or its affiliates. All Rights Reserved.",
|
|
45
|
+
"SPDX-License-Identifier: Apache-2.0",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
"exclude": [],
|
|
49
|
+
"format": {
|
|
50
|
+
"**/*.{js,ts}": {
|
|
51
|
+
"blockEnd": " */",
|
|
52
|
+
"blockStart": "/**",
|
|
53
|
+
"lineStart": " * ",
|
|
54
|
+
},
|
|
55
|
+
"**/*.{py,sh}": {
|
|
56
|
+
"blockEnd": "# ",
|
|
57
|
+
"blockStart": "# ",
|
|
58
|
+
"lineStart": "# ",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
exports[`license config > defaultLicenseConfig > should generate default license config for MIT 1`] = `
|
|
66
|
+
{
|
|
67
|
+
"header": {
|
|
68
|
+
"content": {
|
|
69
|
+
"lines": [
|
|
70
|
+
"Copyright Test Inc. or its affiliates. All Rights Reserved.",
|
|
71
|
+
"SPDX-License-Identifier: MIT",
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
"exclude": [],
|
|
75
|
+
"format": {
|
|
76
|
+
"**/*.{js,ts}": {
|
|
77
|
+
"blockEnd": " */",
|
|
78
|
+
"blockStart": "/**",
|
|
79
|
+
"lineStart": " * ",
|
|
80
|
+
},
|
|
81
|
+
"**/*.{py,sh}": {
|
|
82
|
+
"blockEnd": "# ",
|
|
83
|
+
"blockStart": "# ",
|
|
84
|
+
"lineStart": "# ",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export interface LicenseConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for source code license headers
|
|
8
|
+
* Omit if you do not want any source code license headers to be synced
|
|
9
|
+
*/
|
|
10
|
+
header?: LicenseHeaderConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for LICENSE files
|
|
13
|
+
*/
|
|
14
|
+
files?: LicenseFileConfig;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for the LICENSE file sync
|
|
18
|
+
*/
|
|
19
|
+
export interface LicenseFileConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Exclude LICENSE file sync checks for the given glob patterns
|
|
22
|
+
*/
|
|
23
|
+
exclude?: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Specifies license content as a path to a file
|
|
27
|
+
*/
|
|
28
|
+
export interface LicenseFilePathContent {
|
|
29
|
+
/**
|
|
30
|
+
* Load the license text from the specified file (relative to the workspace root)
|
|
31
|
+
*/
|
|
32
|
+
filePath: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Specifies license content inline
|
|
36
|
+
*/
|
|
37
|
+
export interface LicenseLinesContent {
|
|
38
|
+
/**
|
|
39
|
+
* Inline license text
|
|
40
|
+
*/
|
|
41
|
+
lines: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Configuration for source code license header sync
|
|
45
|
+
*/
|
|
46
|
+
export interface LicenseHeaderConfig {
|
|
47
|
+
/**
|
|
48
|
+
* Content of the license header
|
|
49
|
+
*/
|
|
50
|
+
content: LicenseFilePathContent | LicenseLinesContent;
|
|
51
|
+
/**
|
|
52
|
+
* Specifies the license header format for given glob patterns
|
|
53
|
+
*/
|
|
54
|
+
format: {
|
|
55
|
+
[filePattern: string]: LicenseHeaderFormat;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Exclude out of sync source code license header checks for the given glob patterns
|
|
59
|
+
*/
|
|
60
|
+
exclude?: string[];
|
|
61
|
+
/**
|
|
62
|
+
* User-specified comment syntax for file types we don't have config for
|
|
63
|
+
*/
|
|
64
|
+
commentSyntax?: {
|
|
65
|
+
[ext: string]: CommentSyntax;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Format settings for source code license headers
|
|
70
|
+
*/
|
|
71
|
+
export interface LicenseHeaderFormat {
|
|
72
|
+
/**
|
|
73
|
+
* Text written to the line prior to the license lines
|
|
74
|
+
* Use this to start a block comment if desired
|
|
75
|
+
*/
|
|
76
|
+
blockStart?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Text written to the start of each line of the license
|
|
79
|
+
*/
|
|
80
|
+
lineStart?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Text written to the end of each line of the license
|
|
83
|
+
*/
|
|
84
|
+
lineEnd?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Text written to the line after the license lines
|
|
87
|
+
* Use this to end a block comment if desired
|
|
88
|
+
*/
|
|
89
|
+
blockEnd?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Defines comment syntax for a particular language
|
|
93
|
+
* Used to instruct the license sync generator to find the first comment in a file
|
|
94
|
+
*/
|
|
95
|
+
export interface CommentSyntax {
|
|
96
|
+
/**
|
|
97
|
+
* If the language supports line comments, specify the character(s) used to start a line comment
|
|
98
|
+
*/
|
|
99
|
+
line?: string;
|
|
100
|
+
/**
|
|
101
|
+
* If the language supports block comments, specify the character(s) used to start and end the block comment
|
|
102
|
+
*/
|
|
103
|
+
block?: {
|
|
104
|
+
start: string;
|
|
105
|
+
end: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/license/config-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { Tree } from '@nx/devkit';
|
|
6
|
+
import { SPDXLicenseIdentifier } from './schema';
|
|
7
|
+
import { CommentSyntax, LicenseConfig } from './config-types';
|
|
8
|
+
/**
|
|
9
|
+
* Defines the comment syntax for popular programming languages
|
|
10
|
+
*/
|
|
11
|
+
export declare const LANGUAGE_COMMENT_SYNTAX: {
|
|
12
|
+
[ext: string]: CommentSyntax;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Build the default license config for a given license
|
|
16
|
+
*/
|
|
17
|
+
export declare const defaultLicenseConfig: (spdx: SPDXLicenseIdentifier, copyrightHolder: string) => LicenseConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Write license configuration to the aws nx plugin config
|
|
20
|
+
*/
|
|
21
|
+
export declare const writeLicenseConfig: (tree: Tree, spdx: SPDXLicenseIdentifier, config: LicenseConfig) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Read license configuration
|
|
24
|
+
*/
|
|
25
|
+
export declare const readLicenseConfig: (tree: Tree) => Promise<LicenseConfig | undefined>;
|