@flarum/cli 1.0.0 → 2.0.0-beta.1

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 (185) hide show
  1. package/README.md +2 -2
  2. package/bin/run +5 -3
  3. package/boilerplate/skeleton/extension/.gitattributes +16 -3
  4. package/boilerplate/skeleton/extension/.github/workflows/backend.yml +15 -0
  5. package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +20 -0
  6. package/boilerplate/skeleton/extension/.styleci.yml +14 -0
  7. package/boilerplate/skeleton/extension/LICENSE.md +1 -0
  8. package/boilerplate/skeleton/extension/README.md +7 -7
  9. package/boilerplate/skeleton/extension/composer.json +11 -9
  10. package/boilerplate/skeleton/extension/extend.php +10 -10
  11. package/boilerplate/skeleton/extension/js/admin.js +2 -1
  12. package/boilerplate/skeleton/extension/js/forum.js +2 -1
  13. package/boilerplate/skeleton/extension/js/package.json +13 -9
  14. package/boilerplate/skeleton/extension/js/src/admin/index.js +4 -2
  15. package/boilerplate/skeleton/extension/js/src/common/index.js +5 -0
  16. package/boilerplate/skeleton/extension/js/src/forum/index.js +4 -2
  17. package/boilerplate/skeleton/extension/js/tsconfig.json +6 -1
  18. package/boilerplate/skeleton/extension/locale/en.yml +1 -1
  19. package/boilerplate/stubs/migration.php +1 -1
  20. package/lib/base-command.d.ts +27 -6
  21. package/lib/base-command.js +131 -41
  22. package/lib/boilersmith/exposed-param-manager.d.ts +8 -0
  23. package/lib/boilersmith/exposed-param-manager.js +31 -0
  24. package/lib/boilersmith/io.d.ts +50 -0
  25. package/lib/boilersmith/io.js +72 -0
  26. package/lib/boilersmith/paths.d.ts +22 -0
  27. package/lib/boilersmith/paths.js +29 -0
  28. package/lib/boilersmith/scaffolding/audit-step-factory.d.ts +5 -0
  29. package/lib/boilersmith/scaffolding/audit-step-factory.js +54 -0
  30. package/lib/boilersmith/scaffolding/infra-step-factory.d.ts +5 -0
  31. package/lib/boilersmith/scaffolding/infra-step-factory.js +34 -0
  32. package/lib/boilersmith/scaffolding/init-step-factory.d.ts +5 -0
  33. package/lib/boilersmith/scaffolding/init-step-factory.js +34 -0
  34. package/lib/boilersmith/scaffolding/module.d.ts +68 -0
  35. package/lib/boilersmith/scaffolding/module.js +111 -0
  36. package/lib/boilersmith/scaffolding/scaffolder.d.ts +32 -0
  37. package/lib/boilersmith/scaffolding/scaffolder.js +203 -0
  38. package/lib/boilersmith/scaffolding/template-param.d.ts +23 -0
  39. package/lib/boilersmith/scaffolding/template-param.js +46 -0
  40. package/lib/boilersmith/step-manager.d.ts +85 -0
  41. package/lib/boilersmith/step-manager.js +234 -0
  42. package/lib/boilersmith/steps/stub-base.d.ts +53 -0
  43. package/lib/boilersmith/steps/stub-base.js +54 -0
  44. package/lib/{utils → boilersmith/utils}/clone-and-fill.d.ts +0 -0
  45. package/lib/{utils → boilersmith/utils}/clone-and-fill.js +2 -2
  46. package/lib/boilersmith/utils/cond-format.d.ts +1 -0
  47. package/lib/boilersmith/utils/cond-format.js +8 -0
  48. package/lib/boilersmith/utils/json-leaf-paths.d.ts +7 -0
  49. package/lib/boilersmith/utils/json-leaf-paths.js +17 -0
  50. package/lib/boilersmith/utils/read-tpl.d.ts +2 -0
  51. package/lib/boilersmith/utils/read-tpl.js +10 -0
  52. package/lib/boilersmith/utils/rename-keys.d.ts +1 -0
  53. package/lib/boilersmith/utils/rename-keys.js +7 -0
  54. package/lib/commands/audit/infra.d.ts +16 -0
  55. package/lib/commands/audit/infra.js +27 -0
  56. package/lib/commands/infra.d.ts +20 -0
  57. package/lib/commands/infra.js +55 -0
  58. package/lib/commands/init.d.ts +4 -3
  59. package/lib/commands/init.js +8 -6
  60. package/lib/commands/make/backend/api-controller.d.ts +4 -3
  61. package/lib/commands/make/backend/api-controller.js +3 -2
  62. package/lib/commands/make/backend/api-serializer-attributes.d.ts +4 -3
  63. package/lib/commands/make/backend/api-serializer-attributes.js +1 -1
  64. package/lib/commands/make/backend/api-serializer.d.ts +4 -3
  65. package/lib/commands/make/backend/api-serializer.js +3 -2
  66. package/lib/commands/make/backend/command.d.ts +4 -3
  67. package/lib/commands/make/backend/command.js +3 -2
  68. package/lib/commands/make/backend/event-listener.d.ts +4 -3
  69. package/lib/commands/make/backend/event-listener.js +3 -2
  70. package/lib/commands/make/backend/handler.d.ts +4 -3
  71. package/lib/commands/make/backend/handler.js +4 -3
  72. package/lib/commands/make/backend/integration-test.d.ts +4 -3
  73. package/lib/commands/make/backend/integration-test.js +3 -2
  74. package/lib/commands/make/backend/job.d.ts +4 -3
  75. package/lib/commands/make/backend/job.js +3 -2
  76. package/lib/commands/make/backend/migration.d.ts +4 -3
  77. package/lib/commands/make/backend/migration.js +3 -2
  78. package/lib/commands/make/backend/model.d.ts +4 -3
  79. package/lib/commands/make/backend/model.js +22 -21
  80. package/lib/commands/make/backend/policy.d.ts +4 -3
  81. package/lib/commands/make/backend/policy.js +3 -2
  82. package/lib/commands/make/backend/repository.d.ts +4 -3
  83. package/lib/commands/make/backend/repository.js +3 -2
  84. package/lib/commands/make/backend/route.d.ts +4 -3
  85. package/lib/commands/make/backend/route.js +1 -1
  86. package/lib/commands/make/backend/service-provider.d.ts +4 -3
  87. package/lib/commands/make/backend/service-provider.js +3 -2
  88. package/lib/commands/make/backend/validator.d.ts +4 -3
  89. package/lib/commands/make/backend/validator.js +3 -2
  90. package/lib/commands/make/frontend/component.d.ts +4 -3
  91. package/lib/commands/make/frontend/component.js +3 -2
  92. package/lib/commands/make/frontend/modal.d.ts +4 -3
  93. package/lib/commands/make/frontend/modal.js +3 -2
  94. package/lib/commands/make/frontend/model.d.ts +4 -3
  95. package/lib/commands/make/frontend/model.js +3 -2
  96. package/lib/commands/update/js-imports.d.ts +4 -3
  97. package/lib/commands/update/js-imports.js +1 -1
  98. package/lib/help.d.ts +5 -6
  99. package/lib/help.js +5 -4
  100. package/lib/index.d.ts +1 -1
  101. package/lib/index.js +3 -2
  102. package/lib/providers/index.d.ts +5 -0
  103. package/lib/providers/index.js +2 -0
  104. package/lib/{provider → providers}/php-provider.d.ts +0 -0
  105. package/lib/{provider → providers}/php-provider.js +2 -2
  106. package/lib/steps/extenders/api-serializer.js +2 -3
  107. package/lib/steps/extenders/base.d.ts +10 -10
  108. package/lib/steps/extenders/base.js +11 -11
  109. package/lib/steps/extenders/console-command.js +2 -3
  110. package/lib/steps/extenders/event.js +2 -3
  111. package/lib/steps/extenders/policy.js +2 -3
  112. package/lib/steps/extenders/route.js +2 -3
  113. package/lib/steps/extenders/service-provider.js +2 -3
  114. package/lib/steps/gen-ext-scaffolder.d.ts +6 -0
  115. package/lib/steps/gen-ext-scaffolder.js +508 -0
  116. package/lib/steps/js/base.d.ts +9 -9
  117. package/lib/steps/js/base.js +11 -11
  118. package/lib/steps/js/model.d.ts +5 -5
  119. package/lib/steps/js/model.js +8 -13
  120. package/lib/steps/misc/composer.d.ts +5 -6
  121. package/lib/steps/misc/composer.js +3 -3
  122. package/lib/steps/misc/git.d.ts +11 -0
  123. package/lib/steps/misc/git.js +20 -0
  124. package/lib/steps/misc/yarn.d.ts +5 -6
  125. package/lib/steps/misc/yarn.js +3 -3
  126. package/lib/steps/stubs/backend/api-controller.d.ts +1 -8
  127. package/lib/steps/stubs/backend/api-controller.js +2 -3
  128. package/lib/steps/stubs/backend/api-serializer.d.ts +4 -9
  129. package/lib/steps/stubs/backend/api-serializer.js +4 -4
  130. package/lib/steps/stubs/backend/command.d.ts +0 -5
  131. package/lib/steps/stubs/backend/command.js +1 -1
  132. package/lib/steps/stubs/backend/event-listener.d.ts +0 -5
  133. package/lib/steps/stubs/backend/event-listener.js +1 -1
  134. package/lib/steps/stubs/backend/handler-command.js +1 -1
  135. package/lib/steps/stubs/backend/handler.js +1 -1
  136. package/lib/steps/stubs/backend/migration.d.ts +4 -5
  137. package/lib/steps/stubs/backend/migration.js +8 -8
  138. package/lib/steps/stubs/backend/model.d.ts +4 -4
  139. package/lib/steps/stubs/backend/model.js +4 -4
  140. package/lib/steps/stubs/backend/policy.d.ts +0 -5
  141. package/lib/steps/stubs/backend/policy.js +1 -1
  142. package/lib/steps/stubs/backend/repository.d.ts +0 -5
  143. package/lib/steps/stubs/backend/repository.js +1 -1
  144. package/lib/steps/stubs/flarum-base.d.ts +9 -0
  145. package/lib/steps/stubs/flarum-base.js +10 -0
  146. package/lib/steps/stubs/frontend/component.js +0 -1
  147. package/lib/steps/stubs/frontend/modal.js +0 -1
  148. package/lib/steps/stubs/frontend/model.d.ts +4 -4
  149. package/lib/steps/stubs/frontend/model.js +3 -3
  150. package/lib/steps/stubs/js-base.d.ts +6 -7
  151. package/lib/steps/stubs/js-base.js +11 -16
  152. package/lib/steps/stubs/php-base.d.ts +7 -8
  153. package/lib/steps/stubs/php-base.js +12 -20
  154. package/lib/steps/update/js-imports.d.ts +5 -6
  155. package/lib/steps/update/js-imports.js +13 -17
  156. package/lib/utils/composer.d.ts +64 -0
  157. package/lib/utils/composer.js +8 -0
  158. package/lib/utils/migration.js +3 -3
  159. package/lib/utils/model-name.js +6 -6
  160. package/lib/utils/validation.d.ts +10 -7
  161. package/lib/utils/validation.js +9 -6
  162. package/oclif.manifest.json +1 -1
  163. package/package.json +53 -31
  164. package/php-subsystem/src/NodeVisitors/AddExtender.php +2 -1
  165. package/boilerplate/skeleton/extension/.github/workflows/build.yml +0 -32
  166. package/boilerplate/skeleton/extension/.github/workflows/lint.yml +0 -32
  167. package/boilerplate/skeleton/extension/.github/workflows/test.yml +0 -78
  168. package/lib/commands/infra/backend-testing.d.ts +0 -14
  169. package/lib/commands/infra/backend-testing.js +0 -26
  170. package/lib/provider/param-provider.d.ts +0 -15
  171. package/lib/provider/param-provider.js +0 -39
  172. package/lib/provider/path-provider.d.ts +0 -19
  173. package/lib/provider/path-provider.js +0 -24
  174. package/lib/steps/infra/backend-testing.d.ts +0 -8
  175. package/lib/steps/infra/backend-testing.js +0 -22
  176. package/lib/steps/infra/base.d.ts +0 -20
  177. package/lib/steps/infra/base.js +0 -36
  178. package/lib/steps/init/extension-skeleton.d.ts +0 -12
  179. package/lib/steps/init/extension-skeleton.js +0 -142
  180. package/lib/steps/step-manager.d.ts +0 -71
  181. package/lib/steps/step-manager.js +0 -173
  182. package/lib/steps/stubs/base.d.ts +0 -49
  183. package/lib/steps/stubs/base.js +0 -58
  184. package/lib/utils/extension-metadata.d.ts +0 -2
  185. package/lib/utils/extension-metadata.js +0 -21
@@ -1,12 +1,11 @@
1
1
  import { Store } from 'mem-fs';
2
- import { ParamProvider } from '../../provider/param-provider';
3
- import { PathProvider } from '../../provider/path-provider';
4
- import { PhpProvider } from '../../provider/php-provider';
5
- import { Step } from '../step-manager';
2
+ import { IO } from 'boilersmith/io';
3
+ import { Paths } from 'boilersmith/paths';
4
+ import { DefaultProviders, Step } from 'boilersmith/step-manager';
6
5
  export declare class UpdateJSImports implements Step {
7
6
  type: string;
8
7
  composable: boolean;
9
- run(fs: Store, pathProvider: PathProvider, _paramProvider: ParamProvider, _phpProvider: PhpProvider): Promise<Store>;
8
+ run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise<Store>;
10
9
  exposes: never[];
11
- getExposed(_pathProvider: PathProvider, _paramProvider: ParamProvider): Record<string, unknown>;
10
+ getExposed(_paths: Paths, _paramProvider: IO): Record<string, unknown>;
12
11
  }
@@ -5,49 +5,45 @@ const glob_1 = require("glob");
5
5
  const mem_fs_editor_1 = require("mem-fs-editor");
6
6
  const CORE_JS_NAMESPACES = ['admin', 'common', 'forum'];
7
7
  const CORE_NAMESPACE_REGEX = new RegExp(`^(${CORE_JS_NAMESPACES.join('|')})/`);
8
- const IMPORT_REGEX = /(?<key>import|export)\s+(?:(?<alias>[\w,{}\s*]+)\s+from)?\s*(?:(["'])?(?<ref>[@\w\s\\/.-]+)\3?)\s*;?/gm;
8
+ const IMPORT_REGEX = /(?<key>import|export)\s+(?:(?<alias>[\s\w*,{}]+)\s+from)?\s*(["'])?(?<ref>[\s\w./@\\-]+)\3?\s*;?/gm;
9
9
  class UpdateJSImports {
10
10
  constructor() {
11
11
  this.type = 'Use full flarum/namespace in JS imports';
12
12
  this.composable = false;
13
13
  this.exposes = [];
14
14
  }
15
- async run(fs, pathProvider, _paramProvider, _phpProvider) {
16
- const fsEditor = mem_fs_editor_1.create(fs);
15
+ async run(fs, paths, _paramProvider, _providers) {
16
+ const fsEditor = (0, mem_fs_editor_1.create)(fs);
17
17
  const importMap = {};
18
- const jsSrcDir = pathProvider.ext('vendor/flarum/core/js/src');
18
+ const jsSrcDir = paths.package('vendor/flarum/core/js/src');
19
19
  const vendorRegex = new RegExp(`${jsSrcDir}/.*(js|jsx|ts|tsx)`);
20
20
  const fsVendorFilePaths = fs.all().map(file => file.path).filter(path => path && vendorRegex.test(path));
21
21
  const persistedVendorFilePaths = glob_1.glob.sync(`${jsSrcDir}/**/*.{js,jsx,ts,tsx}`);
22
- [...fsVendorFilePaths, ...persistedVendorFilePaths]
23
- .forEach(currPath => {
22
+ for (const currPath of [...fsVendorFilePaths, ...persistedVendorFilePaths]) {
24
23
  const withNamespace = currPath.slice(jsSrcDir.length + 1).replace(/\.(js|jsx|ts|tsx)$/, '');
25
24
  const noNamespace = withNamespace.replace(CORE_NAMESPACE_REGEX, '');
26
25
  importMap[`flarum/${noNamespace}`] = `flarum/${withNamespace}`;
27
- });
28
- const srcRegex = new RegExp(`${pathProvider.ext('js/src')}/.*(js|jsx|ts|tsx)`);
26
+ }
27
+ const srcRegex = new RegExp(`${paths.package('js/src')}/.*(js|jsx|ts|tsx)`);
29
28
  const fsSrcFilePaths = fs.all().map(file => file.path).filter(path => path && srcRegex.test(path));
30
- const persistedSrcFilePaths = glob_1.glob.sync(pathProvider.ext('js/src/**/*.{js,jsx,ts,tsx}'));
31
- [...fsSrcFilePaths, ...persistedSrcFilePaths]
32
- .forEach(match => {
29
+ const persistedSrcFilePaths = glob_1.glob.sync(paths.package('js/src/**/*.{js,jsx,ts,tsx}'));
30
+ for (const match of [...fsSrcFilePaths, ...persistedSrcFilePaths]) {
33
31
  let fileCounted = false;
34
32
  const currContents = fsEditor.read(match);
35
33
  const newContents = currContents.replace(IMPORT_REGEX, (match, ...args) => {
36
34
  const currImport = args[3];
37
35
  const currImportNoAt = currImport.replace(/^@/, '');
38
36
  const newImport = importMap[currImportNoAt] || currImport;
39
- if (newImport !== currImport) {
40
- if (!fileCounted) {
41
- fileCounted = true;
42
- }
37
+ if (newImport !== currImport && !fileCounted) {
38
+ fileCounted = true;
43
39
  }
44
40
  return match.replace(currImport, newImport);
45
41
  });
46
42
  fsEditor.write(match, newContents);
47
- });
43
+ }
48
44
  return fs;
49
45
  }
50
- getExposed(_pathProvider, _paramProvider) {
46
+ getExposed(_paths, _paramProvider) {
51
47
  return {};
52
48
  }
53
49
  }
@@ -0,0 +1,64 @@
1
+ import { Paths } from 'boilersmith/paths';
2
+ import { Store } from 'mem-fs';
3
+ import { ExtensionModules } from '../steps/gen-ext-scaffolder';
4
+ export declare type ComposerJsonSchema = {
5
+ name?: string;
6
+ description?: string;
7
+ type?: string;
8
+ keywords?: string[];
9
+ homepage?: string;
10
+ readme?: string;
11
+ license?: string;
12
+ authors?: {
13
+ name?: string;
14
+ email?: string;
15
+ homepage?: string;
16
+ role?: string;
17
+ }[];
18
+ support?: {
19
+ email?: string;
20
+ issues?: string;
21
+ forum?: string;
22
+ wiki?: string;
23
+ irc?: string;
24
+ source?: string;
25
+ docs?: string;
26
+ rss?: string;
27
+ chat?: string;
28
+ };
29
+ funding?: {
30
+ type: string;
31
+ url: string;
32
+ }[];
33
+ require?: Record<string, string>;
34
+ 'require-dev'?: Record<string, string>;
35
+ conflict?: Record<string, string>;
36
+ replace?: Record<string, string>;
37
+ provide?: Record<string, string>;
38
+ suggest?: Record<string, string>;
39
+ autoload?: {
40
+ 'psr-4'?: Record<string, string>;
41
+ classmap?: Record<string, string[]>;
42
+ files?: Record<string, string[]>;
43
+ 'exclude-from-classmap'?: string[];
44
+ };
45
+ 'minimum-stability'?: 'dev' | 'alpha' | 'beta' | 'RC' | 'stable';
46
+ 'prefer-stable'?: boolean;
47
+ extra?: {
48
+ 'flarum-cli'?: {
49
+ excludeScaffolding?: string[];
50
+ mainGitBranch?: string;
51
+ modules?: Record<ExtensionModules, boolean>;
52
+ };
53
+ 'flarum-extension'?: {
54
+ title?: string;
55
+ category?: string;
56
+ icon?: {
57
+ name: string;
58
+ backgroundColor: string;
59
+ color: string;
60
+ };
61
+ };
62
+ };
63
+ };
64
+ export declare function getComposerJson(fs: Store, paths: Paths): ComposerJsonSchema;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getComposerJson = void 0;
4
+ const mem_fs_editor_1 = require("mem-fs-editor");
5
+ function getComposerJson(fs, paths) {
6
+ return (0, mem_fs_editor_1.create)(fs).readJSON(paths.package('composer.json'));
7
+ }
8
+ exports.getComposerJson = getComposerJson;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNextMigrationName = void 0;
4
+ const pad = (val, len) => String(val).padStart(len, '0');
4
5
  function getNextMigrationName(currNames, name) {
5
6
  const cleanedName = name.toLowerCase().replace(/ /g, '_');
6
7
  let number = 0;
@@ -9,13 +10,12 @@ function getNextMigrationName(currNames, name) {
9
10
  if (!match)
10
11
  continue;
11
12
  const now = new Date();
12
- if (parseInt(match[1], 10) === now.getFullYear() && parseInt(match[2], 10) === now.getMonth() + 1 && parseInt(match[3], 10) === now.getDate()) {
13
- number = parseInt(match[4], 10) + 1;
13
+ if (Number.parseInt(match[1], 10) === now.getFullYear() && Number.parseInt(match[2], 10) === now.getMonth() + 1 && Number.parseInt(match[3], 10) === now.getDate()) {
14
+ number = Number.parseInt(match[4], 10) + 1;
14
15
  break;
15
16
  }
16
17
  }
17
18
  const now = new Date();
18
- const pad = (val, len) => String(val).padStart(len, '0');
19
19
  return `${pad(now.getFullYear(), 4)}_${pad(now.getMonth() + 1, 2)}_${pad(now.getDate(), 2)}_${pad(number, 6)}_${cleanedName}`;
20
20
  }
21
21
  exports.getNextMigrationName = getNextMigrationName;
@@ -2,18 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pluralKebabCaseModel = exports.pluralSnakeCaseModel = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const pluralize_1 = tslib_1.__importDefault(require("pluralize"));
6
- const string_1 = tslib_1.__importDefault(require("string"));
5
+ const pluralize_1 = (0, tslib_1.__importDefault)(require("pluralize"));
6
+ const string_1 = (0, tslib_1.__importDefault)(require("string"));
7
7
  function pluralSnakeCaseModel(className) {
8
8
  let name;
9
- name = string_1.default(className).underscore().toString();
10
- name = pluralize_1.default(name.replace('_', ' ')).replace(' ', '_');
9
+ name = (0, string_1.default)(className).underscore().toString();
10
+ name = (0, pluralize_1.default)(name.replace('_', ' ')).replace(' ', '_');
11
11
  return name;
12
12
  }
13
13
  exports.pluralSnakeCaseModel = pluralSnakeCaseModel;
14
14
  function pluralKebabCaseModel(className) {
15
- className = pluralize_1.default(className.charAt(0).toLowerCase() + className.slice(1));
16
- className = string_1.default(className).dasherize().s;
15
+ className = (0, pluralize_1.default)(className.charAt(0).toLowerCase() + className.slice(1));
16
+ className = (0, string_1.default)(className).dasherize().s;
17
17
  return className;
18
18
  }
19
19
  exports.pluralKebabCaseModel = pluralKebabCaseModel;
@@ -1,9 +1,12 @@
1
+ declare type ValidatorFunc = true | string;
1
2
  export declare class Validator {
2
- static class(s: string): true | "Invalid PHP class. Must be qualified, but not fully qualified.";
3
- static className(s: string): true | "Invalid PHP class name: only alphanumerical characters allowed.";
4
- static routeName(s: string): true | "Invalid path name: only alphanumerical characters allowed and (._-).";
5
- static commandName(s: string): true | "Invalid path name: only alphanumerical characters allowed and (._-:).";
6
- static migrationName(s: string): true | "Field is required; alphanumerical characters, underscores, and spaces only!";
7
- static tableName(s: string): true | "Invalid table name, must be less than 64 alphanumerical characters.";
8
- static modelType(s: string): true | "Field is required; alphanumerical characters, dashes, and underscores only!";
3
+ static class(s: string): ValidatorFunc;
4
+ static optionalClass(s: string): ValidatorFunc;
5
+ static className(s: string): ValidatorFunc;
6
+ static routeName(s: string): ValidatorFunc;
7
+ static commandName(s: string): ValidatorFunc;
8
+ static migrationName(s: string): ValidatorFunc;
9
+ static tableName(s: string): ValidatorFunc;
10
+ static modelType(s: string): ValidatorFunc;
9
11
  }
12
+ export {};
@@ -3,25 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Validator = void 0;
4
4
  class Validator {
5
5
  static class(s) {
6
- return /^([0-9a-zA-Z]+)(\\([0-9a-zA-Z]+))*$/.test(s.trim()) || 'Invalid PHP class. Must be qualified, but not fully qualified.';
6
+ return /^([\dA-Za-z]+)(\\([\dA-Za-z]+))*$/.test(s.trim()) || 'Invalid PHP class. Must be qualified, but not fully qualified.';
7
+ }
8
+ static optionalClass(s) {
9
+ return s.length === 0 || Validator.class(s);
7
10
  }
8
11
  static className(s) {
9
- return /^([0-9a-zA-Z]+)$/.test(s.trim()) || 'Invalid PHP class name: only alphanumerical characters allowed.';
12
+ return /^([\dA-Za-z]+)$/.test(s.trim()) || 'Invalid PHP class name: only alphanumerical characters allowed.';
10
13
  }
11
14
  static routeName(s) {
12
- return /^([A-z-._0-9]+)$/.test(s.trim()) || 'Invalid path name: only alphanumerical characters allowed and (._-).';
15
+ return /^([\d.A-z-]+)$/.test(s.trim()) || 'Invalid path name: only alphanumerical characters allowed and (._-).';
13
16
  }
14
17
  static commandName(s) {
15
- return /^([A-z-.:_0-9]+)$/.test(s.trim()) || 'Invalid path name: only alphanumerical characters allowed and (._-:).';
18
+ return /^([\d.:A-z-]+)$/.test(s.trim()) || 'Invalid path name: only alphanumerical characters allowed and (._-:).';
16
19
  }
17
20
  static migrationName(s) {
18
21
  return /^\w+$/.test(s.trim()) || 'Field is required; alphanumerical characters, underscores, and spaces only!';
19
22
  }
20
23
  static tableName(s) {
21
- return /^[0-9,a-z,A-Z$_]{0,64}$/.test(s.trim()) || 'Invalid table name, must be less than 64 alphanumerical characters.';
24
+ return /^[\w$,]{0,64}$/.test(s.trim()) || 'Invalid table name, must be less than 64 alphanumerical characters.';
22
25
  }
23
26
  static modelType(s) {
24
- return /^[0-9a-zA-Z_-]+$/.test(s.trim()) || 'Field is required; alphanumerical characters, dashes, and underscores only!';
27
+ return /^[\w-]+$/.test(s.trim()) || 'Field is required; alphanumerical characters, dashes, and underscores only!';
25
28
  }
26
29
  }
27
30
  exports.Validator = Validator;
@@ -1 +1 @@
1
- {"version":"1.0.0","commands":{"init":{"id":"init","description":"Create a new Flarum extension","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"infra:backend-testing":{"id":"infra:backend-testing","description":"Add/Update backend testing infrastructure","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"update:js-imports":{"id":"update:js-imports","description":"Updates JS imports from core to use proper namespaces","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:api-controller":{"id":"make:backend:api-controller","description":"Generate an API controller class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:api-serializer-attributes":{"id":"make:backend:api-serializer-attributes","description":"Generate an API serializer attributes extender","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:api-serializer":{"id":"make:backend:api-serializer","description":"Generate an API serializer class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:command":{"id":"make:backend:command","description":"Generate a console command class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:event-listener":{"id":"make:backend:event-listener","description":"Generate an event listener class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:handler":{"id":"make:backend:handler","description":"Generate a domain logic handler class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:integration-test":{"id":"make:backend:integration-test","description":"Generate an integration test class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:job":{"id":"make:backend:job","description":"Generate a job class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:migration":{"id":"make:backend:migration","description":"Generate a migration","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:model":{"id":"make:backend:model","description":"Generate a model class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:policy":{"id":"make:backend:policy","description":"Generate a policy class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:repository":{"id":"make:backend:repository","description":"Generate a repository class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:route":{"id":"make:backend:route","description":"Generate a routes extender","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:service-provider":{"id":"make:backend:service-provider","description":"Generate a service provider class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:validator":{"id":"make:backend:validator","description":"Generate a validator class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:frontend:component":{"id":"make:frontend:component","description":"Generate a frontend component","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:frontend:modal":{"id":"make:frontend:modal","description":"Generate a modal component","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:frontend:model":{"id":"make:frontend:model","description":"Generate a model class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]}}}
1
+ {"version":"2.0.0-beta.1","commands":{"infra":{"id":"infra","description":"Add/Update infrastructure to the latest scaffolding for some module in an extension. For example, you can use this to add/update TypeScript, backend testing, GitHub Actions, and other features.","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"monorepo":{"name":"monorepo","type":"boolean","char":"m","allowNo":false},"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"module","description":"The name of the module to enable/update.","required":true,"options":["core","icon","js","jsCommon","css","locale","gitConf","githubActions","prettier","typescript","bundlewatch","backendTesting","editorConfig","styleci"]},{"name":"path","description":"Where should this command be executed?"}]},"init":{"id":"init","description":"Create a new Flarum extension","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"audit:infra":{"id":"audit:infra","description":"Check for outdated config files, infrastructure, setup, etc.","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"fix":{"name":"fix","type":"boolean","char":"f","allowNo":false},"monorepo":{"name":"monorepo","type":"boolean","char":"m","allowNo":false},"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"update:js-imports":{"id":"update:js-imports","description":"Updates JS imports from core to use proper namespaces","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:api-controller":{"id":"make:backend:api-controller","description":"Generate an API controller class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:api-serializer-attributes":{"id":"make:backend:api-serializer-attributes","description":"Generate an API serializer attributes extender","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:api-serializer":{"id":"make:backend:api-serializer","description":"Generate an API serializer class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:command":{"id":"make:backend:command","description":"Generate a console command class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:event-listener":{"id":"make:backend:event-listener","description":"Generate an event listener class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:handler":{"id":"make:backend:handler","description":"Generate a domain logic handler class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:integration-test":{"id":"make:backend:integration-test","description":"Generate an integration test class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:job":{"id":"make:backend:job","description":"Generate a job class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:migration":{"id":"make:backend:migration","description":"Generate a migration","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:model":{"id":"make:backend:model","description":"Generate a model class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:policy":{"id":"make:backend:policy","description":"Generate a policy class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:repository":{"id":"make:backend:repository","description":"Generate a repository class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:route":{"id":"make:backend:route","description":"Generate a routes extender","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:service-provider":{"id":"make:backend:service-provider","description":"Generate a service provider class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:backend:validator":{"id":"make:backend:validator","description":"Generate a validator class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:frontend:component":{"id":"make:frontend:component","description":"Generate a frontend component","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:frontend:modal":{"id":"make:frontend:modal","description":"Generate a modal component","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]},"make:frontend:model":{"id":"make:frontend:model","description":"Generate a model class","pluginName":"@flarum/cli","pluginType":"core","aliases":[],"flags":{"defaults":{"name":"defaults","type":"boolean","char":"d","description":"Assume default responses to prompts where possible.","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"path","description":"Where should this command be executed?"}]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flarum/cli",
3
3
  "description": "A CLI for developing Flarum extensions",
4
- "version": "1.0.0",
4
+ "version": "2.0.0-beta.1",
5
5
  "author": "Flarum Team",
6
6
  "bin": {
7
7
  "fl": "bin/run",
@@ -9,30 +9,39 @@
9
9
  },
10
10
  "bugs": "https://github.com/flarum/cli/issues",
11
11
  "devDependencies": {
12
+ "@babel/core": "^7",
12
13
  "@oclif/dev-cli": "^1.26.0",
13
14
  "@oclif/test": "^1.2.8",
14
15
  "@types/chai": "^4.2.20",
15
- "@types/jest": "^26.0.24",
16
+ "@types/ejs": "^3.1.0",
17
+ "@types/jest": "^27.0.3",
16
18
  "@types/mem-fs-editor": "^7.0.0",
17
- "@types/node": "^10.17.55",
19
+ "@types/node": "^16.11.7",
20
+ "@types/pick-deep": "^1.0.0",
18
21
  "@types/pluralize": "0.0.29",
19
22
  "@types/prompts": "^2.0.14",
20
23
  "@types/string": "0.0.31",
21
24
  "@types/yosay": "^0.0.29",
22
- "babel-jest": "^26.6.3",
25
+ "@typescript-eslint/parser": "^5.8.1",
26
+ "babel-jest": "^27.4.5",
27
+ "babel-plugin-module-resolver": "^4.1.0",
23
28
  "chai": "^4.3.3",
24
- "eslint": "^5.16.0",
25
- "eslint-config-oclif": "^3.1.0",
26
- "eslint-config-oclif-typescript": "^0.1.0",
29
+ "eslint": "^7.32.0",
30
+ "eslint-config-oclif": "^4.0.0",
31
+ "eslint-config-oclif-typescript": "1.0.2",
32
+ "eslint-import-resolver-babel-module": "^5.3.1",
33
+ "eslint-import-resolver-typescript": "^2.5.0",
34
+ "eslint-plugin-import": "^2.25.3",
27
35
  "globby": "^10.0.2",
28
- "jest": "^26.6.3",
29
- "jest-extended": "^0.11.5",
30
- "ts-jest": "^26.5.6",
36
+ "jest": "^27.4.5",
37
+ "jest-extended": "^1.2.0",
38
+ "ts-jest": "^27.1.2",
31
39
  "ts-node": "^8.10.2",
32
- "typescript": "^3.9.9"
40
+ "tsconfig-paths": "^3.12.0",
41
+ "typescript": "4.4.4"
33
42
  },
34
43
  "engines": {
35
- "node": ">=8.0.0"
44
+ "node": ">=12.0.0"
36
45
  },
37
46
  "files": [
38
47
  "/bin",
@@ -48,56 +57,69 @@
48
57
  "oclif"
49
58
  ],
50
59
  "license": "MIT",
51
- "main": "lib/index.js",
60
+ "main": "./lib/index.js",
52
61
  "oclif": {
62
+ "additionalHelpFlags": [
63
+ "-h"
64
+ ],
65
+ "additionalVersionFlags": [
66
+ "-v"
67
+ ],
53
68
  "commands": "./lib/commands",
54
69
  "bin": "flarum-cli",
55
70
  "helpClass": "./lib/help",
56
- "plugins": [
57
- "@oclif/plugin-help",
58
- "@tiagonapoli/oclif-plugin-spaced-commands"
59
- ],
71
+ "topicSeparator": " ",
60
72
  "topics": {
61
- "make:backend": {
73
+ "make backend": {
62
74
  "description": "Add backend boilerplate code to an existing Flarum extension."
63
75
  },
64
- "make:frontend": {
76
+ "make frontend": {
65
77
  "description": "Add frontend boilerplate code to an existing Flarum extension."
66
78
  },
67
79
  "make": {
68
80
  "description": "Add boilerplate code to an existing Flarum extension."
69
81
  },
70
- "infra": {
71
- "description": "Add/modify infrastructure for an existing Flarum extension."
82
+ "audit": {
83
+ "description": "Checks for potential errors / updatable parts of a Flarum extension."
72
84
  }
73
- }
85
+ },
86
+ "plugins": [
87
+ "@oclif/plugin-help",
88
+ "@oclif/plugin-plugins",
89
+ "@oclif/plugin-version"
90
+ ]
74
91
  },
75
92
  "repository": "flarum/cli",
76
93
  "scripts": {
94
+ "oclif-dev": "node -r tsconfig-paths/register node_modules/.bin/oclif-dev",
77
95
  "format": "eslint . --ext .ts --config .eslintrc --fix",
78
96
  "postpack": "rm -f oclif.manifest.json",
79
- "posttest": "eslint . --ext .ts --config .eslintrc",
80
- "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
97
+ "posttest": "eslint . --ext .ts --config .eslintrc && tsc --build --dry",
98
+ "prepack": "rm -rf lib && tsc --project tsconfig.build.json && yarn oclif-dev manifest && yarn oclif-dev readme",
81
99
  "test": "jest",
82
- "version": "oclif-dev readme && git add README.md"
100
+ "version": "yarn oclif-dev readme && git add README.md"
83
101
  },
84
102
  "types": "lib/index.d.ts",
85
103
  "dependencies": {
86
104
  "@babel/preset-env": "^7.14.2",
87
- "@oclif/command": "^1.8.0",
88
- "@oclif/config": "^1.17.0",
89
- "@oclif/plugin-autocomplete": "^0.3.0",
90
- "@oclif/plugin-help": "^3.2.2",
91
- "@tiagonapoli/oclif-plugin-spaced-commands": "^0.0.6",
92
- "@zodash/pick": "^1.1.6",
105
+ "@oclif/core": "^1.0.11",
106
+ "@oclif/errors": "^1.3.5",
107
+ "@oclif/plugin-help": "^5",
108
+ "@oclif/plugin-plugins": "^2.0.11",
109
+ "@oclif/plugin-version": "^1",
93
110
  "chalk": "^2.4.2",
111
+ "cli-ux": "^6.0.6",
112
+ "ejs": "^3.1.6",
94
113
  "glob": "^7.1.6",
95
114
  "just-safe-get": "^2.1.2",
96
115
  "mem-fs": "^2.2.1",
97
116
  "mem-fs-editor": "^8.0.0",
98
117
  "modern-async": "^1.0.2",
118
+ "module-alias": "^2.2.2",
119
+ "pick-deep": "^1.0.0",
99
120
  "pluralize": "^8.0.0",
100
121
  "prompts": "^2.4.0",
122
+ "simple-git": "^2.48.0",
101
123
  "spdx-license-list": "^6.4.0",
102
124
  "string": "^3.3.3",
103
125
  "tslib": "^1.14.1",
@@ -32,7 +32,8 @@ class AddExtender extends NodeVisitorAbstract
32
32
  {
33
33
  if ($node instanceof Node\Stmt\Return_ && $node->expr instanceof Node\Expr\Array_) {
34
34
  if (! isset($this->params['extender'])) {
35
- throw new \Exception('Invalid Extender Schema');
35
+ $params = json_encode($this->params);
36
+ throw new \Exception("Invalid Extender Schema. Provided params: $params");
36
37
  }
37
38
 
38
39
  $extender = $this->getOrCreateExtender($node->expr, $this->params['extender']);
@@ -1,32 +0,0 @@
1
- name: JavaScript
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- build:
10
- name: JS / Build
11
- runs-on: ubuntu-latest
12
-
13
- steps:
14
- - name: Check out code
15
- uses: actions/checkout@v2
16
-
17
- - name: Restore npm cache
18
- uses: actions/cache@v2
19
- with:
20
- path: ~/.npm
21
- key: ${{ runner.os }}-node-${{ hashFiles('js/package-lock.json') }}
22
- restore-keys: |
23
- ${{ runner.os }}-node-
24
-
25
- # Our action will install npm, cd into `./js`, run `npm run build` and
26
- # `npm run build-typings`, then commit and upload any changes
27
- - name: Build production JS
28
- uses: flarum/action-build@2
29
- with:
30
- github_token: ${{ secrets.GITHUB_TOKEN }}
31
- build_script: build
32
- package_manager: yarn
@@ -1,32 +0,0 @@
1
- name: Lint
2
-
3
- on:
4
- workflow_dispatch:
5
- push:
6
- paths:
7
- - 'js/src/**'
8
- pull_request:
9
- paths:
10
- - 'js/src/**'
11
-
12
- jobs:
13
- prettier:
14
- name: JS / Prettier
15
- runs-on: ubuntu-latest
16
-
17
- steps:
18
- - name: Check out code
19
- uses: actions/checkout@v2
20
-
21
- - name: Set up Node
22
- uses: actions/setup-node@v2
23
- with:
24
- node-version: "14"
25
-
26
- - name: Install JS dependencies
27
- run: npm i
28
- working-directory: ./js
29
-
30
- - name: Check JS formatting
31
- run: npm run format-check
32
- working-directory: ./js
@@ -1,78 +0,0 @@
1
- name: Tests
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ubuntu-latest
8
-
9
- strategy:
10
- matrix:
11
- php: [7.3, 7.4, '8.0']
12
- service: ['mysql:5.7', mariadb]
13
- prefix: ['', flarum_]
14
-
15
- include:
16
- - service: 'mysql:5.7'
17
- db: MySQL
18
- - service: mariadb
19
- db: MariaDB
20
- - prefix: flarum_
21
- prefixStr: (prefix)
22
-
23
- exclude:
24
- - php: 7.3
25
- service: 'mysql:5.7'
26
- prefix: flarum_
27
- - php: 7.3
28
- service: mariadb
29
- prefix: flarum_
30
- - php: 8.0
31
- service: 'mysql:5.7'
32
- prefix: flarum_
33
- - php: 8.0
34
- service: mariadb
35
- prefix: flarum_
36
-
37
- services:
38
- mysql:
39
- image: ${{ matrix.service }}
40
- ports:
41
- - 13306:3306
42
-
43
- name: 'PHP ${{ matrix.php }} / ${{ matrix.db }} ${{ matrix.prefixStr }}'
44
-
45
- steps:
46
- - uses: actions/checkout@master
47
-
48
- - name: Setup PHP
49
- uses: shivammathur/setup-php@v2
50
- with:
51
- php-version: ${{ matrix.php }}
52
- coverage: xdebug
53
- extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
54
- tools: phpunit, composer:v2
55
-
56
- # The authentication alter is necessary because newer mysql versions use the `caching_sha2_password` driver,
57
- # which isn't supported prior to PHP7.4
58
- # When we drop support for PHP7.3, we should remove this from the setup.
59
- - name: Create MySQL Database
60
- run: |
61
- sudo systemctl start mysql
62
- mysql -uroot -proot -e 'CREATE DATABASE flarum_test;' --port 13306
63
- mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" --port 13306
64
-
65
- - name: Install Composer dependencies
66
- run: composer install
67
-
68
- - name: Setup Composer tests
69
- run: composer test:setup
70
- env:
71
- DB_PORT: 13306
72
- DB_PASSWORD: root
73
- DB_PREFIX: ${{ matrix.prefix }}
74
-
75
- - name: Run Composer tests
76
- run: composer test
77
- env:
78
- COMPOSER_PROCESS_TIMEOUT: 600