@aws/nx-plugin 0.2.0 → 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 +1470 -3006
- package/generators.json +11 -6
- package/package.json +16 -13
- package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +15 -19
- package/src/cloudscape-website/app/files/common/constructs/src/core/static-website.ts.template +5 -0
- package/src/cloudscape-website/app/generator.js +29 -23
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/app/schema.d.ts +0 -1
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +13 -11
- 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 +9 -2
- package/src/cloudscape-website/runtime-config/generator.js +1 -1
- 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 +78 -61
- package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +2 -2
- package/src/infra/app/generator.js +20 -5
- package/src/infra/app/generator.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/trpc/backend/__snapshots__/generator.spec.ts.snap +13 -10
- package/src/trpc/backend/generator.js +2 -2
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/trpc/react/generator.js +2 -2
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +47 -93
- package/src/ts/lib/eslint.d.ts +1 -2
- package/src/ts/lib/eslint.js +26 -37
- package/src/ts/lib/eslint.js.map +1 -1
- package/src/ts/lib/generator.js +34 -2
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.ts +0 -1
- package/src/ts/lib/schema.json +0 -6
- package/src/ts/lib/ts-project-utils.js +3 -18
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.js +2 -4
- package/src/ts/lib/vitest.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/files/common/types/src/runtime-config.ts.template +1 -0
- package/src/utils/format.d.ts +1 -1
- package/src/utils/format.js +2 -2
- package/src/utils/format.js.map +1 -1
- 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/shared-constructs.js +2 -2
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/test.d.ts +2 -0
- package/src/utils/test.js +19 -0
- package/src/utils/test.js.map +1 -0
- package/src/ts/cjs-to-esm/generator.d.ts +0 -12
- package/src/ts/cjs-to-esm/generator.js +0 -189
- package/src/ts/cjs-to-esm/generator.js.map +0 -1
- package/src/ts/cjs-to-esm/schema.d.ts +0 -9
- package/src/ts/cjs-to-esm/schema.json +0 -28
|
@@ -14,11 +14,11 @@ exports[`infra generator > should add required dependencies to package.json > de
|
|
|
14
14
|
exports[`infra generator > should add required dependencies to package.json > dev-dependencies 1`] = `
|
|
15
15
|
{
|
|
16
16
|
"@eslint/js": "^9.8.0",
|
|
17
|
-
"@nx/eslint": "20.
|
|
18
|
-
"@nx/eslint-plugin": "20.
|
|
19
|
-
"@nx/js": "20.
|
|
20
|
-
"@nx/vite": "20.
|
|
21
|
-
"@nx/web": "20.
|
|
17
|
+
"@nx/eslint": "20.4.0",
|
|
18
|
+
"@nx/eslint-plugin": "20.4.0",
|
|
19
|
+
"@nx/js": "20.4.0",
|
|
20
|
+
"@nx/vite": "20.4.0",
|
|
21
|
+
"@nx/web": "20.4.0",
|
|
22
22
|
"@swc-node/register": "~1.9.1",
|
|
23
23
|
"@swc/core": "~1.5.7",
|
|
24
24
|
"@swc/helpers": "~0.5.11",
|
|
@@ -30,8 +30,8 @@ exports[`infra generator > should add required dependencies to package.json > de
|
|
|
30
30
|
"jsdom": "~22.1.0",
|
|
31
31
|
"prettier": "^3.4.2",
|
|
32
32
|
"tsx": "^4.19.2",
|
|
33
|
-
"typescript": "~5.
|
|
34
|
-
"typescript-eslint": "^8.
|
|
33
|
+
"typescript": "~5.7.2",
|
|
34
|
+
"typescript-eslint": "^8.19.0",
|
|
35
35
|
"vite": "^5.0.0",
|
|
36
36
|
"vitest": "^1.3.1",
|
|
37
37
|
}
|
|
@@ -49,11 +49,11 @@ exports[`infra generator > should add required dependencies to package.json > pa
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@eslint/js": "^9.8.0",
|
|
52
|
-
"@nx/eslint": "20.
|
|
53
|
-
"@nx/eslint-plugin": "20.
|
|
54
|
-
"@nx/js": "20.
|
|
55
|
-
"@nx/vite": "20.
|
|
56
|
-
"@nx/web": "20.
|
|
52
|
+
"@nx/eslint": "20.4.0",
|
|
53
|
+
"@nx/eslint-plugin": "20.4.0",
|
|
54
|
+
"@nx/js": "20.4.0",
|
|
55
|
+
"@nx/vite": "20.4.0",
|
|
56
|
+
"@nx/web": "20.4.0",
|
|
57
57
|
"@swc-node/register": "~1.9.1",
|
|
58
58
|
"@swc/core": "~1.5.7",
|
|
59
59
|
"@swc/helpers": "~0.5.11",
|
|
@@ -65,29 +65,27 @@ exports[`infra generator > should add required dependencies to package.json > pa
|
|
|
65
65
|
"jsdom": "~22.1.0",
|
|
66
66
|
"prettier": "^3.4.2",
|
|
67
67
|
"tsx": "^4.19.2",
|
|
68
|
-
"typescript": "~5.
|
|
69
|
-
"typescript-eslint": "^8.
|
|
68
|
+
"typescript": "~5.7.2",
|
|
69
|
+
"typescript-eslint": "^8.19.0",
|
|
70
70
|
"vite": "^5.0.0",
|
|
71
71
|
"vitest": "^1.3.1",
|
|
72
72
|
},
|
|
73
73
|
"name": "@proj/source",
|
|
74
74
|
"type": "module",
|
|
75
|
+
"workspaces": [
|
|
76
|
+
"packages/*",
|
|
77
|
+
"packages/common/*",
|
|
78
|
+
],
|
|
75
79
|
}
|
|
76
80
|
`;
|
|
77
81
|
|
|
78
82
|
exports[`infra generator > should configure project.json with correct targets > build-target 1`] = `
|
|
79
83
|
{
|
|
80
|
-
"cache": true,
|
|
81
84
|
"dependsOn": [
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"command": "cdk synth",
|
|
87
|
-
"cwd": "packages/test",
|
|
88
|
-
},
|
|
89
|
-
"outputs": [
|
|
90
|
-
"{workspaceRoot}/dist/packages/test/cdk.out",
|
|
85
|
+
"lint",
|
|
86
|
+
"compile",
|
|
87
|
+
"test",
|
|
88
|
+
"synth",
|
|
91
89
|
],
|
|
92
90
|
}
|
|
93
91
|
`;
|
|
@@ -112,17 +110,11 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
112
110
|
"tags": [],
|
|
113
111
|
"targets": {
|
|
114
112
|
"build": {
|
|
115
|
-
"cache": true,
|
|
116
113
|
"dependsOn": [
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"command": "cdk synth",
|
|
122
|
-
"cwd": "packages/test",
|
|
123
|
-
},
|
|
124
|
-
"outputs": [
|
|
125
|
-
"{workspaceRoot}/dist/packages/test/cdk.out",
|
|
114
|
+
"lint",
|
|
115
|
+
"compile",
|
|
116
|
+
"test",
|
|
117
|
+
"synth",
|
|
126
118
|
],
|
|
127
119
|
},
|
|
128
120
|
"compile": {
|
|
@@ -131,9 +123,9 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
131
123
|
"assets": [
|
|
132
124
|
"packages/test/*.md",
|
|
133
125
|
],
|
|
134
|
-
"main": "packages/test/src/
|
|
126
|
+
"main": "packages/test/src/main.ts",
|
|
135
127
|
"outputPath": "dist/packages/test",
|
|
136
|
-
"tsConfig": "packages/test/tsconfig.
|
|
128
|
+
"tsConfig": "packages/test/tsconfig.json",
|
|
137
129
|
},
|
|
138
130
|
"outputs": [
|
|
139
131
|
"{options.outputPath}",
|
|
@@ -149,6 +141,20 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
149
141
|
"lint": {
|
|
150
142
|
"executor": "@nx/eslint:lint",
|
|
151
143
|
},
|
|
144
|
+
"synth": {
|
|
145
|
+
"cache": true,
|
|
146
|
+
"dependsOn": [
|
|
147
|
+
"^build",
|
|
148
|
+
],
|
|
149
|
+
"executor": "nx:run-commands",
|
|
150
|
+
"options": {
|
|
151
|
+
"command": "cdk synth",
|
|
152
|
+
"cwd": "packages/test",
|
|
153
|
+
},
|
|
154
|
+
"outputs": [
|
|
155
|
+
"{workspaceRoot}/dist/packages/test/cdk.out",
|
|
156
|
+
],
|
|
157
|
+
},
|
|
152
158
|
"test": {
|
|
153
159
|
"executor": "@nx/vite:test",
|
|
154
160
|
"options": {
|
|
@@ -450,13 +456,16 @@ exports[`infra generator > should generate files with correct content > project-
|
|
|
450
456
|
"tags": [],
|
|
451
457
|
"targets": {
|
|
452
458
|
"build": {
|
|
453
|
-
"
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
"
|
|
459
|
+
"dependsOn": ["lint", "compile", "test", "synth"]
|
|
460
|
+
},
|
|
461
|
+
"compile": {
|
|
462
|
+
"executor": "@nx/js:tsc",
|
|
463
|
+
"outputs": ["{options.outputPath}"],
|
|
457
464
|
"options": {
|
|
458
|
-
"
|
|
459
|
-
"
|
|
465
|
+
"outputPath": "dist/packages/test",
|
|
466
|
+
"main": "packages/test/src/main.ts",
|
|
467
|
+
"tsConfig": "packages/test/tsconfig.json",
|
|
468
|
+
"assets": ["packages/test/*.md"]
|
|
460
469
|
}
|
|
461
470
|
},
|
|
462
471
|
"lint": {
|
|
@@ -469,14 +478,14 @@ exports[`infra generator > should generate files with correct content > project-
|
|
|
469
478
|
"reportsDirectory": "../../coverage/packages/test"
|
|
470
479
|
}
|
|
471
480
|
},
|
|
472
|
-
"
|
|
473
|
-
"
|
|
474
|
-
"
|
|
481
|
+
"synth": {
|
|
482
|
+
"cache": true,
|
|
483
|
+
"executor": "nx:run-commands",
|
|
484
|
+
"outputs": ["{workspaceRoot}/dist/packages/test/cdk.out"],
|
|
485
|
+
"dependsOn": ["^build"],
|
|
475
486
|
"options": {
|
|
476
|
-
"
|
|
477
|
-
"
|
|
478
|
-
"tsConfig": "packages/test/tsconfig.lib.json",
|
|
479
|
-
"assets": ["packages/test/*.md"]
|
|
487
|
+
"cwd": "packages/test",
|
|
488
|
+
"command": "cdk synth"
|
|
480
489
|
}
|
|
481
490
|
},
|
|
482
491
|
"deploy": {
|
|
@@ -746,17 +755,11 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
746
755
|
"tags": [],
|
|
747
756
|
"targets": {
|
|
748
757
|
"build": {
|
|
749
|
-
"cache": true,
|
|
750
758
|
"dependsOn": [
|
|
751
|
-
"
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
"command": "cdk synth",
|
|
756
|
-
"cwd": "packages/custom-infra",
|
|
757
|
-
},
|
|
758
|
-
"outputs": [
|
|
759
|
-
"{workspaceRoot}/dist/packages/custom-infra/cdk.out",
|
|
759
|
+
"lint",
|
|
760
|
+
"compile",
|
|
761
|
+
"test",
|
|
762
|
+
"synth",
|
|
760
763
|
],
|
|
761
764
|
},
|
|
762
765
|
"compile": {
|
|
@@ -765,9 +768,9 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
765
768
|
"assets": [
|
|
766
769
|
"packages/custom-infra/*.md",
|
|
767
770
|
],
|
|
768
|
-
"main": "packages/custom-infra/src/
|
|
771
|
+
"main": "packages/custom-infra/src/main.ts",
|
|
769
772
|
"outputPath": "dist/packages/custom-infra",
|
|
770
|
-
"tsConfig": "packages/custom-infra/tsconfig.
|
|
773
|
+
"tsConfig": "packages/custom-infra/tsconfig.json",
|
|
771
774
|
},
|
|
772
775
|
"outputs": [
|
|
773
776
|
"{options.outputPath}",
|
|
@@ -783,6 +786,20 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
783
786
|
"lint": {
|
|
784
787
|
"executor": "@nx/eslint:lint",
|
|
785
788
|
},
|
|
789
|
+
"synth": {
|
|
790
|
+
"cache": true,
|
|
791
|
+
"dependsOn": [
|
|
792
|
+
"^build",
|
|
793
|
+
],
|
|
794
|
+
"executor": "nx:run-commands",
|
|
795
|
+
"options": {
|
|
796
|
+
"command": "cdk synth",
|
|
797
|
+
"cwd": "packages/custom-infra",
|
|
798
|
+
},
|
|
799
|
+
"outputs": [
|
|
800
|
+
"{workspaceRoot}/dist/packages/custom-infra/cdk.out",
|
|
801
|
+
],
|
|
802
|
+
},
|
|
786
803
|
"test": {
|
|
787
804
|
"executor": "@nx/vite:test",
|
|
788
805
|
"options": {
|
|
@@ -30,7 +30,7 @@ export const suppressRule = (
|
|
|
30
30
|
.filter((resource) => CfnResource.isCfnResource(resource));
|
|
31
31
|
|
|
32
32
|
resources.forEach((resource) => {
|
|
33
|
-
|
|
33
|
+
const metadata = resource.getMetadata('guard') || {};
|
|
34
34
|
metadata['SuppressedRules'] = [
|
|
35
35
|
...(metadata['SuppressedRules'] ?? []),
|
|
36
36
|
ruleName,
|
|
@@ -46,7 +46,7 @@ export enum RuleSet {
|
|
|
46
46
|
NIST_CSF = 'nist-csf.guard',
|
|
47
47
|
PCI_DSS_3_2_1 = 'pci-dss-3-2-1.guard',
|
|
48
48
|
WELL_ARCHITECTED_RELIABILITY = 'wa-reliability-pillar.guard',
|
|
49
|
-
WELL_ARCHITECTED_SECURITY = 'wa-security-pillar.guard'
|
|
49
|
+
WELL_ARCHITECTED_SECURITY = 'wa-security-pillar.guard',
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export class CfnGuardValidator extends _CfnGuardValidator {
|
|
@@ -9,14 +9,15 @@ const tslib_1 = require("tslib");
|
|
|
9
9
|
const devkit_1 = require("@nx/devkit");
|
|
10
10
|
const generator_1 = tslib_1.__importStar(require("../../ts/lib/generator"));
|
|
11
11
|
const versions_1 = require("../../utils/versions");
|
|
12
|
-
const format_1 = require("../../utils/format");
|
|
13
12
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
14
13
|
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
15
14
|
const ast_1 = require("../../utils/ast");
|
|
15
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
16
|
+
const format_1 = require("../../utils/format");
|
|
16
17
|
function infraGenerator(tree, schema) {
|
|
17
18
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
const lib = (0, generator_1.getTsLibDetails)(tree, schema);
|
|
19
|
-
|
|
20
|
+
yield (0, generator_1.default)(tree, schema);
|
|
20
21
|
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree);
|
|
21
22
|
const synthDirFromRoot = `/dist/${lib.dir}/cdk.out`;
|
|
22
23
|
const synthDirFromProject = lib.dir
|
|
@@ -39,8 +40,14 @@ function infraGenerator(tree, schema) {
|
|
|
39
40
|
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
40
41
|
});
|
|
41
42
|
(0, devkit_1.updateJson)(tree, `${libraryRoot}/project.json`, (config) => {
|
|
43
|
+
var _a;
|
|
42
44
|
config.projectType = 'application';
|
|
43
|
-
config.targets.build =
|
|
45
|
+
config.targets.build.dependsOn = [
|
|
46
|
+
...((_a = config.targets.build.dependsOn) !== null && _a !== void 0 ? _a : []),
|
|
47
|
+
'synth',
|
|
48
|
+
];
|
|
49
|
+
config.targets.compile.options.main = (0, devkit_1.joinPathFragments)(libraryRoot, 'src', 'main.ts');
|
|
50
|
+
config.targets.synth = {
|
|
44
51
|
cache: true,
|
|
45
52
|
executor: 'nx:run-commands',
|
|
46
53
|
outputs: [`{workspaceRoot}${synthDirFromRoot}`],
|
|
@@ -68,8 +75,16 @@ function infraGenerator(tree, schema) {
|
|
|
68
75
|
'constructs',
|
|
69
76
|
'source-map-support',
|
|
70
77
|
]), (0, versions_1.withVersions)(['tsx']));
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
(0, devkit_1.updateJson)(tree, `${libraryRoot}/tsconfig.json`, (tsConfig) => (Object.assign(Object.assign({}, tsConfig), { references: [
|
|
79
|
+
...(tsConfig.references || []),
|
|
80
|
+
{
|
|
81
|
+
path: `${path_1.default.relative(libraryRoot, `${tree.root}/${shared_constructs_1.PACKAGES_DIR}`)}/${shared_constructs_1.SHARED_CONSTRUCTS_DIR}/tsconfig.json`,
|
|
82
|
+
},
|
|
83
|
+
] })));
|
|
84
|
+
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
85
|
+
return () => {
|
|
86
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
87
|
+
};
|
|
73
88
|
});
|
|
74
89
|
}
|
|
75
90
|
exports.default = infraGenerator;
|
|
@@ -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":";;AA+BA,wCA2HC;;AA1JD;;;GAGG;AACH,uCAYoB;AAEpB,4EAAyE;AACzE,mDAAoD;AACpD,qDAAwE;AACxE,qEAKuC;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,CAAC,CAAC;QAChD,MAAM,kBAAkB,GAAG,GAAG,cAAc,GAAG,MAAM,CAAC,IAAI,EAAE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AC,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,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
|
+
`;
|