nextpress-core 2.1.1 → 3.0.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 (122) hide show
  1. package/cli/index.js +11 -0
  2. package/cli/meta.js +5 -0
  3. package/cli/np-down.js +10 -0
  4. package/cli/np-install.js +35 -0
  5. package/cli/np-log.js +12 -0
  6. package/cli/np-run-dev.js +34 -0
  7. package/cli/np-run-start.js +33 -0
  8. package/cli/np-run.js +10 -0
  9. package/cli/run-command.js +23 -0
  10. package/cli/start-composer.js +39 -0
  11. package/lib/container-lib/NextJS.Dockerfile +47 -0
  12. package/lib/container-lib/docker-compose.dev.yml +69 -0
  13. package/lib/container-lib/docker-compose.prod.yml +23 -0
  14. package/lib/container-lib/docker-compose.yml +161 -0
  15. package/lib/container-lib/mail.dev.ini +3 -0
  16. package/lib/container-lib/mail.prod.ini +3 -0
  17. package/lib/container-lib/nginx.conf +71 -0
  18. package/lib/container-lib/uploads.ini +3 -0
  19. package/lib/wp-lib/src/acf/acf.php +10 -0
  20. package/lib/wp-lib/src/acf/acf_add_options.php +18 -0
  21. package/lib/wp-lib/src/acf/load_acf_fields.php +34 -0
  22. package/lib/wp-lib/src/api/nextpress_get_admin_bar.php +260 -0
  23. package/lib/wp-lib/src/api/nextpress_validate_user_session.php +114 -0
  24. package/lib/wp-lib/src/index.php +26 -0
  25. package/lib/wp-lib/src/nextpress_dev_mailer_setup.php +17 -0
  26. package/lib/wp-lib/src/nextpress_disable_core_depency_updates.php +49 -0
  27. package/lib/wp-lib/src/nextpress_remove_comments.php +17 -0
  28. package/lib/wp-lib/src/nextpress_remove_menu_pages.php +32 -0
  29. package/lib/wp-lib/src/nextpress_revalidate_frontend.php +57 -0
  30. package/lib/wp-lib/src/nextpress_save_path.php +150 -0
  31. package/lib/wp-lib/src/theme.php +31 -0
  32. package/package.json +15 -10
  33. package/cli/install.js +0 -27
  34. /package/lib/{acf-functions → nextjs-lib/acf-functions}/core/acf-builder.ts +0 -0
  35. /package/lib/{acf-functions → nextjs-lib/acf-functions}/core/acf-component-autoloader.ts +0 -0
  36. /package/lib/{acf-functions → nextjs-lib/acf-functions}/core/acf-field-group-autoloader.ts +0 -0
  37. /package/lib/{acf-functions → nextjs-lib/acf-functions}/services/define-field-group.ts +0 -0
  38. /package/lib/{acf-functions → nextjs-lib/acf-functions}/services/define-layout.ts +0 -0
  39. /package/lib/{acf-functions → nextjs-lib/acf-functions}/services/map-fields/helpers/map-choice-object.ts +0 -0
  40. /package/lib/{acf-functions → nextjs-lib/acf-functions}/services/map-fields/map-fields.ts +0 -0
  41. /package/lib/{acf-functions → nextjs-lib/acf-functions}/types/acf-field-group.ts +0 -0
  42. /package/lib/{acf-functions → nextjs-lib/acf-functions}/types/acf-field.ts +0 -0
  43. /package/lib/{acf-functions → nextjs-lib/acf-functions}/types/acf-layout.ts +0 -0
  44. /package/lib/{acf-functions → nextjs-lib/acf-functions}/types/acf-values.ts +0 -0
  45. /package/lib/{acf-functions → nextjs-lib/acf-functions}/types/components/field-props.ts +0 -0
  46. /package/lib/{acf-functions → nextjs-lib/acf-functions}/types/components/nextpress-component.ts +0 -0
  47. /package/lib/{ambient.d.ts → nextjs-lib/ambient.d.ts} +0 -0
  48. /package/lib/{entities → nextjs-lib/entities}/common.ts +0 -0
  49. /package/lib/{entities → nextjs-lib/entities}/option/option.interface.ts +0 -0
  50. /package/lib/{entities → nextjs-lib/entities}/option/option.ts +0 -0
  51. /package/lib/{entities → nextjs-lib/entities}/post/post.interface.ts +0 -0
  52. /package/lib/{entities → nextjs-lib/entities}/post/post.ts +0 -0
  53. /package/lib/{entities → nextjs-lib/entities}/term/term.interface.ts +0 -0
  54. /package/lib/{entities → nextjs-lib/entities}/term/term.ts +0 -0
  55. /package/lib/{entities → nextjs-lib/entities}/user/user.interface.ts +0 -0
  56. /package/lib/{entities → nextjs-lib/entities}/user/user.ts +0 -0
  57. /package/lib/{globals → nextjs-lib/globals}/entity-loader/entity-loader-base.ts +0 -0
  58. /package/lib/{globals → nextjs-lib/globals}/entity-loader/entity-loader.ts +0 -0
  59. /package/lib/{globals → nextjs-lib/globals}/entity-loader/option-loader.ts +0 -0
  60. /package/lib/{globals → nextjs-lib/globals}/entity-loader/post-loader.ts +0 -0
  61. /package/lib/{globals → nextjs-lib/globals}/entity-loader/term-loader.ts +0 -0
  62. /package/lib/{globals → nextjs-lib/globals}/entity-loader/user-loader.ts +0 -0
  63. /package/lib/{globals → nextjs-lib/globals}/get-field/get-field.ts +0 -0
  64. /package/lib/{globals → nextjs-lib/globals}/globals.ts +0 -0
  65. /package/lib/{globals → nextjs-lib/globals}/nextpress-config/nextpress-config.interface.ts +0 -0
  66. /package/lib/{globals → nextjs-lib/globals}/nextpress-config/nextpress-config.ts +0 -0
  67. /package/lib/{globals → nextjs-lib/globals}/queried-object/queried-object.ts +0 -0
  68. /package/lib/{repository → nextjs-lib/repository}/optionquery/option-query-args.ts +0 -0
  69. /package/lib/{repository → nextjs-lib/repository}/optionquery/option-query.ts +0 -0
  70. /package/lib/{repository → nextjs-lib/repository}/postquery/post-query-args.ts +0 -0
  71. /package/lib/{repository → nextjs-lib/repository}/postquery/post-query.ts +0 -0
  72. /package/lib/{repository → nextjs-lib/repository}/termquery/term-query-args.ts +0 -0
  73. /package/lib/{repository → nextjs-lib/repository}/termquery/term-query.ts +0 -0
  74. /package/lib/{repository → nextjs-lib/repository}/userquery/user-query-args.ts +0 -0
  75. /package/lib/{repository → nextjs-lib/repository}/userquery/user-query.ts +0 -0
  76. /package/lib/{router → nextjs-lib/router}/helpers.ts +0 -0
  77. /package/lib/{router → nextjs-lib/router}/nextpress-layout.tsx +0 -0
  78. /package/lib/{router → nextjs-lib/router}/nextpress-not-found-route.tsx +0 -0
  79. /package/lib/{router → nextjs-lib/router}/nextpress-proxy.ts +0 -0
  80. /package/lib/{router → nextjs-lib/router}/nextpress-static-params.ts +0 -0
  81. /package/lib/{router → nextjs-lib/router}/router.tsx +0 -0
  82. /package/lib/{router → nextjs-lib/router}/routes/api/api-get-admin-bar.ts +0 -0
  83. /package/lib/{router → nextjs-lib/router}/routes/api/api-get-draft-mode.ts +0 -0
  84. /package/lib/{router → nextjs-lib/router}/routes/api/api-get-field-groups.ts +0 -0
  85. /package/lib/{router → nextjs-lib/router}/routes/api/api-post-revalidate.ts +0 -0
  86. /package/lib/{router → nextjs-lib/router}/routes/api/helpers.ts +0 -0
  87. /package/lib/{router → nextjs-lib/router}/routes/author-archive.tsx +0 -0
  88. /package/lib/{router → nextjs-lib/router}/routes/post-index-page.tsx +0 -0
  89. /package/lib/{router → nextjs-lib/router}/routes/singular-page.tsx +0 -0
  90. /package/lib/{router → nextjs-lib/router}/routes/site-front-page.tsx +0 -0
  91. /package/lib/{router → nextjs-lib/router}/routes/term-archive.tsx +0 -0
  92. /package/lib/{router → nextjs-lib/router}/types.ts +0 -0
  93. /package/lib/{services → nextjs-lib/services}/get-menu.ts +0 -0
  94. /package/lib/{services → nextjs-lib/services}/get-theme-mods.ts +0 -0
  95. /package/lib/{services → nextjs-lib/services}/metadata/get-blogname.ts +0 -0
  96. /package/lib/{services → nextjs-lib/services}/metadata/get-favicon-url.ts +0 -0
  97. /package/lib/{services → nextjs-lib/services}/metadata/get-language-attribute.ts +0 -0
  98. /package/lib/{services → nextjs-lib/services}/utilities/capitalise-first-letter.ts +0 -0
  99. /package/lib/{services → nextjs-lib/services}/utilities/esc-html.ts +0 -0
  100. /package/lib/{services → nextjs-lib/services}/utilities/get-date-time-formatter.ts +0 -0
  101. /package/lib/{services → nextjs-lib/services}/utilities/kses-post.ts +0 -0
  102. /package/lib/{services → nextjs-lib/services}/utilities/process-url.ts +0 -0
  103. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/_autoloader/template-autoloader.ts +0 -0
  104. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/archive/archive.tsx +0 -0
  105. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/archive/author.tsx +0 -0
  106. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/archive/category.tsx +0 -0
  107. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/archive/posttypearchive.tsx +0 -0
  108. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/archive/tag.tsx +0 -0
  109. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/archive/taxonomy.tsx +0 -0
  110. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/home/home.tsx +0 -0
  111. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/index.tsx +0 -0
  112. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/not-found.tsx/not-found.tsx +0 -0
  113. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/page/page.tsx +0 -0
  114. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/page/posttype.tsx +0 -0
  115. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/page/single.tsx +0 -0
  116. /package/lib/{template-heirarchy → nextjs-lib/template-heirarchy}/page/singular.tsx +0 -0
  117. /package/lib/{ui → nextjs-lib/ui}/render-attachment-image.tsx +0 -0
  118. /package/lib/{ui → nextjs-lib/ui}/render-components.tsx +0 -0
  119. /package/lib/{ui → nextjs-lib/ui}/render-the-admin-bar.tsx +0 -0
  120. /package/lib/{ui → nextjs-lib/ui}/render-the-logo.tsx +0 -0
  121. /package/lib/{wpdb → nextjs-lib/wpdb}/wpdb.interface.ts +0 -0
  122. /package/lib/{wpdb → nextjs-lib/wpdb}/wpdb.ts +0 -0
