@loopress/cli 0.30.0 → 0.32.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 (86) hide show
  1. package/README.md +494 -222
  2. package/dist/commands/acf/diff.d.ts +2 -2
  3. package/dist/commands/acf/diff.js +3 -1
  4. package/dist/commands/acf/list.d.ts +1 -0
  5. package/dist/commands/acf/list.js +2 -1
  6. package/dist/commands/acf/pull.d.ts +1 -0
  7. package/dist/commands/acf/pull.js +2 -1
  8. package/dist/commands/acf/push.d.ts +7 -2
  9. package/dist/commands/acf/push.js +14 -5
  10. package/dist/commands/acf/rollback.d.ts +2 -2
  11. package/dist/commands/acf/rollback.js +3 -1
  12. package/dist/commands/composer/pull.js +1 -1
  13. package/dist/commands/composer/push.d.ts +1 -0
  14. package/dist/commands/composer/push.js +13 -0
  15. package/dist/commands/content/copy.d.ts +28 -0
  16. package/dist/commands/content/copy.js +97 -0
  17. package/dist/commands/diff.d.ts +1 -0
  18. package/dist/commands/diff.js +13 -2
  19. package/dist/commands/doctor.d.ts +1 -0
  20. package/dist/commands/doctor.js +29 -2
  21. package/dist/commands/form/list.js +1 -1
  22. package/dist/commands/form/pull.js +1 -1
  23. package/dist/commands/form/push.d.ts +2 -1
  24. package/dist/commands/form/push.js +6 -3
  25. package/dist/commands/init.js +0 -23
  26. package/dist/commands/menu/push.d.ts +2 -1
  27. package/dist/commands/menu/push.js +1 -1
  28. package/dist/commands/option/push.d.ts +2 -1
  29. package/dist/commands/option/push.js +5 -3
  30. package/dist/commands/page/push.d.ts +4 -1
  31. package/dist/commands/page/push.js +43 -10
  32. package/dist/commands/pattern/push.js +1 -1
  33. package/dist/commands/pattern/rm.js +1 -1
  34. package/dist/commands/plugin/audit.js +42 -25
  35. package/dist/commands/plugin/push.js +1 -1
  36. package/dist/commands/plugin/status.js +1 -1
  37. package/dist/commands/promote.d.ts +1 -0
  38. package/dist/commands/promote.js +7 -3
  39. package/dist/commands/pull.d.ts +2 -1
  40. package/dist/commands/pull.js +37 -5
  41. package/dist/commands/push.d.ts +6 -2
  42. package/dist/commands/push.js +64 -19
  43. package/dist/commands/snippet/list.js +1 -1
  44. package/dist/commands/snippet/pull.js +1 -1
  45. package/dist/commands/snippet/push.d.ts +3 -1
  46. package/dist/commands/snippet/push.js +26 -5
  47. package/dist/commands/theme/pull.js +1 -1
  48. package/dist/commands/theme/push.d.ts +1 -0
  49. package/dist/commands/theme/push.js +3 -3
  50. package/dist/commands/theme/style/push.d.ts +2 -1
  51. package/dist/commands/theme/style/push.js +4 -5
  52. package/dist/commands/theme/template/list.js +1 -1
  53. package/dist/commands/theme/template/push.d.ts +11 -1
  54. package/dist/commands/theme/template/push.js +34 -5
  55. package/dist/commands/theme/version/pull.js +6 -1
  56. package/dist/commands/theme/version/push.js +1 -1
  57. package/dist/lib/base.d.ts +1 -0
  58. package/dist/lib/base.js +3 -0
  59. package/dist/lib/declared-type-command.d.ts +2 -1
  60. package/dist/lib/declared-type-command.js +1 -1
  61. package/dist/lib/diff-command.d.ts +3 -0
  62. package/dist/lib/diff-command.js +34 -5
  63. package/dist/lib/load-snippets.js +4 -0
  64. package/dist/lib/php-files-command.d.ts +11 -1
  65. package/dist/lib/php-files-command.js +39 -19
  66. package/dist/lib/plugin-detection.d.ts +1 -0
  67. package/dist/lib/plugin-detection.js +4 -0
  68. package/dist/lib/push-command.d.ts +21 -2
  69. package/dist/lib/push-command.js +105 -6
  70. package/dist/lib/resource-state.js +5 -5
  71. package/dist/lib/rollback-command.js +9 -2
  72. package/dist/lib/validate-local.js +21 -8
  73. package/dist/lib/wp-client.d.ts +1 -0
  74. package/dist/lib/wp-client.js +27 -1
  75. package/dist/types/snippet.d.ts +1 -0
  76. package/dist/utils/acf-format.d.ts +5 -0
  77. package/dist/utils/acf-format.js +29 -0
  78. package/dist/utils/php-top-level.d.ts +2 -0
  79. package/dist/utils/php-top-level.js +148 -0
  80. package/dist/utils/resource-dirs.d.ts +1 -0
  81. package/dist/utils/resource-dirs.js +7 -1
  82. package/dist/utils/template-format.d.ts +1 -0
  83. package/dist/utils/theme-styles-format.d.ts +2 -0
  84. package/dist/utils/theme-styles-format.js +32 -4
  85. package/oclif.manifest.json +1132 -919
  86. package/package.json +6 -3
