@codigodoleo/wp-kit 1.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 (112) hide show
  1. package/.cspell.json +104 -0
  2. package/.editorconfig +13 -0
  3. package/.eslintignore +3 -0
  4. package/.eslintrc.json +24 -0
  5. package/.github/workflows/publish-npm.yml +32 -0
  6. package/.github/workflows/release-please.yml +25 -0
  7. package/.gitkeep +0 -0
  8. package/.husky/_/post-merge +0 -0
  9. package/.prettierignore +4 -0
  10. package/.prettierrc +8 -0
  11. package/.vscode/settings.json +19 -0
  12. package/CHANGELOG.md +47 -0
  13. package/README.md +115 -0
  14. package/VSCODE_EXTENSIONS.md +11 -0
  15. package/bin/index.js +4 -0
  16. package/docs/HOOKS-SYSTEM.md +172 -0
  17. package/git-deploy.sh +74 -0
  18. package/index.php +17 -0
  19. package/lib/cli.js +15 -0
  20. package/lib/commands/init.js +132 -0
  21. package/lib/core/generator.js +261 -0
  22. package/lib/core/hook-manager.js +172 -0
  23. package/lib/core/infer-ci-capabilities.js +119 -0
  24. package/lib/prompts/index.js +105 -0
  25. package/lib/prompts/loadModulePrompts.js +27 -0
  26. package/lib/utils/generate-from-template.js +17 -0
  27. package/lib/utils/git.js +17 -0
  28. package/lib/utils/logger.js +28 -0
  29. package/modules/deploy/index.js +39 -0
  30. package/modules/deploy/prompts.js +27 -0
  31. package/modules/deploy/templates/.github/workflows/ci.yml.hbs +103 -0
  32. package/modules/deploy/templates/.gitlab/gitlab-ci.yml.hbs +154 -0
  33. package/modules/deploy/templates/bitbucket-pipelines.yml.hbs +97 -0
  34. package/modules/docs/index.js +3 -0
  35. package/modules/docs/prompts.js +8 -0
  36. package/modules/docs/templates/README.md.hbs +160 -0
  37. package/modules/docs/templates/docs/Arquitetura.md +399 -0
  38. package/modules/docs/templates/docs/Deploy-Pipeline.md +113 -0
  39. package/modules/docs/templates/docs/Desenvolvimento.md +1116 -0
  40. package/modules/docs/templates/docs/Getting-Started.md +493 -0
  41. package/modules/docs/templates/docs/Infraestrutura.md +211 -0
  42. package/modules/docs/templates/docs/Monitoramento.md +302 -0
  43. package/modules/docs/templates/docs/Sync-the-Production-DB-with-the-Staging-DB.md +8 -0
  44. package/modules/docs/templates/docs/Troubleshooting.md +3 -0
  45. package/modules/git/.commitlintrc.json +136 -0
  46. package/modules/git/.github/PULL_REQUEST_TEMPLATE.md +42 -0
  47. package/modules/git/.gitlab/merge_request_templates/default.md +42 -0
  48. package/modules/git/.gitmessage +29 -0
  49. package/modules/git/.husky/commit-msg +4 -0
  50. package/modules/git/.husky/pre-commit +27 -0
  51. package/modules/git/.lintstagedrc.json +7 -0
  52. package/modules/git/.vscode/commit-instructions.md +59 -0
  53. package/modules/git/.vscode/conventional-commits.code-snippets +62 -0
  54. package/modules/git/.vscode/copilot.json +39 -0
  55. package/modules/git/docs/CONVENTIONAL-COMMITS.md +131 -0
  56. package/modules/git/index.js +137 -0
  57. package/modules/git/prompts.js +23 -0
  58. package/modules/git/templates/.lando.yml.hbs +13 -0
  59. package/modules/git/templates/package.json.hbs +15 -0
  60. package/modules/git/templates/workspace.json.hbs +114 -0
  61. package/modules/lint/.eslintignore +36 -0
  62. package/modules/lint/.eslintrc.json +8 -0
  63. package/modules/lint/.prettierignore +36 -0
  64. package/modules/lint/.prettierrc.json +29 -0
  65. package/modules/lint/.stylelintignore +19 -0
  66. package/modules/lint/.stylelintrc.json +9 -0
  67. package/modules/lint/index.js +15 -0
  68. package/modules/lint/pint.json +26 -0
  69. package/modules/lint/prompts.js +16 -0
  70. package/modules/lint/templates/.lando.yml.hbs +10 -0
  71. package/modules/lint/templates/package.json.hbs +16 -0
  72. package/modules/lint/templates/workspace.json.hbs +56 -0
  73. package/modules/php/index.js +3 -0
  74. package/modules/php/prompts.js +8 -0
  75. package/modules/php/scripts/php-wrapper.sh +38 -0
  76. package/modules/php/scripts/pint-wrapper.sh +44 -0
  77. package/modules/php/templates/.lando.yml.hbs +11 -0
  78. package/modules/php/templates/composer.json.hbs +6 -0
  79. package/modules/php/templates/workspace.json.hbs +74 -0
  80. package/modules/redis/prompts.js +8 -0
  81. package/modules/redis/templates/.lando.yml.hbs +8 -0
  82. package/modules/sage/index.js +20 -0
  83. package/modules/sage/prompts.js +16 -0
  84. package/modules/sage/templates/.lando.yml.hbs +64 -0
  85. package/modules/sage/templates/theme/composer.json.hbs +18 -0
  86. package/modules/sage/templates/theme/package.json.hbs +11 -0
  87. package/modules/sage/templates/theme/style.css.hbs +13 -0
  88. package/modules/sage/templates/theme/vite.config.js.hbs +53 -0
  89. package/modules/sage/templates/workspace.json.hbs +67 -0
  90. package/modules/test-directory/assets/module-file.txt +1 -0
  91. package/modules/test-directory/index.js +19 -0
  92. package/modules/test-directory/prompts.js +8 -0
  93. package/modules/test-directory/test-assets/file1.txt +1 -0
  94. package/modules/test-directory/test-assets/file2.txt +1 -0
  95. package/modules/test-directory/test-assets/subfolder/config.json +4 -0
  96. package/package.json +54 -0
  97. package/release-please-config.json +17 -0
  98. package/server/php/php.ini +48 -0
  99. package/server/www/rocket.conf +283 -0
  100. package/templates/.editorconfig.hbs +39 -0
  101. package/templates/.env.hbs +48 -0
  102. package/templates/.gitignore.hbs +86 -0
  103. package/templates/.lando.yml.hbs +44 -0
  104. package/templates/README.md.hbs +12 -0
  105. package/templates/composer.json.hbs +60 -0
  106. package/templates/package.json.hbs +47 -0
  107. package/templates/server/cmd/install-wp.sh.hbs +58 -0
  108. package/templates/server/www/vhosts.conf.hbs +71 -0
  109. package/templates/workspace.json.hbs +177 -0
  110. package/test-copy-directory.js +43 -0
  111. package/test-overwrite.js +45 -0
  112. package/wp-config.php +190 -0
