@flarum/cli 2.0.0-beta.11 → 2.0.0-beta.14

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 (113) hide show
  1. package/README.md +176 -43
  2. package/boilerplate/skeleton/extension/.gitattributes +1 -0
  3. package/boilerplate/skeleton/extension/.github/workflows/backend.yml +1 -1
  4. package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +3 -1
  5. package/boilerplate/skeleton/extension/LICENSE.md +1 -1
  6. package/boilerplate/skeleton/extension/composer.json +4 -2
  7. package/boilerplate/skeleton/extension/extend.php +2 -2
  8. package/boilerplate/skeleton/extension/js/package.json +4 -1
  9. package/boilerplate/skeleton/extension/tests/phpunit.integration.xml +1 -0
  10. package/lib/base-command.d.ts +3 -1
  11. package/lib/base-command.js +27 -14
  12. package/lib/boilersmith/io.d.ts +28 -8
  13. package/lib/boilersmith/io.js +4 -2
  14. package/lib/boilersmith/paths.d.ts +2 -2
  15. package/lib/boilersmith/paths.js +2 -2
  16. package/lib/boilersmith/scaffolding/audit-step-factory.js +10 -10
  17. package/lib/boilersmith/scaffolding/infra-step-factory.js +2 -2
  18. package/lib/boilersmith/scaffolding/init-step-factory.js +5 -5
  19. package/lib/boilersmith/scaffolding/module.d.ts +19 -8
  20. package/lib/boilersmith/scaffolding/module.js +30 -17
  21. package/lib/boilersmith/scaffolding/scaffolder.d.ts +4 -1
  22. package/lib/boilersmith/scaffolding/scaffolder.js +29 -29
  23. package/lib/boilersmith/scaffolding/template-param.d.ts +1 -1
  24. package/lib/boilersmith/scaffolding/template-param.js +2 -2
  25. package/lib/boilersmith/step-manager.d.ts +0 -1
  26. package/lib/boilersmith/step-manager.js +10 -20
  27. package/lib/boilersmith/steps/stub-base.js +1 -1
  28. package/lib/boilersmith/utils/clone-and-fill.js +1 -1
  29. package/lib/boilersmith/utils/commit-async.d.ts +2 -0
  30. package/lib/boilersmith/utils/commit-async.js +15 -0
  31. package/lib/commands/audit/infra.d.ts +1 -1
  32. package/lib/commands/audit/infra.js +30 -8
  33. package/lib/commands/infra.d.ts +2 -2
  34. package/lib/commands/infra.js +18 -12
  35. package/lib/commands/init.d.ts +1 -1
  36. package/lib/commands/init.js +4 -2
  37. package/lib/commands/make/backend/api-controller.js +1 -2
  38. package/lib/commands/make/backend/api-serializer-attributes.js +1 -2
  39. package/lib/commands/make/backend/command.js +1 -2
  40. package/lib/commands/make/backend/event-listener.js +1 -2
  41. package/lib/commands/make/backend/handler.js +2 -5
  42. package/lib/commands/make/backend/integration-test.js +2 -4
  43. package/lib/commands/make/backend/migration.js +1 -2
  44. package/lib/commands/make/backend/model.js +1 -2
  45. package/lib/commands/make/backend/policy.js +1 -2
  46. package/lib/commands/make/backend/route.js +1 -2
  47. package/lib/commands/make/backend/service-provider.js +1 -2
  48. package/lib/commands/make/frontend/model.js +2 -5
  49. package/lib/commands/monorepo/create.d.ts +15 -0
  50. package/lib/commands/monorepo/create.js +20 -0
  51. package/lib/commands/update/js-imports.js +1 -2
  52. package/lib/help.js +1 -1
  53. package/lib/steps/gen-ext-scaffolder.d.ts +2 -2
  54. package/lib/steps/gen-ext-scaffolder.js +144 -46
  55. package/lib/steps/js/base.js +2 -4
  56. package/lib/steps/js/model.js +4 -4
  57. package/lib/steps/misc/git.d.ts +1 -1
  58. package/lib/steps/misc/git.js +2 -2
  59. package/lib/steps/misc/npm.d.ts +11 -0
  60. package/lib/steps/misc/npm.js +19 -0
  61. package/lib/steps/monorepo/create.d.ts +17 -0
  62. package/lib/steps/monorepo/create.js +181 -0
  63. package/lib/steps/stubs/backend/api-controller.d.ts +1 -1
  64. package/lib/steps/stubs/backend/api-controller.js +3 -0
  65. package/lib/steps/stubs/backend/api-serializer.d.ts +1 -1
  66. package/lib/steps/stubs/backend/api-serializer.js +3 -0
  67. package/lib/steps/stubs/backend/command.d.ts +0 -5
  68. package/lib/steps/stubs/backend/command.js +1 -0
  69. package/lib/steps/stubs/backend/event-listener.d.ts +1 -1
  70. package/lib/steps/stubs/backend/event-listener.js +2 -0
  71. package/lib/steps/stubs/backend/handler-command.d.ts +1 -1
  72. package/lib/steps/stubs/backend/handler-command.js +1 -0
  73. package/lib/steps/stubs/backend/handler.d.ts +1 -1
  74. package/lib/steps/stubs/backend/handler.js +4 -0
  75. package/lib/steps/stubs/backend/integration-test.d.ts +1 -1
  76. package/lib/steps/stubs/backend/integration-test.js +2 -0
  77. package/lib/steps/stubs/backend/job.d.ts +1 -1
  78. package/lib/steps/stubs/backend/job.js +1 -0
  79. package/lib/steps/stubs/backend/migration.js +4 -1
  80. package/lib/steps/stubs/backend/model.d.ts +1 -1
  81. package/lib/steps/stubs/backend/model.js +1 -0
  82. package/lib/steps/stubs/backend/policy.d.ts +1 -1
  83. package/lib/steps/stubs/backend/policy.js +2 -0
  84. package/lib/steps/stubs/backend/repository.d.ts +1 -1
  85. package/lib/steps/stubs/backend/repository.js +2 -0
  86. package/lib/steps/stubs/backend/service-provider.d.ts +1 -1
  87. package/lib/steps/stubs/backend/service-provider.js +1 -0
  88. package/lib/steps/stubs/backend/validator.d.ts +1 -1
  89. package/lib/steps/stubs/backend/validator.js +1 -0
  90. package/lib/steps/stubs/flarum-base.js +1 -1
  91. package/lib/steps/stubs/frontend/component.d.ts +0 -5
  92. package/lib/steps/stubs/frontend/component.js +1 -0
  93. package/lib/steps/stubs/frontend/modal.d.ts +0 -5
  94. package/lib/steps/stubs/frontend/modal.js +1 -0
  95. package/lib/steps/stubs/frontend/model.d.ts +0 -5
  96. package/lib/steps/stubs/frontend/model.js +1 -0
  97. package/lib/steps/stubs/js-base.js +8 -5
  98. package/lib/steps/stubs/php-base.js +10 -8
  99. package/lib/steps/update/js-imports.js +8 -2
  100. package/lib/utils/composer.d.ts +1 -0
  101. package/lib/utils/migration.js +3 -1
  102. package/lib/utils/monorepo.d.ts +24 -0
  103. package/lib/utils/monorepo.js +24 -0
  104. package/lib/utils/validation.d.ts +2 -0
  105. package/lib/utils/validation.js +6 -0
  106. package/oclif.manifest.json +1 -1
  107. package/package.json +10 -5
  108. package/php-subsystem/composer.json +9 -9
  109. package/php-subsystem/composer.lock +64 -71
  110. package/php-subsystem/vendor/composer/installed.json +54 -61
  111. package/php-subsystem/vendor/nikic/php-parser/README.md +55 -59
  112. package/php-subsystem/vendor/nikic/php-parser/composer.json +39 -39
  113. package/php-subsystem/vendor/nikic/php-parser/grammar/README.md +17 -20
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const scaffolder_1 = require("boilersmith/scaffolding/scaffolder");
6
6
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
7
7
  const mem_fs_editor_1 = require("mem-fs-editor");
