@loopress/cli 0.20.1 → 0.22.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 (118) hide show
  1. package/README.md +254 -75
  2. package/dist/commands/acf/list.d.ts +2 -2
  3. package/dist/commands/acf/list.js +4 -6
  4. package/dist/commands/acf/pull.js +9 -22
  5. package/dist/commands/acf/push.js +4 -7
  6. package/dist/commands/api/list.d.ts +7 -4
  7. package/dist/commands/api/list.js +5 -11
  8. package/dist/commands/api/publish.js +7 -23
  9. package/dist/commands/api/pull.d.ts +8 -1
  10. package/dist/commands/api/pull.js +22 -18
  11. package/dist/commands/api/push.d.ts +7 -1
  12. package/dist/commands/api/push.js +50 -23
  13. package/dist/commands/composer/init.js +6 -6
  14. package/dist/commands/composer/pull.d.ts +7 -1
  15. package/dist/commands/composer/pull.js +4 -2
  16. package/dist/commands/composer/push.d.ts +8 -1
  17. package/dist/commands/composer/push.js +3 -1
  18. package/dist/commands/dev.d.ts +13 -0
  19. package/dist/commands/dev.js +97 -0
  20. package/dist/commands/doctor.js +6 -5
  21. package/dist/commands/form/list.d.ts +2 -4
  22. package/dist/commands/form/list.js +3 -10
  23. package/dist/commands/form/pull.js +15 -24
  24. package/dist/commands/form/push.js +17 -42
  25. package/dist/commands/init.js +7 -7
  26. package/dist/commands/login.js +9 -5
  27. package/dist/commands/logout.js +2 -1
  28. package/dist/commands/page/list.d.ts +2 -4
  29. package/dist/commands/page/list.js +3 -10
  30. package/dist/commands/page/pull.d.ts +13 -1
  31. package/dist/commands/page/pull.js +21 -29
  32. package/dist/commands/page/push.d.ts +11 -1
  33. package/dist/commands/page/push.js +31 -49
  34. package/dist/commands/plugin/add.js +3 -3
  35. package/dist/commands/plugin/pull.d.ts +8 -1
  36. package/dist/commands/plugin/pull.js +11 -11
  37. package/dist/commands/plugin/push.d.ts +12 -1
  38. package/dist/commands/plugin/push.js +41 -27
  39. package/dist/commands/project/config.js +12 -9
  40. package/dist/commands/project/list.d.ts +16 -1
  41. package/dist/commands/project/list.js +22 -16
  42. package/dist/commands/project/pull.js +3 -2
  43. package/dist/commands/project/push.d.ts +5 -0
  44. package/dist/commands/project/push.js +84 -63
  45. package/dist/commands/project/switch.js +2 -2
  46. package/dist/commands/promote.d.ts +18 -0
  47. package/dist/commands/promote.js +90 -0
  48. package/dist/commands/pull.d.ts +12 -0
  49. package/dist/commands/pull.js +51 -0
  50. package/dist/commands/push.d.ts +13 -0
  51. package/dist/commands/push.js +57 -0
  52. package/dist/commands/seo/list.d.ts +9 -2
  53. package/dist/commands/seo/list.js +9 -11
  54. package/dist/commands/seo/pull.js +14 -37
  55. package/dist/commands/seo/push.js +24 -48
  56. package/dist/commands/snippet/list.d.ts +3 -4
  57. package/dist/commands/snippet/list.js +5 -11
  58. package/dist/commands/snippet/publish.js +5 -21
  59. package/dist/commands/snippet/pull.d.ts +13 -1
  60. package/dist/commands/snippet/pull.js +18 -20
  61. package/dist/commands/snippet/push.d.ts +11 -1
  62. package/dist/commands/snippet/push.js +29 -28
  63. package/dist/commands/status.d.ts +13 -1
  64. package/dist/commands/status.js +25 -18
  65. package/dist/commands/validate.d.ts +8 -0
  66. package/dist/commands/validate.js +24 -0
  67. package/dist/config/auth.manager.d.ts +2 -2
  68. package/dist/config/project-config.manager.d.ts +1 -1
  69. package/dist/config/project-config.manager.js +5 -6
  70. package/dist/lib/base.d.ts +11 -2
  71. package/dist/lib/base.js +54 -24
  72. package/dist/lib/bootstrap-full-install.d.ts +1 -1
  73. package/dist/lib/dev-watch.d.ts +16 -0
  74. package/dist/lib/dev-watch.js +71 -0
  75. package/dist/lib/find-orphaned-files.d.ts +3 -2
  76. package/dist/lib/find-orphaned-files.js +40 -4
  77. package/dist/lib/github-release.js +1 -1
  78. package/dist/lib/guard-production-push.d.ts +12 -0
  79. package/dist/lib/guard-production-push.js +20 -0
  80. package/dist/lib/interactive.js +1 -1
  81. package/dist/lib/load-files.d.ts +1 -0
  82. package/dist/lib/load-files.js +40 -11
  83. package/dist/lib/load-snippets.d.ts +1 -1
  84. package/dist/lib/load-snippets.js +66 -59
  85. package/dist/lib/local-callback-server.js +15 -8
  86. package/dist/lib/plugin-detection.d.ts +1 -1
  87. package/dist/lib/push-command.d.ts +3 -0
  88. package/dist/lib/push-command.js +22 -15
  89. package/dist/lib/put-or-create.d.ts +13 -0
  90. package/dist/lib/put-or-create.js +19 -0
  91. package/dist/lib/readdir-tolerant.d.ts +5 -0
  92. package/dist/lib/readdir-tolerant.js +11 -0
  93. package/dist/lib/resolve-linked-project.d.ts +8 -0
  94. package/dist/lib/resolve-linked-project.js +27 -0
  95. package/dist/lib/rotate-app-password.d.ts +1 -1
  96. package/dist/lib/rotate-app-password.js +1 -1
  97. package/dist/lib/temp-admin.d.ts +3 -3
  98. package/dist/lib/temp-admin.js +2 -2
  99. package/dist/lib/validate-local.d.ts +10 -0
  100. package/dist/lib/validate-local.js +183 -0
  101. package/dist/lib/wp-authorize-flow.js +5 -1
  102. package/dist/lib/wp-client.d.ts +2 -2
  103. package/dist/lib/wp-client.js +7 -0
  104. package/dist/types/plugin.d.ts +4 -4
  105. package/dist/types/snippet.d.ts +3 -3
  106. package/dist/utils/composer.d.ts +2 -2
  107. package/dist/utils/form-format.js +1 -1
  108. package/dist/utils/loopress-config.d.ts +1 -1
  109. package/dist/utils/page-format.js +2 -2
  110. package/dist/utils/plugins.d.ts +5 -5
  111. package/dist/utils/plugins.js +3 -3
  112. package/dist/utils/pluralize.d.ts +1 -0
  113. package/dist/utils/pluralize.js +5 -0
  114. package/dist/utils/seo-format.d.ts +6 -6
  115. package/dist/utils/snippet-format.d.ts +2 -2
  116. package/dist/utils/snippet-format.js +10 -5
  117. package/oclif.manifest.json +394 -57
  118. package/package.json +18 -16
