@flarum/cli 1.0.0 → 2.0.0-beta.4
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.
- package/README.md +2 -2
- package/bin/run +5 -3
- package/boilerplate/skeleton/extension/.gitattributes +16 -3
- package/boilerplate/skeleton/extension/.github/workflows/backend.yml +15 -0
- package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +20 -0
- package/boilerplate/skeleton/extension/.styleci.yml +14 -0
- package/boilerplate/skeleton/extension/LICENSE.md +1 -0
- package/boilerplate/skeleton/extension/README.md +7 -7
- package/boilerplate/skeleton/extension/composer.json +11 -9
- package/boilerplate/skeleton/extension/extend.php +10 -10
- package/boilerplate/skeleton/extension/gitignore +13 -0
- package/boilerplate/skeleton/extension/js/admin.js +2 -1
- package/boilerplate/skeleton/extension/js/forum.js +2 -1
- package/boilerplate/skeleton/extension/js/package.json +13 -9
- package/boilerplate/skeleton/extension/js/src/admin/index.js +4 -2
- package/boilerplate/skeleton/extension/js/src/common/index.js +5 -0
- package/boilerplate/skeleton/extension/js/src/forum/index.js +4 -2
- package/boilerplate/skeleton/extension/js/tsconfig.json +6 -1
- package/boilerplate/skeleton/extension/locale/en.yml +1 -1
- package/boilerplate/stubs/migration.php +1 -1
- package/lib/base-command.d.ts +27 -6
- package/lib/base-command.js +131 -41
- package/lib/boilersmith/exposed-param-manager.d.ts +8 -0
- package/lib/boilersmith/exposed-param-manager.js +31 -0
- package/lib/boilersmith/io.d.ts +50 -0
- package/lib/boilersmith/io.js +72 -0
- package/lib/boilersmith/paths.d.ts +22 -0
- package/lib/boilersmith/paths.js +29 -0
- package/lib/boilersmith/scaffolding/audit-step-factory.d.ts +5 -0
- package/lib/boilersmith/scaffolding/audit-step-factory.js +54 -0
- package/lib/boilersmith/scaffolding/infra-step-factory.d.ts +5 -0
- package/lib/boilersmith/scaffolding/infra-step-factory.js +34 -0
- package/lib/boilersmith/scaffolding/init-step-factory.d.ts +5 -0
- package/lib/boilersmith/scaffolding/init-step-factory.js +34 -0
- package/lib/boilersmith/scaffolding/module.d.ts +73 -0
- package/lib/boilersmith/scaffolding/module.js +111 -0
- package/lib/boilersmith/scaffolding/scaffolder.d.ts +32 -0
- package/lib/boilersmith/scaffolding/scaffolder.js +203 -0
- package/lib/boilersmith/scaffolding/template-param.d.ts +23 -0
- package/lib/boilersmith/scaffolding/template-param.js +46 -0
- package/lib/boilersmith/step-manager.d.ts +85 -0
- package/lib/boilersmith/step-manager.js +234 -0
- package/lib/boilersmith/steps/stub-base.d.ts +53 -0
- package/lib/boilersmith/steps/stub-base.js +54 -0
- package/lib/{utils → boilersmith/utils}/clone-and-fill.d.ts +0 -0
- package/lib/{utils → boilersmith/utils}/clone-and-fill.js +2 -2
- package/lib/boilersmith/utils/cond-format.d.ts +1 -0
- package/lib/boilersmith/utils/cond-format.js +8 -0
- package/lib/boilersmith/utils/json-leaf-paths.d.ts +7 -0
- package/lib/boilersmith/utils/json-leaf-paths.js +17 -0
- package/lib/boilersmith/utils/read-tpl.d.ts +2 -0
- package/lib/boilersmith/utils/read-tpl.js +10 -0
- package/lib/boilersmith/utils/rename-keys.d.ts +1 -0
- package/lib/boilersmith/utils/rename-keys.js +7 -0
- package/lib/commands/audit/infra.d.ts +16 -0
- package/lib/commands/audit/infra.js +27 -0
- package/lib/commands/infra.d.ts +20 -0
- package/lib/commands/infra.js +55 -0
- package/lib/commands/init.d.ts +4 -3
- package/lib/commands/init.js +8 -6
- package/lib/commands/make/backend/api-controller.d.ts +4 -3
- package/lib/commands/make/backend/api-controller.js +3 -2
- package/lib/commands/make/backend/api-serializer-attributes.d.ts +4 -3
- package/lib/commands/make/backend/api-serializer-attributes.js +1 -1
- package/lib/commands/make/backend/api-serializer.d.ts +4 -3
- package/lib/commands/make/backend/api-serializer.js +3 -2
- package/lib/commands/make/backend/command.d.ts +4 -3
- package/lib/commands/make/backend/command.js +3 -2
- package/lib/commands/make/backend/event-listener.d.ts +4 -3
- package/lib/commands/make/backend/event-listener.js +3 -2
- package/lib/commands/make/backend/handler.d.ts +4 -3
- package/lib/commands/make/backend/handler.js +4 -3
- package/lib/commands/make/backend/integration-test.d.ts +4 -3
- package/lib/commands/make/backend/integration-test.js +3 -2
- package/lib/commands/make/backend/job.d.ts +4 -3
- package/lib/commands/make/backend/job.js +3 -2
- package/lib/commands/make/backend/migration.d.ts +4 -3
- package/lib/commands/make/backend/migration.js +3 -2
- package/lib/commands/make/backend/model.d.ts +4 -3
- package/lib/commands/make/backend/model.js +22 -21
- package/lib/commands/make/backend/policy.d.ts +4 -3
- package/lib/commands/make/backend/policy.js +3 -2
- package/lib/commands/make/backend/repository.d.ts +4 -3
- package/lib/commands/make/backend/repository.js +3 -2
- package/lib/commands/make/backend/route.d.ts +4 -3
- package/lib/commands/make/backend/route.js +1 -1
- package/lib/commands/make/backend/service-provider.d.ts +4 -3
- package/lib/commands/make/backend/service-provider.js +3 -2
- package/lib/commands/make/backend/validator.d.ts +4 -3
- package/lib/commands/make/backend/validator.js +3 -2
- package/lib/commands/make/frontend/component.d.ts +4 -3
- package/lib/commands/make/frontend/component.js +3 -2
- package/lib/commands/make/frontend/modal.d.ts +4 -3
- package/lib/commands/make/frontend/modal.js +3 -2
- package/lib/commands/make/frontend/model.d.ts +4 -3
- package/lib/commands/make/frontend/model.js +3 -2
- package/lib/commands/update/js-imports.d.ts +4 -3
- package/lib/commands/update/js-imports.js +1 -1
- package/lib/help.d.ts +5 -6
- package/lib/help.js +5 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -2
- package/lib/providers/index.d.ts +5 -0
- package/lib/providers/index.js +2 -0
- package/lib/{provider → providers}/php-provider.d.ts +0 -0
- package/lib/{provider → providers}/php-provider.js +2 -2
- package/lib/steps/extenders/api-serializer.js +2 -3
- package/lib/steps/extenders/base.d.ts +10 -10
- package/lib/steps/extenders/base.js +11 -11
- package/lib/steps/extenders/console-command.js +2 -3
- package/lib/steps/extenders/event.js +2 -3
- package/lib/steps/extenders/policy.js +2 -3
- package/lib/steps/extenders/route.js +2 -3
- package/lib/steps/extenders/service-provider.js +2 -3
- package/lib/steps/gen-ext-scaffolder.d.ts +6 -0
- package/lib/steps/gen-ext-scaffolder.js +510 -0
- package/lib/steps/js/base.d.ts +9 -9
- package/lib/steps/js/base.js +13 -12
- package/lib/steps/js/model.d.ts +5 -5
- package/lib/steps/js/model.js +8 -13
- package/lib/steps/misc/composer.d.ts +5 -6
- package/lib/steps/misc/composer.js +3 -3
- package/lib/steps/misc/git.d.ts +11 -0
- package/lib/steps/misc/git.js +20 -0
- package/lib/steps/misc/yarn.d.ts +5 -6
- package/lib/steps/misc/yarn.js +3 -3
- package/lib/steps/stubs/backend/api-controller.d.ts +1 -8
- package/lib/steps/stubs/backend/api-controller.js +2 -3
- package/lib/steps/stubs/backend/api-serializer.d.ts +4 -9
- package/lib/steps/stubs/backend/api-serializer.js +4 -4
- package/lib/steps/stubs/backend/command.d.ts +0 -5
- package/lib/steps/stubs/backend/command.js +1 -1
- package/lib/steps/stubs/backend/event-listener.d.ts +0 -5
- package/lib/steps/stubs/backend/event-listener.js +1 -1
- package/lib/steps/stubs/backend/handler-command.js +1 -1
- package/lib/steps/stubs/backend/handler.js +1 -1
- package/lib/steps/stubs/backend/migration.d.ts +4 -5
- package/lib/steps/stubs/backend/migration.js +8 -8
- package/lib/steps/stubs/backend/model.d.ts +4 -4
- package/lib/steps/stubs/backend/model.js +4 -4
- package/lib/steps/stubs/backend/policy.d.ts +0 -5
- package/lib/steps/stubs/backend/policy.js +1 -1
- package/lib/steps/stubs/backend/repository.d.ts +0 -5
- package/lib/steps/stubs/backend/repository.js +1 -1
- package/lib/steps/stubs/flarum-base.d.ts +9 -0
- package/lib/steps/stubs/flarum-base.js +10 -0
- package/lib/steps/stubs/frontend/component.js +0 -1
- package/lib/steps/stubs/frontend/modal.js +0 -1
- package/lib/steps/stubs/frontend/model.d.ts +4 -4
- package/lib/steps/stubs/frontend/model.js +3 -3
- package/lib/steps/stubs/js-base.d.ts +6 -7
- package/lib/steps/stubs/js-base.js +11 -16
- package/lib/steps/stubs/php-base.d.ts +7 -8
- package/lib/steps/stubs/php-base.js +12 -20
- package/lib/steps/update/js-imports.d.ts +5 -6
- package/lib/steps/update/js-imports.js +16 -19
- package/lib/utils/composer.d.ts +64 -0
- package/lib/utils/composer.js +8 -0
- package/lib/utils/migration.js +3 -3
- package/lib/utils/model-name.js +6 -6
- package/lib/utils/validation.d.ts +10 -7
- package/lib/utils/validation.js +9 -6
- package/oclif.manifest.json +1 -1
- package/package.json +55 -36
- package/php-subsystem/src/NodeVisitors/AddExtender.php +2 -1
- package/boilerplate/skeleton/extension/.github/workflows/build.yml +0 -32
- package/boilerplate/skeleton/extension/.github/workflows/lint.yml +0 -32
- package/boilerplate/skeleton/extension/.github/workflows/test.yml +0 -78
- package/lib/commands/infra/backend-testing.d.ts +0 -14
- package/lib/commands/infra/backend-testing.js +0 -26
- package/lib/provider/param-provider.d.ts +0 -15
- package/lib/provider/param-provider.js +0 -39
- package/lib/provider/path-provider.d.ts +0 -19
- package/lib/provider/path-provider.js +0 -24
- package/lib/steps/infra/backend-testing.d.ts +0 -8
- package/lib/steps/infra/backend-testing.js +0 -22
- package/lib/steps/infra/base.d.ts +0 -20
- package/lib/steps/infra/base.js +0 -36
- package/lib/steps/init/extension-skeleton.d.ts +0 -12
- package/lib/steps/init/extension-skeleton.js +0 -142
- package/lib/steps/step-manager.d.ts +0 -71
- package/lib/steps/step-manager.js +0 -173
- package/lib/steps/stubs/base.d.ts +0 -49
- package/lib/steps/stubs/base.js +0 -58
- package/lib/utils/extension-metadata.d.ts +0 -2
- package/lib/utils/extension-metadata.js +0 -21
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Store } from 'mem-fs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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,
|
|
8
|
+
run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise<Store>;
|
|
10
9
|
exposes: never[];
|
|
11
|
-
getExposed(
|
|
10
|
+
getExposed(_paths: Paths, _paramProvider: IO): Record<string, unknown>;
|
|
12
11
|
}
|
|
@@ -1,53 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UpdateJSImports = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const globby_1 = (0, tslib_1.__importDefault)(require("globby"));
|
|
5
6
|
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
6
7
|
const CORE_JS_NAMESPACES = ['admin', 'common', 'forum'];
|
|
7
8
|
const CORE_NAMESPACE_REGEX = new RegExp(`^(${CORE_JS_NAMESPACES.join('|')})/`);
|
|
8
|
-
const IMPORT_REGEX = /(?<key>import|export)\s+(?:(?<alias>[\w
|
|
9
|
+
const IMPORT_REGEX = /(?<key>import|export)\s+(?:(?<alias>[\s\w*,{}]+)\s+from)?\s*(["'])?(?<ref>[\s\w./@\\-]+)\3?\s*;?/gm;
|
|
9
10
|
class UpdateJSImports {
|
|
10
11
|
constructor() {
|
|
11
12
|
this.type = 'Use full flarum/namespace in JS imports';
|
|
12
13
|
this.composable = false;
|
|
13
14
|
this.exposes = [];
|
|
14
15
|
}
|
|
15
|
-
async run(fs,
|
|
16
|
-
const fsEditor = mem_fs_editor_1.create(fs);
|
|
16
|
+
async run(fs, paths, _paramProvider, _providers) {
|
|
17
|
+
const fsEditor = (0, mem_fs_editor_1.create)(fs);
|
|
17
18
|
const importMap = {};
|
|
18
|
-
const jsSrcDir =
|
|
19
|
+
const jsSrcDir = paths.package('vendor/flarum/core/js/src');
|
|
19
20
|
const vendorRegex = new RegExp(`${jsSrcDir}/.*(js|jsx|ts|tsx)`);
|
|
20
21
|
const fsVendorFilePaths = fs.all().map(file => file.path).filter(path => path && vendorRegex.test(path));
|
|
21
|
-
const persistedVendorFilePaths =
|
|
22
|
-
[...fsVendorFilePaths, ...persistedVendorFilePaths]
|
|
23
|
-
.forEach(currPath => {
|
|
22
|
+
const persistedVendorFilePaths = globby_1.default.sync(`${jsSrcDir}/**/*.{js,jsx,ts,tsx}`);
|
|
23
|
+
for (const currPath of [...fsVendorFilePaths, ...persistedVendorFilePaths]) {
|
|
24
24
|
const withNamespace = currPath.slice(jsSrcDir.length + 1).replace(/\.(js|jsx|ts|tsx)$/, '');
|
|
25
25
|
const noNamespace = withNamespace.replace(CORE_NAMESPACE_REGEX, '');
|
|
26
26
|
importMap[`flarum/${noNamespace}`] = `flarum/${withNamespace}`;
|
|
27
|
-
}
|
|
28
|
-
const srcRegex = new RegExp(`${
|
|
27
|
+
}
|
|
28
|
+
const srcRegex = new RegExp(`${paths.package('js/src')}/.*(js|jsx|ts|tsx)`);
|
|
29
29
|
const fsSrcFilePaths = fs.all().map(file => file.path).filter(path => path && srcRegex.test(path));
|
|
30
|
-
const persistedSrcFilePaths =
|
|
31
|
-
[...fsSrcFilePaths, ...persistedSrcFilePaths]
|
|
32
|
-
.forEach(match => {
|
|
30
|
+
const persistedSrcFilePaths = globby_1.default.sync(paths.package('js/src/**/*.{js,jsx,ts,tsx}'));
|
|
31
|
+
for (const match of [...fsSrcFilePaths, ...persistedSrcFilePaths]) {
|
|
33
32
|
let fileCounted = false;
|
|
34
33
|
const currContents = fsEditor.read(match);
|
|
35
34
|
const newContents = currContents.replace(IMPORT_REGEX, (match, ...args) => {
|
|
36
35
|
const currImport = args[3];
|
|
37
36
|
const currImportNoAt = currImport.replace(/^@/, '');
|
|
38
37
|
const newImport = importMap[currImportNoAt] || currImport;
|
|
39
|
-
if (newImport !== currImport) {
|
|
40
|
-
|
|
41
|
-
fileCounted = true;
|
|
42
|
-
}
|
|
38
|
+
if (newImport !== currImport && !fileCounted) {
|
|
39
|
+
fileCounted = true;
|
|
43
40
|
}
|
|
44
41
|
return match.replace(currImport, newImport);
|
|
45
42
|
});
|
|
46
43
|
fsEditor.write(match, newContents);
|
|
47
|
-
}
|
|
44
|
+
}
|
|
48
45
|
return fs;
|
|
49
46
|
}
|
|
50
|
-
getExposed(
|
|
47
|
+
getExposed(_paths, _paramProvider) {
|
|
51
48
|
return {};
|
|
52
49
|
}
|
|
53
50
|
}
|
|
@@ -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;
|
package/lib/utils/migration.js
CHANGED
|
@@ -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;
|
package/lib/utils/model-name.js
CHANGED
|
@@ -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):
|
|
3
|
-
static
|
|
4
|
-
static
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
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 {};
|
package/lib/utils/validation.js
CHANGED
|
@@ -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 /^([
|
|
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 /^([
|
|
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
|
|
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
|
|
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 /^[
|
|
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 /^[
|
|
27
|
+
return /^[\w-]+$/.test(s.trim()) || 'Field is required; alphanumerical characters, dashes, and underscores only!';
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
exports.Validator = Validator;
|
package/oclif.manifest.json
CHANGED
|
@@ -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.4","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": "
|
|
4
|
+
"version": "2.0.0-beta.4",
|
|
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.0.0",
|
|
13
|
+
"@babel/preset-env": "^7.14.2",
|
|
12
14
|
"@oclif/dev-cli": "^1.26.0",
|
|
13
15
|
"@oclif/test": "^1.2.8",
|
|
14
16
|
"@types/chai": "^4.2.20",
|
|
15
|
-
"@types/
|
|
17
|
+
"@types/ejs": "^3.1.0",
|
|
18
|
+
"@types/jest": "^27.0.3",
|
|
16
19
|
"@types/mem-fs-editor": "^7.0.0",
|
|
17
|
-
"@types/node": "^
|
|
20
|
+
"@types/node": "^16.11.7",
|
|
21
|
+
"@types/pick-deep": "^1.0.0",
|
|
18
22
|
"@types/pluralize": "0.0.29",
|
|
19
23
|
"@types/prompts": "^2.0.14",
|
|
20
24
|
"@types/string": "0.0.31",
|
|
21
25
|
"@types/yosay": "^0.0.29",
|
|
22
|
-
"
|
|
26
|
+
"@typescript-eslint/parser": "^5.8.1",
|
|
27
|
+
"babel-jest": "^27.4.5",
|
|
28
|
+
"babel-plugin-module-resolver": "^4.1.0",
|
|
23
29
|
"chai": "^4.3.3",
|
|
24
|
-
"eslint": "^
|
|
25
|
-
"eslint-config-oclif": "^
|
|
26
|
-
"eslint-config-oclif-typescript": "
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
30
|
+
"eslint": "^7.32.0",
|
|
31
|
+
"eslint-config-oclif": "^4.0.0",
|
|
32
|
+
"eslint-config-oclif-typescript": "1.0.2",
|
|
33
|
+
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
34
|
+
"eslint-import-resolver-typescript": "^2.5.0",
|
|
35
|
+
"eslint-plugin-import": "^2.25.3",
|
|
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
|
-
"
|
|
40
|
+
"tsconfig-paths": "^3.12.0",
|
|
41
|
+
"typescript": "4.4.4"
|
|
33
42
|
},
|
|
34
43
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
44
|
+
"node": ">=12.0.0"
|
|
36
45
|
},
|
|
37
46
|
"files": [
|
|
38
47
|
"/bin",
|
|
@@ -48,56 +57,66 @@
|
|
|
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
|
-
"
|
|
57
|
-
"@oclif/plugin-help",
|
|
58
|
-
"@tiagonapoli/oclif-plugin-spaced-commands"
|
|
59
|
-
],
|
|
71
|
+
"topicSeparator": " ",
|
|
60
72
|
"topics": {
|
|
61
|
-
"make
|
|
73
|
+
"make backend": {
|
|
62
74
|
"description": "Add backend boilerplate code to an existing Flarum extension."
|
|
63
75
|
},
|
|
64
|
-
"make
|
|
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
|
-
"
|
|
71
|
-
"description": "
|
|
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
|
|
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
|
-
"@
|
|
87
|
-
"@oclif/
|
|
88
|
-
"@oclif/
|
|
89
|
-
"@oclif/plugin-
|
|
90
|
-
"@oclif/plugin-
|
|
91
|
-
"@tiagonapoli/oclif-plugin-spaced-commands": "^0.0.6",
|
|
92
|
-
"@zodash/pick": "^1.1.6",
|
|
104
|
+
"@oclif/core": "^1.0.11",
|
|
105
|
+
"@oclif/errors": "^1.3.5",
|
|
106
|
+
"@oclif/plugin-help": "^5",
|
|
107
|
+
"@oclif/plugin-plugins": "^2.0.11",
|
|
108
|
+
"@oclif/plugin-version": "^1",
|
|
93
109
|
"chalk": "^2.4.2",
|
|
94
|
-
"
|
|
95
|
-
"
|
|
110
|
+
"cli-ux": "^6.0.6",
|
|
111
|
+
"ejs": "^3.1.6",
|
|
112
|
+
"globby": "^10.0.2",
|
|
96
113
|
"mem-fs": "^2.2.1",
|
|
97
114
|
"mem-fs-editor": "^8.0.0",
|
|
98
|
-
"
|
|
115
|
+
"module-alias": "^2.2.2",
|
|
116
|
+
"pick-deep": "^1.0.0",
|
|
99
117
|
"pluralize": "^8.0.0",
|
|
100
118
|
"prompts": "^2.4.0",
|
|
119
|
+
"simple-git": "^2.48.0",
|
|
101
120
|
"spdx-license-list": "^6.4.0",
|
|
102
121
|
"string": "^3.3.3",
|
|
103
122
|
"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
|
-
|
|
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
|