@@ -1,3 +1,5 @@
1
+ import { resolve } from 'node:path';
2
+ import { readdirTolerant } from '../lib/readdir-tolerant.js';
1
3
  // Global Styles are the user's customizations from the Site Editor's "Styles" screen (colors,
2
4
  // typography, spacing), stored by WordPress core in a `wp_global_styles` post, one per theme.
3
5
  // This is separate from the theme's own theme.json file, which lives in the theme's repo and is
@@ -30,14 +32,40 @@ export function getUserGlobalStylesId(theme) {
30
32
  const match = /\/wp\/v2\/global-styles\/(\d+)/.exec(href);
31
33
  return match ? Number(match[1]) : null;
32
34
  }
33
- // Resolves the active theme's stylesheet slug and the id of its editable Global Styles post in
34
- // one call, failing clearly (rather than with a raw REST error later) when the active theme
35
- // isn't a block theme: classic themes have no Styles screen and no `wp_global_styles` post at all.
36
- export async function getActiveThemeGlobalStyles(wp) {
35
+ async function getActiveTheme(wp) {
37
36
  const themes = await wp.get('wp/v2/themes');
38
37
  const active = themes.find((theme) => theme.status === 'active');
39
38
  if (!active)
40
39
  throw new Error('Could not determine the active theme on WordPress.');
40
+ return active;
41
+ }
42
+ // The project's Global Styles files, one per theme it was pulled from. None: the project doesn't
43
+ // track them.
44
+ export async function globalStylesFiles(dir) {
45
+ return (await readdirTolerant(resolve(dir))).filter((file) => file.endsWith(THEME_STYLES_FILE_SUFFIX));
46
+ }
47
+ // Why the aggregate `lps push` / `lps pull` leave Global Styles out of this run, or undefined to
48
+ // include them. Only a project that tracks them (a `*-global-styles.json` file in `dir`) on a
49
+ // site whose active theme is a block theme qualifies: unlike `lps theme style push`, a classic
50
+ // theme is no error there, the rest of the run must go on. A push also needs the active theme's
51
+ // own file, there is nothing to send otherwise.
52
+ export async function globalStylesSkipNote(wp, dir, action) {
53
+ const files = await globalStylesFiles(dir);
54
+ if (files.length === 0)
55
+ return 'not configured, skipped';
56
+ const active = await getActiveTheme(wp);
57
+ if (!isBlockTheme(active))
58
+ return `the active theme "${active.stylesheet}" is a classic theme, skipped`;
59
+ if (action === 'push' && !files.includes(themeStylesFileName(active.stylesheet))) {
60
+ return `no file for the active theme "${active.stylesheet}", skipped`;
61
+ }
62
+ return undefined;
63
+ }
64
+ // Resolves the active theme's stylesheet slug and the id of its editable Global Styles post in
65
+ // one call, failing clearly (rather than with a raw REST error later) when the active theme
66
+ // isn't a block theme: classic themes have no Styles screen and no `wp_global_styles` post at all.
67
+ export async function getActiveThemeGlobalStyles(wp) {
68
+ const active = await getActiveTheme(wp);
41
69
  if (!isBlockTheme(active)) {
42
70
  throw new Error(`Global Styles sync only supports block themes (Full Site Editing). The active theme "${active.stylesheet}" is a classic theme.`);
43
71
  }