@flarum/cli 2.0.0-beta.13 → 2.0.0-beta.16

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 (125) hide show
  1. package/README.md +136 -39
  2. package/bin/run +2 -1
  3. package/bin/splitsh-lite-darwin +0 -0
  4. package/bin/splitsh-lite-linux +0 -0
  5. package/boilerplate/skeleton/extension/.gitattributes +16 -14
  6. package/boilerplate/skeleton/extension/.github/workflows/backend.yml +1 -1
  7. package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +3 -1
  8. package/boilerplate/skeleton/extension/LICENSE.md +1 -1
  9. package/boilerplate/skeleton/extension/composer.json +6 -4
  10. package/boilerplate/skeleton/extension/js/package.json +5 -1
  11. package/boilerplate/skeleton/extension/js/tsconfig.json +10 -2
  12. package/boilerplate/skeleton/extension/locale/en.yml +1 -1
  13. package/boilerplate/skeleton/extension/tests/phpunit.integration.xml +1 -0
  14. package/lib/base-command.d.ts +3 -1
  15. package/lib/base-command.js +44 -31
  16. package/lib/boilersmith/io.d.ts +28 -8
  17. package/lib/boilersmith/io.js +4 -2
  18. package/lib/boilersmith/paths.d.ts +2 -2
  19. package/lib/boilersmith/paths.js +7 -7
  20. package/lib/boilersmith/scaffolding/audit-step-factory.js +11 -11
  21. package/lib/boilersmith/scaffolding/infra-step-factory.js +2 -2
  22. package/lib/boilersmith/scaffolding/init-step-factory.js +5 -5
  23. package/lib/boilersmith/scaffolding/module.d.ts +19 -8
  24. package/lib/boilersmith/scaffolding/module.js +56 -19
  25. package/lib/boilersmith/scaffolding/scaffolder.d.ts +4 -1
  26. package/lib/boilersmith/scaffolding/scaffolder.js +32 -32
  27. package/lib/boilersmith/scaffolding/template-param.d.ts +1 -1
  28. package/lib/boilersmith/scaffolding/template-param.js +2 -2
  29. package/lib/boilersmith/step-manager.d.ts +0 -1
  30. package/lib/boilersmith/step-manager.js +10 -20
  31. package/lib/boilersmith/steps/stub-base.js +3 -3
  32. package/lib/boilersmith/utils/clone-and-fill.js +1 -1
  33. package/lib/boilersmith/utils/commit-async.d.ts +2 -0
  34. package/lib/boilersmith/utils/commit-async.js +15 -0
  35. package/lib/boilersmith/utils/read-tpl.js +2 -2
  36. package/lib/commands/audit/infra.d.ts +1 -1
  37. package/lib/commands/audit/infra.js +30 -8
  38. package/lib/commands/infra.d.ts +2 -2
  39. package/lib/commands/infra.js +18 -12
  40. package/lib/commands/init.d.ts +1 -1
  41. package/lib/commands/init.js +4 -2
  42. package/lib/commands/make/backend/api-controller.js +1 -2
  43. package/lib/commands/make/backend/api-serializer-attributes.js +1 -2
  44. package/lib/commands/make/backend/command.js +1 -2
  45. package/lib/commands/make/backend/event-listener.js +1 -2
  46. package/lib/commands/make/backend/handler.js +2 -5
  47. package/lib/commands/make/backend/integration-test.js +2 -4
  48. package/lib/commands/make/backend/migration.js +1 -2
  49. package/lib/commands/make/backend/model.js +1 -2
  50. package/lib/commands/make/backend/policy.js +1 -2
  51. package/lib/commands/make/backend/route.js +1 -2
  52. package/lib/commands/make/backend/service-provider.js +1 -2
  53. package/lib/commands/make/frontend/model.js +2 -5
  54. package/lib/commands/monorepo/create.d.ts +15 -0
  55. package/lib/commands/monorepo/create.js +20 -0
  56. package/lib/commands/monorepo/split.d.ts +15 -0
  57. package/lib/commands/monorepo/split.js +19 -0
  58. package/lib/commands/update/js-imports.js +1 -2
  59. package/lib/help.js +1 -1
  60. package/lib/providers/php-provider.js +2 -2
  61. package/lib/steps/gen-ext-scaffolder.d.ts +1 -1
  62. package/lib/steps/gen-ext-scaffolder.js +114 -64
  63. package/lib/steps/js/base.js +2 -4
  64. package/lib/steps/js/model.js +4 -4
  65. package/lib/steps/misc/composer.js +2 -2
  66. package/lib/steps/misc/git.d.ts +1 -1
  67. package/lib/steps/misc/git.js +2 -2
  68. package/lib/steps/misc/npm.d.ts +11 -0
  69. package/lib/steps/misc/npm.js +19 -0
  70. package/lib/steps/misc/yarn.js +2 -2
  71. package/lib/steps/monorepo/create.d.ts +17 -0
  72. package/lib/steps/monorepo/create.js +186 -0
  73. package/lib/steps/monorepo/split.d.ts +14 -0
  74. package/lib/steps/monorepo/split.js +95 -0
  75. package/lib/steps/stubs/backend/api-controller.d.ts +1 -1
  76. package/lib/steps/stubs/backend/api-controller.js +3 -0
  77. package/lib/steps/stubs/backend/api-serializer.d.ts +1 -1
  78. package/lib/steps/stubs/backend/api-serializer.js +3 -0
  79. package/lib/steps/stubs/backend/command.d.ts +0 -5
  80. package/lib/steps/stubs/backend/command.js +1 -0
  81. package/lib/steps/stubs/backend/event-listener.d.ts +1 -1
  82. package/lib/steps/stubs/backend/event-listener.js +2 -0
  83. package/lib/steps/stubs/backend/handler-command.d.ts +1 -1
  84. package/lib/steps/stubs/backend/handler-command.js +1 -0
  85. package/lib/steps/stubs/backend/handler.d.ts +1 -1
  86. package/lib/steps/stubs/backend/handler.js +4 -0
  87. package/lib/steps/stubs/backend/integration-test.d.ts +1 -1
  88. package/lib/steps/stubs/backend/integration-test.js +2 -0
  89. package/lib/steps/stubs/backend/job.d.ts +1 -1
  90. package/lib/steps/stubs/backend/job.js +1 -0
  91. package/lib/steps/stubs/backend/migration.js +6 -3
  92. package/lib/steps/stubs/backend/model.d.ts +1 -1
  93. package/lib/steps/stubs/backend/model.js +1 -0
  94. package/lib/steps/stubs/backend/policy.d.ts +1 -1
  95. package/lib/steps/stubs/backend/policy.js +2 -0
  96. package/lib/steps/stubs/backend/repository.d.ts +1 -1
  97. package/lib/steps/stubs/backend/repository.js +2 -0
  98. package/lib/steps/stubs/backend/service-provider.d.ts +1 -1
  99. package/lib/steps/stubs/backend/service-provider.js +1 -0
  100. package/lib/steps/stubs/backend/validator.d.ts +1 -1
  101. package/lib/steps/stubs/backend/validator.js +1 -0
  102. package/lib/steps/stubs/flarum-base.js +1 -1
  103. package/lib/steps/stubs/frontend/component.d.ts +0 -5
  104. package/lib/steps/stubs/frontend/component.js +1 -0
  105. package/lib/steps/stubs/frontend/modal.d.ts +0 -5
  106. package/lib/steps/stubs/frontend/modal.js +1 -0
  107. package/lib/steps/stubs/frontend/model.d.ts +0 -5
  108. package/lib/steps/stubs/frontend/model.js +1 -0
  109. package/lib/steps/stubs/js-base.js +8 -5
  110. package/lib/steps/stubs/php-base.js +10 -8
  111. package/lib/steps/update/js-imports.js +8 -2
  112. package/lib/utils/composer.d.ts +1 -0
  113. package/lib/utils/migration.js +3 -1
  114. package/lib/utils/monorepo.d.ts +24 -0
  115. package/lib/utils/monorepo.js +24 -0
  116. package/lib/utils/validation.d.ts +2 -0
  117. package/lib/utils/validation.js +6 -0
  118. package/oclif.manifest.json +1 -1
  119. package/package.json +7 -3
  120. package/php-subsystem/composer.json +9 -9
  121. package/php-subsystem/composer.lock +64 -71
  122. package/php-subsystem/vendor/composer/installed.json +54 -61
  123. package/php-subsystem/vendor/nikic/php-parser/README.md +55 -59
  124. package/php-subsystem/vendor/nikic/php-parser/composer.json +39 -39
  125. package/php-subsystem/vendor/nikic/php-parser/grammar/README.md +17 -20
