@spinnaker/scripts 0.0.0-main-2
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/.eslintrc.js +5 -0
- package/CHANGELOG.md +203 -0
- package/LICENSE.txt +203 -0
- package/config/rollup.config.base.js +79 -0
- package/config/rollup.config.base.module.js +16 -0
- package/config/rollup.config.base.plugin.js +60 -0
- package/helpers/rollup-node-auto-external-configurer.js +30 -0
- package/helpers/rollup-plugin-angularjs-template-loader.js +91 -0
- package/index.js +172 -0
- package/package.json +50 -0
- package/read-write-json.js +118 -0
package/.eslintrc.js
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [0.4.0](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.3.1...@spinnaker/scripts@0.4.0) (2023-12-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Expose spinnaker/kayenta to the plugin framework to allow us to create kayenta plugins in Deck ([#10072](https://github.com/spinnaker/deck/issues/10072)) ([dbf0574](https://github.com/spinnaker/deck/commit/dbf0574176cbbca781d970c64dfe49f6911ef8b8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.3.1](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.3.0...@spinnaker/scripts@0.3.1) (2023-10-16)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **publish:** set access config in deck libraries ([#10049](https://github.com/spinnaker/deck/issues/10049)) ([2a5ebe2](https://github.com/spinnaker/deck/commit/2a5ebe25662eeb9d41b5071749266bf9d6d51104))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [0.3.0](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.2.5...@spinnaker/scripts@0.3.0) (2022-08-03)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **dependencies:** Update vulnerable dependencies ([#9875](https://github.com/spinnaker/deck/issues/9875)) ([bf92932](https://github.com/spinnaker/deck/commit/bf92932c9396a88fb902050b52f504e4ac01aaa0))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [0.2.5](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.2.4...@spinnaker/scripts@0.2.5) (2022-03-08)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* **scripts:** update rollup-plugin-esbuild ([#9807](https://github.com/spinnaker/deck/issues/9807)) ([45ebc45](https://github.com/spinnaker/deck/commit/45ebc457fa4dbbad93cd9567fe31bd7d8cb2743b))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## [0.2.4](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.2.3...@spinnaker/scripts@0.2.4) (2021-12-01)
|
|
51
|
+
|
|
52
|
+
**Note:** Version bump only for package @spinnaker/scripts
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## [0.2.3](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.2.2...@spinnaker/scripts@0.2.3) (2021-11-03)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @spinnaker/scripts
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## [0.2.2](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.2.0...@spinnaker/scripts@0.2.2) (2021-09-30)
|
|
67
|
+
|
|
68
|
+
**Note:** Version bump only for package @spinnaker/scripts
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## [0.2.1](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.2.0...@spinnaker/scripts@0.2.1) (2021-09-30)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @spinnaker/scripts
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [0.2.0](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.1.0...@spinnaker/scripts@0.2.0) (2021-09-24)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Bug Fixes
|
|
86
|
+
|
|
87
|
+
* **scripts/read-write-json:** use comment-json package instead of hjson ([9311e37](https://github.com/spinnaker/deck/commit/9311e37fcdbfa85c02554a42e5f10f17a1fd810d))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Features
|
|
91
|
+
|
|
92
|
+
* **packages/scripts:** Add read-write-json helper script ([681b4f8](https://github.com/spinnaker/deck/commit/681b4f8545910ea6f2a06cd33aee7b0f9b9eb469))
|
|
93
|
+
* **scripts/read-write-json:** support boolean and number types ([e713ac4](https://github.com/spinnaker/deck/commit/e713ac4d8e3567c7814ba64089edc58b502c69b5))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# [0.1.0](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.23...@spinnaker/scripts@0.1.0) (2021-08-20)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
* remove postcss nested (#9602) ([a20faf1](https://github.com/spinnaker/deck/commit/a20faf1b6020cf7f079b9486e6662530024a4336)), closes [#9602](https://github.com/spinnaker/deck/issues/9602)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### BREAKING CHANGES
|
|
106
|
+
|
|
107
|
+
* removed postcss-nested plugin. Unlikely that this will break anything, but it's possible.
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## [0.0.23](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.22...@spinnaker/scripts@0.0.23) (2021-08-13)
|
|
114
|
+
|
|
115
|
+
**Note:** Version bump only for package @spinnaker/scripts
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## [0.0.22](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.21...@spinnaker/scripts@0.0.22) (2021-08-02)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Bug Fixes
|
|
125
|
+
|
|
126
|
+
* **vite:** Link app to core source files during dev ([37bf5f9](https://github.com/spinnaker/deck/commit/37bf5f9049c6b76f84afcdfc718124cc35d2b932))
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## [0.0.21](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.20...@spinnaker/scripts@0.0.21) (2021-07-30)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* **rollup:** do not log quotes around NODE_ENV ([#9533](https://github.com/spinnaker/deck/issues/9533)) ([7bcf7d7](https://github.com/spinnaker/deck/commit/7bcf7d7a404814c6d368bdf7f072cd4674ca018b))
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
## [0.0.20](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.15...@spinnaker/scripts@0.0.20) (2021-07-19)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Bug Fixes
|
|
147
|
+
|
|
148
|
+
* **scripts:** Handle double quotes in require calls ([429bdd9](https://github.com/spinnaker/deck/commit/429bdd9e4d7e12d52044e9a62016feb00e4db719))
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## [0.0.19](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.15...@spinnaker/scripts@0.0.19) (2021-07-19)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
### Bug Fixes
|
|
158
|
+
|
|
159
|
+
* **scripts:** Handle double quotes in require calls ([429bdd9](https://github.com/spinnaker/deck/commit/429bdd9e4d7e12d52044e9a62016feb00e4db719))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
## [0.0.18](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.15...@spinnaker/scripts@0.0.18) (2021-07-19)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
### Bug Fixes
|
|
169
|
+
|
|
170
|
+
* **scripts:** Handle double quotes in require calls ([429bdd9](https://github.com/spinnaker/deck/commit/429bdd9e4d7e12d52044e9a62016feb00e4db719))
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
## [0.0.17](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.15...@spinnaker/scripts@0.0.17) (2021-07-19)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
### Bug Fixes
|
|
180
|
+
|
|
181
|
+
* **scripts:** Handle double quotes in require calls ([429bdd9](https://github.com/spinnaker/deck/commit/429bdd9e4d7e12d52044e9a62016feb00e4db719))
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## [0.0.16](https://github.com/spinnaker/deck/compare/@spinnaker/scripts@0.0.15...@spinnaker/scripts@0.0.16) (2021-07-19)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
### Bug Fixes
|
|
191
|
+
|
|
192
|
+
* **scripts:** Handle double quotes in require calls ([429bdd9](https://github.com/spinnaker/deck/commit/429bdd9e4d7e12d52044e9a62016feb00e4db719))
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
## 0.0.15 (2021-07-17)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
### Bug Fixes
|
|
202
|
+
|
|
203
|
+
* **publishing:** Auto approve instead of adding "ready to merge" label ([51f536c](https://github.com/spinnaker/deck/commit/51f536c275e77854d8f173aeec86412ffbd66b6d))
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
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.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2014 Netflix
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const colorMap = require('@spinnaker/styleguide/src/colorMap');
|
|
2
|
+
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
|
3
|
+
const commonjs = require('@rollup/plugin-commonjs');
|
|
4
|
+
const json = require('@rollup/plugin-json');
|
|
5
|
+
const postCss = require('rollup-plugin-postcss');
|
|
6
|
+
const replace = require('@rollup/plugin-replace');
|
|
7
|
+
const url = require('@rollup/plugin-url');
|
|
8
|
+
const svgr = require('@svgr/rollup');
|
|
9
|
+
const autoPrefixer = require('autoprefixer');
|
|
10
|
+
const postCssColorFix = require('postcss-colorfix');
|
|
11
|
+
const postCssUrl = require('postcss-url');
|
|
12
|
+
const esbuild = require('rollup-plugin-esbuild').default;
|
|
13
|
+
const { terser } = require('rollup-plugin-terser');
|
|
14
|
+
const { visualizer } = require('rollup-plugin-visualizer');
|
|
15
|
+
|
|
16
|
+
const ROLLUP_STATS = !!process.env.ROLLUP_STATS;
|
|
17
|
+
const ROLLUP_WATCH = !!process.env.ROLLUP_WATCH;
|
|
18
|
+
const NODE_ENV = process.env.NODE_ENV || 'development';
|
|
19
|
+
const ENV_MINIFY = process.env.ROLLUP_MINIFY;
|
|
20
|
+
const ROLLUP_MINIFY = ENV_MINIFY === 'true' || (NODE_ENV === 'production' && ENV_MINIFY !== 'false');
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.log({ ROLLUP_STATS, ROLLUP_WATCH, ROLLUP_MINIFY, NODE_ENV });
|
|
24
|
+
|
|
25
|
+
const plugins = [
|
|
26
|
+
nodeResolve(),
|
|
27
|
+
commonjs(),
|
|
28
|
+
json(),
|
|
29
|
+
url({
|
|
30
|
+
include: ['**/*.html', '**/*.svg', '**/*.png', '**/*.jp(e)?g', '**/*.gif', '**/*.webp'],
|
|
31
|
+
fileName: '[name][hash][extname]',
|
|
32
|
+
limit: 24000,
|
|
33
|
+
}),
|
|
34
|
+
// Replace literal string 'process.env.NODE_ENV' with the current NODE_ENV
|
|
35
|
+
replace({
|
|
36
|
+
preventAssignment: true,
|
|
37
|
+
values: { 'process.env.NODE_ENV': `"${NODE_ENV}"` },
|
|
38
|
+
}),
|
|
39
|
+
esbuild({
|
|
40
|
+
sourcemap: true,
|
|
41
|
+
target: 'es2018',
|
|
42
|
+
}),
|
|
43
|
+
svgr(),
|
|
44
|
+
// import from .css, .less, and inject into the document <head></head>
|
|
45
|
+
postCss({
|
|
46
|
+
plugins: [
|
|
47
|
+
autoPrefixer(),
|
|
48
|
+
postCssColorFix({
|
|
49
|
+
colors: colorMap,
|
|
50
|
+
}),
|
|
51
|
+
postCssUrl({
|
|
52
|
+
url: 'inline',
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
}),
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
if (ROLLUP_MINIFY) {
|
|
59
|
+
plugins.push(
|
|
60
|
+
terser({
|
|
61
|
+
format: {
|
|
62
|
+
comments: function (node, comment) {
|
|
63
|
+
if (comment.type == 'comment2') {
|
|
64
|
+
// Preserve multiline comments containing any of these strings
|
|
65
|
+
return /@preserve|@license|@cc_on|webpackChunkName|webpackIgnore/i.test(comment.value);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (ROLLUP_STATS) {
|
|
74
|
+
plugins.push(visualizer({ sourcemap: true }));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = {
|
|
78
|
+
plugins,
|
|
79
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const baseRollupConfig = require('./rollup.config.base');
|
|
5
|
+
const angularJsTemplateLoader = require('../helpers/rollup-plugin-angularjs-template-loader');
|
|
6
|
+
const externalConfigurer = require('../helpers/rollup-node-auto-external-configurer');
|
|
7
|
+
|
|
8
|
+
const packageJSON = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
...baseRollupConfig,
|
|
12
|
+
input: 'src/index.ts',
|
|
13
|
+
output: [{ dir: 'dist', format: 'es', sourcemap: true }],
|
|
14
|
+
plugins: [angularJsTemplateLoader({ sourceMap: true }), ...baseRollupConfig.plugins],
|
|
15
|
+
external: externalConfigurer(packageJSON.dependencies),
|
|
16
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const baseRollupConfig = require('./rollup.config.base');
|
|
2
|
+
const externalGlobals = require('rollup-plugin-external-globals');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
...baseRollupConfig,
|
|
6
|
+
input: 'src/index.ts',
|
|
7
|
+
output: [{ dir: 'build/dist', format: 'es', sourcemap: true }],
|
|
8
|
+
plugins: [
|
|
9
|
+
...baseRollupConfig.plugins,
|
|
10
|
+
// map imports from shared libraries (react, etc) to global variables exposed by spinnaker
|
|
11
|
+
externalGlobals(spinnakerSharedLibraries()),
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function spinnakerSharedLibraries() {
|
|
16
|
+
// Updates here should also be added in core/src/plugins/sharedLibraries.ts
|
|
17
|
+
const libraries = [
|
|
18
|
+
'ajv',
|
|
19
|
+
'@spinnaker/core',
|
|
20
|
+
'@spinnaker/kayenta',
|
|
21
|
+
'@uirouter/core',
|
|
22
|
+
'@uirouter/react',
|
|
23
|
+
'@uirouter/rx',
|
|
24
|
+
'lodash',
|
|
25
|
+
'prop-types',
|
|
26
|
+
'react',
|
|
27
|
+
'react-dom',
|
|
28
|
+
'react-redux',
|
|
29
|
+
'redux-actions',
|
|
30
|
+
'reselect',
|
|
31
|
+
'rxjs',
|
|
32
|
+
'rxjs/Observable',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
function getGlobalVariable(libraryName) {
|
|
36
|
+
const prefix = 'spinnaker.plugins.sharedLibraries';
|
|
37
|
+
const sanitizedLibraryName = libraryName.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
38
|
+
return `${prefix}.${sanitizedLibraryName}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// This allows us to share libraries with plugin dependencies that would otherwise be double bundled
|
|
42
|
+
// @rollup/plugin-commonjs rewrites library names in commonjs imported code
|
|
43
|
+
// This block finds known permutations and replaces them with the shared global variable
|
|
44
|
+
return libraries.reduce((globalsMap, libraryName) => {
|
|
45
|
+
const globalVar = getGlobalVariable(libraryName);
|
|
46
|
+
const libName2 = libraryName + '?commonjs-proxy';
|
|
47
|
+
const libName3 = libraryName + '?commonjs-require';
|
|
48
|
+
const libName4 = '\u0000' + libraryName + '?commonjs-proxy';
|
|
49
|
+
const libName5 = '\u0000' + libraryName + '?commonjs-require';
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
...globalsMap,
|
|
53
|
+
[libraryName]: globalVar,
|
|
54
|
+
[libName2]: globalVar,
|
|
55
|
+
[libName3]: globalVar,
|
|
56
|
+
[libName4]: globalVar,
|
|
57
|
+
[libName5]: globalVar,
|
|
58
|
+
};
|
|
59
|
+
}, {});
|
|
60
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
/**
|
|
3
|
+
* `rollup-plugin-auto-external` plugin doesn't handle import statements with paths in them. For example
|
|
4
|
+
* `bootstrap/dist/js/bootstrap` will not be treated as an external. This function is a very simple externals configurer
|
|
5
|
+
* that accepts a map of externals (packages and others) and correctly marks them as externals.
|
|
6
|
+
*
|
|
7
|
+
* The caller can typically pass `packageJSON.dependencies` as `externals`.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = (externals) => {
|
|
10
|
+
return (id) => {
|
|
11
|
+
if (id.startsWith('.') || id.startsWith('/')) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (id in externals) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Handling imports with paths in them. We split the id by `/` and use either the first part or the first + second
|
|
19
|
+
// part (in case of scoped packages) to verify if it is available in `externals`.
|
|
20
|
+
const packageParts = id.split('/');
|
|
21
|
+
if (packageParts.length > 1) {
|
|
22
|
+
// If it is a scoped package, then include the second part of the package name.
|
|
23
|
+
const packageIdentifier = id.startsWith('@') ? packageParts[0] + path.sep + packageParts[1] : packageParts[0];
|
|
24
|
+
|
|
25
|
+
return packageIdentifier in externals;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const MagicString = require('magic-string');
|
|
4
|
+
|
|
5
|
+
// This rollup plugin finds AngularJS templates and loads them into the $templateCache
|
|
6
|
+
// This is a rollup replacement for the ngtemplate-loader webpack loader
|
|
7
|
+
module.exports = function angularJsTemplateLoader(options = {}) {
|
|
8
|
+
function isSourceMapEnabled() {
|
|
9
|
+
return options.sourceMap !== false && options.sourcemap !== false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
name: 'angularJSTemplateLoader',
|
|
14
|
+
transform(originalCode, id) {
|
|
15
|
+
const code = originalCode;
|
|
16
|
+
const templateRegex = /require\(['"]([^'"]+\.html)['"]\)/g;
|
|
17
|
+
|
|
18
|
+
// look for things like require('./template.html')
|
|
19
|
+
if (
|
|
20
|
+
(!code.includes("require('") && !code.includes(`require("`)) ||
|
|
21
|
+
id.includes('node_modules') ||
|
|
22
|
+
id.includes('react-refresh')
|
|
23
|
+
) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!fs.existsSync(id)) {
|
|
28
|
+
throw new Error('Unable to load AngularJS template; could not find source file ' + id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Find the directory the JS source file is in
|
|
32
|
+
const baseDir = fs.lstatSync(id).isDirectory() ? id : path.dirname(id);
|
|
33
|
+
const moduleRootDir = path.resolve('.');
|
|
34
|
+
const moduleDirName = path.basename(moduleRootDir);
|
|
35
|
+
|
|
36
|
+
let match = templateRegex.exec(code);
|
|
37
|
+
if (!match) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const magicString = new MagicString(code);
|
|
42
|
+
|
|
43
|
+
while (match) {
|
|
44
|
+
// i.e., './template.html'
|
|
45
|
+
const templatePath = match[1];
|
|
46
|
+
// Absolute path to the actual template.html file
|
|
47
|
+
const contentPath = path.resolve(baseDir, templatePath);
|
|
48
|
+
if (!fs.existsSync(contentPath)) {
|
|
49
|
+
throw new Error('Unable to load AngularJS template; could not find template file ' + contentPath);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const templatePathFromModuleRoot = `${moduleDirName}${path.sep}${path.relative(moduleRootDir, contentPath)}`;
|
|
53
|
+
|
|
54
|
+
const startIdx = match.index;
|
|
55
|
+
const endIdx = startIdx + match[0].length;
|
|
56
|
+
|
|
57
|
+
// read the contents of template.html
|
|
58
|
+
const content = fs.readFileSync(contentPath, { encoding: 'UTF8' }).replace(/`/g, '\\`');
|
|
59
|
+
|
|
60
|
+
// Replace: templateUrl: require('./template.html')
|
|
61
|
+
// With: templateUrl: 'path/from/module/root/to/template.html'
|
|
62
|
+
magicString.overwrite(startIdx, endIdx, `'${templatePathFromModuleRoot}'`);
|
|
63
|
+
|
|
64
|
+
// Append a run block that adds the HTML content into the $templateCache (used by angularjs when loading templates)
|
|
65
|
+
magicString.append(`
|
|
66
|
+
|
|
67
|
+
/*********************************************************************
|
|
68
|
+
* angularjs-template-loader rollup plugin -- ${templatePathFromModuleRoot} start *
|
|
69
|
+
********************************************************************/
|
|
70
|
+
|
|
71
|
+
window.angular.module('ng').run(['$templateCache', function(templateCache) {
|
|
72
|
+
templateCache.put('${templatePathFromModuleRoot}',
|
|
73
|
+
\`${content}\`)
|
|
74
|
+
}]);
|
|
75
|
+
|
|
76
|
+
/*********************************************************************
|
|
77
|
+
* angularjs-template-loader rollup plugin -- ${templatePathFromModuleRoot} end *
|
|
78
|
+
********************************************************************/
|
|
79
|
+
`);
|
|
80
|
+
// look for another match
|
|
81
|
+
match = templateRegex.exec(code);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (isSourceMapEnabled()) {
|
|
85
|
+
return { code: magicString.toString(), map: magicString.generateMap({ hires: true }) };
|
|
86
|
+
} else {
|
|
87
|
+
return { code: magicString.toString() };
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const child_process = require('child_process');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const loadConfigFile = require('rollup/dist/loadConfigFile');
|
|
7
|
+
const ora = require('ora');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const process = require('process');
|
|
10
|
+
const rollup = require('rollup');
|
|
11
|
+
const util = require('util');
|
|
12
|
+
|
|
13
|
+
const exec = util.promisify(child_process.exec);
|
|
14
|
+
|
|
15
|
+
const getRollupConfigPath = (file) => {
|
|
16
|
+
if (file && !fs.existsSync(path.resolve(path.join('.', file)))) {
|
|
17
|
+
// If the user explicitly provides a rollup config file and if it is not available, then throw an error and exit.
|
|
18
|
+
console.error(`Could not find ${path.join('.', file)}`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
// If user does't provide a rollup config file, then search for `rollup.config.js` in the project directory. If it is
|
|
22
|
+
// not found, then use `rollup.config.base.module.js` which contains pretty reasonable defaults.
|
|
23
|
+
const projectRollupConfigFilePath = path.resolve(path.join('.', file || 'rollup.config.js'));
|
|
24
|
+
return fs.existsSync(projectRollupConfigFilePath)
|
|
25
|
+
? projectRollupConfigFilePath
|
|
26
|
+
: path.resolve(path.join(__dirname), 'config', 'rollup.config.base.module.js');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const OUTPUT_DIR_REGEX = /\/?(\w+)$/;
|
|
30
|
+
|
|
31
|
+
const getOutputDir = (output) => {
|
|
32
|
+
const outputDirMatch = OUTPUT_DIR_REGEX.exec(output);
|
|
33
|
+
return outputDirMatch.length > 1 ? outputDirMatch[1] : output;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Runs typescript compiler for type checking and emitting declarations in a separate process to run in parallel with
|
|
37
|
+
// the bundler.
|
|
38
|
+
const runTsc = (options, exitOnFailure) => {
|
|
39
|
+
const tscBin = path.resolve(`./node_modules/.bin/tsc`);
|
|
40
|
+
return exec(`${tscBin} --emitDeclarationOnly`)
|
|
41
|
+
.then(() => ora().succeed(chalk.green.bold('type checking done')))
|
|
42
|
+
.catch(({ stderr, stdout }) => {
|
|
43
|
+
console.log();
|
|
44
|
+
if (stdout) {
|
|
45
|
+
console.log(stdout);
|
|
46
|
+
}
|
|
47
|
+
if (stderr) {
|
|
48
|
+
console.error(stderr);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (exitOnFailure) {
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.finally(() => {
|
|
56
|
+
options.forEach((option) => {
|
|
57
|
+
const fixTSPathRewritePlugin = option.plugins.find((plugin) => plugin.name == 'fixTSPathRewrite');
|
|
58
|
+
if (fixTSPathRewritePlugin) {
|
|
59
|
+
fixTSPathRewritePlugin.writeBundle();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const startHandler = async ({ file, push }) => {
|
|
66
|
+
process.env.ROLLUP_WATCH = true;
|
|
67
|
+
|
|
68
|
+
const { options, warnings } = await loadConfigFile(getRollupConfigPath(file));
|
|
69
|
+
// A map of `input-output` bundle key to a tracker object. This is used to quickly access a spinner object and
|
|
70
|
+
// startTime when succeeding/failing that object on receiving a `BUNDLE_END`/`ERROR` event.
|
|
71
|
+
const buildTracker = {};
|
|
72
|
+
// Kick-starting rollup's bundling process in watch mode.
|
|
73
|
+
const watcher = rollup.watch(options);
|
|
74
|
+
let startTime;
|
|
75
|
+
|
|
76
|
+
warnings.flush();
|
|
77
|
+
watcher.on('event', (event) => {
|
|
78
|
+
// Rollup will be emitting lifecycle events for the bundling process such as start, end and error. These events are
|
|
79
|
+
// used to control a spinner in the terminal for each `input-output` bundle.
|
|
80
|
+
switch (event.code) {
|
|
81
|
+
case 'START':
|
|
82
|
+
runTsc(options, false);
|
|
83
|
+
break;
|
|
84
|
+
case 'END':
|
|
85
|
+
if (push) {
|
|
86
|
+
console.log();
|
|
87
|
+
console.log(chalk.gray.bold('yalc push'));
|
|
88
|
+
const yalcBin = path.resolve(__dirname, 'node_modules', '.bin', 'yalc');
|
|
89
|
+
const output = child_process.execSync(`${yalcBin} push`);
|
|
90
|
+
console.log(chalk.blue.bold(output.toString('utf-8')));
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case 'BUNDLE_START':
|
|
94
|
+
console.log('');
|
|
95
|
+
event.output.forEach((output) => {
|
|
96
|
+
const outputDir = getOutputDir(output);
|
|
97
|
+
const spinner = ora({
|
|
98
|
+
text: chalk.blue.bold(`${event.input} -> ${outputDir}`),
|
|
99
|
+
});
|
|
100
|
+
buildTracker[`${event.input}-${output}`] = { spinner, startTime: Date.now() };
|
|
101
|
+
|
|
102
|
+
spinner.start();
|
|
103
|
+
});
|
|
104
|
+
break;
|
|
105
|
+
case 'BUNDLE_END':
|
|
106
|
+
event.output.forEach((output) => {
|
|
107
|
+
const tracker = buildTracker[`${event.input}-${output}`];
|
|
108
|
+
if (tracker.spinner) {
|
|
109
|
+
const outputDir = getOutputDir(output);
|
|
110
|
+
const completedTimeInS = (Date.now() - tracker.startTime) / 1000;
|
|
111
|
+
tracker.spinner.succeed(chalk.green.bold(`${event.input} -> ${outputDir} (${completedTimeInS}s)`));
|
|
112
|
+
delete buildTracker[`${event.input}-${output}`];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
break;
|
|
116
|
+
case 'ERROR':
|
|
117
|
+
Object.entries(buildTracker).forEach(([key, tracker]) => {
|
|
118
|
+
tracker.spinner.fail(event.error);
|
|
119
|
+
console.error(event.error);
|
|
120
|
+
delete buildTracker[key];
|
|
121
|
+
});
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
watcher.close();
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const printBundleStart = (option) => {
|
|
130
|
+
const message = option.output.map((output) => `${option.input} -> ${output.dir}...`).join('\n');
|
|
131
|
+
console.log(chalk.blue.bold(message));
|
|
132
|
+
};
|
|
133
|
+
const printBundleComplete = (option, completedTimeInMS) => {
|
|
134
|
+
const outputFolder = chalk.green.bold(option.output.map((output) => output.dir).join(', '));
|
|
135
|
+
const completedTimeInS = chalk.green.bold(`${completedTimeInMS / 1000}s`);
|
|
136
|
+
console.log(chalk.green(`created ${outputFolder} in ${completedTimeInS}`));
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const buildHandler = async ({ file }) => {
|
|
140
|
+
const { options, warnings } = await loadConfigFile(getRollupConfigPath(file));
|
|
141
|
+
warnings.flush();
|
|
142
|
+
|
|
143
|
+
for (const o of options) {
|
|
144
|
+
const start = Date.now();
|
|
145
|
+
console.log('');
|
|
146
|
+
printBundleStart(o);
|
|
147
|
+
|
|
148
|
+
const bundle = await rollup.rollup(o);
|
|
149
|
+
await Promise.all([...o.output.map(bundle.write), runTsc(options, true)]);
|
|
150
|
+
|
|
151
|
+
printBundleComplete(o, Date.now() - start);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const fileOption = {
|
|
156
|
+
alias: 'file',
|
|
157
|
+
describe: 'custom rollup config file',
|
|
158
|
+
type: 'string',
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const pushOption = {
|
|
162
|
+
alias: 'push',
|
|
163
|
+
default: false,
|
|
164
|
+
type: 'boolean',
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
require('yargs')
|
|
168
|
+
.scriptName('spinnaker-scripts')
|
|
169
|
+
.command('start', 'Builds your package in watch mode', { f: fileOption, p: pushOption }, startHandler)
|
|
170
|
+
.command('build', 'Builds your package', { f: fileOption }, buildHandler)
|
|
171
|
+
.help()
|
|
172
|
+
.demandCommand().argv;
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spinnaker/scripts",
|
|
3
|
+
"version": "0.0.0-main-2",
|
|
4
|
+
"description": "Spinnaker scripts",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"spinnaker-scripts": "./index.js",
|
|
8
|
+
"read-write-json": "./read-write-json.js"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"registry": "https://registry.npmjs.org"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@rollup/plugin-commonjs": "^17.0.0",
|
|
20
|
+
"@rollup/plugin-json": "4.1.0",
|
|
21
|
+
"@rollup/plugin-node-resolve": "^11.0.1",
|
|
22
|
+
"@rollup/plugin-replace": "2.4.2",
|
|
23
|
+
"@rollup/plugin-typescript": "^8.1.0",
|
|
24
|
+
"@rollup/plugin-url": "^6.0.0",
|
|
25
|
+
"@spinnaker/eslint-plugin": "^3.0.2",
|
|
26
|
+
"@spinnaker/styleguide": "^2.0.0",
|
|
27
|
+
"@svgr/rollup": "^6.3.1",
|
|
28
|
+
"autoprefixer": "^10.4.8",
|
|
29
|
+
"chalk": "^4.1.1",
|
|
30
|
+
"comment-json": "^4.1.1",
|
|
31
|
+
"esbuild": "^0.12.14",
|
|
32
|
+
"ora": "^5.4.0",
|
|
33
|
+
"postcss": "^8.4.14",
|
|
34
|
+
"postcss-colorfix": "0.0.5",
|
|
35
|
+
"postcss-url": "^10.1.3",
|
|
36
|
+
"rollup": "^2.35.1",
|
|
37
|
+
"rollup-plugin-esbuild": "^4.8.2",
|
|
38
|
+
"rollup-plugin-external-globals": "0.6.1",
|
|
39
|
+
"rollup-plugin-less": "1.1.3",
|
|
40
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
41
|
+
"rollup-plugin-terser": "7.0.2",
|
|
42
|
+
"rollup-plugin-visualizer": "5.4.1",
|
|
43
|
+
"yalc": "^1.0.0-pre.53",
|
|
44
|
+
"yargs": "^17.1.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/yargs": "^17.0.3"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "41637c82dc23fbf1195173a93611a08000fc0e53"
|
|
50
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
// JSON parse/stringify with support for comments (tsconfig.json can have comments)
|
|
4
|
+
const commentJson = require('comment-json');
|
|
5
|
+
const { get, set, unset } = require('lodash');
|
|
6
|
+
const yargs = require('yargs');
|
|
7
|
+
|
|
8
|
+
const configureCli = () => {
|
|
9
|
+
const yargs = require('yargs');
|
|
10
|
+
|
|
11
|
+
const addDefaultPositionalArgs = (_yargs) => {
|
|
12
|
+
_yargs.positional('filename', { description: 'The JSON file' });
|
|
13
|
+
_yargs.positional('jsonpath', { description: 'A lodash-style JSON Path' });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
yargs.command(
|
|
17
|
+
'read <filename> <jsonpath>',
|
|
18
|
+
'Outputs a value from a JSON file at the given path',
|
|
19
|
+
addDefaultPositionalArgs,
|
|
20
|
+
({ filename, jsonpath }) => {
|
|
21
|
+
console.log(readJsonField(filename, jsonpath));
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
yargs.command(
|
|
26
|
+
'write <filename> <jsonpath> <value>',
|
|
27
|
+
'Writes a value to a JSON file at the given path',
|
|
28
|
+
(_yargs) => {
|
|
29
|
+
addDefaultPositionalArgs(_yargs);
|
|
30
|
+
_yargs.positional('value', {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'The new value to write',
|
|
33
|
+
});
|
|
34
|
+
_yargs.option('type', {
|
|
35
|
+
description: 'writes the value as a JSON boolean/number/string',
|
|
36
|
+
type: 'string',
|
|
37
|
+
choices: ['boolean', 'number', 'string'],
|
|
38
|
+
default: 'string',
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
({ filename, jsonpath, value, type }) => {
|
|
42
|
+
let newvalue = value;
|
|
43
|
+
if (type === 'boolean') {
|
|
44
|
+
newvalue = newvalue === 'true' ? true : newvalue === 'false' ? false : newvalue;
|
|
45
|
+
if (typeof newvalue !== 'boolean') {
|
|
46
|
+
throw new Error(`Cannot parse ${value} as a boolean`);
|
|
47
|
+
}
|
|
48
|
+
} else if (type === 'number') {
|
|
49
|
+
const newvalue = Number(value);
|
|
50
|
+
if (isNaN(newvalue)) {
|
|
51
|
+
throw new Error(`Cannot parse ${value} as a number`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
writeJsonField(filename, jsonpath, newvalue);
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
yargs.command(
|
|
59
|
+
'delete <filename> <jsonpath>',
|
|
60
|
+
'Deletes a property from a JSON file at the given path',
|
|
61
|
+
addDefaultPositionalArgs,
|
|
62
|
+
({ filename, jsonpath }) => {
|
|
63
|
+
deleteJsonField(filename, jsonpath);
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
yargs.demandCommand(1);
|
|
68
|
+
yargs.strictCommands();
|
|
69
|
+
yargs.wrap(null);
|
|
70
|
+
|
|
71
|
+
yargs.example('read-write-json.js read package.json version', 'Outputs the version property from package.json');
|
|
72
|
+
yargs.example(
|
|
73
|
+
'read-write-json.js write package.json devDependencies.husky 6.0.0',
|
|
74
|
+
'Writes "husky": "6.0.0" to the "devDependencies" property of package.json',
|
|
75
|
+
);
|
|
76
|
+
yargs.example(
|
|
77
|
+
'read-write-json.js delete package.json devDependencies.husky',
|
|
78
|
+
'Deletes the "husky" key from the "devDependencies" property of package.json',
|
|
79
|
+
);
|
|
80
|
+
yargs.parse();
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (require.main === module) {
|
|
84
|
+
configureCli();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function readJson(filename) {
|
|
88
|
+
const string = fs.readFileSync(filename, 'utf-8');
|
|
89
|
+
return commentJson.parse(string);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function writeJson(filename, json) {
|
|
93
|
+
const data = commentJson.stringify(json, null, 2);
|
|
94
|
+
fs.writeFileSync(filename, data, 'utf-8');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function readJsonField(filename, path) {
|
|
98
|
+
const json = readJson(filename);
|
|
99
|
+
return get(json, path);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function deleteJsonField(filename, field) {
|
|
103
|
+
const json = readJson(filename);
|
|
104
|
+
unset(json, field);
|
|
105
|
+
writeJson(filename, json);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function writeJsonField(filename, field, val) {
|
|
109
|
+
const json = readJson(filename);
|
|
110
|
+
set(json, field, val);
|
|
111
|
+
writeJson(filename, json);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports.readJson = readJson;
|
|
115
|
+
module.exports.writeJson = writeJson;
|
|
116
|
+
module.exports.readJsonField = readJsonField;
|
|
117
|
+
module.exports.writeJsonField = writeJsonField;
|
|
118
|
+
module.exports.deleteJsonField = deleteJsonField;
|