@@ -0,0 +1 @@
1
+ export declare function pluralize(count: number, singular: string, plural?: string): string;
@@ -0,0 +1,5 @@
1
+ // `${pluralize(files.length, 'form')}` renders "1 form" or "3 forms"; pass an explicit
2
+ // plural for irregular words (e.g. `pluralize(n, 'box', 'boxes')`).
3
+ export function pluralize(count, singular, plural = `${singular}s`) {
4
+ return `${count} ${count === 1 ? singular : plural}`;
5
+ }
@@ -3,19 +3,19 @@ export declare const SEO_SETTINGS_ENDPOINT = "loopress/v1/seo/settings";
3
3
  export declare const SEO_REDIRECTS_ENDPOINT = "loopress/v1/seo/redirects";
4
4
  export declare function seoRedirectEndpoint(id: number): string;
5
5
  export declare function seoPostMetaEndpoint(postType: string): string;
6
- export interface SeoPostMeta {
6
+ export type SeoPostMeta = {
7
7
  meta: Record<string, unknown>;
8
8
  slug: string;
9
9
  title: string;
10
- }
11
- export interface SeoRedirect {
12
- createdAt: null | string;
10
+ };
11
+ export type SeoRedirect = {
12
+ createdAt: string | undefined;
13
13
  headerCode: number;
14
14
  hits: number;
15
15
  id: number;
16
16
  sources: unknown;
17
17
  status: string;
18
- updatedAt: null | string;
18
+ updatedAt: string | undefined;
19
19
  urlTo: string;
20
- }
20
+ };
21
21
  export declare function redirectFileBase(redirect: SeoRedirect): string;
