@loopress/cli 0.7.0 → 0.9.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.
Files changed (59) hide show
  1. package/README.md +44 -75
  2. package/dist/commands/composer/pull.d.ts +0 -3
  3. package/dist/commands/composer/pull.js +4 -15
  4. package/dist/commands/composer/push.d.ts +0 -3
  5. package/dist/commands/composer/push.js +7 -17
  6. package/dist/commands/login.js +1 -1
  7. package/dist/commands/logout.js +1 -1
  8. package/dist/commands/plugin/add.d.ts +0 -3
  9. package/dist/commands/plugin/add.js +9 -10
  10. package/dist/commands/plugin/pull.d.ts +0 -3
  11. package/dist/commands/plugin/pull.js +7 -19
  12. package/dist/commands/plugin/push.d.ts +4 -3
  13. package/dist/commands/plugin/push.js +69 -63
  14. package/dist/commands/sentry-test.d.ts +6 -0
  15. package/dist/commands/sentry-test.js +8 -0
  16. package/dist/commands/snippet/list.d.ts +1 -4
  17. package/dist/commands/snippet/list.js +24 -44
  18. package/dist/commands/snippet/pull.d.ts +1 -4
  19. package/dist/commands/snippet/pull.js +40 -56
  20. package/dist/commands/snippet/push.d.ts +2 -4
  21. package/dist/commands/snippet/push.js +90 -77
  22. package/dist/config/auth.manager.d.ts +0 -2
  23. package/dist/config/auth.manager.js +5 -25
  24. package/dist/config/json-file.d.ts +2 -0
  25. package/dist/config/json-file.js +21 -0
  26. package/dist/config/project-config.manager.d.ts +1 -3
  27. package/dist/config/project-config.manager.js +7 -23
  28. package/dist/hooks/finally.d.ts +3 -0
  29. package/dist/hooks/finally.js +21 -0
  30. package/dist/hooks/init.d.ts +3 -0
  31. package/dist/hooks/init.js +18 -0
  32. package/dist/lib/base.d.ts +13 -8
  33. package/dist/lib/base.js +45 -43
  34. package/dist/lib/push-command.d.ts +0 -1
  35. package/dist/lib/push-command.js +0 -1
  36. package/dist/lib/sentry.d.ts +8 -0
  37. package/dist/lib/sentry.js +24 -0
  38. package/dist/lib/wp-client.d.ts +15 -0
  39. package/dist/lib/wp-client.js +53 -0
  40. package/dist/types/config.d.ts +1 -0
  41. package/dist/types/global-config.generated.d.ts +59 -0
  42. package/dist/types/global-config.generated.js +2 -0
  43. package/dist/types/project-config.generated.d.ts +31 -0
  44. package/dist/types/project-config.generated.js +2 -0
  45. package/dist/types/snippet.d.ts +7 -1
  46. package/dist/types/snippet.generated.d.ts +46 -0
  47. package/dist/types/snippet.generated.js +2 -0
  48. package/dist/utils/loopress-config.d.ts +2 -7
  49. package/dist/utils/loopress-config.js +5 -2
  50. package/dist/utils/snippet-plugin-flag.d.ts +3 -0
  51. package/dist/utils/snippet-plugin-flag.js +8 -0
  52. package/dist/utils/snippet-plugin.d.ts +23 -2
  53. package/dist/utils/snippet-plugin.js +168 -13
  54. package/oclif.manifest.json +66 -200
  55. package/package.json +19 -5
  56. package/dist/config/types.d.ts +0 -19
  57. package/dist/types/menu.d.ts +0 -7
  58. package/dist/types/menu.js +0 -1
  59. /package/dist/{config/types.js → types/config.js} +0 -0
package/README.md CHANGED
@@ -9,6 +9,7 @@ A new CLI generated with oclif
9
9
  <!-- toc -->