@@ -0,0 +1,150 @@
1
+ <?php
2
+
3
+ namespace Nextpress;
4
+
5
+ use WP_Post;
6
+ use WP_Term;
7
+ use wpdb;
8
+
9
+ /**
10
+ * Add path postmeta for use in frontend application.
11
+ *
12
+ * @param WP_Post $post The post object being saved.
13
+ * @return void
14
+ */
15
+ function nextpress_save_post_path(WP_Post $post): void {
16
+ if (wp_is_post_revision($post->ID) || $post->post_type === 'attachment' || $post->post_type === 'nav_menu_item') return;
17
+ if (in_array($post->post_status, ['auto-draft', 'trash'])) return;
18
+
19
+ if (is_post_type_hierarchical($post->post_type)) {
20
+ $full_path = get_page_uri($post->ID);
21
+ } else {
22
+ $full_path = $post->post_name;
23
+ }
24
+ if (empty($full_path)) return;
25
+
26
+ $full_path = '/' . ltrim($full_path, '/');
27
+
28
+ update_post_meta($post->ID, '_nextpress_path', $full_path);
29
+ }
30
+
31
+ /**
32
+ * Add path termmeta for use in frontend application.
33
+ *
34
+ * @param int $term_id The ID of the term being saved.
35
+ * @param string $taxonomy The taxonomy of the term.
36
+ * @return void
37
+ */
38
+
39
+ function nextpress_save_term_path(int $term_id, string $taxonomy): void {
40
+ $term = get_term($term_id, $taxonomy);
41
+ if (!($term instanceof WP_Term)) return;
42
+
43
+ $slugs = [$term->slug];
44
+
45
+ while ( $term->parent != 0 ) {
46
+ $term = get_term($term->parent, $taxonomy);
47
+ if (!($term instanceof WP_Term)) return;
48
+
49
+ array_unshift($slugs, $term->slug);
50
+ }
51
+
52
+ $full_path = '/' . implode('/', $slugs);
53
+
54
+ update_term_meta($term_id, '_nextpress_path', $full_path);
55
+ }
56
+
57
+ /**
58
+ * Add path termmeta to all posts on theme switch.
59
+ *
60
+ * @return void
61
+ */
62
+ function nextpress_migrate_paths(): void {
63
+ if (function_exists('set_time_limit')) {
64
+ @set_time_limit(300);
65
+ }
66
+
67
+ // Posts
68
+ $last_processed_id = 0;
69
+ $batch_size = 200;
70
+
71
+ do {
72
+ global $wpdb;
73
+ if (!($wpdb instanceof wpdb)) return;
74
+
75
+ $post_ids = [];
76
+
77
+ try {
78
+ // @phpstan-ignore argument.type
79
+ $post_ids = $wpdb->get_col($wpdb->prepare("
80
+ SELECT ID FROM {$wpdb->posts}
81
+ WHERE ID > %d
82
+ AND post_status IN ('publish', 'draft', 'pending', 'private')
83
+ ORDER BY ID ASC
84
+ LIMIT %d
85
+ ", $last_processed_id, $batch_size));
86
+ } catch (\Throwable $th) {
87
+ error_log('nextpress_run_bulk_path_migration: Error when querying posts: ' . $th->getMessage());
88
+ }
89
+ if (!empty($post_ids)) {
90
+ foreach ($post_ids as $post_id) {
91
+ if (!is_numeric($post_id)) continue;
92
+
93
+ $post = get_post((int) $post_id);
94
+ if ($post) {
95
+ nextpress_save_post_path($post);
96
+ }
97
+ }
98
+
99
+ $last_processed_id = end($post_ids);
100
+ }
101
+
102
+ if (function_exists('wp_cache_flush_runtime')) {
103
+ wp_cache_flush_runtime();
104
+ }
105
+ } while (!empty($post_ids));
106
+
107
+ // Terms
108
+ $taxonomies = get_taxonomies();
109
+ $taxonomy_list = "'" . implode("','", array_map('esc_sql', $taxonomies)) . "'";
110
+ $last_processed_term_id = 0;
111
+
112
+ do {
113
+ global $wpdb;
114
+ if (!($wpdb instanceof wpdb)) return;
115
+
116
+ $terms_data = [];
117
+
118
+ try {
119
+ $terms_data = $wpdb->get_results( $wpdb->prepare(
120
+ // @phpstan-ignore argument.type
121
+ "SELECT t.term_id, tt.taxonomy
122
+ FROM " . $wpdb->terms . " AS t
123
+ INNER JOIN " . $wpdb->term_taxonomy . " AS tt ON t.term_id = tt.term_id
124
+ WHERE t.term_id > %d
125
+ AND tt.taxonomy IN (" . $taxonomy_list . ")
126
+ ORDER BY t.term_id ASC
127
+ LIMIT %d",
128
+ $last_processed_term_id,
129
+ $batch_size
130
+ ) );
131
+ } catch (\Throwable $th) {
132
+ error_log('nextpress_run_bulk_path_migration: Error when querying terms: ' . $th->getMessage());
133
+ }
134
+
135
+ if (!empty($terms_data)) {
136
+ foreach ($terms_data as $term_row) {
137
+ if (!is_numeric($term_row->term_id) || !is_string($term_row->taxonomy)) continue;
138
+ $term_id = (int) $term_row->term_id;
139
+
140
+ nextpress_save_term_path($term_id, $term_row->taxonomy);
141
+
142
+ $last_processed_term_id = $term_id;
143
+ }
144
+ }
145
+
146
+ if (function_exists('wp_cache_flush_runtime')) {
147
+ wp_cache_flush_runtime();
148
+ }
149
+ } while (!empty($terms_data));
150
+ }
@@ -0,0 +1,31 @@
1
+ <?php
2
+
3
+ namespace Nextpress;
4
+
5
+ /**
6
+ * Handles operations that should occur upon switching themes.
7
+ *
8
+ * @return void
9
+ */
10
+ function nextpress_switch_theme(): void
11
+ {
12
+ nextpress_migrate_paths();
13
+ }
14
+
15
+ /**
16
+ * Sets up theme defaults and registers support for various WordPress features.
17
+ *
18
+ * @return void
19
+ */
20
+ function nextpress_setup_theme(): void
21
+ {
22
+ // Adds support for the Custom Logo feature, allowing site administrators to easily upload and manage a site logo through the WordPress Customizer.
23
+ add_theme_support('custom-logo');
24
+
25
+ // Enables support for Featured Images
26
+ // This allows users to attach a main image to posts, pages, or custom post types.
27
+ add_theme_support('post-thumbnails');
28
+
29
+ // Disables the default, out-of-the-box block patterns that come bundled with WordPress.
30
+ remove_theme_support('core-block-patterns');
31
+ }
package/package.json CHANGED
@@ -1,19 +1,28 @@
1
1
  {
2
2
  "name": "nextpress-core",
3
- "version": "2.1.1",
3
+ "version": "3.0.0",
4
4
  "description": "Nextpress Core",
5
5
  "keywords": [],
6
6
  "bin": {
7
- "nextpress-install": "./cli/install.js"
7
+ "np": "./cli/index.js"
8
8
  },
9
9
  "files": [
10
- "lib",
10
+ "lib/container-lib",
11
+ "lib/nextjs-lib",
12
+ "lib/wp-lib/src",
11
13
  "cli"
12
14
  ],
13
15
  "author": "ellsaw",
14
16
  "license": "ISC",
15
17
  "type": "module",
16
18
  "devDependencies": {
19
+ "@microsoft/api-extractor": "^7.58.9",
20
+ "@tailwindcss/postcss": "^4",
21
+ "@types/node": "^20.19.41",
22
+ "@types/react": "^19",
23
+ "@types/react-dom": "^19",
24
+ "babel-plugin-react-compiler": "1.0.0",
25
+ "cross-env": "^10.1.0",
17
26
  "html-react-parser": "^6.1.2",
18
27
  "isomorphic-dompurify": "^3.14.0",
19
28
  "kysely": "^0.29.2",
@@ -22,14 +31,10 @@
22
31
  "php-serialize": "^5.1.3",
23
32
  "react": "19.2.4",
24
33
  "react-dom": "19.2.4",
25
- "@microsoft/api-extractor": "^7.58.9",
26
- "@tailwindcss/postcss": "^4",
27
- "@types/node": "^20.19.41",
28
- "@types/react": "^19",
29
- "@types/react-dom": "^19",
30
- "babel-plugin-react-compiler": "1.0.0",
31
- "cross-env": "^10.1.0",
32
34
  "tailwindcss": "^4",
33
35
  "typescript": "^5"
36
+ },
37
+ "dependencies": {
38
+ "commander": "^15.0.0"
34
39
  }
35
40
  }
package/cli/install.js DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'fs';
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
-
10
- const sourceDir = path.join(__dirname, '..', 'lib');
11
- const destDir = path.join(process.cwd(), '.nextpress');
12
-
13
- try {
14
- if (!fs.existsSync(sourceDir)) {
15
- console.error(`Error: Source folder does not exist at ${sourceDir}`);
16
- process.exit(1);
17
- }
18
-
19
- if (fs.existsSync(destDir)) {
20
- fs.rmSync(destDir, { recursive: true, force: true });
21
- }
22
-
23
- fs.cpSync(sourceDir, destDir, { recursive: true });
24
- } catch (err) {
25
- console.error('Error:', err.message);
26
- process.exit(1);
27
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes