@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.
Files changed (45) hide show
  1. package/LICENSE-THIRD-PARTY +22 -1
  2. package/generators.json +11 -0
  3. package/package.json +5 -2
  4. package/src/index.d.ts +1 -0
  5. package/src/index.js +4 -0
  6. package/src/index.js.map +1 -1
  7. package/src/license/README.md +255 -0
  8. package/src/license/__snapshots__/config.spec.ts.snap +89 -0
  9. package/src/license/config-types.d.ts +107 -0
  10. package/src/license/config-types.js +3 -0
  11. package/src/license/config-types.js.map +1 -0
  12. package/src/license/config.d.ts +25 -0
  13. package/src/license/config.js +174 -0
  14. package/src/license/config.js.map +1 -0
  15. package/src/license/files/licenses/ASL/LICENSE.template +96 -0
  16. package/src/license/files/licenses/Apache-2.0/LICENSE.template +175 -0
  17. package/src/license/files/licenses/MIT/LICENSE.template +21 -0
  18. package/src/license/generator.d.ts +8 -0
  19. package/src/license/generator.js +32 -0
  20. package/src/license/generator.js.map +1 -0
  21. package/src/license/schema.d.ts +17 -0
  22. package/src/license/schema.json +23 -0
  23. package/src/license/sync/generator.d.ts +9 -0
  24. package/src/license/sync/generator.js +307 -0
  25. package/src/license/sync/generator.js.map +1 -0
  26. package/src/license/sync/schema.json +9 -0
  27. package/src/ts/lib/eslint.js +4 -8
  28. package/src/ts/lib/eslint.js.map +1 -1
  29. package/src/utils/ast.d.ts +5 -1
  30. package/src/utils/ast.js +35 -1
  31. package/src/utils/ast.js.map +1 -1
  32. package/src/utils/config/__snapshots__/utils.spec.ts.snap +16 -0
  33. package/src/utils/config/files/aws-nx-plugin.config.mts.template +5 -0
  34. package/src/utils/config/index.d.ts +15 -0
  35. package/src/utils/config/index.js +5 -0
  36. package/src/utils/config/index.js.map +1 -0
  37. package/src/utils/config/utils.d.ts +20 -0
  38. package/src/utils/config/utils.js +71 -0
  39. package/src/utils/config/utils.js.map +1 -0
  40. package/src/utils/git.d.ts +9 -0
  41. package/src/utils/git.js +27 -0
  42. package/src/utils/git.js.map +1 -0
  43. package/src/utils/js.d.ts +8 -0
  44. package/src/utils/js.js +34 -0
  45. package/src/utils/js.js.map +1 -0
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readLicenseConfig = exports.writeLicenseConfig = exports.defaultLicenseConfig = exports.LANGUAGE_COMMENT_SYNTAX = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */
9
+ const devkit_1 = require("@nx/devkit");
10
+ const utils_1 = require("../utils/config/utils");
11
+ /**
12
+ * Defines the comment syntax for popular programming languages
13
+ */
14
+ exports.LANGUAGE_COMMENT_SYNTAX = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Object.fromEntries([
15
+ // Node
16
+ 'js',
17
+ 'ts',
18
+ 'cjs',
19
+ 'mjs',
20
+ 'cts',
21
+ 'mts',
22
+ // React
23
+ 'jsx',
24
+ 'tsx',
25
+ // Web
26
+ 'sass',
27
+ 'scss',
28
+ 'php',
29
+ // Java
30
+ 'java',
31
+ // Smithy
32
+ 'smithy',
33
+ // TypeSpec
34
+ 'tsp',
35
+ // Golang
36
+ 'go',
37
+ // Rust
38
+ 'rs',
39
+ // C and C++
40
+ 'c',
41
+ 'cpp',
42
+ 'cxx',
43
+ 'cc',
44
+ 'h',
45
+ 'hpp',
46
+ // C#
47
+ 'cs',
48
+ // Scala
49
+ 'scala',
50
+ 'sc',
51
+ 'sbt',
52
+ // Kotlin
53
+ 'kt',
54
+ // Swift
55
+ 'swift',
56
+ ].map((ext) => [ext, { line: '//', block: { start: '/*', end: '*/' } }]))), Object.fromEntries([
57
+ // Bash
58
+ 'sh',
59
+ // Perl
60
+ 'pl',
61
+ // YAML
62
+ 'yaml',
63
+ 'yml',
64
+ // R
65
+ 'r',
66
+ ].map((ext) => [ext, { line: '#' }]))), {
67
+ // Docker
68
+ Dockerfile: { line: '#' },
69
+ // Python
70
+ py: { line: '#', block: { start: '"""', end: '"""' } },
71
+ // Web
72
+ html: { block: { start: '<!--', end: '-->' } }, css: { block: { start: '/*', end: '*/' } },
73
+ // Ruby
74
+ rb: { line: '#', block: { start: '=begin', end: '=end' } } }), Object.fromEntries(['fs', 'fsx'].map((ext) => [
75
+ ext,
76
+ { line: '//', block: { start: '(*', end: '*)' } },
77
+ ]))), {
78
+ // Visual Basic
79
+ vb: { line: "' " },
80
+ // Lua
81
+ lua: { line: '--', block: { start: '--[[', end: ']]' } },
82
+ // PowerShell
83
+ ps1: { line: '#', block: { start: '<#', end: '#>' } }, psm1: { line: '#', block: { start: '<#', end: '#>' } },
84
+ // Markdown
85
+ md: { block: { start: '<!--', end: '-->' } } });
86
+ /**
87
+ * Build the default license config for a given license
88
+ */
89
+ const defaultLicenseConfig = (spdx, copyrightHolder) => {
90
+ switch (spdx) {
91
+ case 'ASL': {
92
+ // For ASL, we use a "box" style license header
93
+ const rawContent = [
94
+ `Copyright ${copyrightHolder}. All Rights Reserved.`,
95
+ '',
96
+ 'Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance',
97
+ 'with the License. A copy of the License is located at',
98
+ '',
99
+ ' https://aws.amazon.com/asl/',
100
+ '',
101
+ 'or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES',
102
+ 'OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions',
103
+ 'and limitations under the License.',
104
+ ];
105
+ const maxLen = Math.max(...rawContent.map((line) => line.length));
106
+ const lines = rawContent.map((line) => `${line}${' '.repeat(maxLen - line.length)}`);
107
+ return {
108
+ header: {
109
+ content: { lines },
110
+ format: {
111
+ '**/*.{js,ts}': {
112
+ blockStart: `/***${'*'.repeat(maxLen)}**`,
113
+ lineStart: ' * ',
114
+ lineEnd: ' *',
115
+ blockEnd: ` ***${'*'.repeat(maxLen)}**/`,
116
+ },
117
+ '**/*.{py,sh}': {
118
+ blockStart: `###${'#'.repeat(maxLen)}##`,
119
+ lineStart: '# ',
120
+ lineEnd: ' #',
121
+ blockEnd: `###${'#'.repeat(maxLen)}##`,
122
+ },
123
+ },
124
+ exclude: [],
125
+ },
126
+ };
127
+ }
128
+ default: {
129
+ return {
130
+ header: {
131
+ content: {
132
+ lines: [
133
+ `Copyright ${copyrightHolder}. All Rights Reserved.`,
134
+ `SPDX-License-Identifier: ${spdx}`,
135
+ ],
136
+ },
137
+ format: {
138
+ '**/*.{js,ts}': {
139
+ blockStart: '/**',
140
+ lineStart: ' * ',
141
+ blockEnd: ' */',
142
+ },
143
+ '**/*.{py,sh}': {
144
+ blockStart: '# ',
145
+ lineStart: '# ',
146
+ blockEnd: '# ',
147
+ },
148
+ },
149
+ exclude: [],
150
+ },
151
+ };
152
+ }
153
+ }
154
+ };
155
+ exports.defaultLicenseConfig = defaultLicenseConfig;
156
+ /**
157
+ * Write license configuration to the aws nx plugin config
158
+ */
159
+ const writeLicenseConfig = (tree, spdx, config) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
160
+ (0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => (Object.assign(Object.assign({}, packageJson), { license: spdx })));
161
+ yield (0, utils_1.updateAwsNxPluginConfig)(tree, {
162
+ license: config,
163
+ });
164
+ });
165
+ exports.writeLicenseConfig = writeLicenseConfig;
166
+ /**
167
+ * Read license configuration
168
+ */
169
+ const readLicenseConfig = (tree) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
170
+ var _a;
171
+ return (_a = (yield (0, utils_1.readAwsNxPluginConfig)(tree))) === null || _a === void 0 ? void 0 : _a.license;
172
+ });
173
+ exports.readLicenseConfig = readLicenseConfig;
174
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/license/config.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AAC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I,EAAE;yBACnC;qBACF;oBACD,MAAM,EAAE;wBACN,cAAc,EAAE;4BACd,UAAU,EAAE,KAAK;4BACjB,SAAS,EAAE,KAAK;4BAChB,QAAQ,EAAE,KAAK;yBAChB;wBACD,cAAc,EAAE;4BACd,UAAU,EAAE,IAAI;4BAChB,SAAS,EAAE,IAAI;4BACf,QAAQ,EAAE,IAAI;yBACf;qBACF;oBACD,OAAO,EAAE,EAAE;iBACZ;aACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAtEW,QAAA,oBAAoB,wBAsE/B;AAEF;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAChC,IAAU,EACV,IAA2B,EAC3B,MAAqB,EACrB,EAAE;IACF,IAAA,mBAAU,EAAC,IAAI,EAAE,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,iCAC7C,WAAW,KACd,OAAO,EAAE,IAAI,IACb,CAAC,CAAC;IAEJ,MAAM,IAAA,+BAAuB,EAAC,IAAI,EAAE;QAClC,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAbW,QAAA,kBAAkB,sBAa7B;AAEF;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAC/B,IAAU,EAC0B,EAAE;;IACtC,OAAO,MAAA,CAAC,MAAM,IAAA,6BAAqB,EAAC,IAAI,CAAC,CAAC,0CAAE,OAAO,CAAC;AACtD,CAAC,CAAA,CAAC;AAJW,QAAA,iBAAiB,qBAI5B"}
@@ -0,0 +1,96 @@
1
+ Amazon Software License 1.0
2
+
3
+ This Amazon Software License ("License") governs your use, reproduction, and
4
+ distribution of the accompanying software as specified below.
5
+
6
+ 1. Definitions
7
+
8
+ "Licensor" means any person or entity that distributes its Work.
9
+
10
+ "Software" means the original work of authorship made available under this
11
+ License.
12
+
13
+ "Work" means the Software and any additions to or derivative works of the
14
+ Software that are made available under this License.
15
+
16
+ The terms "reproduce," "reproduction," "derivative works," and
17
+ "distribution" have the meaning as provided under U.S. copyright law;
18
+ provided, however, that for the purposes of this License, derivative works
19
+ shall not include works that remain separable from, or merely link (or bind
20
+ by name) to the interfaces of, the Work.
21
+
22
+ Works, including the Software, are "made available" under this License by
23
+ including in or with the Work either (a) a copyright notice referencing the
24
+ applicability of this License to the Work, or (b) a copy of this License.
25
+
26
+ 2. License Grants
27
+
28
+ 2.1 Copyright Grant. Subject to the terms and conditions of this License,
29
+ each Licensor grants to you a perpetual, worldwide, non-exclusive,
30
+ royalty-free, copyright license to reproduce, prepare derivative works of,
31
+ publicly display, publicly perform, sublicense and distribute its Work and
32
+ any resulting derivative works in any form.
33
+
34
+ 2.2 Patent Grant. Subject to the terms and conditions of this License, each
35
+ Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free
36
+ patent license to make, have made, use, sell, offer for sale, import, and
37
+ otherwise transfer its Work, in whole or in part. The foregoing license
38
+ applies only to the patent claims licensable by Licensor that would be
39
+ infringed by Licensor's Work (or portion thereof) individually and
40
+ excluding any combinations with any other materials or technology.
41
+
42
+ 3. Limitations
43
+
44
+ 3.1 Redistribution. You may reproduce or distribute the Work only if
45
+ (a) you do so under this License, (b) you include a complete copy of this
46
+ License with your distribution, and (c) you retain without modification
47
+ any copyright, patent, trademark, or attribution notices that are present
48
+ in the Work.
49
+
50
+ 3.2 Derivative Works. You may specify that additional or different terms
51
+ apply to the use, reproduction, and distribution of your derivative works
52
+ of the Work ("Your Terms") only if (a) Your Terms provide that the use
53
+ limitation in Section 3.3 applies to your derivative works, and (b) you
54
+ identify the specific derivative works that are subject to Your Terms.
55
+ Notwithstanding Your Terms, this License (including the redistribution
56
+ requirements in Section 3.1) will continue to apply to the Work itself.
57
+
58
+ 3.3 Use Limitation. The Work and any derivative works thereof only may be
59
+ used or intended for use with the web services, computing platforms or
60
+ applications provided by Amazon.com, Inc. or its affiliates, including
61
+ Amazon Web Services, Inc.
62
+
63
+ 3.4 Patent Claims. If you bring or threaten to bring a patent claim against
64
+ any Licensor (including any claim, cross-claim or counterclaim in a
65
+ lawsuit) to enforce any patents that you allege are infringed by any Work,
66
+ then your rights under this License from such Licensor (including the
67
+ grants in Sections 2.1 and 2.2) will terminate immediately.
68
+
69
+ 3.5 Trademarks. This License does not grant any rights to use any
70
+ Licensor's or its affiliates' names, logos, or trademarks, except as
71
+ necessary to reproduce the notices described in this License.
72
+
73
+ 3.6 Termination. If you violate any term of this License, then your rights
74
+ under this License (including the grants in Sections 2.1 and 2.2) will
75
+ terminate immediately.
76
+
77
+ 4. Disclaimer of Warranty.
78
+
79
+ THE WORK IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
80
+ EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF
81
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR
82
+ NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER
83
+ THIS LICENSE. SOME STATES' CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN
84
+ IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU.
85
+
86
+ 5. Limitation of Liability.
87
+
88
+ EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL
89
+ THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE
90
+ SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
91
+ INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR
92
+ RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK (INCLUDING
93
+ BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS
94
+ OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER COMM ERCIAL DAMAGES
95
+ OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF
96
+ SUCH DAMAGES.
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <%- year %> <%- copyrightHolder %>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,8 @@
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 { LicenseGeneratorSchema } from './schema';
7
+ export declare function licenseGenerator(tree: Tree, options: LicenseGeneratorSchema): Promise<void>;
8
+ export default licenseGenerator;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.licenseGenerator = licenseGenerator;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */
9
+ const devkit_1 = require("@nx/devkit");
10
+ const path_1 = require("path");
11
+ const config_1 = require("./config");
12
+ const utils_1 = require("../utils/config/utils");
13
+ const generator_1 = require("./sync/generator");
14
+ function licenseGenerator(tree, options) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ var _a, _b, _c, _d;
17
+ const { license, copyrightHolder } = options;
18
+ // Add LICENSE file
19
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'licenses', license), '.', Object.assign(Object.assign({}, options), { year: new Date().getFullYear() }));
20
+ // Write default config for the license headers
21
+ yield (0, utils_1.ensureAwsNxPluginConfig)(tree);
22
+ yield (0, config_1.writeLicenseConfig)(tree, license, (0, config_1.defaultLicenseConfig)(license, copyrightHolder));
23
+ // Configure sync generator to run as part of all projects' lint target
24
+ const nxJson = (0, devkit_1.readNxJson)(tree);
25
+ (0, devkit_1.updateNxJson)(tree, Object.assign(Object.assign({}, nxJson), { targetDefaults: Object.assign(Object.assign({}, nxJson.targetDefaults), { lint: Object.assign(Object.assign({}, (_a = nxJson.targetDefaults) === null || _a === void 0 ? void 0 : _a.lint), { syncGenerators: [
26
+ ...((_d = (_c = (_b = nxJson.targetDefaults) === null || _b === void 0 ? void 0 : _b.lint) === null || _c === void 0 ? void 0 : _c.syncGenerators) !== null && _d !== void 0 ? _d : []).filter((g) => g !== generator_1.SYNC_GENERATOR_NAME),
27
+ generator_1.SYNC_GENERATOR_NAME,
28
+ ] }) }) }));
29
+ });
30
+ }
31
+ exports.default = licenseGenerator;
32
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/license/generator.ts"],"names":[],"mappings":";;AAWA,4CAqCC;;AAhDD;;;GAGG;AACH,uCAA2E;AAC3E,+BAA4B;AAE5B,qCAAoE;AACpE,iDAAgE;AAChE,gDAAuD;AAEvD,SAAsB,gBAAgB,CACpC,IAAU,EACV,OAA+B;;;QAE/B,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;QAE7C,mBAAmB;QACnB,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,GAAG,kCACjE,OAAO,KACV,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAC9B,CAAC;QAEH,+CAA+C;QAC/C,MAAM,IAAA,+BAAuB,EAAC,IAAI,CAAC,CAAC;QACpC,MAAM,IAAA,2BAAkB,EACtB,IAAI,EACJ,OAAO,EACP,IAAA,6BAAoB,EAAC,OAAO,EAAE,eAAe,CAAC,CAC/C,CAAC;QAEF,uEAAuE;QACvE,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;QAChC,IAAA,qBAAY,EAAC,IAAI,kCACZ,MAAM,KACT,cAAc,kCACT,MAAM,CAAC,cAAc,KACxB,IAAI,kCACC,MAAA,MAAM,CAAC,cAAc,0CAAE,IAAI,KAC9B,cAAc,EAAE;wBACd,GAAG,CAAC,MAAA,MAAA,MAAA,MAAM,CAAC,cAAc,0CAAE,IAAI,0CAAE,cAAc,mCAAI,EAAE,CAAC,CAAC,MAAM,CAC3D,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,+BAAmB,CACjC;wBACD,+BAAmB;qBACpB,UAGL,CAAC;IACL,CAAC;CAAA;AAED,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ export type SPDXLicenseIdentifier = 'Apache-2.0' | 'MIT' | 'ASL';
6
+
7
+ export interface LicenseGeneratorSchema {
8
+ /**
9
+ * SPDX License Identifier
10
+ */
11
+ license: SPDXLicenseIdentifier;
12
+
13
+ /**
14
+ * Copyright holder name
15
+ */
16
+ copyrightHolder: string;
17
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "License",
5
+ "title": "Add LICENSE files, and configure source code license headers",
6
+ "type": "object",
7
+ "properties": {
8
+ "license": {
9
+ "type": "string",
10
+ "description": "SPDX License Identifier",
11
+ "enum": ["Apache-2.0", "MIT", "ASL"],
12
+ "default": "Apache-2.0",
13
+ "x-priority": "important"
14
+ },
15
+ "copyrightHolder": {
16
+ "type": "string",
17
+ "description": "Copyright holder name",
18
+ "default": "Amazon.com, Inc. or its affiliates",
19
+ "x-priority": "important"
20
+ }
21
+ },
22
+ "required": []
23
+ }
@@ -0,0 +1,9 @@
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 { SyncGeneratorResult } from 'nx/src/utils/sync-generators';
7
+ export declare const SYNC_GENERATOR_NAME = "@aws/nx-plugin:license#sync";
8
+ export declare function licenseSyncGenerator(tree: Tree): Promise<SyncGeneratorResult>;
9
+ export default licenseSyncGenerator;