@@ -5,8 +5,9 @@ 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_fs_1 = require("node:fs");
9
- const node_path_1 = require("node:path");
8
+ const child_process_1 = require("child_process");
9
+ const fs_1 = require("fs");
10
+ const path_1 = require("path");
10
11
  const simple_git_1 = (0, tslib_1.__importDefault)(require("simple-git"));
11
12
  const simple_1 = (0, tslib_1.__importDefault)(require("spdx-license-list/simple"));
12
13
  const composer_1 = require("../utils/composer");
@@ -22,8 +23,8 @@ exports.EXTENSION_PARAMS = [
22
23
  'extensionName',
23
24
  'licenseType',
24
25
  'mainGitBranch',
26
+ 'jsPackageManager',
25
27
  'licenseText',
26
- 'packageNamespaceEscapedSlash',
27
28
  'extensionId',
28
29
  'year',
29
30
  'backendDirectory',
@@ -37,8 +38,8 @@ function paramNamesToDef(name) {
37
38
  name,
38
39
  type: 'text',
39
40
  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(),
41
+ validate: (s) => /^([\dA-Za-z-]{2,})\/([\dA-Za-z-]{2,})$/.test(s.trim()) || 'Invalid package name format',
42
+ format: (s) => s.toLowerCase(),
42
43
  },
43
44
  getCurrVal: async (fs, paths) => {
44
45
  const json = (0, composer_1.getComposerJson)(fs, paths);
@@ -64,11 +65,11 @@ function paramNamesToDef(name) {
64
65
  name,
65
66
  type: 'text',
66
67
  message: `Package namespace ${chalk_1.default.dim('(Vendor\\ExtensionName)')}`,
67
- validate: s => /^([\dA-Za-z]+)\\([\dA-Za-z]+)$/.test(s.trim()) || 'Invalid namespace format',
68
+ validate: (s) => /^([\dA-Za-z]+)\\([\dA-Za-z]+)$/.test(s.trim()) || 'Invalid namespace format',
68
69
  format: (str) => str &&
69
70
  str
70
71
  .split('\\')
71
- .map(s => s[0].toUpperCase() + s.slice(1))
72
+ .map((s) => s[0].toUpperCase() + s.slice(1))
72
73
  .join('\\'),
73
74
  },
74
75
  getCurrVal: async (fs, paths) => {
@@ -97,7 +98,7 @@ function paramNamesToDef(name) {
97
98
  name,
98
99
  type: 'text',
99
100
  message: 'Author email',
100
- validate: s => !s || /^[\w!#$%&*+./=?^`{|}~’-]+@[\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*$/.test(s) || 'Invalid email format',
101
+ validate: (s) => !s || /^[\w!#$%&*+./=?^`{|}~’-]+@[\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*$/.test(s) || 'Invalid email format',
101
102
  },
102
103
  getCurrVal: async (fs, paths) => {
103
104
  var _a, _b, _c;
@@ -111,8 +112,8 @@ function paramNamesToDef(name) {
111
112
  name,
112
113
  type: 'text',
113
114
  message: 'Extension name',
114
- validate: str => Boolean(str.trim()) || 'The extension name is required',
115
- format: str => str
115
+ validate: (str) => Boolean(str.trim()) || 'The extension name is required',
116
+ format: (str) => str
116
117
  .split(' ')
117
118
  .map((s) => (s.length > 3 ? s[0].toUpperCase() + s.slice(1) : s))
118
119
  .join(' '),
@@ -131,7 +132,7 @@ function paramNamesToDef(name) {
131
132
  name,
132
133
  type: 'autocomplete',
133
134
  message: 'License',
134
- choices: [...simple_1.default].map(e => ({ title: e, value: e })),
135
+ choices: [...simple_1.default].map((e) => ({ title: e, value: e })),
135
136
  },
136
137
  getCurrVal: async (fs, paths) => {
137
138
  var _a;
@@ -145,12 +146,6 @@ function paramNamesToDef(name) {
145
146
  uses: ['licenseType'],
146
147
  compute: async (_paths, licenseType) => (licenseType ? require(`spdx-license-list/licenses/${licenseType}`).licenseText : ''),
147
148
  };
148
- case 'packageNamespaceEscapedSlash':
149
- return {
150
- name,
151
- uses: ['packageNamespace'],
152
- compute: async (_paths, packageNamespace) => packageNamespace.replace('\\', '\\\\'),
153
- };
154
149
  case 'extensionId':
155
150
  return {
156
151
  name,
@@ -170,12 +165,37 @@ function paramNamesToDef(name) {
170
165
  type: 'text',
171
166
  message: `Main git branch ${chalk_1.default.dim('(JS will automatically build when changes are pushed to GitHub on this branch)')}`,
172
167
  // See https://stackoverflow.com/a/12093994/11091039
173
- validate: s => /^(?!.*\/\.)(?!.*\.\.)(?!\/)(?!.*\/\/)(?!.*@{)(?!.*\\)[^\000-\037 *:?[^~\177]+(?<!\.lock)(?<!\/)(?<!\.)$/.test(s.trim()) || 'Invalid git branch',
168
+ validate: (s) => /^(?!.*\/\.)(?!.*\.\.)(?!\/)(?!.*\/\/)(?!.*@{)(?!.*\\)[^\000-\037 *:?[^~\177]+(?<!\.lock)(?<!\/)(?<!\.)$/.test(s.trim()) ||
169
+ 'Invalid git branch',
174
170
  initial: 'main',
175
171
  },
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';
172
+ getCurrVal: async (_fs, paths) => {
173
+ var _a, _b;
174
+ const cwd = (_a = paths.monorepo()) !== null && _a !== void 0 ? _a : paths.package();
175
+ try {
176
+ const remotes = (0, child_process_1.execSync)('git remote', { cwd, timeout: 2000 }).toString().split('\n');
177
+ if (remotes.includes('origin')) {
178
+ return (0, child_process_1.execSync)("git remote show origin | grep 'HEAD branch' | cut -d' ' -f5", { cwd, timeout: 2000 }).toString();
179
+ }
180
+ }
181
+ catch (_c) { }
182
+ return (_b = (await (0, simple_git_1.default)(cwd, { timeout: { block: 2000 } }).getConfig('init.defaultBranch')).value) !== null && _b !== void 0 ? _b : 'main';
183
+ },
184
+ };
185
+ case 'jsPackageManager':
186
+ return {
187
+ prompt: {
188
+ name,
189
+ type: 'select',
190
+ message: 'JS Package Manager',
191
+ initial: 0,
192
+ choices: [
193
+ { title: 'Yarn', value: 'yarn' },
194
+ { title: 'NPM', value: 'npm' },
195
+ ],
196
+ },
197
+ getCurrVal: async (fs, paths) => {
198
+ return (0, mem_fs_editor_1.create)(fs).exists(paths.package('js/yarn.lock')) ? 'yarn' : 'npm';
179
199
  },
180
200
  };
181
201
  case 'backendDirectory':
@@ -225,17 +245,7 @@ function moduleNameToDef(name) {
225
245
  updatable: false,
226
246
  togglable: false,
227
247
  shortDescription: 'Core Functionality',
228
- filesToReplace: [
229
- 'extend.php',
230
- 'README.md',
231
- 'LICENSE.md',
232
- { path: 'js/src/admin/index.js', moduleDeps: ['js', 'admin', { module: 'typescript', enabled: false }] },
233
- { path: 'js/src/forum/index.js', moduleDeps: ['js', 'forum', { module: 'typescript', enabled: false }] },
234
- { path: 'js/src/common/index.js', moduleDeps: ['js', 'jsCommon', { module: 'typescript', enabled: false }] },
235
- { path: 'js/src/admin/index.ts', moduleDeps: ['js', 'admin', { module: 'typescript', enabled: true }] },
236
- { path: 'js/src/forum/index.ts', moduleDeps: ['js', 'forum', { module: 'typescript', enabled: true }] },
237
- { path: 'js/src/common/index.ts', moduleDeps: ['js', 'jsCommon', { module: 'typescript', enabled: true }] },
238
- ],
248
+ filesToReplace: ['extend.php', 'README.md', 'LICENSE.md'],
239
249
  jsonToAugment: {
240
250
  'composer.json': [
241
251
  'name',
@@ -245,15 +255,17 @@ function moduleNameToDef(name) {
245
255
  'license',
246
256
  'require.flarum/core',
247
257
  'authors',
248
- 'autoload.psr-4.${params.packageNamespaceEscapedSlash}\\',
258
+ 'autoload.psr-4.${params.packageNamespace}\\',
249
259
  'extra.flarum-extension.title',
250
260
  'extra.flarum-extension.category',
261
+ 'minimum-stability',
262
+ 'prefer-stable',
251
263
  ],
252
264
  },
253
265
  needsTemplateParams: [
254
266
  'packageName',
255
267
  'packageNamespace',
256
- 'packageNamespaceEscapedSlash',
268
+ 'packageNamespace',
257
269
  'packageDescription',
258
270
  'extensionName',
259
271
  'licenseType',
@@ -287,13 +299,15 @@ function moduleNameToDef(name) {
287
299
  filesToReplace: [
288
300
  { path: 'js/admin.js', moduleDeps: ['js', { module: 'typescript', enabled: false }] },
289
301
  { path: 'js/admin.ts', moduleDeps: ['js', { module: 'typescript', enabled: true }] },
302
+ { path: 'js/src/admin/index.js', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: false }] },
303
+ { path: 'js/src/admin/index.ts', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: true }] },
290
304
  ],
291
305
  jsonToAugment: {},
292
306
  needsTemplateParams: [],
293
307
  inferEnabled: async (_fs, paths) => {
294
- if (!(0, node_fs_1.existsSync)(paths.package('js')))
308
+ if (!(0, fs_1.existsSync)(paths.package('js')))
295
309
  undefined;
296
- return (0, node_fs_1.existsSync)(paths.package('js/src/admin'));
310
+ return (0, fs_1.existsSync)(paths.package('js/src/admin'));
297
311
  },
298
312
  };
299
313
  case 'forum':
@@ -307,13 +321,15 @@ function moduleNameToDef(name) {
307
321
  filesToReplace: [
308
322
  { path: 'js/forum.js', moduleDeps: ['js', { module: 'typescript', enabled: false }] },
309
323
  { path: 'js/forum.ts', moduleDeps: ['js', { module: 'typescript', enabled: true }] },
324
+ { path: 'js/src/forum/index.js', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: false }] },
325
+ { path: 'js/src/forum/index.ts', doNotUpdate: true, moduleDeps: ['js', { module: 'typescript', enabled: true }] },
310
326
  ],
311
327
  jsonToAugment: {},
312
328
  needsTemplateParams: [],
313
329
  inferEnabled: async (_fs, paths) => {
314
- if (!(0, node_fs_1.existsSync)(paths.package('js')))
330
+ if (!(0, fs_1.existsSync)(paths.package('js')))
315
331
  undefined;
316
- return (0, node_fs_1.existsSync)(paths.package('js/src/forum'));
332
+ return (0, fs_1.existsSync)(paths.package('js/src/forum'));
317
333
  },
318
334
  };
319
335
  case 'js':
@@ -331,11 +347,18 @@ function moduleNameToDef(name) {
331
347
  { path: 'js/forum.js', moduleDeps: ['forum', { module: 'typescript', enabled: false }] },
332
348
  { path: 'js/admin.ts', moduleDeps: ['admin', { module: 'typescript', enabled: true }] },
333
349
  { path: 'js/forum.ts', moduleDeps: ['forum', { module: 'typescript', enabled: true }] },
350
+ { path: 'js/src/admin/index.js', doNotUpdate: true, moduleDeps: ['admin', { module: 'typescript', enabled: false }] },
351
+ { path: 'js/src/forum/index.js', doNotUpdate: true, moduleDeps: ['forum', { module: 'typescript', enabled: false }] },
352
+ { path: 'js/src/common/index.js', doNotUpdate: true, moduleDeps: ['jsCommon', { module: 'typescript', enabled: false }] },
353
+ { path: 'js/src/admin/index.ts', doNotUpdate: true, moduleDeps: ['admin', { module: 'typescript', enabled: true }] },
354
+ { path: 'js/src/forum/index.ts', doNotUpdate: true, moduleDeps: ['forum', { module: 'typescript', enabled: true }] },
355
+ { path: 'js/src/common/index.ts', doNotUpdate: true, moduleDeps: ['jsCommon', { module: 'typescript', enabled: true }] },
334
356
  ],
335
357
  jsonToAugment: {
336
358
  'js/package.json': [
337
359
  'name',
338
360
  'private',
361
+ 'version',
339
362
  'devDependencies.flarum-webpack-config',
340
363
  'devDependencies.webpack',
341
364
  'devDependencies.webpack-cli',
@@ -344,9 +367,9 @@ function moduleNameToDef(name) {
344
367
  'scripts.analyze',
345
368
  ],
346
369
  },
347
- needsTemplateParams: ['packageName'],
370
+ needsTemplateParams: ['packageName', 'jsPackageManager'],
348
371
  inferEnabled: async (_fs, paths) => {
349
- return (0, node_fs_1.existsSync)(paths.package('js'));
372
+ return (0, fs_1.existsSync)(paths.package('js'));
350
373
  },
351
374
  };
352
375
  case 'jsCommon':
@@ -363,27 +386,32 @@ function moduleNameToDef(name) {
363
386
  { path: 'js/forum.js', moduleDeps: ['forum', { module: 'typescript', enabled: false }] },
364
387
  { path: 'js/admin.ts', moduleDeps: ['admin', { module: 'typescript', enabled: true }] },
365
388
  { path: 'js/forum.ts', moduleDeps: ['forum', { module: 'typescript', enabled: true }] },
389
+ { path: 'js/src/common/index.js', doNotUpdate: true, moduleDeps: [{ module: 'typescript', enabled: false }] },
390
+ { path: 'js/src/common/index.ts', doNotUpdate: true, moduleDeps: [{ module: 'typescript', enabled: true }] },
366
391
  ],
367
392
  jsonToAugment: {},
368
393
  needsTemplateParams: [],
369
394
  inferEnabled: async (_fs, paths) => {
370
- return (0, node_fs_1.existsSync)(paths.package('js/src/common'));
395
+ return (0, fs_1.existsSync)(paths.package('js/src/common'));
371
396
  },
372
397
  };
373
398
  case 'css':
374
399
  return {
375
400
  name,
376
- updatable: false,
401
+ updatable: true,
377
402
  togglable: true,
378
403
  defaultEnabled: true,
379
404
  shortDescription: 'CSS',
380
405
  longDescription: "LESS starter files for Flarum's frontend styling.",
381
406
  dependsOn: [],
382
- filesToReplace: ['less/admin.less', 'less/forum.less'],
407
+ filesToReplace: [
408
+ { path: 'less/admin.less', doNotUpdate: true, moduleDeps: ['admin'] },
409
+ { path: 'less/forum.less', doNotUpdate: true, moduleDeps: ['forum'] },
410
+ ],
383
411
  jsonToAugment: {},
384
412
  needsTemplateParams: [],
385
413
  inferEnabled: async (_fs, paths) => {
386
- return (0, node_fs_1.existsSync)(paths.package('less'));
414
+ return (0, fs_1.existsSync)(paths.package('less'));
387
415
  },
388
416
  };
389
417
  case 'locale':
@@ -395,11 +423,11 @@ function moduleNameToDef(name) {
395
423
  shortDescription: 'Locale',
396
424
  longDescription: 'Translation starter files.',
397
425
  dependsOn: [],
398
- filesToReplace: ['locale/en.yml'],
426
+ filesToReplace: [{ path: 'locale/en.yml', doNotUpdate: true }],
399
427
  jsonToAugment: {},
400
428
  needsTemplateParams: [],
401
429
  inferEnabled: async (_fs, paths) => {
402
- return (0, node_fs_1.existsSync)(paths.package('locale'));
430
+ return (0, fs_1.existsSync)(paths.package('locale'));
403
431
  },
404
432
  };
405
433
  case 'gitConf':
@@ -411,7 +439,11 @@ function moduleNameToDef(name) {
411
439
  shortDescription: 'Git Configuration',
412
440
  longDescription: 'Git config files (e.g. .gitignore, .gitattributes).',
413
441
  dependsOn: [],
414
- filesToReplace: [{ path: 'gitignore', destPath: '.gitignore' }, { path: 'js/gitignore', moduleDeps: ['js'], destPath: 'js/.gitignore' }, '.gitattributes'],
442
+ filesToReplace: [
443
+ { path: 'gitignore', destPath: '.gitignore' },
444
+ { path: 'js/gitignore', moduleDeps: ['js'], destPath: 'js/.gitignore' },
445
+ { path: '.gitattributes', monorepoPath: '.gitattributes' },
446
+ ],
415
447
  jsonToAugment: {},
416
448
  needsTemplateParams: [],
417
449
  };
@@ -425,8 +457,17 @@ function moduleNameToDef(name) {
425
457
  longDescription: 'Automatically run checks via GitHub Actions CI. Free for open source projects.',
426
458
  dependsOn: [],
427
459
  filesToReplace: [
428
- { path: '.github/workflows/frontend.yml', monorepoPath: '.github/workflows/${params.extensionId}-frontend.yml' },
429
- { path: '.github/workflows/backend.yml', monorepoPath: '.github/workflows/${params.extensionId}-backend.yml' },
460
+ {
461
+ path: '.github/workflows/frontend.yml',
462
+ monorepoPath: '.github/workflows/${params.extensionId}-frontend.yml',
463
+ requireMonorepo: false,
464
+ moduleDeps: ['js'],
465
+ },
466
+ {
467
+ path: '.github/workflows/backend.yml',
468
+ monorepoPath: '.github/workflows/${params.extensionId}-backend.yml',
469
+ requireMonorepo: false,
470
+ },
430
471
  ],
431
472
  jsonToAugment: {},
432
473
  needsTemplateParams: ['frontendDirectory', 'backendDirectory', 'mainGitBranch', 'extensionId', 'extensionName'],
@@ -441,14 +482,20 @@ function moduleNameToDef(name) {
441
482
  dependsOn: ['js'],
442
483
  filesToReplace: [],
443
484
  jsonToAugment: {
444
- 'js/package.json': ['prettier', 'devDependencies.prettier', 'devDependencies.@flarum/prettier-config', 'scripts.format', 'scripts.format-check'],
485
+ 'js/package.json': [
486
+ 'prettier',
487
+ 'devDependencies.prettier',
488
+ 'devDependencies.@flarum/prettier-config',
489
+ 'scripts.format',
490
+ 'scripts.format-check',
491
+ ],
445
492
  },
446
493
  needsTemplateParams: [],
447
494
  inferEnabled: async (_fs, paths) => {
448
- if (!(0, node_fs_1.existsSync)(paths.package('js/package.json'))) {
495
+ if (!(0, fs_1.existsSync)(paths.package('js/package.json'))) {
449
496
  return false;
450
497
  }
451
- return (0, node_fs_1.readFileSync)('js/package.json').includes('prettier');
498
+ return (0, fs_1.readFileSync)(paths.package('js/package.json')).includes('prettier');
452
499
  },
453
500
  };
454
501
  case 'typescript':
@@ -462,17 +509,19 @@ function moduleNameToDef(name) {
462
509
  filesToReplace: ['js/tsconfig.json'],
463
510
  jsonToAugment: {
464
511
  'js/package.json': [
465
- 'prettier',
466
512
  'devDependencies.flarum-tsconfig',
467
513
  'devDependencies.typescript',
468
514
  'devDependencies.typescript-coverage-report',
515
+ 'scripts.clean-typings',
516
+ 'scripts.build-typings',
517
+ 'scripts.post-build-typings',
469
518
  'scripts.check-typings',
470
519
  'scripts.check-typings-coverage',
471
520
  ],
472
521
  },
473
522
  needsTemplateParams: [],
474
523
  inferEnabled: async (_fs, paths) => {
475
- return (0, node_fs_1.existsSync)(paths.package('js/tsconfig.json'));
524
+ return (0, fs_1.existsSync)(paths.package('js/tsconfig.json'));
476
525
  },
477
526
  };
478
527
  case 'bundlewatch':
@@ -487,7 +536,7 @@ function moduleNameToDef(name) {
487
536
  jsonToAugment: {},
488
537
  needsTemplateParams: [],
489
538
  inferEnabled: async (_fs, paths) => {
490
- return (0, node_fs_1.existsSync)(paths.package('js/.bundlewatch.config.json'));
539
+ return (0, fs_1.existsSync)(paths.package('js/.bundlewatch.config.json'));
491
540
  },
492
541
  };
493
542
  case 'backendTesting':
@@ -507,7 +556,7 @@ function moduleNameToDef(name) {
507
556
  ],
508
557
  jsonToAugment: {
509
558
  'composer.json': [
510
- 'autoload-dev.psr-4.${params.packageNamespaceEscapedSlash}\\Tests\\',
559
+ 'autoload-dev.psr-4.${params.packageNamespace}\\Tests\\',
511
560
  'scripts.test',
512
561
  'scripts.test:unit',
513
562
  'scripts.test:integration',
@@ -519,9 +568,9 @@ function moduleNameToDef(name) {
519
568
  'require-dev.flarum/testing',
520
569
  ],
521
570
  },
522
- needsTemplateParams: ['packageNamespaceEscapedSlash'],
571
+ needsTemplateParams: ['packageNamespace'],
523
572
  inferEnabled: async (_fs, paths) => {
524
- return (0, node_fs_1.existsSync)(paths.package('tests'));
573
+ return (0, fs_1.existsSync)(paths.package('tests'));
525
574
  },
526
575
  };
527
576
  case 'editorConfig':
@@ -544,9 +593,7 @@ function moduleNameToDef(name) {
544
593
  defaultEnabled: true,
545
594
  shortDescription: 'StyleCI config file',
546
595
  dependsOn: [],
547
- filesToReplace: [
548
- { path: '.styleci.yml', monorepoPath: '.styleci.yml' },
549
- ],
596
+ filesToReplace: [{ path: '.styleci.yml', monorepoPath: '.styleci.yml', requireMonorepo: false }],
550
597
  jsonToAugment: {},
551
598
  needsTemplateParams: [],
552
599
  };
@@ -577,11 +624,14 @@ function genExtScaffolder() {
577
624
  },
578
625
  };
579
626
  const excludeScaffoldingFunc = (fs, paths) => {
580
- var _a, _b, _c;
627
+ var _a, _b, _c, _d, _e, _f;
581
628
  const json = (0, composer_1.getComposerJson)(fs, paths);
582
- 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 : [];
629
+ return {
630
+ 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 : [],
631
+ 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 : {},
632
+ };
583
633
  };
584
- const scaffolder = new scaffolder_1.Scaffolder((0, node_path_1.resolve)(__dirname, '../../boilerplate/skeleton/extension'), moduleStatusCache, excludeScaffoldingFunc);
634
+ const scaffolder = new scaffolder_1.Scaffolder((0, path_1.resolve)(__dirname, '../../boilerplate/skeleton/extension'), moduleStatusCache, excludeScaffoldingFunc);
585
635
  for (const name of exports.EXTENSION_MODULES) {
586
636
  scaffolder.registerModule(moduleNameToDef(name));
587
637
  }
@@ -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
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComposerInstall = void 0;
4
- const node_child_process_1 = require("node:child_process");
4
+ const child_process_1 = require("child_process");
5
5
  class ComposerInstall {
6
6
  constructor() {
7
7
  this.type = 'Run composer install/update';
@@ -9,7 +9,7 @@ class ComposerInstall {
9
9
  this.exposes = [];
10
10
  }
11
11
  async run(fs, paths, _paramProvider, _providers) {
12
- (0, node_child_process_1.execSync)('composer update', { cwd: paths.package('') });
12
+ (0, child_process_1.execSync)('composer update', { cwd: paths.package('') });
13
13
  return fs;
14
14
  }
15
15
  getExposed() {
@@ -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 child_process_1 = require("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, child_process_1.execSync)('npm install', { cwd: paths.package('js') });
13
+ return fs;
14
+ }
15
+ getExposed() {
16
+ return {};
17
+ }
18
+ }
19
+ exports.NpmInstall = NpmInstall;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.YarnInstall = void 0;
4
- const node_child_process_1 = require("node:child_process");
4
+ const child_process_1 = require("child_process");
5
5
  class YarnInstall {
6
6
  constructor() {
7
7
  this.type = 'Run yarn install';
@@ -9,7 +9,7 @@ class YarnInstall {
9
9
  this.exposes = [];
10
10
  }
11
11
  async run(fs, paths, _paramProvider, _providers) {
12
- (0, node_child_process_1.execSync)('yarn install', { cwd: paths.package('js') });
12
+ (0, child_process_1.execSync)('yarn install', { cwd: paths.package('js') });
13
13
  return fs;
14
14
  }
15
15
  getExposed() {
@@ -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
+ }