@codigodoleo/wp-kit 5.0.1 → 5.1.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 (68) hide show
  1. package/lib/commands/init.js +87 -78
  2. package/lib/config/versions.js +45 -45
  3. package/lib/core/infer-ci-capabilities.js +39 -26
  4. package/lib/prompts/index.js +113 -92
  5. package/lib/utils/logger.js +1 -1
  6. package/modules/blank-theme/index.js +49 -41
  7. package/modules/blank-theme/prompts.js +9 -25
  8. package/modules/blank-theme/templates/.lando.yml.hbs +5 -8
  9. package/modules/blank-theme/templates/functions.php.hbs +21 -15
  10. package/modules/blank-theme/templates/package.json.hbs +1 -1
  11. package/modules/deploy/index.js +51 -61
  12. package/modules/deploy/prompts.js +36 -12
  13. package/modules/deploy/templates/.github/workflows/ci.yml.hbs +356 -63
  14. package/modules/deploy/templates/.gitlab/ci/lint-blank-theme.yml.hbs +4 -4
  15. package/modules/deploy/templates/.gitlab/ci/lint-mu-plugin.yml.hbs +3 -2
  16. package/modules/deploy/templates/.gitlab/ci/lint-plugin.yml.hbs +3 -2
  17. package/modules/deploy/templates/.gitlab/ci/lint-sage.yml.hbs +17 -14
  18. package/modules/git/.lintstagedrc.json +2 -5
  19. package/modules/lint/.oxlintrc.json +19 -0
  20. package/modules/lint/.prettierignore +16 -1
  21. package/modules/lint/index.js +32 -40
  22. package/modules/lint/templates/mago.toml.hbs +83 -0
  23. package/modules/lint/templates/package.json.hbs +6 -10
  24. package/modules/lint/templates/workspace.json.hbs +2 -36
  25. package/modules/mu-plugin/index.js +64 -56
  26. package/modules/mu-plugin/prompts.js +21 -23
  27. package/modules/mu-plugin/templates/.lando.yml.hbs +8 -10
  28. package/modules/mu-plugin/templates/acorn/app/Providers/CoreServiceProvider.php.hbs +1 -1
  29. package/modules/mu-plugin/templates/acorn/composer.json.hbs +6 -5
  30. package/modules/mu-plugin/templates/composer.json.hbs +4 -2
  31. package/modules/php/templates/.lando.yml.hbs +13 -8
  32. package/modules/php/templates/composer.json.hbs +15 -7
  33. package/modules/php/templates/workspace.json.hbs +22 -19
  34. package/modules/plugin/index.js +10 -18
  35. package/modules/plugin/prompts.js +5 -19
  36. package/modules/plugin/templates/.lando.yml.hbs +8 -10
  37. package/modules/plugin/templates/composer.json.hbs +4 -2
  38. package/modules/sage/index.js +78 -88
  39. package/modules/sage/prompts.js +10 -24
  40. package/modules/sage/templates/.lando.yml.hbs +17 -7
  41. package/modules/sage/templates/theme/composer.json.hbs +36 -23
  42. package/modules/sage/templates/theme/package.json.hbs +24 -13
  43. package/modules/sage/templates/theme/style.css.hbs +12 -20
  44. package/modules/test/templates/composer.json.hbs +1 -1
  45. package/package.json +30 -35
  46. package/templates/.devcontainer/devcontainer.json.hbs +2 -2
  47. package/templates/.gitignore.hbs +9 -3
  48. package/templates/README.md.hbs +1 -1
  49. package/templates/auth.json.hbs +8 -0
  50. package/templates/composer.json.hbs +13 -5
  51. package/templates/package.json.hbs +2 -4
  52. package/templates/workspace.json.hbs +3 -4
  53. package/wp-config.php +5 -0
  54. package/modules/blank-theme/lint/eslint.config.mjs +0 -30
  55. package/modules/blank-theme/lint/pint.json +0 -11
  56. package/modules/deploy/.github/workflows/deploy-docker.yml +0 -104
  57. package/modules/deploy/.github/workflows/deploy-ssh.yml +0 -128
  58. package/modules/deploy/.github/workflows/release.yml +0 -57
  59. package/modules/mu-plugin/lint/eslint.config.mjs +0 -30
  60. package/modules/mu-plugin/lint/pint.json +0 -11
  61. package/modules/mu-plugin/templates/acorn/resources/.gitkeep +0 -0
  62. package/modules/mu-plugin/templates/acorn/storage/framework/cache/.gitkeep +0 -0
  63. package/modules/mu-plugin/templates/acorn/storage/framework/sessions/.gitkeep +0 -0
  64. package/modules/mu-plugin/templates/acorn/storage/framework/views/.gitkeep +0 -0
  65. package/modules/plugin/lint/eslint.config.mjs +0 -30
  66. package/modules/plugin/lint/pint.json +0 -11
  67. package/modules/sage/lint/eslint.config.mjs +0 -30
  68. package/modules/sage/lint/pint.json +0 -11
