@loopress/cli 0.20.0 → 0.20.1
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 +41 -41
- package/dist/commands/composer/pull.js +38 -3
- package/dist/commands/page/push.js +7 -2
- package/dist/lib/wp-client.js +4 -1
- package/dist/lib/wp-site-diagnostic.d.ts +9 -2
- package/dist/lib/wp-site-diagnostic.js +13 -23
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ $ npm install -g @loopress/cli
|
|
|
21
21
|
$ lps COMMAND
|
|
22
22
|
running command...
|
|
23
23
|
$ lps (--version)
|
|
24
|
-
@loopress/cli/0.20.
|
|
24
|
+
@loopress/cli/0.20.1 linux-x64 node-v24.18.0
|
|
25
25
|
$ lps --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ lps COMMAND
|
|
@@ -112,7 +112,7 @@ EXAMPLES
|
|
|
112
112
|
$ lps acf list --type field-groups
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
_See code: [src/commands/acf/list.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
115
|
+
_See code: [src/commands/acf/list.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/acf/list.ts)_
|
|
116
116
|
|
|
117
117
|
## `lps acf pull [PATH]`
|
|
118
118
|
|
|
@@ -141,7 +141,7 @@ EXAMPLES
|
|
|
141
141
|
$ lps acf pull --type field-groups
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
_See code: [src/commands/acf/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
144
|
+
_See code: [src/commands/acf/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/acf/pull.ts)_
|
|
145
145
|
|
|
146
146
|
## `lps acf push [PATH]`
|
|
147
147
|
|
|
@@ -170,7 +170,7 @@ EXAMPLES
|
|
|
170
170
|
$ lps acf push --type field-groups
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
_See code: [src/commands/acf/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
173
|
+
_See code: [src/commands/acf/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/acf/push.ts)_
|
|
174
174
|
|
|
175
175
|
## `lps api list`
|
|
176
176
|
|
|
@@ -191,7 +191,7 @@ EXAMPLES
|
|
|
191
191
|
$ lps api list
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
_See code: [src/commands/api/list.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
194
|
+
_See code: [src/commands/api/list.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/api/list.ts)_
|
|
195
195
|
|
|
196
196
|
## `lps api publish [PATH]`
|
|
197
197
|
|
|
@@ -214,7 +214,7 @@ EXAMPLES
|
|
|
214
214
|
$ lps api publish --path ./api
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
-
_See code: [src/commands/api/publish.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
217
|
+
_See code: [src/commands/api/publish.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/api/publish.ts)_
|
|
218
218
|
|
|
219
219
|
## `lps api pull [PATH]`
|
|
220
220
|
|
|
@@ -241,7 +241,7 @@ EXAMPLES
|
|
|
241
241
|
$ lps api pull --path ./api
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
-
_See code: [src/commands/api/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
244
|
+
_See code: [src/commands/api/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/api/pull.ts)_
|
|
245
245
|
|
|
246
246
|
## `lps api push [PATH]`
|
|
247
247
|
|
|
@@ -268,7 +268,7 @@ EXAMPLES
|
|
|
268
268
|
$ lps api push --path ./api
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
-
_See code: [src/commands/api/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
271
|
+
_See code: [src/commands/api/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/api/push.ts)_
|
|
272
272
|
|
|
273
273
|
## `lps composer init`
|
|
274
274
|
|
|
@@ -291,7 +291,7 @@ EXAMPLES
|
|
|
291
291
|
$ lps composer init --dry-run
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
_See code: [src/commands/composer/init.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
294
|
+
_See code: [src/commands/composer/init.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/composer/init.ts)_
|
|
295
295
|
|
|
296
296
|
## `lps composer pull`
|
|
297
297
|
|
|
@@ -314,7 +314,7 @@ EXAMPLES
|
|
|
314
314
|
$ lps composer pull --dry-run
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
-
_See code: [src/commands/composer/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
317
|
+
_See code: [src/commands/composer/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/composer/pull.ts)_
|
|
318
318
|
|
|
319
319
|
## `lps composer push`
|
|
320
320
|
|
|
@@ -338,7 +338,7 @@ EXAMPLES
|
|
|
338
338
|
$ lps composer push --dry-run
|
|
339
339
|
```
|
|
340
340
|
|
|
341
|
-
_See code: [src/commands/composer/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
341
|
+
_See code: [src/commands/composer/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/composer/push.ts)_
|
|
342
342
|
|
|
343
343
|
## `lps doctor`
|
|
344
344
|
|
|
@@ -360,7 +360,7 @@ EXAMPLES
|
|
|
360
360
|
$ lps doctor --env production
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
_See code: [src/commands/doctor.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
363
|
+
_See code: [src/commands/doctor.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/doctor.ts)_
|
|
364
364
|
|
|
365
365
|
## `lps form list`
|
|
366
366
|
|
|
@@ -381,7 +381,7 @@ EXAMPLES
|
|
|
381
381
|
$ lps form list
|
|
382
382
|
```
|
|
383
383
|
|
|
384
|
-
_See code: [src/commands/form/list.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
384
|
+
_See code: [src/commands/form/list.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/form/list.ts)_
|
|
385
385
|
|
|
386
386
|
## `lps form pull [PATH]`
|
|
387
387
|
|
|
@@ -406,7 +406,7 @@ EXAMPLES
|
|
|
406
406
|
$ lps form pull
|
|
407
407
|
```
|
|
408
408
|
|
|
409
|
-
_See code: [src/commands/form/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
409
|
+
_See code: [src/commands/form/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/form/pull.ts)_
|
|
410
410
|
|
|
411
411
|
## `lps form push [PATH]`
|
|
412
412
|
|
|
@@ -432,7 +432,7 @@ EXAMPLES
|
|
|
432
432
|
$ lps form push
|
|
433
433
|
```
|
|
434
434
|
|
|
435
|
-
_See code: [src/commands/form/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
435
|
+
_See code: [src/commands/form/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/form/push.ts)_
|
|
436
436
|
|
|
437
437
|
## `lps help [COMMAND]`
|
|
438
438
|
|
|
@@ -469,7 +469,7 @@ EXAMPLES
|
|
|
469
469
|
$ lps init
|
|
470
470
|
```
|
|
471
471
|
|
|
472
|
-
_See code: [src/commands/init.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
472
|
+
_See code: [src/commands/init.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/init.ts)_
|
|
473
473
|
|
|
474
474
|
## `lps login`
|
|
475
475
|
|
|
@@ -486,7 +486,7 @@ EXAMPLES
|
|
|
486
486
|
$ lps login
|
|
487
487
|
```
|
|
488
488
|
|
|
489
|
-
_See code: [src/commands/login.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
489
|
+
_See code: [src/commands/login.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/login.ts)_
|
|
490
490
|
|
|
491
491
|
## `lps logout`
|
|
492
492
|
|
|
@@ -503,7 +503,7 @@ EXAMPLES
|
|
|
503
503
|
$ lps logout
|
|
504
504
|
```
|
|
505
505
|
|
|
506
|
-
_See code: [src/commands/logout.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
506
|
+
_See code: [src/commands/logout.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/logout.ts)_
|
|
507
507
|
|
|
508
508
|
## `lps page list`
|
|
509
509
|
|
|
@@ -524,7 +524,7 @@ EXAMPLES
|
|
|
524
524
|
$ lps page list
|
|
525
525
|
```
|
|
526
526
|
|
|
527
|
-
_See code: [src/commands/page/list.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
527
|
+
_See code: [src/commands/page/list.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/page/list.ts)_
|
|
528
528
|
|
|
529
529
|
## `lps page pull [PATH]`
|
|
530
530
|
|
|
@@ -549,7 +549,7 @@ EXAMPLES
|
|
|
549
549
|
$ lps page pull
|
|
550
550
|
```
|
|
551
551
|
|
|
552
|
-
_See code: [src/commands/page/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
552
|
+
_See code: [src/commands/page/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/page/pull.ts)_
|
|
553
553
|
|
|
554
554
|
## `lps page push [PATH]`
|
|
555
555
|
|
|
@@ -574,7 +574,7 @@ EXAMPLES
|
|
|
574
574
|
$ lps page push
|
|
575
575
|
```
|
|
576
576
|
|
|
577
|
-
_See code: [src/commands/page/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
577
|
+
_See code: [src/commands/page/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/page/push.ts)_
|
|
578
578
|
|
|
579
579
|
## `lps plugin add SLUG`
|
|
580
580
|
|
|
@@ -600,7 +600,7 @@ EXAMPLES
|
|
|
600
600
|
$ lps plugin add contact-form-7 --dry-run
|
|
601
601
|
```
|
|
602
602
|
|
|
603
|
-
_See code: [src/commands/plugin/add.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
603
|
+
_See code: [src/commands/plugin/add.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/plugin/add.ts)_
|
|
604
604
|
|
|
605
605
|
## `lps plugin pull`
|
|
606
606
|
|
|
@@ -623,7 +623,7 @@ EXAMPLES
|
|
|
623
623
|
$ lps plugin pull --dry-run
|
|
624
624
|
```
|
|
625
625
|
|
|
626
|
-
_See code: [src/commands/plugin/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
626
|
+
_See code: [src/commands/plugin/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/plugin/pull.ts)_
|
|
627
627
|
|
|
628
628
|
## `lps plugin push`
|
|
629
629
|
|
|
@@ -647,7 +647,7 @@ EXAMPLES
|
|
|
647
647
|
$ lps plugin push --dry-run
|
|
648
648
|
```
|
|
649
649
|
|
|
650
|
-
_See code: [src/commands/plugin/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
650
|
+
_See code: [src/commands/plugin/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/plugin/push.ts)_
|
|
651
651
|
|
|
652
652
|
## `lps project config`
|
|
653
653
|
|
|
@@ -665,7 +665,7 @@ EXAMPLES
|
|
|
665
665
|
$ lps project config
|
|
666
666
|
```
|
|
667
667
|
|
|
668
|
-
_See code: [src/commands/project/config.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
668
|
+
_See code: [src/commands/project/config.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/project/config.ts)_
|
|
669
669
|
|
|
670
670
|
## `lps project list`
|
|
671
671
|
|
|
@@ -682,7 +682,7 @@ EXAMPLES
|
|
|
682
682
|
$ lps project list
|
|
683
683
|
```
|
|
684
684
|
|
|
685
|
-
_See code: [src/commands/project/list.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
685
|
+
_See code: [src/commands/project/list.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/project/list.ts)_
|
|
686
686
|
|
|
687
687
|
## `lps project pull`
|
|
688
688
|
|
|
@@ -699,7 +699,7 @@ EXAMPLES
|
|
|
699
699
|
$ lps project pull
|
|
700
700
|
```
|
|
701
701
|
|
|
702
|
-
_See code: [src/commands/project/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
702
|
+
_See code: [src/commands/project/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/project/pull.ts)_
|
|
703
703
|
|
|
704
704
|
## `lps project push`
|
|
705
705
|
|
|
@@ -719,7 +719,7 @@ EXAMPLES
|
|
|
719
719
|
$ lps project push
|
|
720
720
|
```
|
|
721
721
|
|
|
722
|
-
_See code: [src/commands/project/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
722
|
+
_See code: [src/commands/project/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/project/push.ts)_
|
|
723
723
|
|
|
724
724
|
## `lps project remove`
|
|
725
725
|
|
|
@@ -736,7 +736,7 @@ EXAMPLES
|
|
|
736
736
|
$ lps project remove
|
|
737
737
|
```
|
|
738
738
|
|
|
739
|
-
_See code: [src/commands/project/remove.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
739
|
+
_See code: [src/commands/project/remove.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/project/remove.ts)_
|
|
740
740
|
|
|
741
741
|
## `lps project rotate`
|
|
742
742
|
|
|
@@ -758,7 +758,7 @@ EXAMPLES
|
|
|
758
758
|
$ lps project rotate --env staging
|
|
759
759
|
```
|
|
760
760
|
|
|
761
|
-
_See code: [src/commands/project/rotate.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
761
|
+
_See code: [src/commands/project/rotate.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/project/rotate.ts)_
|
|
762
762
|
|
|
763
763
|
## `lps project switch`
|
|
764
764
|
|
|
@@ -775,7 +775,7 @@ EXAMPLES
|
|
|
775
775
|
$ lps project switch
|
|
776
776
|
```
|
|
777
777
|
|
|
778
|
-
_See code: [src/commands/project/switch.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
778
|
+
_See code: [src/commands/project/switch.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/project/switch.ts)_
|
|
779
779
|
|
|
780
780
|
## `lps seo list`
|
|
781
781
|
|
|
@@ -799,7 +799,7 @@ EXAMPLES
|
|
|
799
799
|
$ lps seo list --post-type post
|
|
800
800
|
```
|
|
801
801
|
|
|
802
|
-
_See code: [src/commands/seo/list.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
802
|
+
_See code: [src/commands/seo/list.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/seo/list.ts)_
|
|
803
803
|
|
|
804
804
|
## `lps seo pull [PATH]`
|
|
805
805
|
|
|
@@ -827,7 +827,7 @@ EXAMPLES
|
|
|
827
827
|
$ lps seo pull --post-type post --post-type page
|
|
828
828
|
```
|
|
829
829
|
|
|
830
|
-
_See code: [src/commands/seo/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
830
|
+
_See code: [src/commands/seo/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/seo/pull.ts)_
|
|
831
831
|
|
|
832
832
|
## `lps seo push [PATH]`
|
|
833
833
|
|
|
@@ -853,7 +853,7 @@ EXAMPLES
|
|
|
853
853
|
$ lps seo push
|
|
854
854
|
```
|
|
855
855
|
|
|
856
|
-
_See code: [src/commands/seo/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
856
|
+
_See code: [src/commands/seo/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/seo/push.ts)_
|
|
857
857
|
|
|
858
858
|
## `lps snippet list`
|
|
859
859
|
|
|
@@ -874,7 +874,7 @@ EXAMPLES
|
|
|
874
874
|
$ lps snippet list
|
|
875
875
|
```
|
|
876
876
|
|
|
877
|
-
_See code: [src/commands/snippet/list.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
877
|
+
_See code: [src/commands/snippet/list.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/snippet/list.ts)_
|
|
878
878
|
|
|
879
879
|
## `lps snippet publish [PATH]`
|
|
880
880
|
|
|
@@ -897,7 +897,7 @@ EXAMPLES
|
|
|
897
897
|
$ lps snippet publish --path ./snippets
|
|
898
898
|
```
|
|
899
899
|
|
|
900
|
-
_See code: [src/commands/snippet/publish.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
900
|
+
_See code: [src/commands/snippet/publish.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/snippet/publish.ts)_
|
|
901
901
|
|
|
902
902
|
## `lps snippet pull [PATH]`
|
|
903
903
|
|
|
@@ -924,7 +924,7 @@ EXAMPLES
|
|
|
924
924
|
$ lps snippet pull --path ./snippets
|
|
925
925
|
```
|
|
926
926
|
|
|
927
|
-
_See code: [src/commands/snippet/pull.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
927
|
+
_See code: [src/commands/snippet/pull.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/snippet/pull.ts)_
|
|
928
928
|
|
|
929
929
|
## `lps snippet push [PATH]`
|
|
930
930
|
|
|
@@ -952,7 +952,7 @@ EXAMPLES
|
|
|
952
952
|
$ lps snippet push --path ./snippets
|
|
953
953
|
```
|
|
954
954
|
|
|
955
|
-
_See code: [src/commands/snippet/push.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
955
|
+
_See code: [src/commands/snippet/push.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/snippet/push.ts)_
|
|
956
956
|
|
|
957
957
|
## `lps status`
|
|
958
958
|
|
|
@@ -974,7 +974,7 @@ EXAMPLES
|
|
|
974
974
|
$ lps status --env staging
|
|
975
975
|
```
|
|
976
976
|
|
|
977
|
-
_See code: [src/commands/status.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
977
|
+
_See code: [src/commands/status.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/status.ts)_
|
|
978
978
|
|
|
979
979
|
## `lps telemetry disable`
|
|
980
980
|
|
|
@@ -991,7 +991,7 @@ EXAMPLES
|
|
|
991
991
|
$ lps telemetry disable
|
|
992
992
|
```
|
|
993
993
|
|
|
994
|
-
_See code: [src/commands/telemetry/disable.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
994
|
+
_See code: [src/commands/telemetry/disable.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/telemetry/disable.ts)_
|
|
995
995
|
|
|
996
996
|
## `lps telemetry enable`
|
|
997
997
|
|
|
@@ -1008,5 +1008,5 @@ EXAMPLES
|
|
|
1008
1008
|
$ lps telemetry enable
|
|
1009
1009
|
```
|
|
1010
1010
|
|
|
1011
|
-
_See code: [src/commands/telemetry/enable.ts](https://github.com/loopress/loopress/blob/v0.20.
|
|
1011
|
+
_See code: [src/commands/telemetry/enable.ts](https://github.com/loopress/loopress/blob/v0.20.1/src/commands/telemetry/enable.ts)_
|
|
1012
1012
|
<!-- commandsstop -->
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { LoopressCommand } from '../../lib/base.js';
|
|
4
|
+
import { isNotFoundError } from '../../lib/wp-client.js';
|
|
5
|
+
// Narrower than isNotFoundError(): a bare 404 also covers the route being absent (plugin not
|
|
6
|
+
// installed, or an edition/version predating Composer support), which must still surface the
|
|
7
|
+
// normal "is the plugin installed?" guidance rather than being read as "no lock yet".
|
|
8
|
+
function isMissingComposerLock(error) {
|
|
9
|
+
if (!isNotFoundError(error))
|
|
10
|
+
return false;
|
|
11
|
+
const body = error.cause?.response?.body;
|
|
12
|
+
if (!body)
|
|
13
|
+
return false;
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(body);
|
|
16
|
+
return parsed.error === 'composer.lock not found';
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
4
22
|
export default class ComposerPull extends LoopressCommand {
|
|
5
23
|
static description = 'Pull composer.json and composer.lock from WordPress';
|
|
6
24
|
static examples = ['$ lps composer pull', '$ lps composer pull --dry-run'];
|
|
@@ -11,14 +29,31 @@ export default class ComposerPull extends LoopressCommand {
|
|
|
11
29
|
const { url } = this.siteConfig;
|
|
12
30
|
this.log(`Pulling composer.json and composer.lock from ${url}`);
|
|
13
31
|
const { composerJson } = await this.wp.get('loopress/v1/composer/json');
|
|
14
|
-
|
|
32
|
+
// A site that never had Composer dependencies pushed has no composer.lock yet: that's a
|
|
33
|
+
// legitimate applicative 404 from the Loopress controller (ComposerController::get_lock(),
|
|
34
|
+
// body `{"error": "composer.lock not found"}`), not a sign anything is broken. Any other
|
|
35
|
+
// 404 (route absent because the plugin isn't installed or predates Composer support) must
|
|
36
|
+
// still surface the normal "is the plugin installed?" guidance instead of being swallowed.
|
|
37
|
+
let composerLock;
|
|
38
|
+
try {
|
|
39
|
+
;
|
|
40
|
+
({ composerLock } = await this.wp.get('loopress/v1/composer/lock'));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (!isMissingComposerLock(error))
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
15
46
|
if (this.dryRun) {
|
|
16
|
-
this.log('[dry-run] Would write composer.json and composer.lock');
|
|
47
|
+
this.log(composerLock ? '[dry-run] Would write composer.json and composer.lock' : '[dry-run] Would write composer.json');
|
|
17
48
|
return;
|
|
18
49
|
}
|
|
19
50
|
const composerJsonPath = join(process.cwd(), this.rootDir, 'composer.json');
|
|
20
|
-
const lockPath = join(process.cwd(), this.rootDir, 'composer.lock');
|
|
21
51
|
await writeFile(composerJsonPath, composerJson, 'utf8');
|
|
52
|
+
if (composerLock === undefined) {
|
|
53
|
+
this.log('Wrote composer.json (no composer.lock on this site yet)');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const lockPath = join(process.cwd(), this.rootDir, 'composer.lock');
|
|
22
57
|
await writeFile(lockPath, composerLock, 'utf8');
|
|
23
58
|
this.log(`Wrote composer.json and composer.lock`);
|
|
24
59
|
}
|
|
@@ -126,10 +126,15 @@ export default class Push extends PushCommand {
|
|
|
126
126
|
}
|
|
127
127
|
catch (error) {
|
|
128
128
|
// The id recorded locally doesn't exist on this site (e.g. a fresh install): create
|
|
129
|
-
// it instead of failing, and adopt whatever id the site assigns.
|
|
129
|
+
// it instead of failing, and adopt whatever id the site assigns. WordPress core
|
|
130
|
+
// rejects any POST that still carries a (now stale) `id` field with a 400 "Cannot
|
|
131
|
+
// create existing post", regardless of whether that id actually exists, so it must
|
|
132
|
+
// be stripped before falling back to create.
|
|
130
133
|
if (!isNotFoundError(error))
|
|
131
134
|
throw error;
|
|
132
|
-
const
|
|
135
|
+
const createPayload = { ...payload };
|
|
136
|
+
delete createPayload.id;
|
|
137
|
+
const created = await this.wp.post(PAGE_ENDPOINT, createPayload);
|
|
133
138
|
const newId = getPageId(created);
|
|
134
139
|
if (newId !== null)
|
|
135
140
|
await this.ensureCanonicalFilename(page, newId, title);
|
package/dist/lib/wp-client.js
CHANGED
|
@@ -53,7 +53,10 @@ export function formatWpError(error, url, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
|
53
53
|
return `Authentication failed (${status}) on ${url}. Check your credentials with \`lps project config\`.`;
|
|
54
54
|
}
|
|
55
55
|
if (status === 404) {
|
|
56
|
-
|
|
56
|
+
const reason = extractServerErrorMessage(err.response?.body);
|
|
57
|
+
return reason
|
|
58
|
+
? `Request failed (404) on ${url}: ${reason}`
|
|
59
|
+
: `Endpoint not found (404) on ${url}. Is the required plugin installed and up to date on the site?`;
|
|
57
60
|
}
|
|
58
61
|
if (status !== undefined) {
|
|
59
62
|
const reason = extractServerErrorMessage(err.response?.body);
|
|
@@ -7,7 +7,14 @@ export type DiagnosticResult = {
|
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Pre-flight checks run before starting the browser authorization flow, so failures
|
|
10
|
-
* (unreachable site, blocked REST API,
|
|
11
|
-
* message instead of a confusing timeout once the browser is already open.
|
|
10
|
+
* (unreachable site, blocked REST API, Application Passwords disabled) surface as an
|
|
11
|
+
* actionable message instead of a confusing timeout once the browser is already open.
|
|
12
|
+
*
|
|
13
|
+
* Whether Application Passwords are enabled can only be read from the `wp-json/` index:
|
|
14
|
+
* WordPress adds `authentication['application-passwords']` there when the feature is on
|
|
15
|
+
* (WP core, rest_add_application_passwords_to_index). The authorize-application.php page
|
|
16
|
+
* can't be probed for this instead, it sits behind the admin login wall, so an unauthenticated
|
|
17
|
+
* request just gets redirected to wp-login.php and never reaches the check that would say
|
|
18
|
+
* whether the feature is disabled.
|
|
12
19
|
*/
|
|
13
20
|
export declare function diagnoseWpSite(siteUrl: string): Promise<DiagnosticResult>;
|
|
@@ -2,12 +2,20 @@ import got from 'got';
|
|
|
2
2
|
export const REQUEST_TIMEOUT_MS = 10_000;
|
|
3
3
|
/**
|
|
4
4
|
* Pre-flight checks run before starting the browser authorization flow, so failures
|
|
5
|
-
* (unreachable site, blocked REST API,
|
|
6
|
-
* message instead of a confusing timeout once the browser is already open.
|
|
5
|
+
* (unreachable site, blocked REST API, Application Passwords disabled) surface as an
|
|
6
|
+
* actionable message instead of a confusing timeout once the browser is already open.
|
|
7
|
+
*
|
|
8
|
+
* Whether Application Passwords are enabled can only be read from the `wp-json/` index:
|
|
9
|
+
* WordPress adds `authentication['application-passwords']` there when the feature is on
|
|
10
|
+
* (WP core, rest_add_application_passwords_to_index). The authorize-application.php page
|
|
11
|
+
* can't be probed for this instead, it sits behind the admin login wall, so an unauthenticated
|
|
12
|
+
* request just gets redirected to wp-login.php and never reaches the check that would say
|
|
13
|
+
* whether the feature is disabled.
|
|
7
14
|
*/
|
|
8
15
|
export async function diagnoseWpSite(siteUrl) {
|
|
16
|
+
let index;
|
|
9
17
|
try {
|
|
10
|
-
await got.get(`${siteUrl}/wp-json/`, { timeout: { request: REQUEST_TIMEOUT_MS } });
|
|
18
|
+
index = await got.get(`${siteUrl}/wp-json/`, { timeout: { request: REQUEST_TIMEOUT_MS } }).json();
|
|
11
19
|
}
|
|
12
20
|
catch (error) {
|
|
13
21
|
return {
|
|
@@ -15,28 +23,10 @@ export async function diagnoseWpSite(siteUrl) {
|
|
|
15
23
|
reason: `Could not reach the WordPress REST API at ${siteUrl}/wp-json/. The site may be unreachable, or a security plugin may be blocking it. (${describe(error)})`,
|
|
16
24
|
};
|
|
17
25
|
}
|
|
18
|
-
|
|
19
|
-
const response = await got.head(`${siteUrl}/wp-admin/authorize-application.php`, {
|
|
20
|
-
throwHttpErrors: false,
|
|
21
|
-
timeout: { request: REQUEST_TIMEOUT_MS },
|
|
22
|
-
});
|
|
23
|
-
if (response.statusCode === 404) {
|
|
24
|
-
return {
|
|
25
|
-
ok: false,
|
|
26
|
-
reason: `The application authorization page was not found on ${siteUrl}. This WordPress site may be older than 5.6, or the feature may be disabled by a plugin.`,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (response.statusCode >= 400) {
|
|
30
|
-
return {
|
|
31
|
-
ok: false,
|
|
32
|
-
reason: `The application authorization page at ${siteUrl}/wp-admin/authorize-application.php returned an error (HTTP ${response.statusCode}).`,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
26
|
+
if (!index?.authentication?.['application-passwords']) {
|
|
37
27
|
return {
|
|
38
28
|
ok: false,
|
|
39
|
-
reason: `
|
|
29
|
+
reason: `Application Passwords are not available on ${siteUrl}. The site may be older than WordPress 5.6, require HTTPS, or have the feature disabled by a plugin or filter.`,
|
|
40
30
|
};
|
|
41
31
|
}
|
|
42
32
|
return { ok: true };
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED