@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.
- 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/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 +68 -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 +508 -0
- package/lib/steps/js/base.d.ts +9 -9
- package/lib/steps/js/base.js +11 -11
- 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 +13 -17
- 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 +53 -31
- 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,49 +0,0 @@
|
|
|
1
|
-
import { Store } from 'mem-fs';
|
|
2
|
-
import { Editor } from 'mem-fs-editor';
|
|
3
|
-
import { PromptObject } from 'prompts';
|
|
4
|
-
import { ParamProvider } from '../../provider/param-provider';
|
|
5
|
-
import { PathProvider } from '../../provider/path-provider';
|
|
6
|
-
import { PhpProvider } from '../../provider/php-provider';
|
|
7
|
-
import { Step } from '../step-manager';
|
|
8
|
-
interface UserProvidedParam extends Omit<PromptObject, 'type'> {
|
|
9
|
-
type: string;
|
|
10
|
-
}
|
|
11
|
-
export interface StubGenerationSchema {
|
|
12
|
-
/**
|
|
13
|
-
* A period-delimited subdirectory for where the stub should be
|
|
14
|
-
* located relative to the extension PHP src.
|
|
15
|
-
*/
|
|
16
|
-
recommendedSubdir: string;
|
|
17
|
-
forceRecommendedSubdir?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Where should the file be created in relation to the extension root?
|
|
20
|
-
*
|
|
21
|
-
* Defaults to `./src`.
|
|
22
|
-
*/
|
|
23
|
-
root?: string;
|
|
24
|
-
/**
|
|
25
|
-
* The relative path to the stub's source file relative to the
|
|
26
|
-
* `stubs` directory.
|
|
27
|
-
*/
|
|
28
|
-
sourceFile: string;
|
|
29
|
-
params: UserProvidedParam[];
|
|
30
|
-
}
|
|
31
|
-
export declare abstract class BaseStubStep implements Step {
|
|
32
|
-
abstract type: string;
|
|
33
|
-
protected abstract defaultRoot: string;
|
|
34
|
-
protected abstract schema: StubGenerationSchema;
|
|
35
|
-
composable: boolean;
|
|
36
|
-
get exposes(): string[];
|
|
37
|
-
protected additionalExposes: string[];
|
|
38
|
-
get implicitParams(): string[];
|
|
39
|
-
protected additionalImplicitParams: string[];
|
|
40
|
-
protected params: Record<string, unknown>;
|
|
41
|
-
protected subdir: string;
|
|
42
|
-
run(fs: Store, pathProvider: PathProvider, paramProvider: ParamProvider, _phpProvider: PhpProvider): Promise<Store>;
|
|
43
|
-
getExposed(_pathProvider: PathProvider, _paramProvider: ParamProvider): Record<string, unknown>;
|
|
44
|
-
protected precompileParams(composerJsonContents: any, _fsEditor: Editor, _pathProvider: PathProvider, _paramProvider: ParamProvider): Promise<Record<string, unknown>>;
|
|
45
|
-
protected compileParams(fsEditor: Editor, pathProvider: PathProvider, paramProvider: ParamProvider): Promise<Record<string, unknown>>;
|
|
46
|
-
protected abstract getFileName(_fs: Store, _pathProvider: PathProvider, paramProvider: ParamProvider): Promise<string>;
|
|
47
|
-
protected composerJsonContents(fsEditor: Editor, pathProvider: PathProvider): any;
|
|
48
|
-
}
|
|
49
|
-
export {};
|
package/lib/steps/stubs/base.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseStubStep = void 0;
|
|
4
|
-
const pick_1 = require("@zodash/pick");
|
|
5
|
-
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
6
|
-
const extension_metadata_1 = require("../../utils/extension-metadata");
|
|
7
|
-
const clone_and_fill_1 = require("../../utils/clone-and-fill");
|
|
8
|
-
class BaseStubStep {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.composable = true;
|
|
11
|
-
this.additionalExposes = [];
|
|
12
|
-
this.additionalImplicitParams = [];
|
|
13
|
-
this.params = {};
|
|
14
|
-
}
|
|
15
|
-
get exposes() {
|
|
16
|
-
return this.additionalExposes;
|
|
17
|
-
}
|
|
18
|
-
get implicitParams() {
|
|
19
|
-
return [...this.additionalImplicitParams, 'extensionId'];
|
|
20
|
-
}
|
|
21
|
-
async run(fs, pathProvider, paramProvider, _phpProvider) {
|
|
22
|
-
const fsEditor = mem_fs_editor_1.create(fs);
|
|
23
|
-
this.params = await this.compileParams(fsEditor, pathProvider, paramProvider);
|
|
24
|
-
const newFileName = await this.getFileName(fs, pathProvider, paramProvider);
|
|
25
|
-
const newFilePath = pathProvider.ext(this.schema.root || this.defaultRoot, this.subdir, newFileName);
|
|
26
|
-
const stub = clone_and_fill_1.cloneAndFill(this.schema.sourceFile, this.params);
|
|
27
|
-
fsEditor.copyTpl(pathProvider.boilerplate('stubs', stub), newFilePath, this.params);
|
|
28
|
-
return fs;
|
|
29
|
-
}
|
|
30
|
-
getExposed(_pathProvider, _paramProvider) {
|
|
31
|
-
return pick_1.pick(this.params, this.exposes);
|
|
32
|
-
}
|
|
33
|
-
async precompileParams(composerJsonContents, _fsEditor, _pathProvider, _paramProvider) {
|
|
34
|
-
const params = {
|
|
35
|
-
extensionId: composerJsonContents.extensionId,
|
|
36
|
-
};
|
|
37
|
-
return params;
|
|
38
|
-
}
|
|
39
|
-
async compileParams(fsEditor, pathProvider, paramProvider) {
|
|
40
|
-
const composerJsonContents = this.composerJsonContents(fsEditor, pathProvider);
|
|
41
|
-
const params = await this.precompileParams(composerJsonContents, fsEditor, pathProvider, paramProvider);
|
|
42
|
-
const paramDefs = this.schema.params.filter(param => !this.implicitParams.includes(param.name) && !Object.keys(params).includes(param.name));
|
|
43
|
-
for (let i = 0; i < paramDefs.length; i++) {
|
|
44
|
-
// eslint-disable-next-line no-await-in-loop
|
|
45
|
-
params[paramDefs[i].name] = await paramProvider.get(paramDefs[i]);
|
|
46
|
-
}
|
|
47
|
-
this.implicitParams.forEach(implicitParam => {
|
|
48
|
-
if (!params[implicitParam] && paramProvider.has(implicitParam)) {
|
|
49
|
-
params[implicitParam] = paramProvider.cached()[implicitParam];
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return params;
|
|
53
|
-
}
|
|
54
|
-
composerJsonContents(fsEditor, pathProvider) {
|
|
55
|
-
return extension_metadata_1.extensionMetadata(fsEditor.readJSON(pathProvider.ext('composer.json')));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.BaseStubStep = BaseStubStep;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extensionMetadata = exports.extensionId = void 0;
|
|
4
|
-
function extensionId(packageName) {
|
|
5
|
-
return packageName.replace(/(flarum-ext-)|(flarum-)/, '').replace('/', '-');
|
|
6
|
-
}
|
|
7
|
-
exports.extensionId = extensionId;
|
|
8
|
-
function extensionMetadata(extensionComposerJson = {}) {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
10
|
-
const data = {};
|
|
11
|
-
data.packageName = (extensionComposerJson === null || extensionComposerJson === void 0 ? void 0 : extensionComposerJson.name) || '';
|
|
12
|
-
data.packageDescription = (extensionComposerJson === null || extensionComposerJson === void 0 ? void 0 : extensionComposerJson.description) || '';
|
|
13
|
-
data.licenseType = (extensionComposerJson === null || extensionComposerJson === void 0 ? void 0 : extensionComposerJson.license) || '';
|
|
14
|
-
data.authorName = '';
|
|
15
|
-
data.authorEmail = '';
|
|
16
|
-
data.packageNamespace = (Object.keys((_b = (_a = extensionComposerJson === null || extensionComposerJson === void 0 ? void 0 : extensionComposerJson.autoload) === null || _a === void 0 ? void 0 : _a['psr-4']) !== null && _b !== void 0 ? _b : {})[0] || '').slice(0, -1);
|
|
17
|
-
data.extensionName = ((_d = (_c = extensionComposerJson === null || extensionComposerJson === void 0 ? void 0 : extensionComposerJson.extra) === null || _c === void 0 ? void 0 : _c['flarum-extension']) === null || _d === void 0 ? void 0 : _d.title) || '';
|
|
18
|
-
data.extensionId = extensionId(data.packageName);
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
exports.extensionMetadata = extensionMetadata;
|