8
+ const node_child_process_1 = require("node:child_process");
8
9
  const node_fs_1 = require("node:fs");
9
10
  const node_path_1 = require("node:path");
10
11
  const simple_git_1 = (0, tslib_1.__importDefault)(require("simple-git"));
@@ -22,6 +23,7 @@ exports.EXTENSION_PARAMS = [
22
23
  'extensionName',
23
24
  'licenseType',
24
25
  'mainGitBranch',
26
+ 'jsPackageManager',
25
27
  'licenseText',
26
28
  'packageNamespaceEscapedSlash',
27
29
  'extensionId',
@@ -37,8 +39,8 @@ function paramNamesToDef(name) {
37
39
  name,
38
40
  type: 'text',
39
41
  message: `Package ${chalk_1.default.dim('(vendor/extension-name)')}`,
40
- validate: s => /^([\dA-Za-z-]{2,})\/([\dA-Za-z-]{2,})$/.test(s.trim()) || 'Invalid package name format',
41
- format: s => s.toLowerCase(),
42
+ validate: (s) => /^([\dA-Za-z-]{2,})\/([\dA-Za-z-]{2,})$/.test(s.trim()) || 'Invalid package name format',
43
+ format: (s) => s.toLowerCase(),
42
44
  },
43
45
  getCurrVal: async (fs, paths) => {
44
46
  const json = (0, composer_1.getComposerJson)(fs, paths);
@@ -64,11 +66,11 @@ function paramNamesToDef(name) {
64
66
  name,
65
67
  type: 'text',
66
68
  message: `Package namespace ${chalk_1.default.dim('(Vendor\\ExtensionName)')}`,
67
- validate: s => /^([\dA-Za-z]+)\\([\dA-Za-z]+)$/.test(s.trim()) || 'Invalid namespace format',
69
+ validate: (s) => /^([\dA-Za-z]+)\\([\dA-Za-z]+)$/.test(s.trim()) || 'Invalid namespace format',
68
70
  format: (str) => str &&
69
71
  str
70
72
  .split('\\')
71
- .map(s => s[0].toUpperCase() + s.slice(1))
73
+ .map((s) => s[0].toUpperCase() + s.slice(1))
72
74
  .join('\\'),
73
75
  },
74
76
  getCurrVal: async (fs, paths) => {
@@ -97,7 +99,7 @@ function paramNamesToDef(name) {
97
99
  name,
98
100
  type: 'text',
99
101
  message: 'Author email',
100
- validate: s => !s || /^[\w!#$%&*+./=?^`{|}~’-]+@[\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*$/.test(s) || 'Invalid email format',
102
+ validate: (s) => !s || /^[\w!#$%&*+./=?^`{|}~’-]+@[\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*$/.test(s) || 'Invalid email format',
101
103
  },
102
104
  getCurrVal: async (fs, paths) => {
103
105
  var _a, _b, _c;
@@ -111,8 +113,8 @@ function paramNamesToDef(name) {
111
113
  name,
112
114
  type: 'text',
113
115
  message: 'Extension name',
114
- validate: str => Boolean(str.trim()) || 'The extension name is required',
115
- format: str => str
116
+ validate: (str) => Boolean(str.trim()) || 'The extension name is required',
117
+ format: (str) => str
116
118
  .split(' ')
117
119
  .map((s) => (s.length > 3 ? s[0].toUpperCase() + s.slice(1) : s))
118
120
  .join(' '),
@@ -131,7 +133,7 @@ function paramNamesToDef(name) {
131
133
  name,
132
134
  type: 'autocomplete',
133
135
  message: 'License',
134
- choices: [...simple_1.default].map(e => ({ title: e, value: e })),
136
+ choices: [...simple_1.default].map((e) => ({ title: e, value: e })),
135
137
  },
136
138
  getCurrVal: async (fs, paths) => {
137
139
  var _a;
@@ -170,12 +172,37 @@ function paramNamesToDef(name) {
170
172
  type: 'text',
171
173
  message: `Main git branch ${chalk_1.default.dim('(JS will automatically build when changes are pushed to GitHub on this branch)')}`,
172
174
  // See https://stackoverflow.com/a/12093994/11091039
173
- validate: s => /^(?!.*\/\.)(?!.*\.\.)(?!\/)(?!.*\/\/)(?!.*@{)(?!.*\\)[^\000-\037 *:?[^~\177]+(?<!\.lock)(?<!\/)(?<!\.)$/.test(s.trim()) || 'Invalid git branch',
175
+ validate: (s) => /^(?!.*\/\.)(?!.*\.\.)(?!\/)(?!.*\/\/)(?!.*@{)(?!.*\\)[^\000-\037 *:?[^~\177]+(?<!\.lock)(?<!\/)(?<!\.)$/.test(s.trim()) ||
176
+ 'Invalid git branch',
174
177
  initial: 'main',
175
178
  },
176
- getCurrVal: async () => {
177
- var _a;
178
- return (_a = (await (0, simple_git_1.default)().getConfig('init.defaultBranch')).value) !== null && _a !== void 0 ? _a : 'main';
179
+ getCurrVal: async (_fs, paths) => {
180
+ var _a, _b;
181
+ const cwd = (_a = paths.monorepo()) !== null && _a !== void 0 ? _a : paths.package();
182
+ try {
183
+ const remotes = (0, node_child_process_1.execSync)('git remote', { cwd, timeout: 2000 }).toString().split('\n');
184
+ if (remotes.includes('origin')) {
185
+ return (0, node_child_process_1.execSync)("git remote show origin | grep 'HEAD branch' | cut -d' ' -f5", { cwd }).toString();
186
+ }
187
+ }
188
+ catch (_c) { }
189
+ return (_b = (await (0, simple_git_1.default)(cwd).getConfig('init.defaultBranch')).value) !== null && _b !== void 0 ? _b : 'main';
190
+ },
191
+ };
192
+ case 'jsPackageManager':
193
+ return {
194
+ prompt: {
195
+ name,
196
+ type: 'select',
197
+ message: 'JS Package Manager',
198
+ initial: 'yarn',
199
+ choices: [
200
+ { title: 'Yarn', value: 'yarn' },
201
+ { title: 'NPM', value: 'npm' },
202
+ ],
203
+ },
204
+ getCurrVal: async (fs, paths) => {
205
+ return (0, mem_fs_editor_1.create)(fs).exists(paths.package('js/yarn.lock')) ? 'yarn' : 'npm';
179
206
  },
180
207
  };
181
208
  case 'backendDirectory':
@@ -202,6 +229,8 @@ function paramNamesToDef(name) {
202
229
  exports.EXTENSION_MODULES = [
203
230
  'core',
204
231
  'icon',
232
+ 'admin',
233
+ 'forum',
205
234
  'js',
206
235
  'jsCommon',
207
236
  'css',
@@ -223,17 +252,7 @@ function moduleNameToDef(name) {
223
252
  updatable: false,
224
253
  togglable: false,
225
254
  shortDescription: 'Core Functionality',
226
- filesToReplace: [
227
- 'extend.php',
228
- 'README.md',
229
- 'LICENSE.md',
230
- { path: 'js/src/admin/index.js', moduleDeps: ['js', { module: 'typescript', enabled: false }] },
231
- { path: 'js/src/forum/index.js', moduleDeps: ['js', { module: 'typescript', enabled: false }] },
232
- { path: 'js/src/common/index.js', moduleDeps: ['js', 'jsCommon', { module: 'typescript', enabled: false }] },
233
- { path: 'js/src/admin/index.ts', moduleDeps: ['js', { module: 'typescript', enabled: true }] },
234
- { path: 'js/src/forum/index.ts', moduleDeps: ['js', { module: 'typescript', enabled: true }] },
235
- { path: 'js/src/common/index.ts', moduleDeps: ['js', 'jsCommon', { module: 'typescript', enabled: true }] },
236
- ],
255
+ filesToReplace: ['extend.php', 'README.md', 'LICENSE.md'],
237
256
  jsonToAugment: {
238
257
  'composer.json': [
239
258
  'name',
@@ -246,6 +265,8 @@ function moduleNameToDef(name) {
246
265
  'autoload.psr-4.${params.packageNamespaceEscapedSlash}\\',
247
266
  'extra.flarum-extension.title',
248
267
  'extra.flarum-extension.category',
268
+ 'minimum-stability',
269
+ 'prefer-stable',
249
270
  ],
250
271
  },
251
272
  needsTemplateParams: [
@@ -274,6 +295,50 @@ function moduleNameToDef(name) {
274
295
  },
275
296
  needsTemplateParams: [],
276
297
  };
298
+ case 'admin':
299
+ return {
300
+ name,
301
+ updatable: true,
302
+ defaultEnabled: true,
303
+ dependsOn: [],
304
+ togglable: true,
305
+ shortDescription: 'Admin Frontend',
306
+ filesToReplace: [
307
+ { path: 'js/admin.js', moduleDeps: ['js', { module: 'typescript', enabled: false }] },
308
+ { path: 'js/admin.ts', moduleDeps: ['js', { module: 'typescript', enabled: true }] },
309
+ { path: 'js/src/admin/index.js', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: false }] },
310
+ { path: 'js/src/admin/index.ts', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: true }] },
311
+ ],
312
+ jsonToAugment: {},
313
+ needsTemplateParams: [],
314
+ inferEnabled: async (_fs, paths) => {
315
+ if (!(0, node_fs_1.existsSync)(paths.package('js')))
316
+ undefined;
317
+ return (0, node_fs_1.existsSync)(paths.package('js/src/admin'));
318
+ },
319
+ };
320
+ case 'forum':
321
+ return {
322
+ name,
323
+ updatable: true,
324
+ defaultEnabled: true,
325
+ dependsOn: [],
326
+ togglable: true,
327
+ shortDescription: 'Forum Frontend',
328
+ filesToReplace: [
329
+ { path: 'js/forum.js', moduleDeps: ['js', { module: 'typescript', enabled: false }] },
330
+ { path: 'js/forum.ts', moduleDeps: ['js', { module: 'typescript', enabled: true }] },
331
+ { path: 'js/src/forum/index.js', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: false }] },
332
+ { path: 'js/src/forum/index.ts', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: true }] },
333
+ ],
334
+ jsonToAugment: {},
335
+ needsTemplateParams: [],
336
+ inferEnabled: async (_fs, paths) => {
337
+ if (!(0, node_fs_1.existsSync)(paths.package('js')))
338
+ undefined;
339
+ return (0, node_fs_1.existsSync)(paths.package('js/src/forum'));
340
+ },
341
+ };
277
342
  case 'js':
278
343
  return {
279
344
  name,
@@ -285,10 +350,16 @@ function moduleNameToDef(name) {
285
350
  dependsOn: [],
286
351
  filesToReplace: [
287
352
  'js/webpack.config.js',
288
- { path: 'js/admin.js', moduleDeps: [{ module: 'typescript', enabled: false }] },
289
- { path: 'js/forum.js', moduleDeps: [{ module: 'typescript', enabled: false }] },
290
- { path: 'js/admin.ts', moduleDeps: [{ module: 'typescript', enabled: true }] },
291
- { path: 'js/forum.ts', moduleDeps: [{ module: 'typescript', enabled: true }] },
353
+ { path: 'js/admin.js', moduleDeps: ['admin', { module: 'typescript', enabled: false }] },
354
+ { path: 'js/forum.js', moduleDeps: ['forum', { module: 'typescript', enabled: false }] },
355
+ { path: 'js/admin.ts', moduleDeps: ['admin', { module: 'typescript', enabled: true }] },
356
+ { path: 'js/forum.ts', moduleDeps: ['forum', { module: 'typescript', enabled: true }] },
357
+ { path: 'js/src/admin/index.js', doNotUpdate: true, moduleDeps: ['admin', { module: 'typescript', enabled: false }] },
358
+ { path: 'js/src/forum/index.js', doNotUpdate: true, moduleDeps: ['forum', { module: 'typescript', enabled: false }] },
359
+ { path: 'js/src/common/index.js', doNotUpdate: true, moduleDeps: ['jsCommon', { module: 'typescript', enabled: false }] },
360
+ { path: 'js/src/admin/index.ts', doNotUpdate: true, moduleDeps: ['admin', { module: 'typescript', enabled: true }] },
361
+ { path: 'js/src/forum/index.ts', doNotUpdate: true, moduleDeps: ['forum', { module: 'typescript', enabled: true }] },
362
+ { path: 'js/src/common/index.ts', doNotUpdate: true, moduleDeps: ['jsCommon', { module: 'typescript', enabled: true }] },
292
363
  ],
293
364
  jsonToAugment: {
294
365
  'js/package.json': [
@@ -302,7 +373,7 @@ function moduleNameToDef(name) {
302
373
  'scripts.analyze',
303
374
  ],
304
375
  },
305
- needsTemplateParams: ['packageName'],
376
+ needsTemplateParams: ['packageName', 'jsPackageManager'],
306
377
  inferEnabled: async (_fs, paths) => {
307
378
  return (0, node_fs_1.existsSync)(paths.package('js'));
308
379
  },
@@ -317,10 +388,12 @@ function moduleNameToDef(name) {
317
388
  longDescription: 'Shared code between the forum and the admin frontends',
318
389
  dependsOn: ['js'],
319
390
  filesToReplace: [
320
- { path: 'js/admin.js', moduleDeps: [{ module: 'typescript', enabled: false }] },
321
- { path: 'js/forum.js', moduleDeps: [{ module: 'typescript', enabled: false }] },
322
- { path: 'js/admin.ts', moduleDeps: [{ module: 'typescript', enabled: true }] },
323
- { path: 'js/forum.ts', moduleDeps: [{ module: 'typescript', enabled: true }] },
391
+ { path: 'js/admin.js', moduleDeps: ['admin', { module: 'typescript', enabled: false }] },
392
+ { path: 'js/forum.js', moduleDeps: ['forum', { module: 'typescript', enabled: false }] },
393
+ { path: 'js/admin.ts', moduleDeps: ['admin', { module: 'typescript', enabled: true }] },
394
+ { path: 'js/forum.ts', moduleDeps: ['forum', { module: 'typescript', enabled: true }] },
395
+ { path: 'js/src/common/index.js', doNotUpdate: true, moduleDeps: [{ module: 'typescript', enabled: false }] },
396
+ { path: 'js/src/common/index.ts', doNotUpdate: true, moduleDeps: [{ module: 'typescript', enabled: true }] },
324
397
  ],
325
398
  jsonToAugment: {},
326
399
  needsTemplateParams: [],
@@ -331,13 +404,16 @@ function moduleNameToDef(name) {
331
404
  case 'css':
332
405
  return {
333
406
  name,
334
- updatable: false,
407
+ updatable: true,
335
408
  togglable: true,
336
409
  defaultEnabled: true,
337
410
  shortDescription: 'CSS',
338
411
  longDescription: "LESS starter files for Flarum's frontend styling.",
339
412
  dependsOn: [],
340
- filesToReplace: ['less/admin.less', 'less/forum.less'],
413
+ filesToReplace: [
414
+ { path: 'less/admin.less', doNotUpdate: true, moduleDeps: ['admin'] },
415
+ { path: 'less/forum.less', doNotUpdate: true, moduleDeps: ['forum'] },
416
+ ],
341
417
  jsonToAugment: {},
342
418
  needsTemplateParams: [],
343
419
  inferEnabled: async (_fs, paths) => {
@@ -353,7 +429,7 @@ function moduleNameToDef(name) {
353
429
  shortDescription: 'Locale',
354
430
  longDescription: 'Translation starter files.',
355
431
  dependsOn: [],
356
- filesToReplace: ['locale/en.yml'],
432
+ filesToReplace: [{ path: 'locale/en.yml', doNotUpdate: true }],
357
433
  jsonToAugment: {},
358
434
  needsTemplateParams: [],
359
435
  inferEnabled: async (_fs, paths) => {
@@ -369,7 +445,11 @@ function moduleNameToDef(name) {
369
445
  shortDescription: 'Git Configuration',
370
446
  longDescription: 'Git config files (e.g. .gitignore, .gitattributes).',
371
447
  dependsOn: [],
372
- filesToReplace: [{ path: 'gitignore', destPath: '.gitignore' }, { path: 'js/gitignore', moduleDeps: ['js'], destPath: 'js/.gitignore' }, '.gitattributes'],
448
+ filesToReplace: [
449
+ { path: 'gitignore', destPath: '.gitignore' },
450
+ { path: 'js/gitignore', moduleDeps: ['js'], destPath: 'js/.gitignore' },
451
+ '.gitattributes',
452
+ ],
373
453
  jsonToAugment: {},
374
454
  needsTemplateParams: [],
375
455
  };
@@ -383,8 +463,17 @@ function moduleNameToDef(name) {
383
463
  longDescription: 'Automatically run checks via GitHub Actions CI. Free for open source projects.',
384
464
  dependsOn: [],
385
465
  filesToReplace: [
386
- { path: '.github/workflows/frontend.yml', monorepoPath: '.github/workflows/${params.extensionId}-frontend.yml' },
387
- { path: '.github/workflows/backend.yml', monorepoPath: '.github/workflows/${params.extensionId}-backend.yml' },
466
+ {
467
+ path: '.github/workflows/frontend.yml',
468
+ monorepoPath: '.github/workflows/${params.extensionId}-frontend.yml',
469
+ requireMonorepo: false,
470
+ moduleDeps: ['js'],
471
+ },
472
+ {
473
+ path: '.github/workflows/backend.yml',
474
+ monorepoPath: '.github/workflows/${params.extensionId}-backend.yml',
475
+ requireMonorepo: false,
476
+ },
388
477
  ],
389
478
  jsonToAugment: {},
390
479
  needsTemplateParams: ['frontendDirectory', 'backendDirectory', 'mainGitBranch', 'extensionId', 'extensionName'],
@@ -399,14 +488,20 @@ function moduleNameToDef(name) {
399
488
  dependsOn: ['js'],
400
489
  filesToReplace: [],
401
490
  jsonToAugment: {
402
- 'js/package.json': ['prettier', 'devDependencies.prettier', 'devDependencies.@flarum/prettier-config', 'scripts.format', 'scripts.format-check'],
491
+ 'js/package.json': [
492
+ 'prettier',
493
+ 'devDependencies.prettier',
494
+ 'devDependencies.@flarum/prettier-config',
495
+ 'scripts.format',
496
+ 'scripts.format-check',
497
+ ],
403
498
  },
404
499
  needsTemplateParams: [],
405
500
  inferEnabled: async (_fs, paths) => {
406
501
  if (!(0, node_fs_1.existsSync)(paths.package('js/package.json'))) {
407
502
  return false;
408
503
  }
409
- return (0, node_fs_1.readFileSync)('js/package.json').includes('prettier');
504
+ return (0, node_fs_1.readFileSync)(paths.package('js/package.json')).includes('prettier');
410
505
  },
411
506
  };
412
507
  case 'typescript':
@@ -420,10 +515,12 @@ function moduleNameToDef(name) {
420
515
  filesToReplace: ['js/tsconfig.json'],
421
516
  jsonToAugment: {
422
517
  'js/package.json': [
423
- 'prettier',
424
518
  'devDependencies.flarum-tsconfig',
425
519
  'devDependencies.typescript',
426
520
  'devDependencies.typescript-coverage-report',
521
+ 'scripts.clean-typings',
522
+ 'scripts.build-typings',
523
+ 'scripts.post-build-typings',
427
524
  'scripts.check-typings',
428
525
  'scripts.check-typings-coverage',
429
526
  ],
@@ -502,9 +599,7 @@ function moduleNameToDef(name) {
502
599
  defaultEnabled: true,
503
600
  shortDescription: 'StyleCI config file',
504
601
  dependsOn: [],
505
- filesToReplace: [
506
- { path: '.styleci.yml', monorepoPath: '.styleci.yml' },
507
- ],
602
+ filesToReplace: [{ path: '.styleci.yml', monorepoPath: '.styleci.yml', requireMonorepo: false }],
508
603
  jsonToAugment: {},
509
604
  needsTemplateParams: [],
510
605
  };
@@ -535,9 +630,12 @@ function genExtScaffolder() {
535
630
  },
536
631
  };
537
632
  const excludeScaffoldingFunc = (fs, paths) => {
538
- var _a, _b, _c;
633
+ var _a, _b, _c, _d, _e, _f;
539
634
  const json = (0, composer_1.getComposerJson)(fs, paths);
540
- return (_c = (_b = (_a = json === null || json === void 0 ? void 0 : json.extra) === null || _a === void 0 ? void 0 : _a['flarum-cli']) === null || _b === void 0 ? void 0 : _b.excludeScaffolding) !== null && _c !== void 0 ? _c : [];
635
+ return {
636
+ files: (_c = (_b = (_a = json === null || json === void 0 ? void 0 : json.extra) === null || _a === void 0 ? void 0 : _a['flarum-cli']) === null || _b === void 0 ? void 0 : _b.excludeScaffolding) !== null && _c !== void 0 ? _c : [],
637
+ configKeys: (_f = (_e = (_d = json === null || json === void 0 ? void 0 : json.extra) === null || _d === void 0 ? void 0 : _d['flarum-cli']) === null || _e === void 0 ? void 0 : _e.excludeScaffoldingConfigKeys) !== null && _f !== void 0 ? _f : {},
638
+ };
541
639
  };
542
640
  const scaffolder = new scaffolder_1.Scaffolder((0, node_path_1.resolve)(__dirname, '../../boilerplate/skeleton/extension'), moduleStatusCache, excludeScaffoldingFunc);
543
641
  for (const name of exports.EXTENSION_MODULES) {
@@ -13,7 +13,7 @@ class BaseJsStep {
13
13
  }
14
14
  async run(fs, paths, io, _providers) {
15
15
  const fsEditor = (0, mem_fs_editor_1.create)(fs);
16
- const frontend = await io.getParam({ name: 'frontend', type: 'text' });
16
+ const frontend = await io.getParam({ name: 'frontend', message: 'Frontend', type: 'text' });
17
17
  let frontends = [frontend];
18
18
  if (frontend === 'common') {
19
19
  frontends = ['admin', 'forum'];
@@ -27,9 +27,7 @@ class BaseJsStep {
27
27
  const currContents = fsEditor.read(match);
28
28
  const imports = await this.getImports(frontend, paths, io);
29
29
  const definition = await this.getDefinition(io);
30
- const newContents = currContents
31
- .replace(INIT_REGEX, `$1\n ${definition}\n`)
32
- .replace(IMPORTS_REGEX, `$1${imports}\n\n$5`);
30
+ const newContents = currContents.replace(INIT_REGEX, `$1\n ${definition}\n`).replace(IMPORTS_REGEX, `$1${imports}\n\n$5`);
33
31
  fsEditor.write(match, newContents);
34
32
  });
35
33
  }
@@ -9,14 +9,14 @@ class GenerateModelDefinition extends base_1.BaseJsStep {
9
9
  this.exposes = [];
10
10
  }
11
11
  async getDefinition(io) {
12
- const className = await io.getParam({ name: 'className', type: 'text' });
13
- let modelType = await io.getParam({ name: 'modelType', type: 'text' });
12
+ const className = await io.getParam({ name: 'className', message: 'Class name', type: 'text' });
13
+ let modelType = await io.getParam({ name: 'modelType', message: 'Model type', type: 'text' });
14
14
  modelType = modelType.includes('-') ? `['${modelType}']` : `.${modelType}`;
15
15
  return `app.store.models${modelType} = ${className};`;
16
16
  }
17
17
  async getImports(frontend, paths, io) {
18
- const className = await io.getParam({ name: 'className', type: 'text' });
19
- const classNamespace = await io.getParam({ name: 'classNamespace', type: 'text' });
18
+ const className = await io.getParam({ name: 'className', message: 'Class name', type: 'text' });
19
+ const classNamespace = await io.getParam({ name: 'classNamespace', message: 'Class namespace', type: 'text' });
20
20
  const importPath = this.importPath(frontend, classNamespace);
21
21
  return `import ${className} from '${importPath}';`;
22
22
  }
@@ -5,7 +5,7 @@ import { DefaultProviders, Step } from 'boilersmith/step-manager';
5
5
  export declare class GitInit implements Step {
6
6
  type: string;
7
7
  composable: boolean;
8
- run(fs: Store, _paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise<Store>;
8
+ run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise<Store>;
9
9
  exposes: never[];
10
10
  getExposed(): Record<string, unknown>;
11
11
  }
@@ -9,8 +9,8 @@ class GitInit {
9
9
  this.composable = false;
10
10
  this.exposes = [];
11
11
  }
12
- async run(fs, _paths, _paramProvider, _providers) {
13
- (0, simple_git_1.default)().init();
12
+ async run(fs, paths, _paramProvider, _providers) {
13
+ (0, simple_git_1.default)(paths.package()).init();
14
14
  return fs;
15
15
  }
16
16
  getExposed() {
@@ -0,0 +1,11 @@
1
+ import { Store } from 'mem-fs';
2
+ import { IO } from 'boilersmith/io';
3
+ import { Paths } from 'boilersmith/paths';
4
+ import { DefaultProviders, Step } from 'boilersmith/step-manager';
5
+ export declare class NpmInstall implements Step {
6
+ type: string;
7
+ composable: boolean;
8
+ run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise<Store>;
9
+ exposes: never[];
10
+ getExposed(): Record<string, unknown>;
11
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NpmInstall = void 0;
4
+ const node_child_process_1 = require("node:child_process");
5
+ class NpmInstall {
6
+ constructor() {
7
+ this.type = 'Run npm install';
8
+ this.composable = false;
9
+ this.exposes = [];
10
+ }
11
+ async run(fs, paths, _paramProvider, _providers) {
12
+ (0, node_child_process_1.execSync)('npm install', { cwd: paths.package('js') });
13
+ return fs;
14
+ }
15
+ getExposed() {
16
+ return {};
17
+ }
18
+ }
19
+ exports.NpmInstall = NpmInstall;
@@ -0,0 +1,17 @@
1
+ import { Store } from 'mem-fs';
2
+ import { IO } from 'boilersmith/io';
3
+ import { Paths } from 'boilersmith/paths';
4
+ import { Step } from 'boilersmith/step-manager';
5
+ import { FlarumProviders } from '../../providers';
6
+ import { Scaffolder } from 'boilersmith/scaffolding/scaffolder';
7
+ import { ExtensionModules, ExtensionParams } from '../gen-ext-scaffolder';
8
+ export declare class MonorepoCreate implements Step<FlarumProviders> {
9
+ type: string;
10
+ composable: boolean;
11
+ protected monorepoConfPath?: string;
12
+ protected scaffolder: Scaffolder<ExtensionParams, ExtensionModules>;
13
+ constructor(scaffolder: Scaffolder<ExtensionParams, ExtensionModules>, monorepoConfPath?: string);
14
+ run(fs: Store, paths: Paths, io: IO, providers: FlarumProviders): Promise<Store>;
15
+ exposes: never[];
16
+ getExposed(): Record<string, unknown>;
17
+ }