Skip to content

Commit

Permalink
chore: yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Mar 30, 2024
1 parent e77f416 commit 8d747d9
Show file tree
Hide file tree
Showing 52 changed files with 439 additions and 336 deletions.
2 changes: 1 addition & 1 deletion src/boilersmith/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class PromptsIO implements IO {
);
}

pushCache(params: Record<string, unknown>) {
pushCache(params: Record<string, unknown>): void {
for (const [key, value] of Object.entries(params)) {
this.cache.set(key, value);
}
Expand Down
37 changes: 17 additions & 20 deletions src/boilersmith/step-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,26 +277,23 @@ export class StepManager<Providers extends DefaultProviders> {
}
});

const initial: Record<string, unknown> = storedStep.dependencies.reduce(
(initial, dep) => {
const sourceStep = this.namedSteps.get(dep.sourceStep);

let depValue;
depValue =
dep.exposedName === '__succeeded'
? this.exposedParams.stepRan(dep.sourceStep, packagePath)
: this.exposedParams.get(dep.sourceStep, dep.exposedName, sourceStep?.mapPaths.length ? packagePath : undefined);

if (dep.modifier) {
depValue = dep.modifier(depValue);
}
const initial: Record<string, unknown> = storedStep.dependencies.reduce((initial, dep) => {
const sourceStep = this.namedSteps.get(dep.sourceStep);

initial[dep.consumedName || dep.exposedName] = depValue;
let depValue;
depValue =
dep.exposedName === '__succeeded'
? this.exposedParams.stepRan(dep.sourceStep, packagePath)
: this.exposedParams.get(dep.sourceStep, dep.exposedName, sourceStep?.mapPaths.length ? packagePath : undefined);

if (dep.modifier) {
depValue = dep.modifier(depValue);
}

return initial;
},
cached
);
initial[dep.consumedName || dep.exposedName] = depValue;

return initial;
}, cached);

const cloned = io.newInstance({ ...initial, ...storedStep.predefinedParams }, io.getOutput());

Expand Down Expand Up @@ -359,7 +356,7 @@ export class AtomicStepManager<Providers = DefaultProviders> extends StepManager
async run(paths: Paths, io: IO, providers: Providers, dry = false, args: Record<string, unknown> = {}): Promise<StepsResult> {
let fs = createMemFs();

const checkAndRun = async (step: StoredStep<Providers>, packagePath?: string, firstStep = false) => {
const checkAndRun = async (step: StoredStep<Providers>, packagePath?: string) => {
const shouldRun: boolean = await this.stepShouldRun(step, io, packagePath);
if (!shouldRun) return;

Expand All @@ -377,7 +374,7 @@ export class AtomicStepManager<Providers = DefaultProviders> extends StepManager
await checkAndRun(storedStep, path);
}
} else {
await checkAndRun(storedStep, undefined);
await checkAndRun(storedStep);
}
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/make/backend/api-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FlarumProviders } from '../../../providers';
import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
import BaseCommand from '../../../base-command';
import { GenerateApiResourceStub } from '../../../steps/stubs/backend/api-resource';
import {GenerateApiResourceExtender} from "../../../steps/extenders/api-resource";
import { GenerateApiResourceExtender } from '../../../steps/extenders/api-resource';

export default class ApiResource extends BaseCommand {
static description = 'Generate an API resource class';
Expand Down
5 changes: 1 addition & 4 deletions src/commands/make/backend/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export default class Command extends BaseCommand {

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
Expand Down
33 changes: 17 additions & 16 deletions src/commands/make/backend/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@ export default class Controller extends BaseCommand {

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
stepManager
.namedStep('controller', new GenerateControllerStub(this.STUB_PATH, genExtScaffolder()))
.step(new GenerateRoutesExtender(), { optional: true, confirmationMessage: 'Generate corresponding extender?', default: ! this.args.className }, [
{
sourceStep: 'controller',
exposedName: 'class',
consumedName: 'routeHandler',
},
{
sourceStep: 'controller',
exposedName: 'frontend',
consumedName: 'frontend',
},
]);
.step(
new GenerateRoutesExtender(),
{ optional: true, confirmationMessage: 'Generate corresponding extender?', default: !this.args.className },
[
{
sourceStep: 'controller',
exposedName: 'class',
consumedName: 'routeHandler',
},
{
sourceStep: 'controller',
exposedName: 'frontend',
consumedName: 'frontend',
},
]
);
});
}
}
23 changes: 12 additions & 11 deletions src/commands/make/backend/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ export default class Filter extends BaseCommand {

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
stepManager
.namedStep('filter', new GenerateFilterStub(this.STUB_PATH, genExtScaffolder()))
.step(new GenerateSearchFilterExtender(), { optional: true, confirmationMessage: 'Generate corresponding extender?', default: ! this.args.className }, [
{
sourceStep: 'filter',
exposedName: 'class',
consumedName: 'filterClass',
},
]);
.step(
new GenerateSearchFilterExtender(),
{ optional: true, confirmationMessage: 'Generate corresponding extender?', default: !this.args.className },
[
{
sourceStep: 'filter',
exposedName: 'class',
consumedName: 'filterClass',
},
]
);
});
}
}
5 changes: 1 addition & 4 deletions src/commands/make/backend/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export default class Handler extends BaseCommand {

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
Expand Down
5 changes: 1 addition & 4 deletions src/commands/make/backend/integration-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export default class IntegrationTest extends BaseCommand {

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
Expand Down
5 changes: 1 addition & 4 deletions src/commands/make/backend/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export default class Job extends BaseCommand {

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.step(new GenerateJobStub(this.STUB_PATH, genExtScaffolder()));
Expand Down
19 changes: 11 additions & 8 deletions src/commands/make/backend/mail-driver.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import {PredefinedParameters, ShouldRunConfig, StepDependency, StepManager} from 'boilersmith/step-manager';
import { PredefinedParameters, ShouldRunConfig, StepDependency, StepManager } from 'boilersmith/step-manager';
import BaseCommand from '../../../base-command';
import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
import { FlarumProviders } from '../../../providers';
import {GenerateMailDriverStub} from "../../../steps/stubs/backend/mail-driver";
import {GenerateMailDriverExtender} from "../../../steps/extenders/mail-driver";
import { GenerateMailDriverStub } from '../../../steps/stubs/backend/mail-driver';
import { GenerateMailDriverExtender } from '../../../steps/extenders/mail-driver';

export default class MailDriver extends BaseCommand {
static description = 'Generate a mail driver class';

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
MailDriver.steps(stepManager, this.STUB_PATH);
});
}

public static steps(stepManager: StepManager<FlarumProviders>, STUB_PATH: string, shouldRun?: ShouldRunConfig, dependencies?: StepDependency[], predefinedDependencies?: PredefinedParameters): StepManager<FlarumProviders> {
public static steps(
stepManager: StepManager<FlarumProviders>,
STUB_PATH: string,
shouldRun?: ShouldRunConfig,
dependencies?: StepDependency[],
predefinedDependencies?: PredefinedParameters
): StepManager<FlarumProviders> {
return stepManager
.namedStep('driver', new GenerateMailDriverStub(STUB_PATH, genExtScaffolder()), shouldRun, dependencies, predefinedDependencies)
.step(new GenerateMailDriverExtender(), { optional: true, confirmationMessage: 'Generate corresponding extender?', default: true }, [
Expand Down
2 changes: 1 addition & 1 deletion src/commands/make/backend/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class Migration extends BaseCommand {
description: 'The name of the migration',
required: false,
},
...BaseCommand.args
...BaseCommand.args,
];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
Expand Down
20 changes: 11 additions & 9 deletions src/commands/make/backend/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-warning-comments */
import {PredefinedParameters, ShouldRunConfig, StepDependency, StepManager} from 'boilersmith/step-manager';
import { PredefinedParameters, ShouldRunConfig, StepDependency, StepManager } from 'boilersmith/step-manager';
import BaseCommand from '../../../base-command';
import { GenerateModelStub } from '../../../steps/stubs/backend/model';
import { GenerateMigrationStub } from '../../../steps/stubs/backend/migration';
Expand All @@ -8,26 +7,29 @@ import { GeneratePolicyStub } from '../../../steps/stubs/backend/policy';
import { GeneratePolicyExtender } from '../../../steps/extenders/policy';
import { FlarumProviders } from '../../../providers';
import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
import {GenerateApiResourceExtender} from "../../../steps/extenders/api-resource";
import * as Interfaces from "@oclif/core/lib/interfaces";
import { GenerateApiResourceExtender } from '../../../steps/extenders/api-resource';
import * as Interfaces from '@oclif/core/lib/interfaces';

export default class BackendModel extends BaseCommand {
static description = 'Generate a model class';

static flags = { ...BaseCommand.flags };

static args: Interfaces.ArgInput = [
BaseCommand.classNameArg,
...BaseCommand.args,
];
static args: Interfaces.ArgInput = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
BackendModel.steps(stepManager, this.STUB_PATH);
});
}

public static steps(stepManager: StepManager<FlarumProviders>, STUB_PATH: string, shouldRun?: ShouldRunConfig, dependencies?: StepDependency[], predefinedDependencies?: PredefinedParameters): StepManager<FlarumProviders> {
public static steps(
stepManager: StepManager<FlarumProviders>,
STUB_PATH: string,
shouldRun?: ShouldRunConfig,
dependencies?: StepDependency[],
predefinedDependencies?: PredefinedParameters
): StepManager<FlarumProviders> {
return stepManager
.namedStep('backendModel', new GenerateModelStub(STUB_PATH, genExtScaffolder()), shouldRun, dependencies, predefinedDependencies)
.step(
Expand Down
15 changes: 9 additions & 6 deletions src/commands/make/backend/notification-blueprint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PredefinedParameters, ShouldRunConfig, StepDependency, StepManager} from 'boilersmith/step-manager';
import { PredefinedParameters, ShouldRunConfig, StepDependency, StepManager } from 'boilersmith/step-manager';
import BaseCommand from '../../../base-command';
import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
import { FlarumProviders } from '../../../providers';
Expand All @@ -10,18 +10,21 @@ export default class NotificationBlueprint extends BaseCommand {

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
NotificationBlueprint.steps(stepManager, this.STUB_PATH);
});
}

public static steps(stepManager: StepManager<FlarumProviders>, STUB_PATH: string, shouldRun?: ShouldRunConfig, dependencies?: StepDependency[], predefinedDependencies?: PredefinedParameters): StepManager<FlarumProviders> {
public static steps(
stepManager: StepManager<FlarumProviders>,
STUB_PATH: string,
shouldRun?: ShouldRunConfig,
dependencies?: StepDependency[],
predefinedDependencies?: PredefinedParameters
): StepManager<FlarumProviders> {
return stepManager
.namedStep('blueprint', new GenerateNotificationBlueprintStub(STUB_PATH, genExtScaffolder()), shouldRun, dependencies, predefinedDependencies)
.step(new GenerateNotificationTypeExtender(), { optional: true, confirmationMessage: 'Generate corresponding extender?', default: true }, [
Expand Down
19 changes: 11 additions & 8 deletions src/commands/make/backend/notification-driver.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import {PredefinedParameters, ShouldRunConfig, StepDependency, StepManager} from 'boilersmith/step-manager';
import { PredefinedParameters, ShouldRunConfig, StepDependency, StepManager } from 'boilersmith/step-manager';
import BaseCommand from '../../../base-command';
import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
import { FlarumProviders } from '../../../providers';
import {GenerateNotificationDriverStub} from "../../../steps/stubs/backend/notification-driver";
import {GenerateNotificationDriverExtender} from "../../../steps/extenders/notification-driver";
import { GenerateNotificationDriverStub } from '../../../steps/stubs/backend/notification-driver';
import { GenerateNotificationDriverExtender } from '../../../steps/extenders/notification-driver';

export default class NotificationDriver extends BaseCommand {
static description = 'Generate a notification driver class';

static flags = { ...BaseCommand.flags };

static args = [
BaseCommand.classNameArg,
...BaseCommand.args
];
static args = [BaseCommand.classNameArg, ...BaseCommand.args];

protected steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders> {
return stepManager.atomicGroup((stepManager) => {
NotificationDriver.steps(stepManager, this.STUB_PATH);
});
}

public static steps(stepManager: StepManager<FlarumProviders>, STUB_PATH: string, shouldRun?: ShouldRunConfig, dependencies?: StepDependency[], predefinedDependencies?: PredefinedParameters): StepManager<FlarumProviders> {
public static steps(
stepManager: StepManager<FlarumProviders>,
STUB_PATH: string,
shouldRun?: ShouldRunConfig,
dependencies?: StepDependency[],
predefinedDependencies?: PredefinedParameters
): StepManager<FlarumProviders> {
return stepManager
.namedStep('driver', new GenerateNotificationDriverStub(STUB_PATH, genExtScaffolder()), shouldRun, dependencies, predefinedDependencies)
.step(new GenerateNotificationDriverExtender(), { optional: true, confirmationMessage: 'Generate corresponding extender?', default: true }, [
Expand Down
Loading

0 comments on commit 8d747d9

Please sign in to comment.