@loopress/cli 0.4.0 → 0.6.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/README.md +122 -102
- package/dist/commands/{style → composer}/pull.d.ts +2 -2
- package/dist/commands/composer/pull.js +33 -0
- package/dist/commands/{style → composer}/push.d.ts +3 -4
- package/dist/commands/composer/push.js +49 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.js +73 -0
- package/dist/commands/plugin/{require.d.ts → add.d.ts} +3 -1
- package/dist/commands/plugin/{require.js → add.js} +29 -8
- package/dist/commands/plugin/pull.js +10 -1
- package/dist/commands/plugin/push.d.ts +2 -2
- package/dist/commands/plugin/push.js +15 -4
- package/dist/commands/project/config.js +2 -2
- package/dist/commands/snippet/list.d.ts +1 -1
- package/dist/commands/snippet/list.js +3 -3
- package/dist/commands/snippet/pull.d.ts +4 -1
- package/dist/commands/snippet/pull.js +26 -37
- package/dist/commands/snippet/push.d.ts +4 -5
- package/dist/commands/snippet/push.js +50 -39
- package/dist/config/auth.manager.js +2 -2
- package/dist/config/project-config.manager.js +2 -2
- package/dist/lib/base.d.ts +1 -1
- package/dist/lib/base.js +18 -6
- package/dist/lib/push-command.d.ts +7 -0
- package/dist/lib/push-command.js +32 -0
- package/dist/utils/composer.d.ts +7 -0
- package/dist/utils/composer.js +33 -0
- package/dist/utils/loopress-config.d.ts +3 -2
- package/dist/utils/snippet-plugin.js +1 -1
- package/oclif.manifest.json +238 -220
- package/package.json +17 -17
- package/dist/commands/style/pull.js +0 -52
- package/dist/commands/style/push.js +0 -78
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @loopress/cli
|
|
|
20
20
|
$ lps COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ lps (--version)
|
|
23
|
-
@loopress/cli/0.
|
|
23
|
+
@loopress/cli/0.6.0 linux-x64 node-v24.17.0
|
|
24
24
|
$ lps --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ lps COMMAND
|
|
@@ -31,12 +31,15 @@ USAGE
|
|
|
31
31
|
# Commands
|
|
32
32
|
|
|
33
33
|
<!-- commands -->
|
|
34
|
+
* [`lps composer pull`](#lps-composer-pull)
|
|
35
|
+
* [`lps composer push`](#lps-composer-push)
|
|
34
36
|
* [`lps help [COMMAND]`](#lps-help-command)
|
|
37
|
+
* [`lps init`](#lps-init)
|
|
35
38
|
* [`lps login`](#lps-login)
|
|
36
39
|
* [`lps logout`](#lps-logout)
|
|
40
|
+
* [`lps plugin add SLUG [VERSION]`](#lps-plugin-add-slug-version)
|
|
37
41
|
* [`lps plugin pull`](#lps-plugin-pull)
|
|
38
42
|
* [`lps plugin push`](#lps-plugin-push)
|
|
39
|
-
* [`lps plugin require SLUG [VERSION]`](#lps-plugin-require-slug-version)
|
|
40
43
|
* [`lps project config`](#lps-project-config)
|
|
41
44
|
* [`lps project list`](#lps-project-list)
|
|
42
45
|
* [`lps project remove`](#lps-project-remove)
|
|
@@ -46,8 +49,60 @@ USAGE
|
|
|
46
49
|
* [`lps snippet list`](#lps-snippet-list)
|
|
47
50
|
* [`lps snippet pull [PATH]`](#lps-snippet-pull-path)
|
|
48
51
|
* [`lps snippet push [PATH]`](#lps-snippet-push-path)
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
|
|
53
|
+
## `lps composer pull`
|
|
54
|
+
|
|
55
|
+
Pull composer.lock from the WordPress server
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
USAGE
|
|
59
|
+
$ lps composer pull [--password <value>] [--url <value>] [--user <value>] [-d]
|
|
60
|
+
|
|
61
|
+
FLAGS
|
|
62
|
+
-d, --dry-run Show what would be written without making changes
|
|
63
|
+
|
|
64
|
+
GLOBAL FLAGS
|
|
65
|
+
--password=<value> WordPress application password (fallback; prefer `lps project config`)
|
|
66
|
+
--url=<value> WordPress URL (fallback; prefer `lps project config`)
|
|
67
|
+
--user=<value> WordPress username (fallback; prefer `lps project config`)
|
|
68
|
+
|
|
69
|
+
DESCRIPTION
|
|
70
|
+
Pull composer.lock from the WordPress server
|
|
71
|
+
|
|
72
|
+
EXAMPLES
|
|
73
|
+
$ lps composer pull
|
|
74
|
+
|
|
75
|
+
$ lps composer pull --dry-run
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
_See code: [src/commands/composer/pull.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/composer/pull.ts)_
|
|
79
|
+
|
|
80
|
+
## `lps composer push`
|
|
81
|
+
|
|
82
|
+
Upload composer.json and composer.lock to WordPress and run composer install
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
USAGE
|
|
86
|
+
$ lps composer push [--password <value>] [--url <value>] [--user <value>] [-d]
|
|
87
|
+
|
|
88
|
+
FLAGS
|
|
89
|
+
-d, --dry-run Show what would change without making changes
|
|
90
|
+
|
|
91
|
+
GLOBAL FLAGS
|
|
92
|
+
--password=<value> WordPress application password (fallback; prefer `lps project config`)
|
|
93
|
+
--url=<value> WordPress URL (fallback; prefer `lps project config`)
|
|
94
|
+
--user=<value> WordPress username (fallback; prefer `lps project config`)
|
|
95
|
+
|
|
96
|
+
DESCRIPTION
|
|
97
|
+
Upload composer.json and composer.lock to WordPress and run composer install
|
|
98
|
+
|
|
99
|
+
EXAMPLES
|
|
100
|
+
$ lps composer push
|
|
101
|
+
|
|
102
|
+
$ lps composer push --dry-run
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
_See code: [src/commands/composer/push.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/composer/push.ts)_
|
|
51
106
|
|
|
52
107
|
## `lps help [COMMAND]`
|
|
53
108
|
|
|
@@ -67,7 +122,24 @@ DESCRIPTION
|
|
|
67
122
|
Display help for lps.
|
|
68
123
|
```
|
|
69
124
|
|
|
70
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/6.2.
|
|
125
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/6.2.53/src/commands/help.ts)_
|
|
126
|
+
|
|
127
|
+
## `lps init`
|
|
128
|
+
|
|
129
|
+
Initialize a loopress.json config file in the current directory
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
USAGE
|
|
133
|
+
$ lps init
|
|
134
|
+
|
|
135
|
+
DESCRIPTION
|
|
136
|
+
Initialize a loopress.json config file in the current directory
|
|
137
|
+
|
|
138
|
+
EXAMPLES
|
|
139
|
+
$ lps init
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
_See code: [src/commands/init.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/init.ts)_
|
|
71
143
|
|
|
72
144
|
## `lps login`
|
|
73
145
|
|
|
@@ -84,7 +156,7 @@ EXAMPLES
|
|
|
84
156
|
$ lps login
|
|
85
157
|
```
|
|
86
158
|
|
|
87
|
-
_See code: [src/commands/login.ts](https://github.com/loopress/loopress/blob/v0.
|
|
159
|
+
_See code: [src/commands/login.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/login.ts)_
|
|
88
160
|
|
|
89
161
|
## `lps logout`
|
|
90
162
|
|
|
@@ -101,15 +173,19 @@ EXAMPLES
|
|
|
101
173
|
$ lps logout
|
|
102
174
|
```
|
|
103
175
|
|
|
104
|
-
_See code: [src/commands/logout.ts](https://github.com/loopress/loopress/blob/v0.
|
|
176
|
+
_See code: [src/commands/logout.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/logout.ts)_
|
|
105
177
|
|
|
106
|
-
## `lps plugin
|
|
178
|
+
## `lps plugin add SLUG [VERSION]`
|
|
107
179
|
|
|
108
|
-
|
|
180
|
+
Add a plugin to loopress.json (WordPress.org) or run composer require (vendor/package)
|
|
109
181
|
|
|
110
182
|
```
|
|
111
183
|
USAGE
|
|
112
|
-
$ lps plugin
|
|
184
|
+
$ lps plugin add SLUG [VERSION] [--password <value>] [--url <value>] [--user <value>] [-d]
|
|
185
|
+
|
|
186
|
+
ARGUMENTS
|
|
187
|
+
SLUG Plugin slug (WordPress.org) or Composer package (vendor/package)
|
|
188
|
+
[VERSION] Version to pin (default: latest)
|
|
113
189
|
|
|
114
190
|
FLAGS
|
|
115
191
|
-d, --dry-run Show what would be written without making changes
|
|
@@ -120,26 +196,30 @@ GLOBAL FLAGS
|
|
|
120
196
|
--user=<value> WordPress username (fallback; prefer `lps project config`)
|
|
121
197
|
|
|
122
198
|
DESCRIPTION
|
|
123
|
-
|
|
199
|
+
Add a plugin to loopress.json (WordPress.org) or run composer require (vendor/package)
|
|
124
200
|
|
|
125
201
|
EXAMPLES
|
|
126
|
-
$ lps
|
|
202
|
+
$ lps plugin add woocommerce
|
|
127
203
|
|
|
128
|
-
$ lps
|
|
204
|
+
$ lps plugin add woocommerce 8.9.1
|
|
205
|
+
|
|
206
|
+
$ lps plugin add wpackagist-plugin/advanced-custom-fields
|
|
207
|
+
|
|
208
|
+
$ lps plugin add contact-form-7 --dry-run
|
|
129
209
|
```
|
|
130
210
|
|
|
131
|
-
_See code: [src/commands/plugin/
|
|
211
|
+
_See code: [src/commands/plugin/add.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/plugin/add.ts)_
|
|
132
212
|
|
|
133
|
-
## `lps plugin
|
|
213
|
+
## `lps plugin pull`
|
|
134
214
|
|
|
135
|
-
|
|
215
|
+
Pull installed plugins from WordPress into loopress.json
|
|
136
216
|
|
|
137
217
|
```
|
|
138
218
|
USAGE
|
|
139
|
-
$ lps plugin
|
|
219
|
+
$ lps plugin pull [--password <value>] [--url <value>] [--user <value>] [-d]
|
|
140
220
|
|
|
141
221
|
FLAGS
|
|
142
|
-
-d, --dry-run Show what would
|
|
222
|
+
-d, --dry-run Show what would be written without making changes
|
|
143
223
|
|
|
144
224
|
GLOBAL FLAGS
|
|
145
225
|
--password=<value> WordPress application password (fallback; prefer `lps project config`)
|
|
@@ -147,30 +227,26 @@ GLOBAL FLAGS
|
|
|
147
227
|
--user=<value> WordPress username (fallback; prefer `lps project config`)
|
|
148
228
|
|
|
149
229
|
DESCRIPTION
|
|
150
|
-
|
|
230
|
+
Pull installed plugins from WordPress into loopress.json
|
|
151
231
|
|
|
152
232
|
EXAMPLES
|
|
153
|
-
$ lps plugins
|
|
233
|
+
$ lps plugins pull
|
|
154
234
|
|
|
155
|
-
$ lps plugins
|
|
235
|
+
$ lps plugins pull --dry-run
|
|
156
236
|
```
|
|
157
237
|
|
|
158
|
-
_See code: [src/commands/plugin/
|
|
238
|
+
_See code: [src/commands/plugin/pull.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/plugin/pull.ts)_
|
|
159
239
|
|
|
160
|
-
## `lps plugin
|
|
240
|
+
## `lps plugin push`
|
|
161
241
|
|
|
162
|
-
|
|
242
|
+
Sync plugins on WordPress to match loopress.json
|
|
163
243
|
|
|
164
244
|
```
|
|
165
245
|
USAGE
|
|
166
|
-
$ lps plugin
|
|
167
|
-
|
|
168
|
-
ARGUMENTS
|
|
169
|
-
SLUG Plugin slug (WordPress.org)
|
|
170
|
-
[VERSION] Version to pin (default: latest)
|
|
246
|
+
$ lps plugin push [--password <value>] [--url <value>] [--user <value>] [-d]
|
|
171
247
|
|
|
172
248
|
FLAGS
|
|
173
|
-
-d, --dry-run Show what would
|
|
249
|
+
-d, --dry-run Show what would change without making changes
|
|
174
250
|
|
|
175
251
|
GLOBAL FLAGS
|
|
176
252
|
--password=<value> WordPress application password (fallback; prefer `lps project config`)
|
|
@@ -178,17 +254,15 @@ GLOBAL FLAGS
|
|
|
178
254
|
--user=<value> WordPress username (fallback; prefer `lps project config`)
|
|
179
255
|
|
|
180
256
|
DESCRIPTION
|
|
181
|
-
|
|
257
|
+
Sync plugins on WordPress to match loopress.json
|
|
182
258
|
|
|
183
259
|
EXAMPLES
|
|
184
|
-
$ lps plugins
|
|
185
|
-
|
|
186
|
-
$ lps plugins require woocommerce 8.9.1
|
|
260
|
+
$ lps plugins push
|
|
187
261
|
|
|
188
|
-
$ lps plugins
|
|
262
|
+
$ lps plugins push --dry-run
|
|
189
263
|
```
|
|
190
264
|
|
|
191
|
-
_See code: [src/commands/plugin/
|
|
265
|
+
_See code: [src/commands/plugin/push.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/plugin/push.ts)_
|
|
192
266
|
|
|
193
267
|
## `lps project config`
|
|
194
268
|
|
|
@@ -205,7 +279,7 @@ EXAMPLES
|
|
|
205
279
|
$ lps project config
|
|
206
280
|
```
|
|
207
281
|
|
|
208
|
-
_See code: [src/commands/project/config.ts](https://github.com/loopress/loopress/blob/v0.
|
|
282
|
+
_See code: [src/commands/project/config.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/project/config.ts)_
|
|
209
283
|
|
|
210
284
|
## `lps project list`
|
|
211
285
|
|
|
@@ -222,7 +296,7 @@ EXAMPLES
|
|
|
222
296
|
$ lps project list
|
|
223
297
|
```
|
|
224
298
|
|
|
225
|
-
_See code: [src/commands/project/list.ts](https://github.com/loopress/loopress/blob/v0.
|
|
299
|
+
_See code: [src/commands/project/list.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/project/list.ts)_
|
|
226
300
|
|
|
227
301
|
## `lps project remove`
|
|
228
302
|
|
|
@@ -239,7 +313,7 @@ EXAMPLES
|
|
|
239
313
|
$ lps project remove
|
|
240
314
|
```
|
|
241
315
|
|
|
242
|
-
_See code: [src/commands/project/remove.ts](https://github.com/loopress/loopress/blob/v0.
|
|
316
|
+
_See code: [src/commands/project/remove.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/project/remove.ts)_
|
|
243
317
|
|
|
244
318
|
## `lps project remove-env`
|
|
245
319
|
|
|
@@ -256,7 +330,7 @@ EXAMPLES
|
|
|
256
330
|
$ lps project remove-env
|
|
257
331
|
```
|
|
258
332
|
|
|
259
|
-
_See code: [src/commands/project/remove-env.ts](https://github.com/loopress/loopress/blob/v0.
|
|
333
|
+
_See code: [src/commands/project/remove-env.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/project/remove-env.ts)_
|
|
260
334
|
|
|
261
335
|
## `lps project switch`
|
|
262
336
|
|
|
@@ -273,7 +347,7 @@ EXAMPLES
|
|
|
273
347
|
$ lps project switch
|
|
274
348
|
```
|
|
275
349
|
|
|
276
|
-
_See code: [src/commands/project/switch.ts](https://github.com/loopress/loopress/blob/v0.
|
|
350
|
+
_See code: [src/commands/project/switch.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/project/switch.ts)_
|
|
277
351
|
|
|
278
352
|
## `lps project switch-env`
|
|
279
353
|
|
|
@@ -290,7 +364,7 @@ EXAMPLES
|
|
|
290
364
|
$ lps project switch-env
|
|
291
365
|
```
|
|
292
366
|
|
|
293
|
-
_See code: [src/commands/project/switch-env.ts](https://github.com/loopress/loopress/blob/v0.
|
|
367
|
+
_See code: [src/commands/project/switch-env.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/project/switch-env.ts)_
|
|
294
368
|
|
|
295
369
|
## `lps snippet list`
|
|
296
370
|
|
|
@@ -302,7 +376,7 @@ USAGE
|
|
|
302
376
|
|
|
303
377
|
FLAGS
|
|
304
378
|
-j, --json Output in JSON format
|
|
305
|
-
-p, --plugin=<option>
|
|
379
|
+
-p, --plugin=<option> WordPress snippet plugin to target (overrides loopress.json)
|
|
306
380
|
<options: code-snippets|wpcode>
|
|
307
381
|
|
|
308
382
|
GLOBAL FLAGS
|
|
@@ -321,7 +395,7 @@ EXAMPLES
|
|
|
321
395
|
$ lps snippets list --plugin wpcode
|
|
322
396
|
```
|
|
323
397
|
|
|
324
|
-
_See code: [src/commands/snippet/list.ts](https://github.com/loopress/loopress/blob/v0.
|
|
398
|
+
_See code: [src/commands/snippet/list.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/snippet/list.ts)_
|
|
325
399
|
|
|
326
400
|
## `lps snippet pull [PATH]`
|
|
327
401
|
|
|
@@ -336,7 +410,7 @@ ARGUMENTS
|
|
|
336
410
|
|
|
337
411
|
FLAGS
|
|
338
412
|
-d, --dryRun Dry run - show what would happen without making changes
|
|
339
|
-
-p, --plugin=<option>
|
|
413
|
+
-p, --plugin=<option> WordPress snippet plugin to target (overrides loopress.json)
|
|
340
414
|
<options: code-snippets|wpcode>
|
|
341
415
|
|
|
342
416
|
GLOBAL FLAGS
|
|
@@ -357,7 +431,7 @@ EXAMPLES
|
|
|
357
431
|
$ lps snippets pull --plugin wpcode
|
|
358
432
|
```
|
|
359
433
|
|
|
360
|
-
_See code: [src/commands/snippet/pull.ts](https://github.com/loopress/loopress/blob/v0.
|
|
434
|
+
_See code: [src/commands/snippet/pull.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/snippet/pull.ts)_
|
|
361
435
|
|
|
362
436
|
## `lps snippet push [PATH]`
|
|
363
437
|
|
|
@@ -372,7 +446,7 @@ ARGUMENTS
|
|
|
372
446
|
|
|
373
447
|
FLAGS
|
|
374
448
|
-d, --dryRun Dry run - show what would happen without making changes
|
|
375
|
-
-p, --plugin=<option>
|
|
449
|
+
-p, --plugin=<option> WordPress snippet plugin to target (overrides loopress.json)
|
|
376
450
|
<options: code-snippets|wpcode>
|
|
377
451
|
|
|
378
452
|
GLOBAL FLAGS
|
|
@@ -393,59 +467,5 @@ EXAMPLES
|
|
|
393
467
|
$ lps snippets push --plugin wpcode
|
|
394
468
|
```
|
|
395
469
|
|
|
396
|
-
_See code: [src/commands/snippet/push.ts](https://github.com/loopress/loopress/blob/v0.
|
|
397
|
-
|
|
398
|
-
## `lps style pull`
|
|
399
|
-
|
|
400
|
-
Pull Global Styles from WordPress
|
|
401
|
-
|
|
402
|
-
```
|
|
403
|
-
USAGE
|
|
404
|
-
$ lps style pull [--password <value>] [--url <value>] [--user <value>] [-d]
|
|
405
|
-
|
|
406
|
-
FLAGS
|
|
407
|
-
-d, --dryRun Dry run - show what would happen without making changes
|
|
408
|
-
|
|
409
|
-
GLOBAL FLAGS
|
|
410
|
-
--password=<value> WordPress application password (fallback; prefer `lps project config`)
|
|
411
|
-
--url=<value> WordPress URL (fallback; prefer `lps project config`)
|
|
412
|
-
--user=<value> WordPress username (fallback; prefer `lps project config`)
|
|
413
|
-
|
|
414
|
-
DESCRIPTION
|
|
415
|
-
Pull Global Styles from WordPress
|
|
416
|
-
|
|
417
|
-
EXAMPLES
|
|
418
|
-
$ lps styles pull
|
|
419
|
-
|
|
420
|
-
$ lps styles pull --url http://example.com
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
_See code: [src/commands/style/pull.ts](https://github.com/loopress/loopress/blob/v0.4.0/src/commands/style/pull.ts)_
|
|
424
|
-
|
|
425
|
-
## `lps style push`
|
|
426
|
-
|
|
427
|
-
Push Global Styles to WordPress
|
|
428
|
-
|
|
429
|
-
```
|
|
430
|
-
USAGE
|
|
431
|
-
$ lps style push [--password <value>] [--url <value>] [--user <value>] [-d]
|
|
432
|
-
|
|
433
|
-
FLAGS
|
|
434
|
-
-d, --dryRun Dry run - show what would happen without making changes
|
|
435
|
-
|
|
436
|
-
GLOBAL FLAGS
|
|
437
|
-
--password=<value> WordPress application password (fallback; prefer `lps project config`)
|
|
438
|
-
--url=<value> WordPress URL (fallback; prefer `lps project config`)
|
|
439
|
-
--user=<value> WordPress username (fallback; prefer `lps project config`)
|
|
440
|
-
|
|
441
|
-
DESCRIPTION
|
|
442
|
-
Push Global Styles to WordPress
|
|
443
|
-
|
|
444
|
-
EXAMPLES
|
|
445
|
-
$ lps styles push
|
|
446
|
-
|
|
447
|
-
$ lps styles push --url http://example.com
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
_See code: [src/commands/style/push.ts](https://github.com/loopress/loopress/blob/v0.4.0/src/commands/style/push.ts)_
|
|
470
|
+
_See code: [src/commands/snippet/push.ts](https://github.com/loopress/loopress/blob/v0.6.0/src/commands/snippet/push.ts)_
|
|
451
471
|
<!-- commandsstop -->
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LoopressCommand } from '../../lib/base.js';
|
|
2
|
-
export default class
|
|
2
|
+
export default class ComposerPull extends LoopressCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
6
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
7
|
password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import got from 'got';
|
|
3
|
+
import { writeFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { LoopressCommand } from '../../lib/base.js';
|
|
6
|
+
import { readLocalConfig } from '../../utils/loopress-config.js';
|
|
7
|
+
export default class ComposerPull extends LoopressCommand {
|
|
8
|
+
static description = 'Pull composer.lock from the WordPress server';
|
|
9
|
+
static examples = ['$ lps composer pull', '$ lps composer pull --dry-run'];
|
|
10
|
+
static flags = {
|
|
11
|
+
...LoopressCommand.baseFlags,
|
|
12
|
+
'dry-run': Flags.boolean({ char: 'd', description: 'Show what would be written without making changes' }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { flags } = await this.parse(ComposerPull);
|
|
16
|
+
const dryRun = flags['dry-run'];
|
|
17
|
+
const { url } = this.siteConfig;
|
|
18
|
+
this.log(`Pulling composer.lock from ${url}`);
|
|
19
|
+
const headers = await this.buildAuthHeaders();
|
|
20
|
+
const { composerLock } = await got
|
|
21
|
+
.get(`${url}/wp-json/loopress/v1/composer/lock`, { headers })
|
|
22
|
+
.json();
|
|
23
|
+
if (dryRun) {
|
|
24
|
+
this.log('[dry-run] Would write composer.lock');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const localConfig = await readLocalConfig();
|
|
28
|
+
const rootDir = localConfig.rootDir ?? '.';
|
|
29
|
+
const lockPath = join(process.cwd(), rootDir, 'composer.lock');
|
|
30
|
+
await writeFile(lockPath, composerLock, 'utf8');
|
|
31
|
+
this.log(`Wrote composer.lock`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class
|
|
1
|
+
import { PushCommand } from '../../lib/push-command.js';
|
|
2
|
+
export default class ComposerPush extends PushCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
6
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
7
|
password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
};
|
|
11
11
|
run(): Promise<void>;
|
|
12
|
-
private readOrFetchGlobalStyles;
|
|
13
12
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import got from 'got';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { PushCommand } from '../../lib/push-command.js';
|
|
7
|
+
import { readLocalConfig } from '../../utils/loopress-config.js';
|
|
8
|
+
export default class ComposerPush extends PushCommand {
|
|
9
|
+
static description = 'Upload composer.json and composer.lock to WordPress and run composer install';
|
|
10
|
+
static examples = ['$ lps composer push', '$ lps composer push --dry-run'];
|
|
11
|
+
static flags = {
|
|
12
|
+
...PushCommand.baseFlags,
|
|
13
|
+
'dry-run': Flags.boolean({ char: 'd', description: 'Show what would change without making changes' }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { flags } = await this.parse(ComposerPush);
|
|
17
|
+
const dryRun = flags['dry-run'];
|
|
18
|
+
this.dryRun = dryRun;
|
|
19
|
+
const { url } = this.siteConfig;
|
|
20
|
+
const localConfig = await readLocalConfig();
|
|
21
|
+
const rootDir = localConfig.rootDir ?? '.';
|
|
22
|
+
const composerJsonPath = join(process.cwd(), rootDir, 'composer.json');
|
|
23
|
+
const composerLockPath = join(process.cwd(), rootDir, 'composer.lock');
|
|
24
|
+
if (!existsSync(composerJsonPath)) {
|
|
25
|
+
this.error(`No composer.json found at ${composerJsonPath}`);
|
|
26
|
+
}
|
|
27
|
+
const composerJsonRaw = await readFile(composerJsonPath, 'utf8');
|
|
28
|
+
const parsed = JSON.parse(composerJsonRaw);
|
|
29
|
+
const packageCount = Object.keys(parsed.require ?? {}).length;
|
|
30
|
+
const hasLock = existsSync(composerLockPath);
|
|
31
|
+
const composerLockRaw = hasLock ? await readFile(composerLockPath, 'utf8') : null;
|
|
32
|
+
this.log(`Pushing composer.json (${packageCount} ${packageCount === 1 ? 'package' : 'packages'}) to ${url}`);
|
|
33
|
+
if (composerLockRaw) {
|
|
34
|
+
this.log(' + composer.lock included (reproducible install)');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.warn('No composer.lock found. The server will resolve versions freely.');
|
|
38
|
+
}
|
|
39
|
+
if (dryRun)
|
|
40
|
+
return;
|
|
41
|
+
const headers = await this.buildAuthHeaders();
|
|
42
|
+
await got.post(`${url}/wp-json/loopress/v1/composer/sync`, {
|
|
43
|
+
headers,
|
|
44
|
+
json: { composerJson: composerJsonRaw, composerLock: composerLockRaw },
|
|
45
|
+
});
|
|
46
|
+
this.log('composer install completed on the server.');
|
|
47
|
+
await this.recordSuccess();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { confirm, input, select } from '@inquirer/prompts';
|
|
2
|
+
import { Command } from '@oclif/core';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { configManager } from '../config/project-config.manager.js';
|
|
6
|
+
import { writeLocalConfig } from '../utils/loopress-config.js';
|
|
7
|
+
export default class Init extends Command {
|
|
8
|
+
static description = 'Initialize a loopress.json config file in the current directory';
|
|
9
|
+
static examples = ['$ lps init'];
|
|
10
|
+
async run() {
|
|
11
|
+
await this.parse(Init);
|
|
12
|
+
const configPath = join(process.cwd(), 'loopress.json');
|
|
13
|
+
if (existsSync(configPath)) {
|
|
14
|
+
const overwrite = await confirm({
|
|
15
|
+
default: false,
|
|
16
|
+
message: 'loopress.json already exists. Overwrite?',
|
|
17
|
+
});
|
|
18
|
+
if (!overwrite) {
|
|
19
|
+
this.log('Aborted.');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const projects = configManager.listProjects();
|
|
24
|
+
let projectId;
|
|
25
|
+
if (projects.length > 0) {
|
|
26
|
+
const choices = [
|
|
27
|
+
...projects.map((p) => ({ name: p.name, value: p.name })),
|
|
28
|
+
{ name: 'Enter a project ID manually', value: '__manual__' },
|
|
29
|
+
];
|
|
30
|
+
const choice = await select({
|
|
31
|
+
choices,
|
|
32
|
+
message: 'WordPress project',
|
|
33
|
+
});
|
|
34
|
+
projectId = choice === '__manual__' ? (await input({
|
|
35
|
+
message: 'Project ID',
|
|
36
|
+
validate: (value) => (value.trim().length > 0 ? true : 'Project ID cannot be empty'),
|
|
37
|
+
})) : choice;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.log('No projects configured yet. Run `lps project config` to add one first.');
|
|
41
|
+
projectId = await input({
|
|
42
|
+
message: 'Project ID',
|
|
43
|
+
validate: (value) => (value.trim().length > 0 ? true : 'Project ID cannot be empty'),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const snippetPlugin = await select({
|
|
47
|
+
choices: [
|
|
48
|
+
{ name: 'WPCode', value: 'wpcode' },
|
|
49
|
+
{ name: 'Code Snippets', value: 'code-snippets' },
|
|
50
|
+
],
|
|
51
|
+
message: 'Snippet plugin',
|
|
52
|
+
});
|
|
53
|
+
const rootDir = await input({
|
|
54
|
+
default: '.',
|
|
55
|
+
message: 'Root directory',
|
|
56
|
+
});
|
|
57
|
+
const snippetsDir = await input({
|
|
58
|
+
default: 'snippets',
|
|
59
|
+
message: 'Snippets directory (relative to root)',
|
|
60
|
+
});
|
|
61
|
+
const config = {
|
|
62
|
+
projectId,
|
|
63
|
+
rootDir,
|
|
64
|
+
snippetPlugin: snippetPlugin,
|
|
65
|
+
snippetsDir,
|
|
66
|
+
};
|
|
67
|
+
await writeLocalConfig(config);
|
|
68
|
+
this.log(`\n✓ loopress.json created`);
|
|
69
|
+
this.log(` Project: ${projectId}`);
|
|
70
|
+
this.log(` Plugin: ${snippetPlugin}`);
|
|
71
|
+
this.log(` Snippets: ${join(rootDir, snippetsDir)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LoopressCommand } from '../../lib/base.js';
|
|
2
2
|
export declare function resolvePluginVersion(slug: string, version: string): Promise<string>;
|
|
3
|
-
export default class
|
|
3
|
+
export default class Add extends LoopressCommand {
|
|
4
4
|
static args: {
|
|
5
5
|
slug: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
6
|
version: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
@@ -14,4 +14,6 @@ export default class Require extends LoopressCommand {
|
|
|
14
14
|
user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
};
|
|
16
16
|
run(): Promise<void>;
|
|
17
|
+
private requireComposerPackage;
|
|
18
|
+
private requireWpOrgPlugin;
|
|
17
19
|
}
|