@aws/nx-plugin 0.2.1 → 0.4.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 +77 -66
- package/generators.json +11 -0
- package/package.json +6 -2
- package/src/cloudscape-website/app/README.md +1 -1
- package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +93 -29
- package/src/cloudscape-website/app/files/app/README.md.template +4 -2
- package/src/cloudscape-website/app/files/app/src/{layouts/App → components/AppLayout}/index.tsx.template +38 -19
- package/src/cloudscape-website/app/files/app/src/{layouts/App → components/AppLayout}/navitems.ts.template +1 -1
- package/src/cloudscape-website/app/files/app/src/hooks/useAppLayout.tsx.template +5 -0
- package/src/cloudscape-website/app/files/app/src/main.tsx.template +13 -6
- package/src/cloudscape-website/app/files/app/src/routeTree.gen.ts.template +111 -0
- package/src/cloudscape-website/app/files/app/src/routes/__root.tsx.template +6 -0
- package/src/cloudscape-website/app/files/app/src/routes/index.tsx.template +5 -0
- package/src/cloudscape-website/app/files/app/src/routes/welcome/index.tsx.template +21 -0
- package/src/cloudscape-website/app/files/app/src/styles.css.template +1 -0
- package/src/cloudscape-website/app/generator.js +24 -13
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/cloudscape-website/cognito-auth/generator.js +2 -2
- package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
- package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +2 -4
- package/src/cloudscape-website/runtime-config/generator.js +3 -3
- package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/infra/app/generator.js.map +1 -1
- package/src/license/README.md +290 -0
- package/src/license/__snapshots__/config.spec.ts.snap +96 -0
- package/src/license/config-types.d.ts +121 -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 +177 -0
- package/src/license/config.js.map +1 -0
- package/src/license/generator.d.ts +8 -0
- package/src/license/generator.js +29 -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/files/licenses/ASL/LICENSE.template +96 -0
- package/src/license/sync/files/licenses/Apache-2.0/LICENSE.template +175 -0
- package/src/license/sync/files/licenses/MIT/LICENSE.template +21 -0
- package/src/license/sync/generator.d.ts +9 -0
- package/src/license/sync/generator.js +315 -0
- package/src/license/sync/generator.js.map +1 -0
- package/src/license/sync/project-file-sync.d.ts +15 -0
- package/src/license/sync/project-file-sync.js +52 -0
- package/src/license/sync/project-file-sync.js.map +1 -0
- package/src/license/sync/schema.json +9 -0
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +4 -6
- package/src/trpc/react/generator.js +1 -1
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/lib/eslint.js +5 -9
- 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/src/utils/toml.d.ts +10 -0
- package/src/utils/toml.js +17 -0
- package/src/utils/toml.js.map +1 -0
- package/src/utils/versions.d.ts +4 -3
- package/src/utils/versions.js +3 -2
- package/src/utils/versions.js.map +1 -1
- package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +0 -16
- package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;AA8BA,wCA2HC;;AAzJD;;;GAGG;AACH,uCAYoB;AAEpB,4EAAyE;AACzE,mDAAoD;AACpD,qDAAwE;AACxE,qEAIuC;AACvC,yCAAgD;AAChD,wDAAwB;AACxB,+CAA0D;AAE1D,SAAsB,cAAc,CAClC,IAAU,EACV,MAA4B;;QAE5B,MAAM,GAAG,GAAG,IAAA,2BAAe,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,IAAA,mBAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,MAAM,IAAA,6CAAyB,EAAC,IAAI,CAAC,CAAC;QACtC,MAAM,gBAAgB,GAAG,SAAS,GAAG,CAAC,GAAG,UAAU,CAAC;QACpD,MAAM,mBAAmB,GACvB,GAAG,CAAC,GAAG;aACJ,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC;QAClC,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAC7E,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;QACvC,MAAM,cAAc,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAA,wBAAY,EAAC,cAAc,CA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,IAAI,IAAI,gCAAY,EAAE,CAC/B,IAAI,yCAAqB,gBAAgB;iBAC3C;aACF,IACD,CAAC,CAAC;QAEJ,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,290 @@
|
|
|
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 your project's LICENSE files are correct, and licensing information is included in relevant project files.
|
|
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 configure the license sync generator to ensure that your project contains the correct LICENSE files, and 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
|
+
└── nx.json # The "lint" target is configured to sync LICENSE files and source file headers
|
|
57
|
+
└── aws-nx-plugin.config.mts # Configuration for the license sync, such as customising the license header content and format for different languages
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
## License Sync Behaviour
|
|
63
|
+
|
|
64
|
+
The license sync generator performs three main tasks:
|
|
65
|
+
|
|
66
|
+
### 1. Synchronise Source File License Headers
|
|
67
|
+
|
|
68
|
+
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).
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
### 2. Synchronise LICENSE Files
|
|
73
|
+
|
|
74
|
+
When the sync generator is run, it will ensure that the root `LICENSE` file corresponds to your configured license, as well as ensuring that all subprojects in your workspace also contain the correct `LICENSE` file.
|
|
75
|
+
|
|
76
|
+
You can exclude projects in the configuration if required. For more details, please see the [configuration section](#configuration) below.
|
|
77
|
+
|
|
78
|
+
### 3. Synchronise licensing information in project files
|
|
79
|
+
|
|
80
|
+
When the sync generator is run, it will ensure the `license` fields in `package.json` and `pyproject.toml` files are set to your configured license.
|
|
81
|
+
|
|
82
|
+
You can exclude projects in the configuration if required. For more details, please see the [configuration section](#configuration) below.
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
Configuration is defined in the `aws-nx-plugin.config.mts` file in the root of your workspace.
|
|
87
|
+
|
|
88
|
+
### SPDX and Copyright Holder
|
|
89
|
+
|
|
90
|
+
Your chosen license can be updated at any time via the `spdx` configuration property:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
{
|
|
94
|
+
license: {
|
|
95
|
+
spdx: 'MIT',
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
When the sync generator runs, all `LICENSE` files, `package.json` and `pyproject.toml` files will be updated to reflect the configured license.
|
|
101
|
+
|
|
102
|
+
You can additionally configure the copyright holder and copyright year, which are included in some `LICENSE` files:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
{
|
|
106
|
+
license: {
|
|
107
|
+
spdx: 'MIT',
|
|
108
|
+
copyrightHolder: 'Amazon.com, Inc. or its affiliates',
|
|
109
|
+
copyrightYear: 2025,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### License Headers
|
|
115
|
+
|
|
116
|
+
#### Content
|
|
117
|
+
|
|
118
|
+
The license header content can be configured in two ways:
|
|
119
|
+
|
|
120
|
+
1. Using inline content:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
{
|
|
124
|
+
license: {
|
|
125
|
+
header: {
|
|
126
|
+
content: {
|
|
127
|
+
lines: ['Copyright My Company, Inc.', 'Licensed under MIT License', 'All rights reserved'];
|
|
128
|
+
}
|
|
129
|
+
// ... format configuration
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
2. Loading from a file:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
{
|
|
139
|
+
license: {
|
|
140
|
+
header: {
|
|
141
|
+
content: {
|
|
142
|
+
filePath: 'license-header.txt'; // relative to workspace root
|
|
143
|
+
}
|
|
144
|
+
// ... format configuration
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Including files and specifying header format
|
|
151
|
+
|
|
152
|
+
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:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
{
|
|
156
|
+
license: {
|
|
157
|
+
header: {
|
|
158
|
+
content: {
|
|
159
|
+
lines: ['Copyright notice here']
|
|
160
|
+
},
|
|
161
|
+
format: {
|
|
162
|
+
// Line comments
|
|
163
|
+
'**/*.ts': {
|
|
164
|
+
lineStart: '// '
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
// Block comments
|
|
168
|
+
'**/*.css': {
|
|
169
|
+
blockStart: '/*',
|
|
170
|
+
blockEnd: '*/'
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
// Block comments with line prefixes
|
|
174
|
+
'**/*.java': {
|
|
175
|
+
blockStart: '/*',
|
|
176
|
+
lineStart: ' * ',
|
|
177
|
+
blockEnd: ' */'
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// Line comments with header/footer
|
|
181
|
+
'**/*.py': {
|
|
182
|
+
blockStart: '# ------------',
|
|
183
|
+
lineStart: '# ',
|
|
184
|
+
blockEnd: '# ------------'
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The format configuration supports:
|
|
193
|
+
|
|
194
|
+
- `blockStart`: Text written before the license content (e.g., to start a block comment)
|
|
195
|
+
- `lineStart`: Text prepended to each line of the license content
|
|
196
|
+
- `lineEnd`: Text appended to each line of the license content
|
|
197
|
+
- `blockEnd`: Text written after the license content (e.g., to end a block comment)
|
|
198
|
+
|
|
199
|
+
#### Custom comment syntax
|
|
200
|
+
|
|
201
|
+
For file types that aren't natively supported, you can specify custom comment syntax:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
{
|
|
205
|
+
license: {
|
|
206
|
+
header: {
|
|
207
|
+
content: {
|
|
208
|
+
lines: ['My license header']
|
|
209
|
+
},
|
|
210
|
+
format: {
|
|
211
|
+
'**/*.xyz': {
|
|
212
|
+
lineStart: '## '
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
commentSyntax: {
|
|
216
|
+
xyz: {
|
|
217
|
+
line: '##' // Define line comment syntax
|
|
218
|
+
},
|
|
219
|
+
abc: {
|
|
220
|
+
block: { // Define block comment syntax
|
|
221
|
+
start: '<!--',
|
|
222
|
+
end: '-->'
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
This tells the sync generator how to identify existing license headers in these file types. The `commentSyntax` configuration supports:
|
|
232
|
+
|
|
233
|
+
- `line`: Characters that start a line comment
|
|
234
|
+
- `block`: Characters that start and end a block comment
|
|
235
|
+
|
|
236
|
+
#### Excluding files
|
|
237
|
+
|
|
238
|
+
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.
|
|
239
|
+
|
|
240
|
+
You can exclude additional files from license header synchronization using glob patterns:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
{
|
|
244
|
+
license: {
|
|
245
|
+
header: {
|
|
246
|
+
content: {
|
|
247
|
+
lines: ['My license header']
|
|
248
|
+
},
|
|
249
|
+
format: {
|
|
250
|
+
'**/*.ts': {
|
|
251
|
+
lineStart: '// '
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
exclude: [
|
|
255
|
+
'**/generated/**',
|
|
256
|
+
'**/dist/**',
|
|
257
|
+
'some-specific-file.ts'
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Excluding project files from sync
|
|
265
|
+
|
|
266
|
+
All `LICENSE` files, `package.json` files and `pyproject.toml` files are synchronised with the configured license by default.
|
|
267
|
+
|
|
268
|
+
You can exclude specific projects or files from synchronization using glob patterns:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
{
|
|
272
|
+
license: {
|
|
273
|
+
files: {
|
|
274
|
+
exclude: [
|
|
275
|
+
'packages/excluded-project', // do not sync LICENSE file, package.json or pyproject.toml
|
|
276
|
+
'apps/internal/LICENSE', // do not sync LICENSE file, but sync package.json and/or pyproject.toml
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Disabling license sync
|
|
284
|
+
|
|
285
|
+
To disable the license sync generator:
|
|
286
|
+
|
|
287
|
+
1. Remove the `license` section from your configuration in `aws-nx-plugin.config.mts` (or remove the `aws-nx-plugin.config.mts` file)
|
|
288
|
+
2. Remove the `@aws/nx-plugin:license#sync` generator from `targetDefaults.lint.syncGenerators`
|
|
289
|
+
|
|
290
|
+
To re-enable license sync, simply run the `license` generator again.
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
"copyrightHolder": "Test Inc. or its affiliates",
|
|
6
|
+
"header": {
|
|
7
|
+
"content": {
|
|
8
|
+
"lines": [
|
|
9
|
+
"Copyright Test Inc. or its affiliates. All Rights Reserved. ",
|
|
10
|
+
" ",
|
|
11
|
+
"Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance ",
|
|
12
|
+
"with the License. A copy of the License is located at ",
|
|
13
|
+
" ",
|
|
14
|
+
" https://aws.amazon.com/asl/ ",
|
|
15
|
+
" ",
|
|
16
|
+
"or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES",
|
|
17
|
+
"OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions ",
|
|
18
|
+
"and limitations under the License. ",
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
"exclude": [],
|
|
22
|
+
"format": {
|
|
23
|
+
"**/*.{js,ts,jsx,tsx,mjs,mts}": {
|
|
24
|
+
"blockEnd": " **********************************************************************************************************************/",
|
|
25
|
+
"blockStart": "/**********************************************************************************************************************",
|
|
26
|
+
"lineEnd": " *",
|
|
27
|
+
"lineStart": " * ",
|
|
28
|
+
},
|
|
29
|
+
"**/*.{py,sh}": {
|
|
30
|
+
"blockEnd": "######################################################################################################################",
|
|
31
|
+
"blockStart": "######################################################################################################################",
|
|
32
|
+
"lineEnd": " #",
|
|
33
|
+
"lineStart": "# ",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
"spdx": "ASL",
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
exports[`license config > defaultLicenseConfig > should generate default license config for Apache-2.0 1`] = `
|
|
42
|
+
{
|
|
43
|
+
"copyrightHolder": "Test Inc. or its affiliates",
|
|
44
|
+
"header": {
|
|
45
|
+
"content": {
|
|
46
|
+
"lines": [
|
|
47
|
+
"Copyright Test Inc. or its affiliates. All Rights Reserved.",
|
|
48
|
+
"SPDX-License-Identifier: Apache-2.0",
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
"exclude": [],
|
|
52
|
+
"format": {
|
|
53
|
+
"**/*.{js,ts,jsx,tsx,mjs,mts}": {
|
|
54
|
+
"blockEnd": " */",
|
|
55
|
+
"blockStart": "/**",
|
|
56
|
+
"lineStart": " * ",
|
|
57
|
+
},
|
|
58
|
+
"**/*.{py,sh}": {
|
|
59
|
+
"blockEnd": "# ",
|
|
60
|
+
"blockStart": "# ",
|
|
61
|
+
"lineStart": "# ",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
"spdx": "Apache-2.0",
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
exports[`license config > defaultLicenseConfig > should generate default license config for MIT 1`] = `
|
|
70
|
+
{
|
|
71
|
+
"copyrightHolder": "Test Inc. or its affiliates",
|
|
72
|
+
"copyrightYear": 2025,
|
|
73
|
+
"header": {
|
|
74
|
+
"content": {
|
|
75
|
+
"lines": [
|
|
76
|
+
"Copyright Test Inc. or its affiliates. All Rights Reserved.",
|
|
77
|
+
"SPDX-License-Identifier: MIT",
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
"exclude": [],
|
|
81
|
+
"format": {
|
|
82
|
+
"**/*.{js,ts,jsx,tsx,mjs,mts}": {
|
|
83
|
+
"blockEnd": " */",
|
|
84
|
+
"blockStart": "/**",
|
|
85
|
+
"lineStart": " * ",
|
|
86
|
+
},
|
|
87
|
+
"**/*.{py,sh}": {
|
|
88
|
+
"blockEnd": "# ",
|
|
89
|
+
"blockStart": "# ",
|
|
90
|
+
"lineStart": "# ",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
"spdx": "MIT",
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { SPDXLicenseIdentifier } from './schema';
|
|
6
|
+
export interface LicenseConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The SPDX license identifier for your chosen license.
|
|
9
|
+
* License files will be synchronised according to the chosen SPDX
|
|
10
|
+
*/
|
|
11
|
+
spdx: SPDXLicenseIdentifier;
|
|
12
|
+
/**
|
|
13
|
+
* The copyright holder for the license
|
|
14
|
+
*/
|
|
15
|
+
copyrightHolder: string;
|
|
16
|
+
/**
|
|
17
|
+
* The copyright year (if any)
|
|
18
|
+
*/
|
|
19
|
+
copyrightYear?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for source code license headers
|
|
22
|
+
* Omit if you do not want any source code license headers to be synced
|
|
23
|
+
*/
|
|
24
|
+
header?: LicenseHeaderConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for LICENSE files
|
|
27
|
+
*/
|
|
28
|
+
files?: LicenseFileConfig;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for the LICENSE file sync
|
|
32
|
+
*/
|
|
33
|
+
export interface LicenseFileConfig {
|
|
34
|
+
/**
|
|
35
|
+
* Exclude LICENSE file sync checks for the given glob patterns
|
|
36
|
+
*/
|
|
37
|
+
exclude?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Specifies license content as a path to a file
|
|
41
|
+
*/
|
|
42
|
+
export interface LicenseFilePathContent {
|
|
43
|
+
/**
|
|
44
|
+
* Load the license text from the specified file (relative to the workspace root)
|
|
45
|
+
*/
|
|
46
|
+
filePath: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Specifies license content inline
|
|
50
|
+
*/
|
|
51
|
+
export interface LicenseLinesContent {
|
|
52
|
+
/**
|
|
53
|
+
* Inline license text
|
|
54
|
+
*/
|
|
55
|
+
lines: string[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Configuration for source code license header sync
|
|
59
|
+
*/
|
|
60
|
+
export interface LicenseHeaderConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Content of the license header
|
|
63
|
+
*/
|
|
64
|
+
content: LicenseFilePathContent | LicenseLinesContent;
|
|
65
|
+
/**
|
|
66
|
+
* Specifies the license header format for given glob patterns
|
|
67
|
+
*/
|
|
68
|
+
format: {
|
|
69
|
+
[filePattern: string]: LicenseHeaderFormat;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Exclude out of sync source code license header checks for the given glob patterns
|
|
73
|
+
*/
|
|
74
|
+
exclude?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* User-specified comment syntax for file types we don't have config for
|
|
77
|
+
*/
|
|
78
|
+
commentSyntax?: {
|
|
79
|
+
[ext: string]: CommentSyntax;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Format settings for source code license headers
|
|
84
|
+
*/
|
|
85
|
+
export interface LicenseHeaderFormat {
|
|
86
|
+
/**
|
|
87
|
+
* Text written to the line prior to the license lines
|
|
88
|
+
* Use this to start a block comment if desired
|
|
89
|
+
*/
|
|
90
|
+
blockStart?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Text written to the start of each line of the license
|
|
93
|
+
*/
|
|
94
|
+
lineStart?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Text written to the end of each line of the license
|
|
97
|
+
*/
|
|
98
|
+
lineEnd?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Text written to the line after the license lines
|
|
101
|
+
* Use this to end a block comment if desired
|
|
102
|
+
*/
|
|
103
|
+
blockEnd?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Defines comment syntax for a particular language
|
|
107
|
+
* Used to instruct the license sync generator to find the first comment in a file
|
|
108
|
+
*/
|
|
109
|
+
export interface CommentSyntax {
|
|
110
|
+
/**
|
|
111
|
+
* If the language supports line comments, specify the character(s) used to start a line comment
|
|
112
|
+
*/
|
|
113
|
+
line?: string;
|
|
114
|
+
/**
|
|
115
|
+
* If the language supports block comments, specify the character(s) used to start and end the block comment
|
|
116
|
+
*/
|
|
117
|
+
block?: {
|
|
118
|
+
start: string;
|
|
119
|
+
end: string;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -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, config: LicenseConfig) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Read license configuration
|
|
24
|
+
*/
|
|
25
|
+
export declare const readLicenseConfig: (tree: Tree) => Promise<LicenseConfig | undefined>;
|