package/wp-config.php ADDED
@@ -0,0 +1,190 @@
1
+ <?php
2
+
3
+ /**
4
+ * The base configuration for WordPress
5
+ *
6
+ * The wp-config.php creation script uses this file during the installation.
7
+ * You don't have to use the website, you can copy this file to "wp-config.php"
8
+ * and fill in the values.
9
+ *
10
+ * This file contains the following configurations:
11
+ *
12
+ * * Database settings
13
+ * * Secret keys
14
+ * * Database table prefix
15
+ * * ABSPATH
16
+ *
17
+ * This has been slightly modified (to read environment variables) for use in Docker.
18
+ *
19
+ * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
20
+ *
21
+ * @package WordPress
22
+ */
23
+
24
+ // ** Load Composer autoload ** //
25
+ if (file_exists(__DIR__ . '/vendor/autoload.php')) {
26
+ require_once __DIR__ . '/vendor/autoload.php';
27
+ } else {
28
+ die('Error: Composer autoload not found.');
29
+ }
30
+
31
+
32
+ // ** Carregar o .env para variáveis de ambiente ** //
33
+ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
34
+ $dotenv->safeLoad();
35
+ $requiredEnvs = ['WORDPRESS_DB_NAME', 'WORDPRESS_DB_USER', 'WORDPRESS_DB_PASSWORD', 'WORDPRESS_DB_HOST', 'WORDPRESS_SITE_URL'];
36
+ $dotenv->required($requiredEnvs);
37
+
38
+ // a helper function to lookup "env_FILE", "env", then fallback
39
+ if (!function_exists('getenv_docker')) {
40
+ // https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x)
41
+ function getenv_docker($env, $default)
42
+ {
43
+ if (getenv('LANDO_INFO')) {
44
+ // Lando-specific environment variable
45
+ return $_ENV[$env] ?? $default;
46
+ } else if ($fileEnv = getenv($env . '_FILE')) {
47
+ return rtrim(file_get_contents($fileEnv), "\r\n");
48
+ } else if (($val = getenv($env)) !== false) {
49
+ return $val;
50
+ } else {
51
+ return $default;
52
+ }
53
+ }
54
+ }
55
+
56
+ // ** Database settings - You can get this info from your web host ** //
57
+ /** The name of the database for WordPress */
58
+ define('DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress'));
59
+
60
+ /** Database username */
61
+ define('DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username'));
62
+
63
+ /** Database password */
64
+ define('DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password'));
65
+
66
+ /**
67
+ * Docker image fallback values above are sourced from the official WordPress installation wizard:
68
+ * https://github.com/WordPress/WordPress/blob/1356f6537220ffdc32b9dad2a6cdbe2d010b7a88/wp-admin/setup-config.php#L224-L238
69
+ * (However, using "example username" and "example password" in your database is strongly discouraged. Please use strong, random credentials!)
70
+ */
71
+
72
+ /** Database hostname */
73
+ define('DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql'));
74
+
75
+ /** Database charset to use in creating database tables. */
76
+ define('DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8'));
77
+
78
+ /** The database collate type. Don't change this if in doubt. */
79
+ define('DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', ''));
80
+
81
+ /**#@+
82
+ * Authentication unique keys and salts.
83
+ *
84
+ * Change these to different unique phrases! You can generate these using
85
+ * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
86
+ *
87
+ * You can change these at any point in time to invalidate all existing cookies.
88
+ * This will force all users to have to log in again.
89
+ *
90
+ * @since 2.6.0
91
+ */
92
+ define('AUTH_KEY', getenv_docker('WORDPRESS_AUTH_KEY', 'put your unique phrase here'));
93
+ define('SECURE_AUTH_KEY', getenv_docker('WORDPRESS_SECURE_AUTH_KEY', 'put your unique phrase here'));
94
+ define('LOGGED_IN_KEY', getenv_docker('WORDPRESS_LOGGED_IN_KEY', 'put your unique phrase here'));
95
+ define('NONCE_KEY', getenv_docker('WORDPRESS_NONCE_KEY', 'put your unique phrase here'));
96
+ define('AUTH_SALT', getenv_docker('WORDPRESS_AUTH_SALT', 'put your unique phrase here'));
97
+ define('SECURE_AUTH_SALT', getenv_docker('WORDPRESS_SECURE_AUTH_SALT', 'put your unique phrase here'));
98
+ define('LOGGED_IN_SALT', getenv_docker('WORDPRESS_LOGGED_IN_SALT', 'put your unique phrase here'));
99
+ define('NONCE_SALT', getenv_docker('WORDPRESS_NONCE_SALT', 'put your unique phrase here'));
100
+ // (See also https://wordpress.stackexchange.com/a/152905/199287)
101
+
102
+ /**#@-*/
103
+
104
+ /**
105
+ * WordPress database table prefix.
106
+ *
107
+ * You can have multiple installations in one database if you give each
108
+ * a unique prefix. Only numbers, letters, and underscores please!
109
+ *
110
+ * At the installation time, database tables are created with the specified prefix.
111
+ * Changing this value after WordPress is installed will make your site think
112
+ * it has not been installed.
113
+ *
114
+ * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
115
+ */
116
+ $table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');
117
+
118
+ /**
119
+ * For developers: WordPress debugging mode.
120
+ *
121
+ * Change this to true to enable the display of notices during development.
122
+ * It is strongly recommended that plugin and theme developers use WP_DEBUG
123
+ * in their development environments.
124
+ *
125
+ * For information on other constants that can be used for debugging,
126
+ * visit the documentation.
127
+ *
128
+ * @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
129
+ */
130
+ define('WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', ''));
131
+
132
+ /* Add any custom values between this line and the "stop editing" line. */
133
+
134
+ // If we're running in a Docker container, we need to set the HTTP_HOST and SERVER_PORT
135
+ // to empty strings, otherwise WordPress will try to use the container name as the host.
136
+ // This is necessary for WordPress to work correctly in a Docker environment.
137
+ // This is a workaround for the issue where WordPress tries to use the container name as the host,
138
+ // which can cause issues with SSL and other configurations.
139
+ if (defined('WP_CLI') && constant('WP_CLI')) {
140
+ $_SERVER["HTTP_HOST"] = "";
141
+ $_SERVER['SERVER_PORT'] = 80;
142
+ }
143
+
144
+ // If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
145
+ // see also https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy
146
+ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
147
+ $_SERVER['HTTPS'] = 'on';
148
+ }
149
+
150
+ /** URL routing (Optional, may not be necessary) */
151
+ $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
152
+ $siteUrl = getenv_docker('WORDPRESS_SITE_URL', 'localhost');
153
+ $siteUrl = (strpos($siteUrl, 'http') === 0) ? $siteUrl : $protocol . $siteUrl;
154
+ define('WP_HOME', $siteUrl);
155
+ define('WP_SITEURL', $siteUrl . '/wp');
156
+
157
+ // Define the content directory and URL
158
+ // This is where your themes, plugins, and uploads will be stored.
159
+ // The default is to use the "content" directory in the same directory as this file.
160
+ // If you want to use a different directory, you can change the path below.
161
+ // Note: This is not the same as the "wp-content" directory, which is the default location for WordPress content.
162
+ define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/content' );
163
+ define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
164
+
165
+ // Load all WordPress environment variables from the .env file
166
+ $wordpressEnvs = array_filter($_ENV, function ($key) {
167
+ return strpos($key, 'WORDPRESS_') === 0;
168
+ }, ARRAY_FILTER_USE_KEY);
169
+
170
+ // Define all remaining WordPress environment variables
171
+ foreach ($wordpressEnvs as $key => $value) {
172
+ $key = str_replace('WORDPRESS_', '', $key);
173
+ if (!defined($key))
174
+ define($key, $value);
175
+ }
176
+
177
+ // If there's a WORDPRESS_CONFIG_EXTRA environment variable, evaluate it
178
+ if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {
179
+ eval($configExtra);
180
+ }
181
+
182
+ /* That's all, stop editing! Happy publishing. */
183
+
184
+ /** Absolute path to the WordPress directory. */
185
+ if (! defined('ABSPATH')) {
186
+ define('ABSPATH', __DIR__ . '/');
187
+ }
188
+
189
+ /** Sets up WordPress vars and included files. */
190
+ require_once ABSPATH . 'wp-settings.php';