@@ -1,6 +1,6 @@
1
- import path from 'path';
1
+ import path from "path";
2
2
 
3
- import fs from 'fs-extra';
3
+ import fs from "fs-extra";
4
4
 
5
5
  /**
6
6
  * Builds the lint-staged entries object from active development modules.
@@ -9,73 +9,65 @@ import fs from 'fs-extra';
9
9
  function buildLintStagedEntries(context) {
10
10
  const entries = {};
11
11
 
12
- // Infra: YAML, JSON, Markdown at root (never touching module folders)
13
- entries['*.{yml,yaml}'] = ['prettier --write'];
14
- entries['*.{json,md}'] = ['prettier --write'];
12
+ // Infra: YAML, JSON, Markdown at root
13
+ entries["*.{js,mjs,ts,vue,jsx,tsx}"] = ["oxfmt --write", "oxlint --fix"];
14
+ entries["*.{json,jsonc,html,yml,yaml,md,mdx}"] = ["oxfmt --write"];
15
15
 
16
- // Sage
16
+ // Sage — PHP via mago (format only on pre-commit, lint runs in CI)
17
17
  if (context.enable_sage) {
18
18
  const dir = `content/themes/${context.projectName}`;
19
- if (context.sage_lint_eslint !== false) {
20
- entries[`${dir}/resources/**/*.{js,ts,vue,mjs}`] = ['eslint --fix'];
21
- }
19
+ entries[`${dir}/{app,routes,config}/**/*.php`] = [
20
+ "lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
21
+ ];
22
22
  if (context.sage_lint_stylelint !== false) {
23
- entries[`${dir}/resources/**/*.{css,scss}`] = ['stylelint --fix'];
24
- }
25
- if (context.sage_lint_pint !== false) {
26
- entries[`${dir}/app/**/*.php`] = ['pint'];
23
+ entries[`${dir}/resources/**/*.{css,scss}`] = ["stylelint --fix"];
27
24
  }
28
25
  }
29
26
 
30
- // MU-Plugin
27
+ // MU-Plugin — PHP via mago
31
28
  if (context.enable_mu_plugin) {
32
29
  const dir = `content/mu-plugins/${context.mu_plugin_name || `${context.projectName}-core`}`;
33
- if (context.mu_plugin_lint_eslint !== false) {
34
- entries[`${dir}/resources/**/*.{js,ts}`] = ['eslint --fix'];
35
- }
36
- if (context.mu_plugin_lint_pint !== false) {
37
- entries[`${dir}/src/**/*.php`] = ['pint'];
38
- }
30
+ entries[`${dir}/app/**/*.php`] = [
31
+ "lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
32
+ ];
39
33
  }
40
34
 
41
- // Plugin
35
+ // Plugin — PHP via mago
42
36
  if (context.enable_plugin) {
43
37
  const dir = `content/plugins/${context.plugin_name || `${context.projectName}-plugin`}`;
44
- if (context.plugin_lint_eslint !== false) {
45
- entries[`${dir}/resources/**/*.{js,ts}`] = ['eslint --fix'];
46
- }
47
- if (context.plugin_lint_pint !== false) {
48
- entries[`${dir}/src/**/*.php`] = ['pint'];
49
- }
38
+ entries[`${dir}/src/**/*.php`] = [
39
+ "lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
40
+ ];
50
41
  }
51
42
 
52
43
  // Blank Theme
53
44
  if (context.enable_blank_theme) {
54
45
  const dir = `content/themes/${context.blank_theme_name || `${context.projectName}-theme`}`;
55
- if (context.blank_theme_lint_eslint !== false) {
56
- entries[`${dir}/src/**/*.{js,ts}`] = ['eslint --fix'];
57
- }
46
+ entries[`${dir}/src/**/*.{js,ts}`] = ["oxfmt --write", "oxlint --fix"];
58
47
  if (context.blank_theme_lint_stylelint !== false) {
59
- entries[`${dir}/src/**/*.{css,scss}`] = ['stylelint --fix'];
60
- }
61
- if (context.blank_theme_lint_pint !== false) {
62
- entries[`${dir}/src/**/*.php`] = ['pint'];
48
+ entries[`${dir}/src/**/*.{css,scss}`] = ["stylelint --fix"];
63
49
  }
64
50
  }
65
51
 
52
+ // Tests PHP
53
+ entries["tests/**/*.php"] = ["lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'"];
54
+
66
55
  return entries;
67
56
  }
68
57
 
69
58
  export async function setupModule(context, generator) {
70
59
  if (!context.enable_lint) return;
71
60
 
72
- // Root developer tooling (always present when lint is enabled)
73
- await generator.copyFile('.commitlintrc.json', 'lint');
74
- await generator.copyFile('.prettierrc.json', 'lint');
75
- await generator.copyFile('.prettierignore', 'lint');
61
+ // Root developer tooling
62
+ await generator.copyFile(".commitlintrc.json", "lint");
63
+ await generator.copyFile(".prettierignore", "lint");
64
+ await generator.copyFile(".oxlintrc.json", "lint");
65
+
66
+ // mago.toml — generated (paths depend on active modules)
67
+ await generator.generateFile("mago.toml", context, "lint", "mago.toml");
76
68
 
77
69
  // Compose .lintstagedrc.json from active modules
78
70
  const entries = buildLintStagedEntries(context);
79
- const lintStagedPath = path.join(generator.cwd, '.lintstagedrc.json');
80
- await fs.outputFile(lintStagedPath, JSON.stringify(entries, null, 2) + '\n');
71
+ const lintStagedPath = path.join(generator.cwd, ".lintstagedrc.json");
72
+ await fs.outputFile(lintStagedPath, JSON.stringify(entries, null, 2) + "\n");
81
73
  }
@@ -0,0 +1,83 @@
1
+ # Mago — PHP format + lint configuration
2
+ # https://carthage.software/mago
3
+ #
4
+ # Replaces Laravel Pint and adds a linter we never had.
5
+ #
6
+ # WordPress-aware rule overrides: a number of "best practices" lints fire on
7
+ # idioms that are unavoidable inside WordPress / ACF / Acorn — they are
8
+ # disabled explicitly with a comment so a future reader knows why.
9
+
10
+ [source]
11
+ paths = [
12
+ {{#if enable_sage}} "content/themes/{{projectName}}/app/",
13
+ "content/themes/{{projectName}}/routes/",
14
+ "content/themes/{{projectName}}/config/",
15
+ {{/if}}{{#if enable_mu_plugin}} "content/mu-plugins/{{mu_plugin_name}}/app/",
16
+ {{/if}}{{#if enable_plugin}} "content/plugins/{{plugin_name}}/src/",
17
+ {{/if}} "tests/",
18
+ ]
19
+ excludes = [
20
+ {{#if enable_sage}} "content/themes/{{projectName}}/public/**",
21
+ "content/themes/{{projectName}}/vendor/**",
22
+ "content/themes/{{projectName}}/node_modules/**",
23
+ {{/if}} "vendor/**",
24
+ "wp/**",
25
+ "content/plugins/**",
26
+ "content/mu-plugins/**",
27
+ ]
28
+
29
+ [formatter]
30
+ print-width = 120
31
+ null-type-hint = "question"
32
+ space-before-arrow-function-parameter-list-parenthesis = true
33
+ space-after-logical-not-unary-prefix-operator = true
34
+ sort-uses = true
35
+
36
+ [linter]
37
+ integrations = ["laravel"]
38
+
39
+ [linter.rules]
40
+ # Too noisy with WordPress i18n functions (__(), _e(), _x(), etc.)
41
+ literal-named-argument = { enabled = false }
42
+
43
+ no-else-clause = { enabled = true }
44
+
45
+ # Common WordPress pattern: if ($x = get_option(...)) { ... }
46
+ no-assign-in-condition = { enabled = false }
47
+
48
+ no-empty = { enabled = false }
49
+
50
+ # Unavoidable in WordPress: $GLOBALS['wpdb'], global $wp_rest_server, etc.
51
+ no-global = { enabled = false }
52
+
53
+ # False positive on Laravel cast definitions
54
+ no-literal-password = { enabled = false }
55
+
56
+ # We use empty comments to keep callback bodies expanded for readability
57
+ no-empty-comment = { enabled = false }
58
+
59
+ no-eval = { enabled = true }
60
+
61
+ # Common WordPress REST API test pattern
62
+ no-multi-assignments = { enabled = false }
63
+
64
+ # WordPress functions often return false instead of null
65
+ no-redundant-nullsafe = { enabled = false }
66
+
67
+ no-redundant-parentheses = { enabled = true }
68
+ no-redundant-use = { enabled = true }
69
+ no-shorthand-ternary = { enabled = false }
70
+
71
+ # Arrow functions should be a stylistic choice
72
+ prefer-arrow-function = { enabled = false }
73
+
74
+ # False positive — doesn't recognize `return new class extends Migration`
75
+ prefer-anonymous-migration = { enabled = false }
76
+
77
+ # False positive with spread operator: fn ($params) => func(...$params)
78
+ prefer-first-class-callable = { enabled = false }
79
+
80
+ prefer-static-closure = { enabled = false }
81
+ strict-types = { enabled = false }
82
+
83
+ too-many-methods = { threshold = 20 }
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "scripts": {
3
- "format": "prettier --write .",
4
- "lint": "lando eslint .",
5
- "lint:fix": "lando eslint . --fix"
3
+ "format": "oxfmt && lando ssh -c 'cd /app && vendor/bin/mago format'",
4
+ "format:check": "oxfmt --check && lando ssh -c 'cd /app && vendor/bin/mago format --check'",
5
+ "lint": "oxlint && lando ssh -c 'cd /app && vendor/bin/mago lint'",
6
+ "lint:fix": "oxlint --fix"
6
7
  },
7
8
  "devDependencies": {
8
- "globals": "^16.3.0",
9
- "@eslint/eslintrc": "^3.3.1",
10
- "@eslint/js": "^9.30.1",
11
- "eslint": "^9.30.1",
12
- "eslint-config-prettier": "^10.1.5",
13
- "eslint-plugin-prettier": "^5.3.1",
14
- "prettier": "^3.6.2"
9
+ "oxfmt": "^0.52.0",
10
+ "oxlint": "^1.67.0"
15
11
  }
16
12
  }
@@ -1,52 +1,18 @@
1
1
  {
2
2
  "settings": {
3
- "editor.defaultFormatter": "esbenp.prettier-vscode",
4
3
  "editor.formatOnSave": false,
5
4
  "editor.codeActionsOnSave": {
6
5
  "source.fixAll": "explicit",
7
- "source.fixAll.eslint": "explicit",
8
6
  "source.organizeImports": "explicit"
9
7
  },
10
- "prettier.requireConfig": true,
11
- "prettier.useEditorConfig": true,
12
- "[blade]": {
13
- "editor.defaultFormatter": "esbenp.prettier-vscode",
14
- "editor.formatOnSave": false,
15
- "editor.insertSpaces": true,
16
- "editor.tabSize": 2
17
- },
18
- "[javascript]": {
19
- "editor.defaultFormatter": "esbenp.prettier-vscode",
20
- "editor.formatOnSave": false,
21
- "editor.insertSpaces": true,
22
- "editor.tabSize": 2
23
- },
24
- "[typescript]": {
25
- "editor.defaultFormatter": "esbenp.prettier-vscode",
26
- "editor.formatOnSave": false,
27
- "editor.insertSpaces": true,
28
- "editor.tabSize": 2
29
- },
30
- "[css]": {
31
- "editor.defaultFormatter": "esbenp.prettier-vscode",
32
- "editor.formatOnSave": false,
33
- "editor.insertSpaces": true,
34
- "editor.tabSize": 2
35
- },
36
- "[scss]": {
37
- "editor.defaultFormatter": "esbenp.prettier-vscode",
38
- "editor.formatOnSave": false,
39
- "editor.insertSpaces": true,
40
- "editor.tabSize": 2
41
- },
42
8
  "files.eol": "\n",
43
9
  "files.trimTrailingWhitespace": true,
44
10
  "files.insertFinalNewline": true
45
11
  },
46
12
  "extensions": {
47
13
  "recommendations": [
48
- "esbenp.prettier-vscode",
49
- "dbaeumer.vscode-eslint",
14
+ "carthage-software.mago",
15
+ "oxc.oxc-vscode",
50
16
  "editorconfig.editorconfig",
51
17
  "stylelint.vscode-stylelint",
52
18
  "bmewburn.vscode-intelephense-client",
@@ -1,8 +1,8 @@
1
- import path from 'path';
1
+ import path from "path";
2
2
 
3
- import fs from 'fs-extra';
3
+ import fs from "fs-extra";
4
4
 
5
- import { log, color } from '../../lib/utils/logger.js';
5
+ import { log, color } from "../../lib/utils/logger.js";
6
6
 
7
7
  /**
8
8
  * Derive a StudlyCase PSR-4 namespace fragment from a kebab/snake plugin slug.
@@ -16,7 +16,7 @@ function toStudlyCase(slug) {
16
16
  .split(/[-_]/)
17
17
  .filter(Boolean)
18
18
  .map((segment) => segment[0].toUpperCase() + segment.slice(1).toLowerCase())
19
- .join('');
19
+ .join("");
20
20
  }
21
21
 
22
22
  /**
@@ -30,12 +30,28 @@ function toConstantPrefix(slug) {
30
30
  .split(/[-_]/)
31
31
  .filter(Boolean)
32
32
  .map((segment) => segment.toUpperCase())
33
- .join('_');
33
+ .join("_");
34
34
  }
35
35
 
36
36
  export async function setupModule(context, generator) {
37
37
  const pluginName = context.mu_plugin_name || `${context.projectName}-core`;
38
- const useAcorn = context.mu_plugin_acorn !== false; // default to Acorn-flavored
38
+
39
+ // Sage and an Acorn-flavored MU plugin cannot coexist: both call
40
+ // `Application::configure()->boot()` and the second wins with a
41
+ // clobbered container that drops half its providers (most visibly
42
+ // `view`). The prompts module already hides `mu_plugin_acorn` when
43
+ // Sage is selected, but we also defend at scaffold time so non-
44
+ // interactive paths (env-var driven, --defaults) cannot drift into
45
+ // the broken state.
46
+ const hasSage = (context.selectedContentModules || []).includes("sage");
47
+ if (hasSage && context.mu_plugin_acorn === true) {
48
+ log(
49
+ color.orange,
50
+ "[mu-plugin] ⚠️ Sage is also selected — forcing the minimal (non-Acorn) flavor to avoid a competing Application singleton. If you want the MU plugin to own Acorn, regenerate the project with the `blank-theme` module instead of `sage`.",
51
+ );
52
+ }
53
+ const useAcorn = !hasSage && context.mu_plugin_acorn !== false;
54
+
39
55
  const pluginDir = `content/mu-plugins/${pluginName}`;
40
56
  const absolutePluginDir = path.join(generator.cwd, pluginDir);
41
57
 
@@ -49,7 +65,7 @@ export async function setupModule(context, generator) {
49
65
 
50
66
  log(
51
67
  color.blue,
52
- `[mu-plugin] 📂 Scaffolding ${useAcorn ? 'Acorn-flavored' : 'minimal'} MU plugin: ${pluginDir}`
68
+ `[mu-plugin] 📂 Scaffolding ${useAcorn ? "Acorn-flavored" : "minimal"} MU plugin: ${pluginDir}`,
53
69
  );
54
70
 
55
71
  // 1. Ensure directory exists
@@ -61,18 +77,6 @@ export async function setupModule(context, generator) {
61
77
  await scaffoldMinimal(pluginContext, generator, pluginDir, absolutePluginDir);
62
78
  }
63
79
 
64
- // Lint configs co-located in plugin — always installed (IDE/editor support)
65
- log(color.blue, '[mu-plugin] 🔧 Installing lint configurations...');
66
- await generator.copyFile('lint/.prettierrc.json', 'mu-plugin', `${pluginDir}/.prettierrc.json`);
67
- await generator.copyFile('lint/pint.json', 'mu-plugin', `${pluginDir}/pint.json`);
68
- if (context.mu_plugin_lint_eslint === true) {
69
- await generator.copyFile(
70
- 'lint/eslint.config.mjs',
71
- 'mu-plugin',
72
- `${pluginDir}/eslint.config.mjs`
73
- );
74
- }
75
-
76
80
  log(color.green, `[mu-plugin] ✅ MU plugin scaffolded: ${pluginDir}`);
77
81
  }
78
82
 
@@ -82,76 +86,80 @@ export async function setupModule(context, generator) {
82
86
  * config/app/storage/resources layout, and four documented gotcha fixes
83
87
  * baked into the plugin entry file.
84
88
  */
85
- async function scaffoldAcorn(context, generator, pluginDir, _absolutePluginDir) {
89
+ async function scaffoldAcorn(context, generator, pluginDir, absolutePluginDir) {
86
90
  const { mu_plugin_name: pluginName } = context;
87
91
 
88
92
  // Bedrock Autoloader bootstrap (lives at the mu-plugins root, NOT inside
89
93
  // the plugin directory). Required because native WP does not recurse into
90
94
  // subdirectory mu-plugins.
91
95
  await generator.copyFile(
92
- 'templates/bedrock-autoloader.php',
93
- 'mu-plugin',
94
- 'content/mu-plugins/bedrock-autoloader.php'
96
+ "templates/bedrock-autoloader.php",
97
+ "mu-plugin",
98
+ "content/mu-plugins/bedrock-autoloader.php",
95
99
  );
96
100
 
97
101
  // Plugin entry file (Acorn boot, WP-CLI guard, APP_DEBUG=false, Filesystem provider)
98
102
  await generator.generateFile(
99
- 'acorn/plugin.php',
103
+ "acorn/plugin.php",
100
104
  context,
101
- 'mu-plugin',
102
- `${pluginDir}/${pluginName}.php`
105
+ "mu-plugin",
106
+ `${pluginDir}/${pluginName}.php`,
103
107
  );
104
108
 
105
109
  // composer.json with type=wordpress-muplugin, Acorn + acf-composer, allow-plugins
106
110
  await generator.generateFile(
107
- 'acorn/composer.json',
111
+ "acorn/composer.json",
108
112
  context,
109
- 'mu-plugin',
110
- `${pluginDir}/composer.json`
113
+ "mu-plugin",
114
+ `${pluginDir}/composer.json`,
111
115
  );
112
116
 
113
117
  // .gitignore for vendor/, composer.lock, storage runtime
114
- await generator.generateFile('acorn/.gitignore', context, 'mu-plugin', `${pluginDir}/.gitignore`);
118
+ await generator.generateFile("acorn/.gitignore", context, "mu-plugin", `${pluginDir}/.gitignore`);
115
119
 
116
120
  // README.md (purpose + structure + install + documented traps)
117
- await generator.generateFile('acorn/README.md', context, 'mu-plugin', `${pluginDir}/README.md`);
121
+ await generator.generateFile("acorn/README.md", context, "mu-plugin", `${pluginDir}/README.md`);
118
122
 
119
123
  // config/ files
120
124
  await generator.generateFile(
121
- 'acorn/config/app.php',
125
+ "acorn/config/app.php",
122
126
  context,
123
- 'mu-plugin',
124
- `${pluginDir}/config/app.php`
127
+ "mu-plugin",
128
+ `${pluginDir}/config/app.php`,
125
129
  );
126
130
  await generator.generateFile(
127
- 'acorn/config/logging.php',
131
+ "acorn/config/logging.php",
128
132
  context,
129
- 'mu-plugin',
130
- `${pluginDir}/config/logging.php`
133
+ "mu-plugin",
134
+ `${pluginDir}/config/logging.php`,
131
135
  );
132
136
 
133
137
  // app/Providers/CoreServiceProvider.php stub
134
138
  await generator.generateFile(
135
- 'acorn/app/Providers/CoreServiceProvider.php',
139
+ "acorn/app/Providers/CoreServiceProvider.php",
136
140
  context,
137
- 'mu-plugin',
138
- `${pluginDir}/app/Providers/CoreServiceProvider.php`
141
+ "mu-plugin",
142
+ `${pluginDir}/app/Providers/CoreServiceProvider.php`,
139
143
  );
140
144
 
141
145
  // Storage and resources scaffolding (.gitkeep markers committed; runtime
142
- // contents are ignored via .gitignore above).
146
+ // contents are ignored via the plugin's own .gitignore).
147
+ //
148
+ // We write the markers directly with fs.ensureFile instead of copying
149
+ // .gitkeep templates because shipping placeholder .gitkeep files is
150
+ // brittle: this repo's own .gitignore has a top-level `logs` rule
151
+ // (Node convention) which silently dropped storage/logs/.gitkeep from
152
+ // the v5.0.0 npm tarball and broke scaffolds at runtime. Writing the
153
+ // marker on the consumer side bypasses both this repo's .gitignore
154
+ // and any future similar trap.
143
155
  for (const subdir of [
144
- 'storage/framework/cache',
145
- 'storage/framework/views',
146
- 'storage/framework/sessions',
147
- 'storage/logs',
148
- 'resources',
156
+ "storage/framework/cache",
157
+ "storage/framework/views",
158
+ "storage/framework/sessions",
159
+ "storage/logs",
160
+ "resources",
149
161
  ]) {
150
- await generator.copyFile(
151
- `templates/acorn/${subdir}/.gitkeep`,
152
- 'mu-plugin',
153
- `${pluginDir}/${subdir}/.gitkeep`
154
- );
162
+ await fs.ensureFile(path.join(absolutePluginDir, subdir, ".gitkeep"));
155
163
  }
156
164
  }
157
165
 
@@ -163,13 +171,13 @@ async function scaffoldMinimal(context, generator, pluginDir, absolutePluginDir)
163
171
  const { mu_plugin_name: pluginName } = context;
164
172
 
165
173
  await generator.generateFile(
166
- 'plugin.php',
174
+ "plugin.php",
167
175
  context,
168
- 'mu-plugin',
169
- `${pluginDir}/${pluginName}.php`
176
+ "mu-plugin",
177
+ `${pluginDir}/${pluginName}.php`,
170
178
  );
171
179
 
172
- await generator.generateFile('composer.json', context, 'mu-plugin', `${pluginDir}/composer.json`);
180
+ await generator.generateFile("composer.json", context, "mu-plugin", `${pluginDir}/composer.json`);
173
181
 
174
- await fs.ensureFile(path.join(absolutePluginDir, 'src', '.gitkeep'));
182
+ await fs.ensureFile(path.join(absolutePluginDir, "src", ".gitkeep"));
175
183
  }
@@ -1,30 +1,28 @@
1
1
  export default [
2
2
  {
3
- type: 'input',
4
- name: 'mu_plugin_name',
5
- message: 'MU Plugin slug (used as directory name):',
6
- default: (answers) => `${answers.projectName || 'wordpress'}-core`,
7
- when: (answers) => answers.selectedContentModules?.includes('mu-plugin'),
3
+ type: "input",
4
+ name: "mu_plugin_name",
5
+ message: "MU Plugin slug (used as directory name):",
6
+ default: (answers) => `${answers.projectName || "wordpress"}-core`,
7
+ when: (answers) => answers.selectedContentModules?.includes("mu-plugin"),
8
8
  },
9
9
  {
10
- type: 'confirm',
11
- name: 'mu_plugin_acorn',
12
- message: 'MU Plugin: bootstrap with Roots Acorn (recommended for the Roots stack)?',
10
+ // Acorn-flavored MU plugin and Sage cannot both boot Acorn in the same
11
+ // project — two `Application::configure()->boot()` calls produce
12
+ // competing singletons that clobber providers (View, in particular)
13
+ // and cascade into runtime fatals. The convention this kit enforces:
14
+ //
15
+ // - Sage selected: MU plugin stays minimal (no Acorn), and Sage
16
+ // owns the single Acorn Application.
17
+ // - Sage NOT selected: MU plugin can opt into the Acorn flavor and
18
+ // become the project's Acorn Application host. The recommended
19
+ // theme companion is then the `blank-theme` module.
20
+ type: "confirm",
21
+ name: "mu_plugin_acorn",
22
+ message: "MU Plugin: bootstrap with Roots Acorn (project becomes the Acorn host)?",
13
23
  default: true,
14
- when: (answers) => answers.selectedContentModules?.includes('mu-plugin'),
15
- },
16
- {
17
- type: 'confirm',
18
- name: 'mu_plugin_lint_pint',
19
- message: 'MU Plugin: enable Pint for PHP?',
20
- default: true,
21
- when: (answers) => answers.selectedContentModules?.includes('mu-plugin') && answers.enable_lint,
22
- },
23
- {
24
- type: 'confirm',
25
- name: 'mu_plugin_lint_eslint',
26
- message: 'MU Plugin: enable ESLint for JS/TS?',
27
- default: false,
28
- when: (answers) => answers.selectedContentModules?.includes('mu-plugin') && answers.enable_lint,
24
+ when: (answers) =>
25
+ answers.selectedContentModules?.includes("mu-plugin") &&
26
+ !answers.selectedContentModules?.includes("sage"),
29
27
  },
30
28
  ];
@@ -1,15 +1,13 @@
1
1
  tooling:
2
2
  {{#if enable_lint}}
3
- mu-pint:
3
+ mu-mago:
4
+ service: appserver
5
+ description: Format PHP in the MU plugin
6
+ dir: /app
7
+ cmd: vendor/bin/mago format content/mu-plugins/{{mu_plugin_name}}/
8
+ mu-mago-lint:
4
9
  service: appserver
5
10
  description: Lint PHP in the MU plugin
6
- dir: /app/content/mu-plugins/{{mu_plugin_name}}
7
- cmd: ./vendor/bin/pint
8
- {{#if mu_plugin_lint_eslint}}
9
- mu-eslint:
10
- service: build
11
- description: Lint JS/TS in the MU plugin
12
- dir: /app/content/mu-plugins/{{mu_plugin_name}}
13
- cmd: npx eslint --fix resources/
14
- {{/if}}
11
+ dir: /app
12
+ cmd: vendor/bin/mago lint content/mu-plugins/{{mu_plugin_name}}/
15
13
  {{/if}}
@@ -4,7 +4,7 @@ declare(strict_types=1);
4
4
 
5
5
  namespace {{mu_plugin_namespace}}\Providers;
6
6
 
7
- use Roots\Acorn\ServiceProvider;
7
+ use Illuminate\Support\ServiceProvider;
8
8
 
9
9
  class CoreServiceProvider extends ServiceProvider
10
10
  {
@@ -5,11 +5,11 @@
5
5
  "license": "proprietary",
6
6
  "require": {
7
7
  "php": ">={{phpVersion}}",
8
- "roots/acorn": "^6.1",
9
- "log1x/acf-composer": "^3.4"
8
+ "roots/acorn": "6.1.0",
9
+ "log1x/acf-composer": "3.4.6"
10
10
  },
11
11
  "require-dev": {
12
- "laravel/pint": "^1.21"
12
+ "carthage-software/mago": "^1.0"
13
13
  },
14
14
  "autoload": {
15
15
  "psr-4": {
@@ -23,8 +23,9 @@
23
23
  "sort-packages": true
24
24
  },
25
25
  "scripts": {
26
- "lint": ["./vendor/bin/pint --test"],
27
- "lint:fix": ["./vendor/bin/pint"]
26
+ "format": ["vendor/bin/mago format"],
27
+ "format:check": ["vendor/bin/mago format --check"],
28
+ "lint": ["vendor/bin/mago lint"]
28
29
  },
29
30
  "minimum-stability": "stable",
30
31
  "prefer-stable": true
@@ -6,9 +6,11 @@
6
6
  }
7
7
  },
8
8
  "require-dev": {
9
- "laravel/pint": "^1.21"
9
+ "carthage-software/mago": "^1.0"
10
10
  },
11
11
  "scripts": {
12
- "lint": ["./vendor/bin/pint --test"]
12
+ "format": ["vendor/bin/mago format"],
13
+ "format:check": ["vendor/bin/mago format --check"],
14
+ "lint": ["vendor/bin/mago lint"]
13
15
  }
14
16
  }
@@ -1,11 +1,16 @@
1
1
  tooling:
2
- pint:
2
+ mago:
3
3
  service: appserver
4
- description: PHP Code Style (modern PSR-12)
5
- cmd:
6
- - pint
7
- pint-check:
4
+ description: Format PHP files
5
+ dir: /app
6
+ cmd: vendor/bin/mago format
7
+ mago-check:
8
8
  service: appserver
9
- description: Check code style without fixing
10
- cmd:
11
- - pint --test
9
+ description: Check PHP formatting without modifying files
10
+ dir: /app
11
+ cmd: vendor/bin/mago format --check
12
+ mago-lint:
13
+ service: appserver
14
+ description: Lint PHP files
15
+ dir: /app
16
+ cmd: vendor/bin/mago lint