Skip to content

Commit

Permalink
feat: add bundle project command to simplify agent-nodejs migration (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-moncel authored Oct 14, 2024
1 parent cf806df commit 47e9328
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/abstract-project-create-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default abstract class AbstractProjectCreateCommand extends AbstractAuthe

protected abstract generateProject(config: Config): Promise<void>;

private async getConfig(): Promise<{
protected async getConfig(): Promise<{
appConfig: AppConfig;
dbConfig: DbConfig;
language: Language | null;
Expand Down
29 changes: 29 additions & 0 deletions src/commands/projects/bundle/nosql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import AbstractProjectCreateCommand from '../../../abstract-project-create-command';
import { optionsToFlags } from '../../../utils/option-parser';
import NosqlCommand from '../create/nosql';

export default class NoSqlBundleCommand extends NosqlCommand {
/** @see https://oclif.io/docs/args */
static override readonly args = AbstractProjectCreateCommand.args;

/** @see https://oclif.io/docs/flags */
static override readonly flags = optionsToFlags(this.options);

static override description = 'Bundle files for Forest Admin project.';

protected override async runAuthenticated(): Promise<void> {
const { appConfig, dbConfig, language } = await this.getConfig();

await this.testDatabaseConnection(dbConfig);

await this.generateProject({
dbConfig,
appConfig,
forestAuthSecret: '<TO BE FILLED WITH FOREST INIT COMMAND RESULT>',
forestEnvSecret: '<TO BE FILLED WITH FOREST INIT COMMAND RESULT>',
language,
});

this.logger.info(`Hooray, ${this.chalk.green('installation success')}!`);
}
}
29 changes: 29 additions & 0 deletions src/commands/projects/bundle/sql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import AbstractProjectCreateCommand from '../../../abstract-project-create-command';
import { optionsToFlags } from '../../../utils/option-parser';
import SqlCommand from '../create/sql';

export default class SqlBundleCommand extends SqlCommand {
/** @see https://oclif.io/docs/args */
static override readonly args = AbstractProjectCreateCommand.args;

/** @see https://oclif.io/docs/flags */
static override readonly flags = optionsToFlags(this.options);

static override description = 'Bundle files for Forest Admin project.';

protected override async runAuthenticated(): Promise<void> {
const { appConfig, dbConfig, language } = await this.getConfig();

await this.testDatabaseConnection(dbConfig);

await this.generateProject({
dbConfig,
appConfig,
forestAuthSecret: '<TO BE FILLED WITH FOREST INIT COMMAND RESULT>',
forestEnvSecret: '<TO BE FILLED WITH FOREST INIT COMMAND RESULT>',
language,
});

this.logger.info(`Hooray, ${this.chalk.green('installation success')}!`);
}
}

0 comments on commit 47e9328

Please sign in to comment.