@@ -2,7 +2,7 @@ export declare const SNIPPETS_ENDPOINT = "loopress/v1/snippets";
2
2
  export type SnippetType = 'css' | 'html' | 'js' | 'php' | 'text';
3
3
  export type SnippetInsertMethod = 'auto' | 'shortcode';
4
4
  export type SnippetLocation = 'admin' | 'body' | 'everywhere' | 'footer' | 'frontend' | 'header' | 'once';
5
- export interface NormalizedSnippet {
5
+ export type NormalizedSnippet = {
6
6
  active: boolean;
7
7
  code: string;
8
8
  description: string;
@@ -14,7 +14,7 @@ export interface NormalizedSnippet {
14
14
  shortcodeAttributes: string[];
15
15
  tags: string[];
16
16
  type: SnippetType;
17
- }
17
+ };
18
18
  export declare function parseType(raw: unknown): null | SnippetType;
19
19
  export declare function parseLocation(raw: unknown): null | SnippetLocation;
20
20
  export declare function parseInsertMethod(raw: unknown): null | SnippetInsertMethod;
@@ -1,12 +1,17 @@
1
1
  export const SNIPPETS_ENDPOINT = 'loopress/v1/snippets';
2
+ // Coerces server JSON that should be a string but, being unknown, could in principle be an
3
+ // object; a plain String() on that would print "[object Object]" instead of falling back.
4
+ function coerceString(value, fallback = '') {
5
+ return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' ? String(value) : fallback;
6
+ }
2
7
  export function parseType(raw) {
3
8
  const valid = ['css', 'html', 'js', 'php', 'text'];
4
- const value = String(raw ?? '').toLowerCase();
9
+ const value = coerceString(raw).toLowerCase();
5
10
  return valid.includes(value) ? value : null;
6
11
  }
7
12
  const VALID_LOCATIONS = new Set(['admin', 'body', 'everywhere', 'footer', 'frontend', 'header', 'once']);
8
13
  export function parseLocation(raw) {
9
- const value = String(raw ?? '').toLowerCase();
14
+ const value = coerceString(raw).toLowerCase();
10
15
  return VALID_LOCATIONS.has(value) ? value : null;
11
16
  }
12
17
  export function parseInsertMethod(raw) {
@@ -69,12 +74,12 @@ export function buildMetaFile(snippet) {
69
74
  export function normalizeSnippet(data) {
70
75
  return {
71
76
  active: Boolean(data.active),
72
- code: String(data.code ?? ''),
73
- description: String(data.description ?? ''),
77
+ code: coerceString(data.code),
78
+ description: coerceString(data.description),
74
79
  id: Number(data.id),
75
80
  insertMethod: parseInsertMethod(data.insertMethod) ?? 'auto',
76
81
  location: parseLocation(data.location) ?? defaultLocationForType(parseType(data.type) ?? 'php'),
77
- name: String(data.name ?? ''),
82
+ name: coerceString(data.name),
78
83
  priority: resolvePriority(data.priority),
79
84
  shortcodeAttributes: Array.isArray(data.shortcodeAttributes) ? data.shortcodeAttributes.map(String) : [],
80
85
  tags: Array.isArray(data.tags) ? data.tags : [],