10
10
  * [Loopress](#loopress)
11
11
  * [Usage](#usage)
12
+ * [Error reporting](#error-reporting)
12
13
  * [Commands](#commands)
13
14
  <!-- tocstop -->
14
15
 
@@ -20,7 +21,7 @@ $ npm install -g @loopress/cli
20
21
  $ lps COMMAND
21
22
  running command...
22
23
  $ lps (--version)
23
- @loopress/cli/0.7.0 linux-x64 node-v24.18.0
24
+ @loopress/cli/0.9.0 linux-x64 node-v24.18.0
24
25
  $ lps --help [COMMAND]
25
26
  USAGE
26
27
  $ lps COMMAND
@@ -28,6 +29,20 @@ USAGE
28
29
  ```
29
30
  <!-- usagestop -->
30
31
 
32
+ # Error reporting
33
+
34
+ Loopress sends crash reports to our Sentry project so we can find and fix bugs.
35
+
36
+ To opt out, either:
37
+
38
+ - set `LOOPRESS_TELEMETRY_DISABLED=1`, or
39
+ - pass `--no-error-reporting` on the command.
40
+
41
+ A crash report includes the command name, its flags/args as typed, your Node.js
42
+ version, and OS. WordPress credentials are configured via `lps project config`
43
+ and are never passed as command-line arguments, so they don't end up in a
44
+ report.
45
+
31
46
  # Commands
32
47
 
33
48
  <!-- commands -->
@@ -55,15 +70,10 @@ Pull composer.lock from WordPress
55
70
 
56
71
  ```
57
72
  USAGE
58
- $ lps composer pull [--password <value>] [--url <value>] [--user <value>] [-d]
73
+ $ lps composer pull [-d]
59
74
 
60
75
  FLAGS
61
- -d, --dry-run Show what would be written without making changes
62
-
63
- GLOBAL FLAGS
64
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
65
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
66
- --user=<value> WordPress username (fallback; prefer `lps project config`)
76
+ -d, --dry-run Show what would change without making changes
67
77
 
68
78
  DESCRIPTION
69
79
  Pull composer.lock from WordPress
@@ -74,7 +84,7 @@ EXAMPLES
74
84
  $ lps composer pull --dry-run
75
85
  ```
76
86
 
77
- _See code: [src/commands/composer/pull.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/composer/pull.ts)_
87
+ _See code: [src/commands/composer/pull.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/composer/pull.ts)_
78
88
 
79
89
  ## `lps composer push`
80
90
 
@@ -82,16 +92,11 @@ Push composer.json and composer.lock to WordPress and run composer install
82
92
 
83
93
  ```
84
94
  USAGE
85
- $ lps composer push [--password <value>] [--url <value>] [--user <value>] [-d]
95
+ $ lps composer push [-d]
86
96
 
87
97
  FLAGS
88
98
  -d, --dry-run Show what would change without making changes
89
99
 
90
- GLOBAL FLAGS
91
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
92
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
93
- --user=<value> WordPress username (fallback; prefer `lps project config`)
94
-
95
100
  DESCRIPTION
96
101
  Push composer.json and composer.lock to WordPress and run composer install
97
102
 
@@ -101,7 +106,7 @@ EXAMPLES
101
106
  $ lps composer push --dry-run
102
107
  ```
103
108
 
104
- _See code: [src/commands/composer/push.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/composer/push.ts)_
109
+ _See code: [src/commands/composer/push.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/composer/push.ts)_
105
110
 
106
111
  ## `lps help [COMMAND]`
107
112
 
@@ -138,7 +143,7 @@ EXAMPLES
138
143
  $ lps init
139
144
  ```
140
145
 
141
- _See code: [src/commands/init.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/init.ts)_
146
+ _See code: [src/commands/init.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/init.ts)_
142
147
 
143
148
  ## `lps login`
144
149
 
@@ -155,7 +160,7 @@ EXAMPLES
155
160
  $ lps login
156
161
  ```
157
162
 
158
- _See code: [src/commands/login.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/login.ts)_
163
+ _See code: [src/commands/login.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/login.ts)_
159
164
 
160
165
  ## `lps logout`
161
166
 
@@ -172,7 +177,7 @@ EXAMPLES
172
177
  $ lps logout
173
178
  ```
174
179
 
175
- _See code: [src/commands/logout.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/logout.ts)_
180
+ _See code: [src/commands/logout.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/logout.ts)_
176
181
 
177
182
  ## `lps plugin add SLUG [VERSION]`
178
183
 
@@ -180,19 +185,14 @@ Add a WordPress.org plugin to loopress.json
180
185
 
181
186
  ```
182
187
  USAGE
183
- $ lps plugin add SLUG [VERSION] [--password <value>] [--url <value>] [--user <value>] [-d]
188
+ $ lps plugin add SLUG [VERSION] [-d]
184
189
 
185
190
  ARGUMENTS
186
191
  SLUG Plugin slug on WordPress.org
187
192
  [VERSION] Version to pin (default: latest)
188
193
 
189
194
  FLAGS
190
- -d, --dry-run Show what would be written without making changes
191
-
192
- GLOBAL FLAGS
193
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
194
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
195
- --user=<value> WordPress username (fallback; prefer `lps project config`)
195
+ -d, --dry-run Show what would change without making changes
196
196
 
197
197
  DESCRIPTION
198
198
  Add a WordPress.org plugin to loopress.json
@@ -205,7 +205,7 @@ EXAMPLES
205
205
  $ lps plugin add contact-form-7 --dry-run
206
206
  ```
207
207
 
208
- _See code: [src/commands/plugin/add.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/plugin/add.ts)_
208
+ _See code: [src/commands/plugin/add.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/plugin/add.ts)_
209
209
 
210
210
  ## `lps plugin pull`
211
211
 
@@ -213,15 +213,10 @@ Pull installed plugins from WordPress into loopress.json
213
213
 
214
214
  ```
215
215
  USAGE
216
- $ lps plugin pull [--password <value>] [--url <value>] [--user <value>] [-d]
216
+ $ lps plugin pull [-d]
217
217
 
218
218
  FLAGS
219
- -d, --dry-run Show what would be written without making changes
220
-
221
- GLOBAL FLAGS
222
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
223
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
224
- --user=<value> WordPress username (fallback; prefer `lps project config`)
219
+ -d, --dry-run Show what would change without making changes
225
220
 
226
221
  DESCRIPTION
227
222
  Pull installed plugins from WordPress into loopress.json
@@ -232,7 +227,7 @@ EXAMPLES
232
227
  $ lps plugin pull --dry-run
233
228
  ```
234
229
 
235
- _See code: [src/commands/plugin/pull.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/plugin/pull.ts)_
230
+ _See code: [src/commands/plugin/pull.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/plugin/pull.ts)_
236
231
 
237
232
  ## `lps plugin push`
238
233
 
@@ -240,16 +235,11 @@ Push plugins to WordPress to match loopress.json
240
235
 
241
236
  ```
242
237
  USAGE
243
- $ lps plugin push [--password <value>] [--url <value>] [--user <value>] [-d]
238
+ $ lps plugin push [-d]
244
239
 
245
240
  FLAGS
246
241
  -d, --dry-run Show what would change without making changes
247
242
 
248
- GLOBAL FLAGS
249
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
250
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
251
- --user=<value> WordPress username (fallback; prefer `lps project config`)
252
-
253
243
  DESCRIPTION
254
244
  Push plugins to WordPress to match loopress.json
255
245
 
@@ -259,7 +249,7 @@ EXAMPLES
259
249
  $ lps plugin push --dry-run
260
250
  ```
261
251
 
262
- _See code: [src/commands/plugin/push.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/plugin/push.ts)_
252
+ _See code: [src/commands/plugin/push.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/plugin/push.ts)_
263
253
 
264
254
  ## `lps project config`
265
255
 
@@ -276,7 +266,7 @@ EXAMPLES
276
266
  $ lps project config
277
267
  ```
278
268
 
279
- _See code: [src/commands/project/config.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/project/config.ts)_
269
+ _See code: [src/commands/project/config.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/project/config.ts)_
280
270
 
281
271
  ## `lps project list`
282
272
 
@@ -293,7 +283,7 @@ EXAMPLES
293
283
  $ lps project list
294
284
  ```
295
285
 
296
- _See code: [src/commands/project/list.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/project/list.ts)_
286
+ _See code: [src/commands/project/list.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/project/list.ts)_
297
287
 
298
288
  ## `lps project remove`
299
289
 
@@ -310,7 +300,7 @@ EXAMPLES
310
300
  $ lps project remove
311
301
  ```
312
302
 
313
- _See code: [src/commands/project/remove.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/project/remove.ts)_
303
+ _See code: [src/commands/project/remove.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/project/remove.ts)_
314
304
 
315
305
  ## `lps project switch`
316
306
 
@@ -327,7 +317,7 @@ EXAMPLES
327
317
  $ lps project switch
328
318
  ```
329
319
 
330
- _See code: [src/commands/project/switch.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/project/switch.ts)_
320
+ _See code: [src/commands/project/switch.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/project/switch.ts)_
331
321
 
332
322
  ## `lps snippet list`
333
323
 
@@ -335,30 +325,23 @@ List snippets from WordPress
335
325
 
336
326
  ```
337
327
  USAGE
338
- $ lps snippet list [--password <value>] [--url <value>] [--user <value>] [-j] [-p code-snippets|wpcode]
328
+ $ lps snippet list [-j] [-p code-snippets|wpcode]
339
329
 
340
330
  FLAGS
341
331
  -j, --json Output in JSON format
342
332
  -p, --plugin=<option> WordPress snippet plugin to target (overrides loopress.json)
343
333
  <options: code-snippets|wpcode>
344
334
 
345
- GLOBAL FLAGS
346
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
347
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
348
- --user=<value> WordPress username (fallback; prefer `lps project config`)
349
-
350
335
  DESCRIPTION
351
336
  List snippets from WordPress
352
337
 
353
338
  EXAMPLES
354
339
  $ lps snippet list
355
340
 
356
- $ lps snippet list --url http://example.com
357
-
358
341
  $ lps snippet list --plugin wpcode
359
342
  ```
360
343
 
361
- _See code: [src/commands/snippet/list.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/snippet/list.ts)_
344
+ _See code: [src/commands/snippet/list.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/snippet/list.ts)_
362
345
 
363
346
  ## `lps snippet pull [PATH]`
364
347
 
@@ -366,35 +349,28 @@ Pull snippets from WordPress
366
349
 
367
350
  ```
368
351
  USAGE
369
- $ lps snippet pull [PATH] [--password <value>] [--url <value>] [--user <value>] [-d] [-p code-snippets|wpcode]
352
+ $ lps snippet pull [PATH] [-d] [-p code-snippets|wpcode]
370
353
 
371
354
  ARGUMENTS
372
355
  [PATH] Path to snippets directory (overrides project config)
373
356
 
374
357
  FLAGS
375
- -d, --dry-run Show what would be written without making changes
358
+ -d, --dry-run Show what would change without making changes
376
359
  -p, --plugin=<option> WordPress snippet plugin to target (overrides loopress.json)
377
360
  <options: code-snippets|wpcode>
378
361
 
379
- GLOBAL FLAGS
380
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
381
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
382
- --user=<value> WordPress username (fallback; prefer `lps project config`)
383
-
384
362
  DESCRIPTION
385
363
  Pull snippets from WordPress
386
364
 
387
365
  EXAMPLES
388
366
  $ lps snippet pull
389
367
 
390
- $ lps snippet pull --url http://example.com
391
-
392
368
  $ lps snippet pull --path ./snippets
393
369
 
394
370
  $ lps snippet pull --plugin wpcode
395
371
  ```
396
372
 
397
- _See code: [src/commands/snippet/pull.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/snippet/pull.ts)_
373
+ _See code: [src/commands/snippet/pull.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/snippet/pull.ts)_
398
374
 
399
375
  ## `lps snippet push [PATH]`
400
376
 
@@ -402,7 +378,7 @@ Push snippets to WordPress. Local snippet files created or updated remotely are
402
378
 
403
379
  ```
404
380
  USAGE
405
- $ lps snippet push [PATH] [--password <value>] [--url <value>] [--user <value>] [-d] [-p code-snippets|wpcode]
381
+ $ lps snippet push [PATH] [-d] [-p code-snippets|wpcode]
406
382
 
407
383
  ARGUMENTS
408
384
  [PATH] Path to snippets directory (overrides project config)
@@ -412,11 +388,6 @@ FLAGS
412
388
  -p, --plugin=<option> WordPress snippet plugin to target (overrides loopress.json)
413
389
  <options: code-snippets|wpcode>
414
390
 
415
- GLOBAL FLAGS
416
- --password=<value> WordPress application password (fallback; prefer `lps project config`)
417
- --url=<value> WordPress URL (fallback; prefer `lps project config`)
418
- --user=<value> WordPress username (fallback; prefer `lps project config`)
419
-
420
391
  DESCRIPTION
421
392
  Push snippets to WordPress. Local snippet files created or updated remotely are renamed on disk to the `<id>-<slug>`
422
393
  convention.
@@ -424,14 +395,12 @@ DESCRIPTION
424
395
  EXAMPLES
425
396
  $ lps snippet push
426
397
 
427
- $ lps snippet push --url http://example.com
428
-
429
398
  $ lps snippet push --path ./snippets
430
399
 
431
400
  $ lps snippet push --plugin wpcode
432
401
  ```
433
402
 
434
- _See code: [src/commands/snippet/push.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/snippet/push.ts)_
403
+ _See code: [src/commands/snippet/push.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/snippet/push.ts)_
435
404
 
436
405
  ## `lps status`
437
406
 
@@ -448,5 +417,5 @@ EXAMPLES
448
417
  $ lps status
449
418
  ```
450
419
 
451
- _See code: [src/commands/status.ts](https://github.com/loopress/loopress/blob/v0.7.0/src/commands/status.ts)_
420
+ _See code: [src/commands/status.ts](https://github.com/loopress/loopress/blob/v0.9.0/src/commands/status.ts)_
452
421
  <!-- commandsstop -->
@@ -4,9 +4,6 @@ export default class ComposerPull extends LoopressCommand {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
- password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
7
  };
11
8
  run(): Promise<void>;
12
9
  }
@@ -1,32 +1,21 @@
1
- import { Flags } from '@oclif/core';
2
- import got from 'got';
3
1
  import { writeFile } from 'node:fs/promises';
4
2
  import { join } from 'node:path';
5
3
  import { LoopressCommand } from '../../lib/base.js';
6
- import { readLocalConfig } from '../../utils/loopress-config.js';
7
4
  export default class ComposerPull extends LoopressCommand {
8
5
  static description = 'Pull composer.lock from WordPress';
9
6
  static examples = ['$ lps composer pull', '$ lps composer pull --dry-run'];
10
7
  static flags = {
11
- ...LoopressCommand.baseFlags,
12
- 'dry-run': Flags.boolean({ char: 'd', description: 'Show what would be written without making changes' }),
8
+ ...LoopressCommand.dryRunFlag,
13
9
  };
14
10
  async run() {
15
- const { flags } = await this.parse(ComposerPull);
16
- const dryRun = flags['dry-run'];
17
11
  const { url } = this.siteConfig;
18
12
  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) {
13
+ const { composerLock } = await this.wp.get('loopress/v1/composer/lock');
14
+ if (this.dryRun) {
24
15
  this.log('[dry-run] Would write composer.lock');
25
16
  return;
26
17
  }
27
- const localConfig = await readLocalConfig();
28
- const rootDir = localConfig.rootDir ?? '.';
29
- const lockPath = join(process.cwd(), rootDir, 'composer.lock');
18
+ const lockPath = join(process.cwd(), this.rootDir, 'composer.lock');
30
19
  await writeFile(lockPath, composerLock, 'utf8');
31
20
  this.log(`Wrote composer.lock`);
32
21
  }
@@ -4,9 +4,6 @@ export default class ComposerPush extends PushCommand {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
- password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
7
  };
11
8
  run(): Promise<void>;
12
9
  }
@@ -1,26 +1,17 @@
1
- import { Flags } from '@oclif/core';
2
- import got from 'got';
3
1
  import { existsSync } from 'node:fs';
4
2
  import { readFile } from 'node:fs/promises';
5
3
  import { join } from 'node:path';
6
4
  import { PushCommand } from '../../lib/push-command.js';
7
- import { readLocalConfig } from '../../utils/loopress-config.js';
8
5
  export default class ComposerPush extends PushCommand {
9
6
  static description = 'Push composer.json and composer.lock to WordPress and run composer install';
10
7
  static examples = ['$ lps composer push', '$ lps composer push --dry-run'];
11
8
  static flags = {
12
- ...PushCommand.baseFlags,
13
- 'dry-run': Flags.boolean({ char: 'd', description: 'Show what would change without making changes' }),
9
+ ...PushCommand.dryRunFlag,
14
10
  };
15
11
  async run() {
16
- const { flags } = await this.parse(ComposerPush);
17
- const dryRun = flags['dry-run'];
18
- this.dryRun = dryRun;
19
12
  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');
13
+ const composerJsonPath = join(process.cwd(), this.rootDir, 'composer.json');
14
+ const composerLockPath = join(process.cwd(), this.rootDir, 'composer.lock');
24
15
  if (!existsSync(composerJsonPath)) {
25
16
  this.error(`No composer.json found at ${composerJsonPath}`);
26
17
  }
@@ -36,12 +27,11 @@ export default class ComposerPush extends PushCommand {
36
27
  else {
37
28
  this.warn('No composer.lock found. The server will resolve versions freely.');
38
29
  }
39
- if (dryRun)
30
+ if (this.dryRun)
40
31
  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 },
32
+ await this.wp.post('loopress/v1/composer/sync', {
33
+ composerJson: composerJsonRaw,
34
+ composerLock: composerLockRaw,
45
35
  });
46
36
  this.log('composer install completed on the server.');
47
37
  await this.recordSuccess();
@@ -10,7 +10,7 @@ export default class Login extends Command {
10
10
  async run() {
11
11
  const { email, token } = await this.waitForCallback();
12
12
  authManager.setAuth({ email, savedAt: new Date().toISOString(), token });
13
- this.log(`\n✅ Logged in${email ? ` as ${email}` : ''}. You're all set!`);
13
+ this.log(`\nLogged in${email ? ` as ${email}` : ''}. You're all set!`);
14
14
  }
15
15
  openBrowser(url) {
16
16
  const cmds = {
@@ -10,6 +10,6 @@ export default class Logout extends Command {
10
10
  return;
11
11
  }
12
12
  authManager.clearAuth();
13
- this.log(`✅ Logged out${auth.email ? ` (${auth.email})` : ''}.`);
13
+ this.log(`Logged out${auth.email ? ` (${auth.email})` : ''}.`);
14
14
  }
15
15
  }
@@ -9,9 +9,6 @@ export default class Add extends LoopressCommand {
9
9
  static examples: string[];
10
10
  static flags: {
11
11
  'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
- password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
- user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
12
  };
16
13
  run(): Promise<void>;
17
14
  }
@@ -1,8 +1,9 @@
1
- import { Args, Flags } from '@oclif/core';
1
+ import { Args } from '@oclif/core';
2
2
  import got from 'got';
3
3
  import { LoopressCommand } from '../../lib/base.js';
4
- import { readLocalConfig, writeLocalConfig } from '../../utils/loopress-config.js';
4
+ import { writeLocalConfig } from '../../utils/loopress-config.js';
5
5
  const WP_ORG_API = 'https://api.wordpress.org/plugins/info/1.2/';
6
+ const WP_ORG_TIMEOUT_MS = 10_000;
6
7
  export async function resolvePluginVersion(slug, version) {
7
8
  if (version !== 'latest')
8
9
  return version;
@@ -14,6 +15,7 @@ export async function resolvePluginVersion(slug, version) {
14
15
  action: 'plugin_information',
15
16
  'request[slug]': slug,
16
17
  },
18
+ timeout: { request: WP_ORG_TIMEOUT_MS },
17
19
  })
18
20
  .json();
19
21
  }
@@ -36,12 +38,10 @@ export default class Add extends LoopressCommand {
36
38
  '$ lps plugin add contact-form-7 --dry-run',
37
39
  ];
38
40
  static flags = {
39
- ...LoopressCommand.baseFlags,
40
- 'dry-run': Flags.boolean({ char: 'd', description: 'Show what would be written without making changes' }),
41
+ ...LoopressCommand.dryRunFlag,
41
42
  };
42
43
  async run() {
43
- const { args, flags } = await this.parse(Add);
44
- const dryRun = flags['dry-run'];
44
+ const { args } = await this.parse(Add);
45
45
  const { slug } = args;
46
46
  const requestedVersion = args.version ?? 'latest';
47
47
  this.log(`Resolving ${slug}@${requestedVersion}...`);
@@ -53,20 +53,19 @@ export default class Add extends LoopressCommand {
53
53
  this.error(error.message);
54
54
  }
55
55
  this.log(`Resolved: ${slug}@${resolvedVersion}`);
56
- const localConfig = await readLocalConfig();
57
- const existing = localConfig.plugins ?? {};
56
+ const existing = this.localConfig.plugins ?? {};
58
57
  if (existing[slug] === resolvedVersion) {
59
58
  this.log(`${slug}@${resolvedVersion} is already in loopress.json, nothing to do.`);
60
59
  return;
61
60
  }
62
61
  const updated = existing[slug] !== undefined;
63
62
  const label = updated ? `${existing[slug]} → ${resolvedVersion}` : resolvedVersion;
64
- if (dryRun) {
63
+ if (this.dryRun) {
65
64
  this.log(`[dry-run] Would ${updated ? 'update' : 'add'} ${slug}: ${label}`);
66
65
  return;
67
66
  }
68
67
  await writeLocalConfig({
69
- ...localConfig,
68
+ ...this.localConfig,
70
69
  plugins: { ...existing, [slug]: resolvedVersion },
71
70
  });
72
71
  this.log(`${updated ? 'Updated' : 'Added'} ${slug}: ${label}`);
@@ -4,9 +4,6 @@ export default class Pull extends LoopressCommand {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
- password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
7
  };
11
8
  run(): Promise<void>;
12
9
  }
@@ -1,23 +1,17 @@
1
- import { Flags } from '@oclif/core';
2
- import got from 'got';
3
1
  import { LoopressCommand } from '../../lib/base.js';
4
2
  import { getComposerManagedSlugs, readComposerJson } from '../../utils/composer.js';
5
- import { readLocalConfig, writeLocalConfig } from '../../utils/loopress-config.js';
3
+ import { writeLocalConfig } from '../../utils/loopress-config.js';
6
4
  import { mergePluginManifest } from '../../utils/plugins.js';
7
5
  export default class Pull extends LoopressCommand {
8
6
  static description = 'Pull installed plugins from WordPress into loopress.json';
9
7
  static examples = ['$ lps plugin pull', '$ lps plugin pull --dry-run'];
10
8
  static flags = {
11
- ...LoopressCommand.baseFlags,
12
- 'dry-run': Flags.boolean({ char: 'd', description: 'Show what would be written without making changes' }),
9
+ ...LoopressCommand.dryRunFlag,
13
10
  };
14
11
  async run() {
15
- const { flags } = await this.parse(Pull);
16
- const dryRun = flags['dry-run'];
17
12
  const { url } = this.siteConfig;
18
13
  this.log(`Pulling plugins from ${url}`);
19
- const headers = await this.buildAuthHeaders();
20
- const installed = await got.get(`${url}/wp-json/loopress/v1/plugins`, { headers }).json();
14
+ const installed = await this.wp.get('loopress/v1/plugins');
21
15
  const composerJson = await readComposerJson();
22
16
  const composerSlugs = composerJson ? getComposerManagedSlugs(composerJson) : [];
23
17
  const incoming = Object.fromEntries(installed.filter((p) => !composerSlugs.includes(p.slug)).map((p) => [p.slug, p.version]));
@@ -27,9 +21,8 @@ export default class Pull extends LoopressCommand {
27
21
  this.log(`Skipping ${found.length} Composer-managed ${found.length === 1 ? 'plugin' : 'plugins'}: ${found.join(', ')}`);
28
22
  }
29
23
  }
30
- const localConfig = await readLocalConfig();
31
- const { added, merged, updated } = mergePluginManifest(localConfig.plugins ?? {}, incoming);
32
- if (dryRun) {
24
+ const { added, merged, updated } = mergePluginManifest(this.localConfig.plugins ?? {}, incoming);
25
+ if (this.dryRun) {
33
26
  this.log(`[dry-run] Would write ${Object.keys(merged).length} plugins to loopress.json`);
34
27
  if (added.length > 0)
35
28
  this.log(` + ${added.join(', ')}`);
@@ -39,19 +32,14 @@ export default class Pull extends LoopressCommand {
39
32
  }
40
33
  return;
41
34
  }
42
- await writeLocalConfig({ ...localConfig, plugins: merged });
35
+ await writeLocalConfig({ ...this.localConfig, plugins: merged });
43
36
  this.log(`Wrote ${Object.keys(merged).length} plugins to loopress.json`);
44
37
  if (added.length > 0)
45
38
  this.log(` + Added: ${added.join(', ')}`);
46
39
  for (const u of updated)
47
40
  this.log(` ~ Updated: ${u.slug} ${u.from} → ${u.to}`);
48
41
  if (Object.keys(merged).length > 0) {
49
- await got
50
- .post(`${url}/wp-json/loopress/v1/plugins/auto-updates/disable`, {
51
- headers,
52
- json: { slugs: Object.keys(merged) },
53
- })
54
- .json();
42
+ await this.wp.post('loopress/v1/plugins/auto-updates/disable', { slugs: Object.keys(merged) });
55
43
  }
56
44
  }
57
45
  }
@@ -4,10 +4,11 @@ export default class Push extends PushCommand {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
- password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
7
  };
8
+ private failedCount;
11
9
  run(): Promise<void>;
12
10
  private activatePlugin;
11
+ private installAndActivate;
12
+ private performPluginAction;
13
+ private syncDrifted;
13
14
  }