@loopress/cli 0.6.0 → 0.7.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 +71 -90
- package/dist/commands/composer/pull.js +1 -1
- package/dist/commands/composer/push.js +1 -1
- package/dist/commands/init.js +15 -6
- package/dist/commands/login.js +1 -1
- package/dist/commands/logout.js +1 -1
- package/dist/commands/plugin/add.d.ts +0 -2
- package/dist/commands/plugin/add.js +2 -23
- package/dist/commands/plugin/pull.js +1 -1
- package/dist/commands/plugin/push.js +3 -3
- package/dist/commands/project/config.d.ts +1 -0
- package/dist/commands/project/config.js +36 -17
- package/dist/commands/project/list.js +4 -5
- package/dist/commands/project/remove.js +33 -14
- package/dist/commands/project/switch.d.ts +2 -0
- package/dist/commands/project/switch.js +28 -9
- package/dist/commands/snippet/list.js +3 -3
- package/dist/commands/snippet/pull.d.ts +1 -1
- package/dist/commands/snippet/pull.js +7 -6
- package/dist/commands/snippet/push.d.ts +2 -2
- package/dist/commands/snippet/push.js +47 -15
- package/dist/commands/{project/remove-env.d.ts → status.d.ts} +3 -1
- package/dist/commands/status.js +66 -0
- package/dist/config/project-config.manager.d.ts +17 -10
- package/dist/config/project-config.manager.js +91 -44
- package/dist/config/types.d.ts +5 -2
- package/dist/lib/base.js +13 -3
- package/dist/types/snippet.d.ts +2 -0
- package/dist/utils/snippet-plugin.d.ts +2 -1
- package/dist/utils/snippet-plugin.js +5 -4
- package/oclif.manifest.json +149 -175
- package/package.json +17 -2
- package/dist/commands/project/remove-env.js +0 -33
- package/dist/commands/project/switch-env.d.ts +0 -6
- package/dist/commands/project/switch-env.js +0 -33
package/oclif.manifest.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"login": {
|
|
27
27
|
"aliases": [],
|
|
28
28
|
"args": {},
|
|
29
|
-
"description": "Log in to Loopress
|
|
29
|
+
"description": "Log in to the Loopress console",
|
|
30
30
|
"examples": [
|
|
31
31
|
"$ lps login"
|
|
32
32
|
],
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"logout": {
|
|
50
50
|
"aliases": [],
|
|
51
51
|
"args": {},
|
|
52
|
-
"description": "Log out from Loopress console",
|
|
52
|
+
"description": "Log out from the Loopress console",
|
|
53
53
|
"examples": [
|
|
54
54
|
"$ lps logout"
|
|
55
55
|
],
|
|
@@ -69,10 +69,33 @@
|
|
|
69
69
|
"logout.js"
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
|
+
"status": {
|
|
73
|
+
"aliases": [],
|
|
74
|
+
"args": {},
|
|
75
|
+
"description": "Show which WordPress project and environment commands will target",
|
|
76
|
+
"examples": [
|
|
77
|
+
"$ lps status"
|
|
78
|
+
],
|
|
79
|
+
"flags": {},
|
|
80
|
+
"hasDynamicHelp": false,
|
|
81
|
+
"hiddenAliases": [],
|
|
82
|
+
"id": "status",
|
|
83
|
+
"pluginAlias": "@loopress/cli",
|
|
84
|
+
"pluginName": "@loopress/cli",
|
|
85
|
+
"pluginType": "core",
|
|
86
|
+
"strict": true,
|
|
87
|
+
"enableJsonFlag": false,
|
|
88
|
+
"isESM": true,
|
|
89
|
+
"relativePath": [
|
|
90
|
+
"dist",
|
|
91
|
+
"commands",
|
|
92
|
+
"status.js"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
72
95
|
"composer:pull": {
|
|
73
96
|
"aliases": [],
|
|
74
97
|
"args": {},
|
|
75
|
-
"description": "Pull composer.lock from
|
|
98
|
+
"description": "Pull composer.lock from WordPress",
|
|
76
99
|
"examples": [
|
|
77
100
|
"$ lps composer pull",
|
|
78
101
|
"$ lps composer pull --dry-run"
|
|
@@ -129,7 +152,7 @@
|
|
|
129
152
|
"composer:push": {
|
|
130
153
|
"aliases": [],
|
|
131
154
|
"args": {},
|
|
132
|
-
"description": "
|
|
155
|
+
"description": "Push composer.json and composer.lock to WordPress and run composer install",
|
|
133
156
|
"examples": [
|
|
134
157
|
"$ lps composer push",
|
|
135
158
|
"$ lps composer push --dry-run"
|
|
@@ -186,7 +209,7 @@
|
|
|
186
209
|
"aliases": [],
|
|
187
210
|
"args": {
|
|
188
211
|
"slug": {
|
|
189
|
-
"description": "Plugin slug
|
|
212
|
+
"description": "Plugin slug on WordPress.org",
|
|
190
213
|
"name": "slug",
|
|
191
214
|
"required": true
|
|
192
215
|
},
|
|
@@ -195,11 +218,10 @@
|
|
|
195
218
|
"name": "version"
|
|
196
219
|
}
|
|
197
220
|
},
|
|
198
|
-
"description": "Add a plugin to loopress.json
|
|
221
|
+
"description": "Add a WordPress.org plugin to loopress.json",
|
|
199
222
|
"examples": [
|
|
200
223
|
"$ lps plugin add woocommerce",
|
|
201
224
|
"$ lps plugin add woocommerce 8.9.1",
|
|
202
|
-
"$ lps plugin add wpackagist-plugin/advanced-custom-fields",
|
|
203
225
|
"$ lps plugin add contact-form-7 --dry-run"
|
|
204
226
|
],
|
|
205
227
|
"flags": {
|
|
@@ -256,8 +278,8 @@
|
|
|
256
278
|
"args": {},
|
|
257
279
|
"description": "Pull installed plugins from WordPress into loopress.json",
|
|
258
280
|
"examples": [
|
|
259
|
-
"$ lps
|
|
260
|
-
"$ lps
|
|
281
|
+
"$ lps plugin pull",
|
|
282
|
+
"$ lps plugin pull --dry-run"
|
|
261
283
|
],
|
|
262
284
|
"flags": {
|
|
263
285
|
"password": {
|
|
@@ -311,10 +333,10 @@
|
|
|
311
333
|
"plugin:push": {
|
|
312
334
|
"aliases": [],
|
|
313
335
|
"args": {},
|
|
314
|
-
"description": "
|
|
336
|
+
"description": "Push plugins to WordPress to match loopress.json",
|
|
315
337
|
"examples": [
|
|
316
|
-
"$ lps
|
|
317
|
-
"$ lps
|
|
338
|
+
"$ lps plugin push",
|
|
339
|
+
"$ lps plugin push --dry-run"
|
|
318
340
|
],
|
|
319
341
|
"flags": {
|
|
320
342
|
"password": {
|
|
@@ -364,14 +386,110 @@
|
|
|
364
386
|
"push.js"
|
|
365
387
|
]
|
|
366
388
|
},
|
|
389
|
+
"project:config": {
|
|
390
|
+
"aliases": [],
|
|
391
|
+
"args": {},
|
|
392
|
+
"description": "Add or update a WordPress project environment",
|
|
393
|
+
"examples": [
|
|
394
|
+
"$ lps project config"
|
|
395
|
+
],
|
|
396
|
+
"flags": {},
|
|
397
|
+
"hasDynamicHelp": false,
|
|
398
|
+
"hiddenAliases": [],
|
|
399
|
+
"id": "project:config",
|
|
400
|
+
"pluginAlias": "@loopress/cli",
|
|
401
|
+
"pluginName": "@loopress/cli",
|
|
402
|
+
"pluginType": "core",
|
|
403
|
+
"strict": true,
|
|
404
|
+
"enableJsonFlag": false,
|
|
405
|
+
"isESM": true,
|
|
406
|
+
"relativePath": [
|
|
407
|
+
"dist",
|
|
408
|
+
"commands",
|
|
409
|
+
"project",
|
|
410
|
+
"config.js"
|
|
411
|
+
]
|
|
412
|
+
},
|
|
413
|
+
"project:list": {
|
|
414
|
+
"aliases": [],
|
|
415
|
+
"args": {},
|
|
416
|
+
"description": "List configured WordPress projects",
|
|
417
|
+
"examples": [
|
|
418
|
+
"$ lps project list"
|
|
419
|
+
],
|
|
420
|
+
"flags": {},
|
|
421
|
+
"hasDynamicHelp": false,
|
|
422
|
+
"hiddenAliases": [],
|
|
423
|
+
"id": "project:list",
|
|
424
|
+
"pluginAlias": "@loopress/cli",
|
|
425
|
+
"pluginName": "@loopress/cli",
|
|
426
|
+
"pluginType": "core",
|
|
427
|
+
"strict": true,
|
|
428
|
+
"enableJsonFlag": false,
|
|
429
|
+
"isESM": true,
|
|
430
|
+
"relativePath": [
|
|
431
|
+
"dist",
|
|
432
|
+
"commands",
|
|
433
|
+
"project",
|
|
434
|
+
"list.js"
|
|
435
|
+
]
|
|
436
|
+
},
|
|
437
|
+
"project:remove": {
|
|
438
|
+
"aliases": [],
|
|
439
|
+
"args": {},
|
|
440
|
+
"description": "Remove one or more WordPress projects or environments",
|
|
441
|
+
"examples": [
|
|
442
|
+
"$ lps project remove"
|
|
443
|
+
],
|
|
444
|
+
"flags": {},
|
|
445
|
+
"hasDynamicHelp": false,
|
|
446
|
+
"hiddenAliases": [],
|
|
447
|
+
"id": "project:remove",
|
|
448
|
+
"pluginAlias": "@loopress/cli",
|
|
449
|
+
"pluginName": "@loopress/cli",
|
|
450
|
+
"pluginType": "core",
|
|
451
|
+
"strict": true,
|
|
452
|
+
"enableJsonFlag": false,
|
|
453
|
+
"isESM": true,
|
|
454
|
+
"relativePath": [
|
|
455
|
+
"dist",
|
|
456
|
+
"commands",
|
|
457
|
+
"project",
|
|
458
|
+
"remove.js"
|
|
459
|
+
]
|
|
460
|
+
},
|
|
461
|
+
"project:switch": {
|
|
462
|
+
"aliases": [],
|
|
463
|
+
"args": {},
|
|
464
|
+
"description": "Switch the active project and environment",
|
|
465
|
+
"examples": [
|
|
466
|
+
"$ lps project switch"
|
|
467
|
+
],
|
|
468
|
+
"flags": {},
|
|
469
|
+
"hasDynamicHelp": false,
|
|
470
|
+
"hiddenAliases": [],
|
|
471
|
+
"id": "project:switch",
|
|
472
|
+
"pluginAlias": "@loopress/cli",
|
|
473
|
+
"pluginName": "@loopress/cli",
|
|
474
|
+
"pluginType": "core",
|
|
475
|
+
"strict": true,
|
|
476
|
+
"enableJsonFlag": false,
|
|
477
|
+
"isESM": true,
|
|
478
|
+
"relativePath": [
|
|
479
|
+
"dist",
|
|
480
|
+
"commands",
|
|
481
|
+
"project",
|
|
482
|
+
"switch.js"
|
|
483
|
+
]
|
|
484
|
+
},
|
|
367
485
|
"snippet:list": {
|
|
368
486
|
"aliases": [],
|
|
369
487
|
"args": {},
|
|
370
488
|
"description": "List snippets from WordPress",
|
|
371
489
|
"examples": [
|
|
372
|
-
"$ lps
|
|
373
|
-
"$ lps
|
|
374
|
-
"$ lps
|
|
490
|
+
"$ lps snippet list",
|
|
491
|
+
"$ lps snippet list --url http://example.com",
|
|
492
|
+
"$ lps snippet list --plugin wpcode"
|
|
375
493
|
],
|
|
376
494
|
"flags": {
|
|
377
495
|
"password": {
|
|
@@ -444,10 +562,10 @@
|
|
|
444
562
|
},
|
|
445
563
|
"description": "Pull snippets from WordPress",
|
|
446
564
|
"examples": [
|
|
447
|
-
"$ lps
|
|
448
|
-
"$ lps
|
|
449
|
-
"$ lps
|
|
450
|
-
"$ lps
|
|
565
|
+
"$ lps snippet pull",
|
|
566
|
+
"$ lps snippet pull --url http://example.com",
|
|
567
|
+
"$ lps snippet pull --path ./snippets",
|
|
568
|
+
"$ lps snippet pull --plugin wpcode"
|
|
451
569
|
],
|
|
452
570
|
"flags": {
|
|
453
571
|
"password": {
|
|
@@ -474,10 +592,10 @@
|
|
|
474
592
|
"multiple": false,
|
|
475
593
|
"type": "option"
|
|
476
594
|
},
|
|
477
|
-
"
|
|
595
|
+
"dry-run": {
|
|
478
596
|
"char": "d",
|
|
479
|
-
"description": "
|
|
480
|
-
"name": "
|
|
597
|
+
"description": "Show what would be written without making changes",
|
|
598
|
+
"name": "dry-run",
|
|
481
599
|
"allowNo": false,
|
|
482
600
|
"type": "boolean"
|
|
483
601
|
},
|
|
@@ -518,12 +636,12 @@
|
|
|
518
636
|
"name": "path"
|
|
519
637
|
}
|
|
520
638
|
},
|
|
521
|
-
"description": "Push snippets to WordPress",
|
|
639
|
+
"description": "Push snippets to WordPress. Local snippet files created or updated remotely are renamed on disk to the `<id>-<slug>` convention.",
|
|
522
640
|
"examples": [
|
|
523
|
-
"$ lps
|
|
524
|
-
"$ lps
|
|
525
|
-
"$ lps
|
|
526
|
-
"$ lps
|
|
641
|
+
"$ lps snippet push",
|
|
642
|
+
"$ lps snippet push --url http://example.com",
|
|
643
|
+
"$ lps snippet push --path ./snippets",
|
|
644
|
+
"$ lps snippet push --plugin wpcode"
|
|
527
645
|
],
|
|
528
646
|
"flags": {
|
|
529
647
|
"password": {
|
|
@@ -550,10 +668,10 @@
|
|
|
550
668
|
"multiple": false,
|
|
551
669
|
"type": "option"
|
|
552
670
|
},
|
|
553
|
-
"
|
|
671
|
+
"dry-run": {
|
|
554
672
|
"char": "d",
|
|
555
|
-
"description": "
|
|
556
|
-
"name": "
|
|
673
|
+
"description": "Show what would change without making changes",
|
|
674
|
+
"name": "dry-run",
|
|
557
675
|
"allowNo": false,
|
|
558
676
|
"type": "boolean"
|
|
559
677
|
},
|
|
@@ -584,151 +702,7 @@
|
|
|
584
702
|
"snippet",
|
|
585
703
|
"push.js"
|
|
586
704
|
]
|
|
587
|
-
},
|
|
588
|
-
"project:config": {
|
|
589
|
-
"aliases": [],
|
|
590
|
-
"args": {},
|
|
591
|
-
"description": "Add or update a WordPress project environment",
|
|
592
|
-
"examples": [
|
|
593
|
-
"$ lps project config"
|
|
594
|
-
],
|
|
595
|
-
"flags": {},
|
|
596
|
-
"hasDynamicHelp": false,
|
|
597
|
-
"hiddenAliases": [],
|
|
598
|
-
"id": "project:config",
|
|
599
|
-
"pluginAlias": "@loopress/cli",
|
|
600
|
-
"pluginName": "@loopress/cli",
|
|
601
|
-
"pluginType": "core",
|
|
602
|
-
"strict": true,
|
|
603
|
-
"enableJsonFlag": false,
|
|
604
|
-
"isESM": true,
|
|
605
|
-
"relativePath": [
|
|
606
|
-
"dist",
|
|
607
|
-
"commands",
|
|
608
|
-
"project",
|
|
609
|
-
"config.js"
|
|
610
|
-
]
|
|
611
|
-
},
|
|
612
|
-
"project:list": {
|
|
613
|
-
"aliases": [],
|
|
614
|
-
"args": {},
|
|
615
|
-
"description": "List configured WordPress projects",
|
|
616
|
-
"examples": [
|
|
617
|
-
"$ lps project list"
|
|
618
|
-
],
|
|
619
|
-
"flags": {},
|
|
620
|
-
"hasDynamicHelp": false,
|
|
621
|
-
"hiddenAliases": [],
|
|
622
|
-
"id": "project:list",
|
|
623
|
-
"pluginAlias": "@loopress/cli",
|
|
624
|
-
"pluginName": "@loopress/cli",
|
|
625
|
-
"pluginType": "core",
|
|
626
|
-
"strict": true,
|
|
627
|
-
"enableJsonFlag": false,
|
|
628
|
-
"isESM": true,
|
|
629
|
-
"relativePath": [
|
|
630
|
-
"dist",
|
|
631
|
-
"commands",
|
|
632
|
-
"project",
|
|
633
|
-
"list.js"
|
|
634
|
-
]
|
|
635
|
-
},
|
|
636
|
-
"project:remove-env": {
|
|
637
|
-
"aliases": [],
|
|
638
|
-
"args": {},
|
|
639
|
-
"description": "Remove one or more environments from the current project",
|
|
640
|
-
"examples": [
|
|
641
|
-
"$ lps project remove-env"
|
|
642
|
-
],
|
|
643
|
-
"flags": {},
|
|
644
|
-
"hasDynamicHelp": false,
|
|
645
|
-
"hiddenAliases": [],
|
|
646
|
-
"id": "project:remove-env",
|
|
647
|
-
"pluginAlias": "@loopress/cli",
|
|
648
|
-
"pluginName": "@loopress/cli",
|
|
649
|
-
"pluginType": "core",
|
|
650
|
-
"strict": true,
|
|
651
|
-
"enableJsonFlag": false,
|
|
652
|
-
"isESM": true,
|
|
653
|
-
"relativePath": [
|
|
654
|
-
"dist",
|
|
655
|
-
"commands",
|
|
656
|
-
"project",
|
|
657
|
-
"remove-env.js"
|
|
658
|
-
]
|
|
659
|
-
},
|
|
660
|
-
"project:remove": {
|
|
661
|
-
"aliases": [],
|
|
662
|
-
"args": {},
|
|
663
|
-
"description": "Remove one or more WordPress project configurations",
|
|
664
|
-
"examples": [
|
|
665
|
-
"$ lps project remove"
|
|
666
|
-
],
|
|
667
|
-
"flags": {},
|
|
668
|
-
"hasDynamicHelp": false,
|
|
669
|
-
"hiddenAliases": [],
|
|
670
|
-
"id": "project:remove",
|
|
671
|
-
"pluginAlias": "@loopress/cli",
|
|
672
|
-
"pluginName": "@loopress/cli",
|
|
673
|
-
"pluginType": "core",
|
|
674
|
-
"strict": true,
|
|
675
|
-
"enableJsonFlag": false,
|
|
676
|
-
"isESM": true,
|
|
677
|
-
"relativePath": [
|
|
678
|
-
"dist",
|
|
679
|
-
"commands",
|
|
680
|
-
"project",
|
|
681
|
-
"remove.js"
|
|
682
|
-
]
|
|
683
|
-
},
|
|
684
|
-
"project:switch-env": {
|
|
685
|
-
"aliases": [],
|
|
686
|
-
"args": {},
|
|
687
|
-
"description": "Switch the active environment within the current project",
|
|
688
|
-
"examples": [
|
|
689
|
-
"$ lps project switch-env"
|
|
690
|
-
],
|
|
691
|
-
"flags": {},
|
|
692
|
-
"hasDynamicHelp": false,
|
|
693
|
-
"hiddenAliases": [],
|
|
694
|
-
"id": "project:switch-env",
|
|
695
|
-
"pluginAlias": "@loopress/cli",
|
|
696
|
-
"pluginName": "@loopress/cli",
|
|
697
|
-
"pluginType": "core",
|
|
698
|
-
"strict": true,
|
|
699
|
-
"enableJsonFlag": false,
|
|
700
|
-
"isESM": true,
|
|
701
|
-
"relativePath": [
|
|
702
|
-
"dist",
|
|
703
|
-
"commands",
|
|
704
|
-
"project",
|
|
705
|
-
"switch-env.js"
|
|
706
|
-
]
|
|
707
|
-
},
|
|
708
|
-
"project:switch": {
|
|
709
|
-
"aliases": [],
|
|
710
|
-
"args": {},
|
|
711
|
-
"description": "Switch the active project",
|
|
712
|
-
"examples": [
|
|
713
|
-
"$ lps project switch"
|
|
714
|
-
],
|
|
715
|
-
"flags": {},
|
|
716
|
-
"hasDynamicHelp": false,
|
|
717
|
-
"hiddenAliases": [],
|
|
718
|
-
"id": "project:switch",
|
|
719
|
-
"pluginAlias": "@loopress/cli",
|
|
720
|
-
"pluginName": "@loopress/cli",
|
|
721
|
-
"pluginType": "core",
|
|
722
|
-
"strict": true,
|
|
723
|
-
"enableJsonFlag": false,
|
|
724
|
-
"isESM": true,
|
|
725
|
-
"relativePath": [
|
|
726
|
-
"dist",
|
|
727
|
-
"commands",
|
|
728
|
-
"project",
|
|
729
|
-
"switch.js"
|
|
730
|
-
]
|
|
731
705
|
}
|
|
732
706
|
},
|
|
733
|
-
"version": "0.
|
|
707
|
+
"version": "0.7.0"
|
|
734
708
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopress/cli",
|
|
3
3
|
"description": "CLI tool for syncing WordPress CodeSnippets, styles, and menus via the REST API",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"author": "jean-smaug",
|
|
6
6
|
"bin": {
|
|
7
7
|
"loopress": "bin/run.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@oclif/prettier-config": "^0.2.1",
|
|
25
25
|
"@oclif/test": "^4.1.20",
|
|
26
26
|
"@types/node": "26.0.1",
|
|
27
|
+
"@vitest/coverage-v8": "4.1.9",
|
|
27
28
|
"eslint": "^9",
|
|
28
29
|
"eslint-config-oclif": "^6.0.174",
|
|
29
30
|
"eslint-config-prettier": "^10",
|
|
@@ -65,7 +66,21 @@
|
|
|
65
66
|
"plugins": [
|
|
66
67
|
"@oclif/plugin-help"
|
|
67
68
|
],
|
|
68
|
-
"topicSeparator": " "
|
|
69
|
+
"topicSeparator": " ",
|
|
70
|
+
"topics": {
|
|
71
|
+
"composer": {
|
|
72
|
+
"description": "Sync composer.json and composer.lock between your project and WordPress"
|
|
73
|
+
},
|
|
74
|
+
"plugin": {
|
|
75
|
+
"description": "Manage WordPress.org plugins tracked in loopress.json"
|
|
76
|
+
},
|
|
77
|
+
"project": {
|
|
78
|
+
"description": "Manage WordPress project and environment configurations"
|
|
79
|
+
},
|
|
80
|
+
"snippet": {
|
|
81
|
+
"description": "Manage WordPress code snippets"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
69
84
|
},
|
|
70
85
|
"repository": {
|
|
71
86
|
"type": "git",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { checkbox } from '@inquirer/prompts';
|
|
2
|
-
import { Command } from '@oclif/core';
|
|
3
|
-
import { configManager } from '../../config/project-config.manager.js';
|
|
4
|
-
export default class RemoveEnv extends Command {
|
|
5
|
-
static description = 'Remove one or more environments from the current project';
|
|
6
|
-
static examples = ['$ lps project remove-env'];
|
|
7
|
-
async run() {
|
|
8
|
-
await this.parse(RemoveEnv);
|
|
9
|
-
const project = configManager.getCurrentProject();
|
|
10
|
-
if (!project) {
|
|
11
|
-
this.error('No project configured. Run `lps project config` first.');
|
|
12
|
-
}
|
|
13
|
-
const envs = configManager.listEnvironments(project.name);
|
|
14
|
-
if (envs.length === 0) {
|
|
15
|
-
this.error('No environments configured.');
|
|
16
|
-
}
|
|
17
|
-
const chosen = await checkbox({
|
|
18
|
-
choices: envs.map((env) => ({
|
|
19
|
-
name: `${env.isCurrent ? '●' : '○'} ${env.name.padEnd(20)} ${env.url}${env.isCurrent ? ' [current]' : ''}`,
|
|
20
|
-
value: env.name,
|
|
21
|
-
})),
|
|
22
|
-
message: 'Select environments to remove',
|
|
23
|
-
});
|
|
24
|
-
if (chosen.length === 0) {
|
|
25
|
-
this.log('Nothing removed.');
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
for (const envName of chosen) {
|
|
29
|
-
configManager.removeEnvironment(project.name, envName);
|
|
30
|
-
}
|
|
31
|
-
this.log(`✓ Removed: ${chosen.join(', ')}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { select } from '@inquirer/prompts';
|
|
2
|
-
import { Command } from '@oclif/core';
|
|
3
|
-
import { configManager } from '../../config/project-config.manager.js';
|
|
4
|
-
export default class SwitchEnv extends Command {
|
|
5
|
-
static description = 'Switch the active environment within the current project';
|
|
6
|
-
static examples = ['$ lps project switch-env'];
|
|
7
|
-
async run() {
|
|
8
|
-
await this.parse(SwitchEnv);
|
|
9
|
-
const project = configManager.getCurrentProject();
|
|
10
|
-
if (!project) {
|
|
11
|
-
this.error('No project configured. Run `lps project config` first.');
|
|
12
|
-
}
|
|
13
|
-
const envs = configManager.listEnvironments(project.name);
|
|
14
|
-
if (envs.length === 0) {
|
|
15
|
-
this.error('No environments configured for this project.');
|
|
16
|
-
}
|
|
17
|
-
if (envs.length === 1) {
|
|
18
|
-
configManager.setCurrentEnv(project.name, envs[0].name);
|
|
19
|
-
this.log(`✓ Switched to "${project.name}/${envs[0].name}"`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const chosen = await select({
|
|
23
|
-
choices: envs.map((env) => ({
|
|
24
|
-
name: `${env.isCurrent ? '●' : '○'} ${env.name.padEnd(20)} ${env.url}${env.isCurrent ? ' [current]' : ''}`,
|
|
25
|
-
value: env.name,
|
|
26
|
-
})),
|
|
27
|
-
default: envs.find((e) => e.isCurrent)?.name,
|
|
28
|
-
message: `Select environment for "${project.name}"`,
|
|
29
|
-
});
|
|
30
|
-
configManager.setCurrentEnv(project.name, chosen);
|
|
31
|
-
this.log(`✓ Switched to "${project.name}/${chosen}"`);
|
|
32
|
-
}
|
|
33
|
-
}
|