@automattic/jetpack-cli 1.0.2 → 1.1.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.txt +88 -90
- package/bin/jp.js +194 -4
- package/package.json +2 -1
package/LICENSE.txt
CHANGED
|
@@ -9,24 +9,23 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
9
9
|
GNU General Public License for more details.
|
|
10
10
|
|
|
11
11
|
You should have received a copy of the GNU General Public License
|
|
12
|
-
along with this program; if not,
|
|
13
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
12
|
+
along with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
===================================
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
GNU GENERAL PUBLIC LICENSE
|
|
20
|
-
|
|
18
|
+
GNU GENERAL PUBLIC LICENSE
|
|
19
|
+
Version 2, June 1991
|
|
21
20
|
|
|
22
|
-
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
|
23
|
-
|
|
24
|
-
Everyone is permitted to copy and distribute verbatim copies
|
|
25
|
-
of this license document, but changing it is not allowed.
|
|
21
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
|
22
|
+
<https://fsf.org/>
|
|
23
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
24
|
+
of this license document, but changing it is not allowed.
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
Preamble
|
|
28
27
|
|
|
29
|
-
The licenses for most software are designed to take away your
|
|
28
|
+
The licenses for most software are designed to take away your
|
|
30
29
|
freedom to share and change it. By contrast, the GNU General Public
|
|
31
30
|
License is intended to guarantee your freedom to share and change free
|
|
32
31
|
software--to make sure the software is free for all its users. This
|
|
@@ -36,48 +35,48 @@ using it. (Some other Free Software Foundation software is covered by
|
|
|
36
35
|
the GNU Lesser General Public License instead.) You can apply it to
|
|
37
36
|
your programs, too.
|
|
38
37
|
|
|
39
|
-
When we speak of free software, we are referring to freedom, not
|
|
38
|
+
When we speak of free software, we are referring to freedom, not
|
|
40
39
|
price. Our General Public Licenses are designed to make sure that you
|
|
41
40
|
have the freedom to distribute copies of free software (and charge for
|
|
42
41
|
this service if you wish), that you receive source code or can get it
|
|
43
42
|
if you want it, that you can change the software or use pieces of it
|
|
44
43
|
in new free programs; and that you know you can do these things.
|
|
45
44
|
|
|
46
|
-
To protect your rights, we need to make restrictions that forbid
|
|
45
|
+
To protect your rights, we need to make restrictions that forbid
|
|
47
46
|
anyone to deny you these rights or to ask you to surrender the rights.
|
|
48
47
|
These restrictions translate to certain responsibilities for you if you
|
|
49
48
|
distribute copies of the software, or if you modify it.
|
|
50
49
|
|
|
51
|
-
For example, if you distribute copies of such a program, whether
|
|
50
|
+
For example, if you distribute copies of such a program, whether
|
|
52
51
|
gratis or for a fee, you must give the recipients all the rights that
|
|
53
52
|
you have. You must make sure that they, too, receive or can get the
|
|
54
53
|
source code. And you must show them these terms so they know their
|
|
55
54
|
rights.
|
|
56
55
|
|
|
57
|
-
We protect your rights with two steps: (1) copyright the software, and
|
|
56
|
+
We protect your rights with two steps: (1) copyright the software, and
|
|
58
57
|
(2) offer you this license which gives you legal permission to copy,
|
|
59
58
|
distribute and/or modify the software.
|
|
60
59
|
|
|
61
|
-
Also, for each author's protection and ours, we want to make certain
|
|
60
|
+
Also, for each author's protection and ours, we want to make certain
|
|
62
61
|
that everyone understands that there is no warranty for this free
|
|
63
62
|
software. If the software is modified by someone else and passed on, we
|
|
64
63
|
want its recipients to know that what they have is not the original, so
|
|
65
64
|
that any problems introduced by others will not reflect on the original
|
|
66
65
|
authors' reputations.
|
|
67
66
|
|
|
68
|
-
Finally, any free program is threatened constantly by software
|
|
67
|
+
Finally, any free program is threatened constantly by software
|
|
69
68
|
patents. We wish to avoid the danger that redistributors of a free
|
|
70
69
|
program will individually obtain patent licenses, in effect making the
|
|
71
70
|
program proprietary. To prevent this, we have made it clear that any
|
|
72
71
|
patent must be licensed for everyone's free use or not licensed at all.
|
|
73
72
|
|
|
74
|
-
The precise terms and conditions for copying, distribution and
|
|
73
|
+
The precise terms and conditions for copying, distribution and
|
|
75
74
|
modification follow.
|
|
76
75
|
|
|
77
|
-
GNU GENERAL PUBLIC LICENSE
|
|
78
|
-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
76
|
+
GNU GENERAL PUBLIC LICENSE
|
|
77
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
79
78
|
|
|
80
|
-
0. This License applies to any program or other work which contains
|
|
79
|
+
0. This License applies to any program or other work which contains
|
|
81
80
|
a notice placed by the copyright holder saying it may be distributed
|
|
82
81
|
under the terms of this General Public License. The "Program", below,
|
|
83
82
|
refers to any such program or work, and a "work based on the Program"
|
|
@@ -94,7 +93,7 @@ is covered only if its contents constitute a work based on the
|
|
|
94
93
|
Program (independent of having been made by running the Program).
|
|
95
94
|
Whether that is true depends on what the Program does.
|
|
96
95
|
|
|
97
|
-
1. You may copy and distribute verbatim copies of the Program's
|
|
96
|
+
1. You may copy and distribute verbatim copies of the Program's
|
|
98
97
|
source code as you receive it, in any medium, provided that you
|
|
99
98
|
conspicuously and appropriately publish on each copy an appropriate
|
|
100
99
|
copyright notice and disclaimer of warranty; keep intact all the
|
|
@@ -105,29 +104,29 @@ along with the Program.
|
|
|
105
104
|
You may charge a fee for the physical act of transferring a copy, and
|
|
106
105
|
you may at your option offer warranty protection in exchange for a fee.
|
|
107
106
|
|
|
108
|
-
2. You may modify your copy or copies of the Program or any portion
|
|
107
|
+
2. You may modify your copy or copies of the Program or any portion
|
|
109
108
|
of it, thus forming a work based on the Program, and copy and
|
|
110
109
|
distribute such modifications or work under the terms of Section 1
|
|
111
110
|
above, provided that you also meet all of these conditions:
|
|
112
111
|
|
|
113
|
-
a) You must cause the modified files to carry prominent notices
|
|
114
|
-
stating that you changed the files and the date of any change.
|
|
115
|
-
|
|
116
|
-
b) You must cause any work that you distribute or publish, that in
|
|
117
|
-
whole or in part contains or is derived from the Program or any
|
|
118
|
-
part thereof, to be licensed as a whole at no charge to all third
|
|
119
|
-
parties under the terms of this License.
|
|
120
|
-
|
|
121
|
-
c) If the modified program normally reads commands interactively
|
|
122
|
-
when run, you must cause it, when started running for such
|
|
123
|
-
interactive use in the most ordinary way, to print or display an
|
|
124
|
-
announcement including an appropriate copyright notice and a
|
|
125
|
-
notice that there is no warranty (or else, saying that you provide
|
|
126
|
-
a warranty) and that users may redistribute the program under
|
|
127
|
-
these conditions, and telling the user how to view a copy of this
|
|
128
|
-
License. (Exception: if the Program itself is interactive but
|
|
129
|
-
does not normally print such an announcement, your work based on
|
|
130
|
-
the Program is not required to print an announcement.)
|
|
112
|
+
a) You must cause the modified files to carry prominent notices
|
|
113
|
+
stating that you changed the files and the date of any change.
|
|
114
|
+
|
|
115
|
+
b) You must cause any work that you distribute or publish, that in
|
|
116
|
+
whole or in part contains or is derived from the Program or any
|
|
117
|
+
part thereof, to be licensed as a whole at no charge to all third
|
|
118
|
+
parties under the terms of this License.
|
|
119
|
+
|
|
120
|
+
c) If the modified program normally reads commands interactively
|
|
121
|
+
when run, you must cause it, when started running for such
|
|
122
|
+
interactive use in the most ordinary way, to print or display an
|
|
123
|
+
announcement including an appropriate copyright notice and a
|
|
124
|
+
notice that there is no warranty (or else, saying that you provide
|
|
125
|
+
a warranty) and that users may redistribute the program under
|
|
126
|
+
these conditions, and telling the user how to view a copy of this
|
|
127
|
+
License. (Exception: if the Program itself is interactive but
|
|
128
|
+
does not normally print such an announcement, your work based on
|
|
129
|
+
the Program is not required to print an announcement.)
|
|
131
130
|
|
|
132
131
|
These requirements apply to the modified work as a whole. If
|
|
133
132
|
identifiable sections of that work are not derived from the Program,
|
|
@@ -149,26 +148,26 @@ with the Program (or with a work based on the Program) on a volume of
|
|
|
149
148
|
a storage or distribution medium does not bring the other work under
|
|
150
149
|
the scope of this License.
|
|
151
150
|
|
|
152
|
-
3. You may copy and distribute the Program (or a work based on it,
|
|
151
|
+
3. You may copy and distribute the Program (or a work based on it,
|
|
153
152
|
under Section 2) in object code or executable form under the terms of
|
|
154
153
|
Sections 1 and 2 above provided that you also do one of the following:
|
|
155
154
|
|
|
156
|
-
a) Accompany it with the complete corresponding machine-readable
|
|
157
|
-
source code, which must be distributed under the terms of Sections
|
|
158
|
-
1 and 2 above on a medium customarily used for software interchange; or,
|
|
155
|
+
a) Accompany it with the complete corresponding machine-readable
|
|
156
|
+
source code, which must be distributed under the terms of Sections
|
|
157
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
|
159
158
|
|
|
160
|
-
b) Accompany it with a written offer, valid for at least three
|
|
161
|
-
years, to give any third party, for a charge no more than your
|
|
162
|
-
cost of physically performing source distribution, a complete
|
|
163
|
-
machine-readable copy of the corresponding source code, to be
|
|
164
|
-
distributed under the terms of Sections 1 and 2 above on a medium
|
|
165
|
-
customarily used for software interchange; or,
|
|
159
|
+
b) Accompany it with a written offer, valid for at least three
|
|
160
|
+
years, to give any third party, for a charge no more than your
|
|
161
|
+
cost of physically performing source distribution, a complete
|
|
162
|
+
machine-readable copy of the corresponding source code, to be
|
|
163
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
|
164
|
+
customarily used for software interchange; or,
|
|
166
165
|
|
|
167
|
-
c) Accompany it with the information you received as to the offer
|
|
168
|
-
to distribute corresponding source code. (This alternative is
|
|
169
|
-
allowed only for noncommercial distribution and only if you
|
|
170
|
-
received the program in object code or executable form with such
|
|
171
|
-
an offer, in accord with Subsection b above.)
|
|
166
|
+
c) Accompany it with the information you received as to the offer
|
|
167
|
+
to distribute corresponding source code. (This alternative is
|
|
168
|
+
allowed only for noncommercial distribution and only if you
|
|
169
|
+
received the program in object code or executable form with such
|
|
170
|
+
an offer, in accord with Subsection b above.)
|
|
172
171
|
|
|
173
172
|
The source code for a work means the preferred form of the work for
|
|
174
173
|
making modifications to it. For an executable work, complete source
|
|
@@ -187,7 +186,7 @@ access to copy the source code from the same place counts as
|
|
|
187
186
|
distribution of the source code, even though third parties are not
|
|
188
187
|
compelled to copy the source along with the object code.
|
|
189
188
|
|
|
190
|
-
4. You may not copy, modify, sublicense, or distribute the Program
|
|
189
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
|
191
190
|
except as expressly provided under this License. Any attempt
|
|
192
191
|
otherwise to copy, modify, sublicense or distribute the Program is
|
|
193
192
|
void, and will automatically terminate your rights under this License.
|
|
@@ -195,7 +194,7 @@ However, parties who have received copies, or rights, from you under
|
|
|
195
194
|
this License will not have their licenses terminated so long as such
|
|
196
195
|
parties remain in full compliance.
|
|
197
196
|
|
|
198
|
-
5. You are not required to accept this License, since you have not
|
|
197
|
+
5. You are not required to accept this License, since you have not
|
|
199
198
|
signed it. However, nothing else grants you permission to modify or
|
|
200
199
|
distribute the Program or its derivative works. These actions are
|
|
201
200
|
prohibited by law if you do not accept this License. Therefore, by
|
|
@@ -204,7 +203,7 @@ Program), you indicate your acceptance of this License to do so, and
|
|
|
204
203
|
all its terms and conditions for copying, distributing or modifying
|
|
205
204
|
the Program or works based on it.
|
|
206
205
|
|
|
207
|
-
6. Each time you redistribute the Program (or any work based on the
|
|
206
|
+
6. Each time you redistribute the Program (or any work based on the
|
|
208
207
|
Program), the recipient automatically receives a license from the
|
|
209
208
|
original licensor to copy, distribute or modify the Program subject to
|
|
210
209
|
these terms and conditions. You may not impose any further
|
|
@@ -212,7 +211,7 @@ restrictions on the recipients' exercise of the rights granted herein.
|
|
|
212
211
|
You are not responsible for enforcing compliance by third parties to
|
|
213
212
|
this License.
|
|
214
213
|
|
|
215
|
-
7. If, as a consequence of a court judgment or allegation of patent
|
|
214
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
|
216
215
|
infringement or for any other reason (not limited to patent issues),
|
|
217
216
|
conditions are imposed on you (whether by court order, agreement or
|
|
218
217
|
otherwise) that contradict the conditions of this License, they do not
|
|
@@ -244,7 +243,7 @@ impose that choice.
|
|
|
244
243
|
This section is intended to make thoroughly clear what is believed to
|
|
245
244
|
be a consequence of the rest of this License.
|
|
246
245
|
|
|
247
|
-
8. If the distribution and/or use of the Program is restricted in
|
|
246
|
+
8. If the distribution and/or use of the Program is restricted in
|
|
248
247
|
certain countries either by patents or by copyrighted interfaces, the
|
|
249
248
|
original copyright holder who places the Program under this License
|
|
250
249
|
may add an explicit geographical distribution limitation excluding
|
|
@@ -252,7 +251,7 @@ those countries, so that distribution is permitted only in or among
|
|
|
252
251
|
countries not thus excluded. In such case, this License incorporates
|
|
253
252
|
the limitation as if written in the body of this License.
|
|
254
253
|
|
|
255
|
-
9. The Free Software Foundation may publish revised and/or new versions
|
|
254
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
|
256
255
|
of the General Public License from time to time. Such new versions will
|
|
257
256
|
be similar in spirit to the present version, but may differ in detail to
|
|
258
257
|
address new problems or concerns.
|
|
@@ -265,7 +264,7 @@ Software Foundation. If the Program does not specify a version number of
|
|
|
265
264
|
this License, you may choose any version ever published by the Free Software
|
|
266
265
|
Foundation.
|
|
267
266
|
|
|
268
|
-
10. If you wish to incorporate parts of the Program into other free
|
|
267
|
+
10. If you wish to incorporate parts of the Program into other free
|
|
269
268
|
programs whose distribution conditions are different, write to the author
|
|
270
269
|
to ask for permission. For software which is copyrighted by the Free
|
|
271
270
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
@@ -273,9 +272,9 @@ make exceptions for this. Our decision will be guided by the two goals
|
|
|
273
272
|
of preserving the free status of all derivatives of our free software and
|
|
274
273
|
of promoting the sharing and reuse of software generally.
|
|
275
274
|
|
|
276
|
-
|
|
275
|
+
NO WARRANTY
|
|
277
276
|
|
|
278
|
-
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
277
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
279
278
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
280
279
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
281
280
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
@@ -285,7 +284,7 @@ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
|
285
284
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
286
285
|
REPAIR OR CORRECTION.
|
|
287
286
|
|
|
288
|
-
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
287
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
289
288
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
290
289
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
291
290
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
@@ -295,45 +294,44 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
|
295
294
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
296
295
|
POSSIBILITY OF SUCH DAMAGES.
|
|
297
296
|
|
|
298
|
-
|
|
297
|
+
END OF TERMS AND CONDITIONS
|
|
299
298
|
|
|
300
|
-
How to Apply These Terms to Your New Programs
|
|
299
|
+
How to Apply These Terms to Your New Programs
|
|
301
300
|
|
|
302
|
-
If you develop a new program, and you want it to be of the greatest
|
|
301
|
+
If you develop a new program, and you want it to be of the greatest
|
|
303
302
|
possible use to the public, the best way to achieve this is to make it
|
|
304
303
|
free software which everyone can redistribute and change under these terms.
|
|
305
304
|
|
|
306
|
-
To do so, attach the following notices to the program. It is safest
|
|
305
|
+
To do so, attach the following notices to the program. It is safest
|
|
307
306
|
to attach them to the start of each source file to most effectively
|
|
308
307
|
convey the exclusion of warranty; and each file should have at least
|
|
309
308
|
the "copyright" line and a pointer to where the full notice is found.
|
|
310
309
|
|
|
311
|
-
<one line to give the program's name and a brief idea of what it does.>
|
|
312
|
-
Copyright (C) <year> <name of author>
|
|
310
|
+
<one line to give the program's name and a brief idea of what it does.>
|
|
311
|
+
Copyright (C) <year> <name of author>
|
|
313
312
|
|
|
314
|
-
This program is free software; you can redistribute it and/or modify
|
|
315
|
-
it under the terms of the GNU General Public License as published by
|
|
316
|
-
the Free Software Foundation; either version 2 of the License, or
|
|
317
|
-
(at your option) any later version.
|
|
313
|
+
This program is free software; you can redistribute it and/or modify
|
|
314
|
+
it under the terms of the GNU General Public License as published by
|
|
315
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
316
|
+
(at your option) any later version.
|
|
318
317
|
|
|
319
|
-
This program is distributed in the hope that it will be useful,
|
|
320
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
321
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
322
|
-
GNU General Public License for more details.
|
|
318
|
+
This program is distributed in the hope that it will be useful,
|
|
319
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
320
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
321
|
+
GNU General Public License for more details.
|
|
323
322
|
|
|
324
|
-
You should have received a copy of the GNU General Public License along
|
|
325
|
-
with this program; if not,
|
|
326
|
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
323
|
+
You should have received a copy of the GNU General Public License along
|
|
324
|
+
with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
327
325
|
|
|
328
326
|
Also add information on how to contact you by electronic and paper mail.
|
|
329
327
|
|
|
330
328
|
If the program is interactive, make it output a short notice like this
|
|
331
329
|
when it starts in an interactive mode:
|
|
332
330
|
|
|
333
|
-
Gnomovision version 69, Copyright (C) year name of author
|
|
334
|
-
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
335
|
-
This is free software, and you are welcome to redistribute it
|
|
336
|
-
under certain conditions; type `show c' for details.
|
|
331
|
+
Gnomovision version 69, Copyright (C) year name of author
|
|
332
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
333
|
+
This is free software, and you are welcome to redistribute it
|
|
334
|
+
under certain conditions; type `show c' for details.
|
|
337
335
|
|
|
338
336
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
339
337
|
parts of the General Public License. Of course, the commands you use may
|
|
@@ -344,11 +342,11 @@ You should also get your employer (if you work as a programmer) or your
|
|
|
344
342
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
345
343
|
necessary. Here is a sample; alter the names:
|
|
346
344
|
|
|
347
|
-
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
348
|
-
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
345
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
346
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
349
347
|
|
|
350
|
-
<signature of
|
|
351
|
-
|
|
348
|
+
<signature of Moe Ghoul>, 1 April 1989
|
|
349
|
+
Moe Ghoul, President of Vice
|
|
352
350
|
|
|
353
351
|
This General Public License does not permit incorporating your program into
|
|
354
352
|
proprietary programs. If your program is a subroutine library, you may
|
package/bin/jp.js
CHANGED
|
@@ -6,7 +6,7 @@ import { dirname, resolve } from 'path';
|
|
|
6
6
|
import process from 'process';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import chalk from 'chalk';
|
|
9
|
-
import dotenv from 'dotenv';
|
|
9
|
+
import * as dotenv from 'dotenv';
|
|
10
10
|
import prompts from 'prompts';
|
|
11
11
|
import updateNotifier from 'update-notifier';
|
|
12
12
|
|
|
@@ -42,6 +42,37 @@ const isMonorepoRoot = dir => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Check if the CLI is running from monorepo source (vs npm installed).
|
|
47
|
+
*
|
|
48
|
+
* @return {boolean} True if running from source
|
|
49
|
+
*/
|
|
50
|
+
const isRunningFromSource = () => {
|
|
51
|
+
let dir = __dirname;
|
|
52
|
+
let prevDir;
|
|
53
|
+
while ( dir !== prevDir ) {
|
|
54
|
+
if ( isMonorepoRoot( dir ) ) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
prevDir = dir;
|
|
58
|
+
dir = dirname( dir );
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Compute development version by incrementing patch number.
|
|
65
|
+
*
|
|
66
|
+
* @return {string} Development version string (e.g., "1.0.3-alpha" for released "1.0.2")
|
|
67
|
+
*/
|
|
68
|
+
const computeDevVersion = () => {
|
|
69
|
+
const [ major, minor, patch ] = packageJson.version.split( '.' ).map( Number );
|
|
70
|
+
return `${ major }.${ minor }.${ patch + 1 }-alpha`;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Version to display - dev version when running from source, package version otherwise
|
|
74
|
+
const displayVersion = isRunningFromSource() ? computeDevVersion() : packageJson.version;
|
|
75
|
+
|
|
45
76
|
/**
|
|
46
77
|
* Find monorepo root from a starting directory.
|
|
47
78
|
*
|
|
@@ -81,6 +112,142 @@ const cloneMonorepo = async targetDir => {
|
|
|
81
112
|
}
|
|
82
113
|
};
|
|
83
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Get list of git hooks from the .husky directory.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} monorepoRoot - Path to the monorepo root
|
|
119
|
+
* @return {Array<string>} List of hook names
|
|
120
|
+
*/
|
|
121
|
+
const getHuskyHooks = monorepoRoot => {
|
|
122
|
+
const huskyDir = resolve( monorepoRoot, '.husky' );
|
|
123
|
+
if ( ! fs.existsSync( huskyDir ) ) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Filter for valid git hook names (lowercase letters and hyphens)
|
|
128
|
+
const hookPattern = /^[a-z][a-z-]*$/;
|
|
129
|
+
return fs.readdirSync( huskyDir ).filter( name => {
|
|
130
|
+
const fullPath = resolve( huskyDir, name );
|
|
131
|
+
return hookPattern.test( name ) && fs.statSync( fullPath ).isFile();
|
|
132
|
+
} );
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Check if a husky hook file exists.
|
|
137
|
+
*
|
|
138
|
+
* @param {string} monorepoRoot - Path to the monorepo root
|
|
139
|
+
* @param {string} hookName - Name of the hook
|
|
140
|
+
* @return {boolean} True if the hook exists
|
|
141
|
+
*/
|
|
142
|
+
const huskyHookExists = ( monorepoRoot, hookName ) => {
|
|
143
|
+
return fs.existsSync( resolve( monorepoRoot, '.husky', hookName ) );
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Initialize git hooks that work with Docker.
|
|
148
|
+
*
|
|
149
|
+
* @param {string} monorepoRoot - Path to the monorepo root
|
|
150
|
+
* @throws {Error} If hook installation fails
|
|
151
|
+
*/
|
|
152
|
+
const initHooks = monorepoRoot => {
|
|
153
|
+
const hooksDir = resolve( monorepoRoot, '.git/hooks' );
|
|
154
|
+
|
|
155
|
+
if ( ! fs.existsSync( hooksDir ) ) {
|
|
156
|
+
throw new Error( 'Git hooks directory not found. Is this a git repository?' );
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
console.log( chalk.blue( 'Setting up jp git hooks...' ) );
|
|
160
|
+
|
|
161
|
+
// Check if git is configured to use a custom hooks path (e.g., husky)
|
|
162
|
+
const hooksPathResult = spawnSync( 'git', [ 'config', 'core.hooksPath' ], {
|
|
163
|
+
cwd: monorepoRoot,
|
|
164
|
+
encoding: 'utf8',
|
|
165
|
+
} );
|
|
166
|
+
|
|
167
|
+
if ( hooksPathResult.stdout && hooksPathResult.stdout.trim() ) {
|
|
168
|
+
const currentHooksPath = hooksPathResult.stdout.trim();
|
|
169
|
+
console.log( chalk.yellow( ` Detected custom git hooks path: ${ currentHooksPath }` ) );
|
|
170
|
+
console.log( chalk.yellow( ' Resetting to use .git/hooks/ for jp hooks' ) );
|
|
171
|
+
|
|
172
|
+
const unsetResult = spawnSync( 'git', [ 'config', '--unset', 'core.hooksPath' ], {
|
|
173
|
+
cwd: monorepoRoot,
|
|
174
|
+
} );
|
|
175
|
+
|
|
176
|
+
if ( unsetResult.status !== 0 ) {
|
|
177
|
+
throw new Error( 'Failed to unset core.hooksPath git configuration' );
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const hooks = getHuskyHooks( monorepoRoot );
|
|
182
|
+
if ( hooks.length === 0 ) {
|
|
183
|
+
console.log( chalk.yellow( ' No hooks found in .husky/' ) );
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
for ( const hookName of hooks ) {
|
|
188
|
+
const hookPath = resolve( hooksDir, hookName );
|
|
189
|
+
const hookContent = `#!/bin/sh
|
|
190
|
+
# Jetpack CLI git hook
|
|
191
|
+
# Runs the .husky hook in Docker to ensure consistent environment
|
|
192
|
+
|
|
193
|
+
# Exit gracefully if the .husky hook was removed
|
|
194
|
+
if [ ! -f .husky/${ hookName } ]; then
|
|
195
|
+
exit 0
|
|
196
|
+
fi
|
|
197
|
+
|
|
198
|
+
# Check if we're already in the Docker container
|
|
199
|
+
if [ -n "$JETPACK_MONOREPO_ENV" ]; then
|
|
200
|
+
echo "✓ Using jp hooks (running in Docker)"
|
|
201
|
+
sh .husky/${ hookName } "$@"
|
|
202
|
+
exit $?
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
# Not in Docker - delegate to jp to run in Docker
|
|
206
|
+
echo "✓ Using jp hooks (delegating to Docker)"
|
|
207
|
+
jp git-hook ${ hookName } "$@"
|
|
208
|
+
exit $?
|
|
209
|
+
`;
|
|
210
|
+
|
|
211
|
+
fs.writeFileSync( hookPath, hookContent, { mode: 0o755 } );
|
|
212
|
+
console.log( chalk.green( ` Created ${ hookName } hook` ) );
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
console.log(
|
|
216
|
+
chalk.green( '\n✓ Git hooks installed! Hooks will run automatically in Docker.\n' )
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Run a git hook inside the Docker container.
|
|
222
|
+
*
|
|
223
|
+
* @param {string} monorepoRoot - Path to the monorepo root
|
|
224
|
+
* @param {string} hookName - Name of the hook to run
|
|
225
|
+
* @param {Array} hookArgs - Arguments to pass to the hook
|
|
226
|
+
* @throws {Error} If hook execution fails
|
|
227
|
+
*/
|
|
228
|
+
const runGitHook = ( monorepoRoot, hookName, hookArgs ) => {
|
|
229
|
+
console.log( chalk.blue( `Running ${ hookName } hook in Docker...` ) );
|
|
230
|
+
|
|
231
|
+
if ( ! huskyHookExists( monorepoRoot, hookName ) ) {
|
|
232
|
+
throw new Error( `Unknown git hook: ${ hookName }` );
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Run the .husky hook directly through the monorepo script
|
|
236
|
+
// TTY detection is handled by the monorepo script itself (reconnects to /dev/tty if available)
|
|
237
|
+
const result = spawnSync(
|
|
238
|
+
resolve( monorepoRoot, 'tools/docker/bin/monorepo' ),
|
|
239
|
+
[ 'sh', `.husky/${ hookName }`, ...hookArgs ],
|
|
240
|
+
{
|
|
241
|
+
stdio: 'inherit',
|
|
242
|
+
cwd: monorepoRoot,
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
if ( result.status !== 0 ) {
|
|
247
|
+
throw new Error( `Git hook ${ hookName } failed with status ${ result.status }` );
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
84
251
|
/**
|
|
85
252
|
* Initialize a new Jetpack development environment.
|
|
86
253
|
*
|
|
@@ -109,6 +276,9 @@ const initJetpack = async () => {
|
|
|
109
276
|
|
|
110
277
|
console.log( chalk.green( '\nJetpack monorepo has been cloned successfully!' ) );
|
|
111
278
|
|
|
279
|
+
// Initialize git hooks
|
|
280
|
+
initHooks( targetDir );
|
|
281
|
+
|
|
112
282
|
console.log( '\nNext steps:' );
|
|
113
283
|
|
|
114
284
|
console.log( '1. cd', response.directory );
|
|
@@ -128,7 +298,7 @@ const main = async () => {
|
|
|
128
298
|
|
|
129
299
|
// Handle version flag
|
|
130
300
|
if ( args[ 0 ] === '--version' || args[ 0 ] === '-v' ) {
|
|
131
|
-
console.log( chalk.green(
|
|
301
|
+
console.log( chalk.green( displayVersion ) );
|
|
132
302
|
return;
|
|
133
303
|
}
|
|
134
304
|
|
|
@@ -154,6 +324,27 @@ const main = async () => {
|
|
|
154
324
|
throw new Error( 'Monorepo not found' );
|
|
155
325
|
}
|
|
156
326
|
|
|
327
|
+
// Handle 'init-hooks' command
|
|
328
|
+
if ( args[ 0 ] === 'init-hooks' ) {
|
|
329
|
+
initHooks( monorepoRoot );
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Handle 'git-hook' command
|
|
334
|
+
if ( args[ 0 ] === 'git-hook' ) {
|
|
335
|
+
const hookName = args[ 1 ];
|
|
336
|
+
const hookArgs = args.slice( 2 );
|
|
337
|
+
|
|
338
|
+
if ( ! hookName ) {
|
|
339
|
+
console.error( chalk.red( 'Error: git-hook command requires a hook name' ) );
|
|
340
|
+
console.log( 'Usage: jp git-hook <hook-name> [args...]' );
|
|
341
|
+
throw new Error( 'Missing hook name' );
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
runGitHook( monorepoRoot, hookName, hookArgs );
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
157
348
|
// Handle docker commands that must run on the host machine
|
|
158
349
|
if ( args[ 0 ] === 'docker' ) {
|
|
159
350
|
const hostCommands = [ 'up', 'down', 'stop', 'clean' ];
|
|
@@ -312,8 +503,7 @@ const main = async () => {
|
|
|
312
503
|
[ 'pnpm', 'jetpack', ...args ],
|
|
313
504
|
{
|
|
314
505
|
stdio: 'inherit',
|
|
315
|
-
|
|
316
|
-
cwd: monorepoRoot, // Ensure we're in the monorepo root when running commands
|
|
506
|
+
cwd: monorepoRoot,
|
|
317
507
|
}
|
|
318
508
|
);
|
|
319
509
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Docker-based CLI for Jetpack development",
|
|
5
5
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/jetpack-cli/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"url": "https://github.com/Automattic/jetpack.git",
|
|
12
12
|
"directory": "projects/js-packages/jetpack-cli"
|
|
13
13
|
},
|
|
14
|
+
"license": "GPL-2.0-or-later",
|
|
14
15
|
"type": "module",
|
|
15
16
|
"bin": {
|
|
16
17
|
"jp": "bin/jp.js"
|