diff --git a/src/applications/amps.ts b/src/applications/amps.ts index 14fc4ef..12ab60d 100644 --- a/src/applications/amps.ts +++ b/src/applications/amps.ts @@ -56,7 +56,6 @@ export class AMPS { const nodes = AMPS.getNodes('//*[local-name()=\'packaging\']'); return nodes.some(item => item.textContent === 'atlassian-plugin'); } catch (err) { - console.log(err); return false; } } diff --git a/src/applications/bamboo.ts b/src/applications/bamboo.ts index cae8174..123639b 100644 --- a/src/applications/bamboo.ts +++ b/src/applications/bamboo.ts @@ -24,7 +24,7 @@ export class Bamboo extends Base { // ------------------------------------------------------------------------------------------ Protected Methods - protected getService = (): Service => { + protected getService(): Service { const volumes = this.getVolumes(); const environment = this.getEnvironmentVariables(); diff --git a/src/applications/base.ts b/src/applications/base.ts index e279cfc..2377ba6 100644 --- a/src/applications/base.ts +++ b/src/applications/base.ts @@ -1,6 +1,6 @@ import axios from 'axios'; import { spawn } from 'child_process'; -import { downAll, execCompose, ps, upAll } from 'docker-compose/dist/v2.js'; +import { downAll, execCompose, ps, stop, upAll } from 'docker-compose/dist/v2.js'; import EventEmitter from 'events'; import { gracefulExit } from 'exit-hook'; import { existsSync, mkdirSync } from 'fs'; @@ -37,7 +37,10 @@ export abstract class Base extends EventEmitter { // ------------------------------------------------------------------------------------------ Properties protected get baseUrl(): string { - const baseUrl = `http://localhost:${this.options.port}`; + let baseUrl = `http://localhost`; + if (this.options.port) { + baseUrl += `:${this.options.port}`; + } return this.options.contextPath ? `${baseUrl}/${this.options.contextPath}` : baseUrl; } @@ -52,15 +55,32 @@ export abstract class Base extends EventEmitter { } async start() { - await this.stop(); + if (this.options.clean) { + await this.down(); + } await this.build(this.options.version); - await this.database.start(this.name, this.options.version); + await this.database.start(this.options.clean); await this.up(); } - async stop() { - await this.database.stop(); + async stop(): Promise { + await this.database.stop(this.options.prune); + if (this.options.prune) { + await this.down(); + } else { + const configAsString = dump(this.getDockerComposeConfig()); + await stop({ + cwd: cwd(), + configAsString, + log: true + }); + } + this.emit(`${this.name}:stopped`); + } + + async reset() { + await this.database.stop(true); await this.down(); } @@ -140,15 +160,12 @@ export abstract class Base extends EventEmitter { private async down() { const configAsString = dump(this.getDockerComposeConfig()); - await downAll({ cwd: cwd(), configAsString, commandOptions: [ '-v', '--remove-orphans', '--rmi', 'local' ], log: true }); - - this.emit(`${this.name}:stopped`); } private async getServiceState() { @@ -205,10 +222,8 @@ export abstract class Base extends EventEmitter { const docker = spawn( 'docker', [ 'build', '-t', `dcdx/${this.name}:${version}`, '--build-arg', `${this.name.toUpperCase()}_VERSION=${version}`, '.'], - { cwd: checkoutPath } + { cwd: checkoutPath, stdio: 'inherit' } ); - docker.stdout.on('data', (lines: Buffer) => { console.log(lines.toString('utf-8').trim()); }); - docker.stderr.on('data', (lines: Buffer) => { console.log(lines.toString('utf-8').trim()); }); docker.on('exit', (code) => (code === 0) ? resolve() : reject(new Error(`Docker exited with code ${code}`))); }); } diff --git a/src/applications/bitbucket.ts b/src/applications/bitbucket.ts index 80452ae..22ec401 100644 --- a/src/applications/bitbucket.ts +++ b/src/applications/bitbucket.ts @@ -22,7 +22,7 @@ export class Bitbucket extends Base { // ------------------------------------------------------------------------------------------ Protected Methods - protected getService = (): Service => { + protected getService(): Service { const volumes = this.getVolumes(); const environment = this.getEnvironmentVariables(); diff --git a/src/applications/confluence.ts b/src/applications/confluence.ts index 0da16cc..adf6a45 100644 --- a/src/applications/confluence.ts +++ b/src/applications/confluence.ts @@ -22,7 +22,7 @@ export class Confluence extends Base { // ------------------------------------------------------------------------------------------ Protected Methods - protected getService = (): Service => { + protected getService(): Service { const volumes = this.getVolumes(); const environment = this.getEnvironmentVariables(); diff --git a/src/applications/jira.ts b/src/applications/jira.ts index 2b78d5c..c33eada 100644 --- a/src/applications/jira.ts +++ b/src/applications/jira.ts @@ -22,7 +22,7 @@ export class Jira extends Base { // ------------------------------------------------------------------------------------------ Protected Methods - protected getService = (): Service => { + protected getService(): Service { const volumes = this.getVolumes(); const environment = this.getEnvironmentVariables(); diff --git a/src/commands/database-mssql.ts b/src/commands/database-mssql.ts index cf2c24e..1ec6781 100644 --- a/src/commands/database-mssql.ts +++ b/src/commands/database-mssql.ts @@ -12,6 +12,8 @@ import { MSSQL, MSSQLOptions } from '../databases/mssql'; .addOption(new Option('-e, --edition ', 'The edition of Microsoft SQL Server').choices([ 'Developer', 'Express', 'Standard', 'Enterprise', 'EnterpriseCore' ]).default('Developer')) .addOption(new Option('-p, --port ', 'The port on which the database will be accessible').default('1433')) .addOption(new Option('-P, --password ', 'The value passed to MSSQL_SA_PASSWORD environment variable. MS SQL Server password policy applies.').default('DataCenterDX!')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .parse(process.argv) .opts(); @@ -20,6 +22,8 @@ import { MSSQL, MSSQLOptions } from '../databases/mssql'; edition: options.edition, port: Number(options.port), password: options.password, + clean: options.clean, + prune: options.prune, logging: true } as MSSQLOptions); diff --git a/src/commands/database-mysql.ts b/src/commands/database-mysql.ts index 8770127..6c4609e 100644 --- a/src/commands/database-mysql.ts +++ b/src/commands/database-mysql.ts @@ -13,6 +13,8 @@ import { MySQL } from '../databases/mysql'; .addOption(new Option('-p, --port ', 'The port on which the database will be accessible').default('3306')) .addOption(new Option('-U, --username ', 'The value passed to MYSQL_USER environment variable').default('dcdx')) .addOption(new Option('-P, --password ', 'The value passed to MYSQL_PASSWORD environment variable').default('dcdx')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .parse(process.argv) .opts(); @@ -22,6 +24,8 @@ import { MySQL } from '../databases/mysql'; port: Number(options.port), username: options.username, password: options.password, + clean: options.clean, + prune: options.prune, logging: true }); diff --git a/src/commands/database-postgres.ts b/src/commands/database-postgres.ts index 6800961..7e09a6b 100644 --- a/src/commands/database-postgres.ts +++ b/src/commands/database-postgres.ts @@ -13,6 +13,8 @@ import { Postgres } from '../databases/postgres'; .addOption(new Option('-p, --port ', 'The port on which the database will be accessible').default('5432')) .addOption(new Option('-U, --username ', 'The value passed to POSTGRES_USER environment variable').default('dcdx')) .addOption(new Option('-P, --password ', 'The value passed to POSTGRES_PASSWORD environment variable').default('dcdx')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .parse(process.argv) .opts(); @@ -22,6 +24,8 @@ import { Postgres } from '../databases/postgres'; port: Number(options.port), username: options.username, password: options.password, + clean: options.clean, + prune: options.prune, logging: true }) diff --git a/src/commands/reset-bamboo.ts b/src/commands/reset-bamboo.ts new file mode 100644 index 0000000..e70a6cb --- /dev/null +++ b/src/commands/reset-bamboo.ts @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import { Option, program } from 'commander'; +import { gracefulExit } from 'exit-hook'; + +import { AMPS } from '../applications/amps'; +import { Bamboo } from '../applications/bamboo'; + +const version = AMPS.getApplicationVersion() || '9.6.1'; + +(async () => { + const options = program + .showHelpAfterError(true) + .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '9.4.3' ]).default(version)) + .addOption(new Option('-d, --database ', 'The database engine to remove data from').choices([ 'postgresql', 'mysql', 'mssql' ]).default('postgresql')) + .parse(process.argv) + .opts(); + + const instance = new Bamboo({ + version: options.version, + database: options.database + }); + + await instance.reset(); +})(); + +process.on('SIGINT', () => { + console.log(`Received term signal, trying to stop gracefully 💪`); + gracefulExit(); +}); \ No newline at end of file diff --git a/src/commands/reset-bitbucket.ts b/src/commands/reset-bitbucket.ts new file mode 100644 index 0000000..1439075 --- /dev/null +++ b/src/commands/reset-bitbucket.ts @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import { Option, program } from 'commander'; +import { gracefulExit } from 'exit-hook'; + +import { AMPS } from '../applications/amps'; +import { Bitbucket } from '../applications/bitbucket'; + +const version = AMPS.getApplicationVersion() || '9.4.3'; + +(async () => { + const options = program + .showHelpAfterError(true) + .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '9.4.3' ]).default(version)) + .addOption(new Option('-d, --database ', 'The database engine to remove data from').choices([ 'postgresql', 'mysql', 'mssql' ]).default('postgresql')) + .parse(process.argv) + .opts(); + + const instance = new Bitbucket({ + version: options.version, + database: options.database + }); + + await instance.reset(); +})(); + +process.on('SIGINT', () => { + console.log(`Received term signal, trying to stop gracefully 💪`); + gracefulExit(); +}); \ No newline at end of file diff --git a/src/commands/reset-confluence.ts b/src/commands/reset-confluence.ts new file mode 100644 index 0000000..8723ca7 --- /dev/null +++ b/src/commands/reset-confluence.ts @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import { Option, program } from 'commander'; +import { gracefulExit } from 'exit-hook'; + +import { AMPS } from '../applications/amps'; +import { Confluence } from '../applications/confluence'; + +const version = AMPS.getApplicationVersion() || '8.9.0'; + +(async () => { + const options = program + .showHelpAfterError(true) + .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '8.9.0' ]).default(version)) + .addOption(new Option('-d, --database ', 'The database engine to remove data from').choices([ 'postgresql', 'mysql', 'mssql' ]).default('postgresql')) + .parse(process.argv) + .opts(); + + const instance = new Confluence({ + version: options.version, + database: options.database + }); + + await instance.reset(); +})(); + +process.on('SIGINT', () => { + console.log(`Received term signal, trying to stop gracefully 💪`); + gracefulExit(); +}); \ No newline at end of file diff --git a/src/commands/reset-jira.ts b/src/commands/reset-jira.ts new file mode 100644 index 0000000..0dddec7 --- /dev/null +++ b/src/commands/reset-jira.ts @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import { Option, program } from 'commander'; +import { gracefulExit } from 'exit-hook'; + +import { AMPS } from '../applications/amps'; +import { Jira } from '../applications/jira'; + +const version = AMPS.getApplicationVersion() || '9.15.0'; + +(async () => { + const options = program + .showHelpAfterError(true) + .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '9.15.0' ]).default(version)) + .addOption(new Option('-d, --database ', 'The database engine to remove data from').choices([ 'postgresql', 'mysql', 'mssql' ]).default('postgresql')) + .parse(process.argv) + .opts(); + + const instance = new Jira({ + version: options.version, + database: options.database, + }); + + await instance.reset(); +})(); + +process.on('SIGINT', () => { + console.log(`Received term signal, trying to stop gracefully 💪`); + gracefulExit(); +}); \ No newline at end of file diff --git a/src/commands/reset.ts b/src/commands/reset.ts new file mode 100644 index 0000000..2458499 --- /dev/null +++ b/src/commands/reset.ts @@ -0,0 +1,28 @@ +#!/usr/bin/env node + +import { Option, program } from 'commander'; + +import { AMPS } from '../applications/amps'; +import { SupportedApplications } from '../types/SupportedApplications'; + +// Check if there is a command in the arguments +const isDefaultCommand = !process.argv.some(item => Object.values(SupportedApplications).includes(item as SupportedApplications)); +// If there is no command, check if we are running this within the context of an Atlassian Plugin project +if (isDefaultCommand) { + const application = AMPS.getApplication(); + if (application) { + const args = [ application, ...process.argv.splice(2) ]; + process.argv = [ ...process.argv.slice(0, 2), ...args ]; + } +} + +program + .name('dcdx reset') + .addOption(new Option('-P, --activate-profiles ', 'Comma-delimited list of profiles to activate')) + .command('bamboo', 'Remove all data (incl. database) for Atlassian Bamboo (standalone)', { executableFile: './reset-bamboo.js'}) + .command('bitbucket', 'Remove all data (incl. database) for Atlassian Bitbucket (standalone)', { executableFile: './reset-bitbucket.js'}) + .command('confluence', 'Remove all data (incl. database) for Atlassian Confluence (standalone)', { executableFile: './reset-confluence.js'}) + .command('jira', 'Remove all data (incl. database) for Atlassian Jira (standalone)', { executableFile: './reset-jira.js'}) + .showHelpAfterError(true); + +program.parse(process.argv); \ No newline at end of file diff --git a/src/commands/run-bamboo.ts b/src/commands/run-bamboo.ts index e1c2cf3..0694f16 100644 --- a/src/commands/run-bamboo.ts +++ b/src/commands/run-bamboo.ts @@ -8,11 +8,13 @@ import { Bamboo } from '../applications/bamboo'; (async () => { const options = program .showHelpAfterError(true) - .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '9.4.3' ]).default('9.4.3')) + .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '9.4.3' ]).default('9.6.1')) .addOption(new Option('-d, --database ', 'The database engine on which the host application will run').choices([ 'postgresql', 'mysql', 'mssql' ]).default('postgresql')) .addOption(new Option('-p, --port ', 'The HTTP port on which the host application will be accessible').default('80')) .addOption(new Option('-c, --contextPath ', 'The context path on which the host application will be accessible')) .addOption(new Option('-qr, --quickReload ', 'Add support for QuickReload and add the provided path to the watch list')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .addOption(new Option('--debug', 'Add support for JVM debugger on port 5005')) .parse(process.argv) .opts(); @@ -23,6 +25,8 @@ import { Bamboo } from '../applications/bamboo'; port: Number(options.port), contextPath: options.contextPath, quickReload: options.qr, + clean: options.clean, + prune: options.prune, debug: options.debug }); diff --git a/src/commands/run-bitbucket.ts b/src/commands/run-bitbucket.ts index fd0ae9e..39e470b 100644 --- a/src/commands/run-bitbucket.ts +++ b/src/commands/run-bitbucket.ts @@ -8,10 +8,12 @@ import { Bitbucket } from '../applications/bitbucket'; (async () => { const options = program .showHelpAfterError(true) - .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '8.9.0' ]).default('8.9.0')) + .addOption(new Option('-v, --version ', 'The version of the host application').choices([ '8.19.1' ]).default('8.19.1')) .addOption(new Option('-d, --database ', 'The database engine on which the host application will run').choices([ 'postgresql', 'mysql', 'mssql' ]).default('postgresql')) .addOption(new Option('-p, --port ', 'The HTTP port on which the host application will be accessible').default('80')) .addOption(new Option('-qr, --quickReload ', 'Add support for QuickReload and add the provided path to the watch list')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .addOption(new Option('--debug', 'Add support for JVM debugger on port 5005')) .parse(process.argv) .opts(); @@ -21,6 +23,8 @@ import { Bitbucket } from '../applications/bitbucket'; database: options.database, port: Number(options.port), quickReload: options.qr, + clean: options.clean, + prune: options.prune, debug: options.debug }); diff --git a/src/commands/run-confluence.ts b/src/commands/run-confluence.ts index 114f7d3..7e9d731 100644 --- a/src/commands/run-confluence.ts +++ b/src/commands/run-confluence.ts @@ -13,6 +13,8 @@ import { Confluence } from '../applications/confluence'; .addOption(new Option('-p, --port ', 'The HTTP port on which the host application will be accessible').default('80')) .addOption(new Option('-c, --contextPath ', 'The context path on which the host application will be accessible')) .addOption(new Option('-qr, --quickReload ', 'Add support for QuickReload and add the provided path to the watch list')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .addOption(new Option('--debug', 'Add support for JVM debugger on port 5005')) .parse(process.argv) .opts(); @@ -23,6 +25,8 @@ import { Confluence } from '../applications/confluence'; port: Number(options.port), contextPath: options.contextPath, quickReload: options.qr, + clean: options.clean, + prune: options.prune, debug: options.debug }); diff --git a/src/commands/run-jira.ts b/src/commands/run-jira.ts index 5de033c..0cbfb70 100644 --- a/src/commands/run-jira.ts +++ b/src/commands/run-jira.ts @@ -13,6 +13,8 @@ import { Jira } from '../applications/jira'; .addOption(new Option('-p, --port ', 'The HTTP port on which the host application will be accessible').default('80')) .addOption(new Option('-c, --contextPath ', 'The context path on which the host application will be accessible')) .addOption(new Option('-qr, --quickReload ', 'Add support for QuickReload and add the provided path to the watch list')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .addOption(new Option('--debug', 'Add support for JVM debugger on port 5005')) .parse(process.argv) .opts(); @@ -23,6 +25,8 @@ import { Jira } from '../applications/jira'; port: Number(options.port), contextPath: options.contextPath, quickReload: options.qr, + clean: options.clean, + prune: options.prune, debug: options.debug }); diff --git a/src/commands/run.ts b/src/commands/run.ts index e2fd8ef..c539997 100644 --- a/src/commands/run.ts +++ b/src/commands/run.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { program } from 'commander'; +import { Option, program } from 'commander'; import { AMPS } from '../applications/amps'; import { SupportedApplications } from '../types/SupportedApplications'; @@ -18,6 +18,7 @@ if (isDefaultCommand) { program .name('dcdx run') + .addOption(new Option('-P, --activate-profiles ', 'Comma-delimited list of profiles to activate')) .command('bamboo', 'Start Atlassian Bamboo (standalone)', { executableFile: './run-bamboo.js'}) .command('bitbucket', 'Start Atlassian Bitbucket (standalone)', { executableFile: './run-bitbucket.js'}) .command('confluence', 'Start Atlassian Confluence (standalone)', { executableFile: './run-confluence.js'}) diff --git a/src/commands/start.ts b/src/commands/start.ts index d58c711..eec4b77 100644 --- a/src/commands/start.ts +++ b/src/commands/start.ts @@ -41,6 +41,8 @@ const version = AMPS.getApplicationVersion(); .addOption(new Option('-c, --contextPath ', 'The context path on which the host application will be accessible')) .addOption(new Option('-P, --activate-profiles ', 'Comma-delimited list of profiles to activate')) .addOption(new Option('-o, --outputDirectory ', 'Output directory where QuickReload will look for generated JAR files').default('target')) + .addOption(new Option('--clean', 'Remove data files before starting the database').default(false)) + .addOption(new Option('--prune', 'Remove data files when stopping the database').default(false)) .addOption(new Option('--debug', 'Add support for JVM debugger on port 5005').default(true)) .allowUnknownOption(true) .parse(process.argv) @@ -51,6 +53,8 @@ const version = AMPS.getApplicationVersion(); database: options.database, port: Number(options.port), contextPath: options.contextPath, + clean: options.clean, + prune: options.prune, debug: options.debug }); diff --git a/src/databases/base.ts b/src/databases/base.ts index 23181f4..189877c 100644 --- a/src/databases/base.ts +++ b/src/databases/base.ts @@ -1,6 +1,6 @@ import { spawn } from 'child_process'; import { upAll } from 'docker-compose'; -import { downAll, ps } from 'docker-compose/dist/v2.js'; +import { downAll, ps, stop } from 'docker-compose/dist/v2.js'; import EventEmitter from 'events'; import { gracefulExit } from 'exit-hook'; import { dump } from 'js-yaml'; @@ -42,13 +42,16 @@ export abstract class Base extends EventEmitter implements DatabaseEngine { return null; } - async start(): Promise { + async start(clean = this.options.clean): Promise { console.log(`Starting instance of ${this.name} ⏳`); - await this.stop(); - await this.up(); + if (clean) { + await this.down(); + } + await this.up(); this.emit(`${this.name}:up`); + const isAvailable = await this.waitUntilReady(); if (!isAvailable) { console.log(`Failed to start database ${this.name} ⛔`); @@ -67,8 +70,17 @@ export abstract class Base extends EventEmitter implements DatabaseEngine { } } - async stop(): Promise { - await this.down(); + async stop(prune = this.options.prune): Promise { + if (prune) { + await this.down(); + } else { + const configAsString = dump(this.getDockerComposeConfig()); + await stop({ + cwd: cwd(), + configAsString, + log: true + }) + } this.emit('db:stopped'); } @@ -103,7 +115,6 @@ export abstract class Base extends EventEmitter implements DatabaseEngine { private async down() { const configAsString = dump(this.getDockerComposeConfig()); - return downAll({ cwd: cwd(), configAsString, @@ -149,10 +160,8 @@ export abstract class Base extends EventEmitter implements DatabaseEngine { const docker = spawn( 'docker', [ 'logs', '-f', '-n', '5000', service ], - { cwd: cwd() } + { cwd: cwd(), stdio: 'inherit' } ); - docker.stdout.on('data', (lines: Buffer) => { console.log(lines.toString('utf-8').trim()); }); - docker.stderr.on('data', (lines: Buffer) => { console.log(lines.toString('utf-8').trim()); }); docker.on('exit', (code) => (code === 0) ? resolve() : reject(new Error(`Docker exited with code ${code}`))); }); } diff --git a/src/index.ts b/src/index.ts index 2ae762f..157833b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,11 +10,13 @@ program .version(pkg.version) .showHelpAfterError(true); -// ------------------------------------------------------------------------------------------ Run +// ------------------------------------------------------------------------------------------ Start program .command('start', 'Build & install the Atlassian Data Center plugin from the current directory', { executableFile: './commands/start.js' }); +// ------------------------------------------------------------------------------------------ Run + program .command('run', 'Start the Atlassian host application (standalone)', { executableFile: './commands/run.js' }); @@ -87,6 +89,11 @@ program program.parse(process.argv); }); +// ------------------------------------------------------------------------------------------ Reset + +program + .command('reset', 'Remove all application data (incl. database) and start fresh!', { executableFile: './commands/reset.js' }); + // ------------------------------------------------------------------------------------------ Profile program diff --git a/src/types/ApplicationOptions.ts b/src/types/ApplicationOptions.ts index 7cf3453..1f77fb4 100644 --- a/src/types/ApplicationOptions.ts +++ b/src/types/ApplicationOptions.ts @@ -3,9 +3,11 @@ import { SupportedDatabaseEngines } from './SupportedDatabaseEngines'; export type ApplicationOptions = { version: string; database: SupportedDatabaseEngines; - port: number; + port?: number; contextPath?: string; quickReload?: boolean; license?: string; + clean?: boolean; + prune?: boolean; debug?: boolean; } \ No newline at end of file diff --git a/src/types/DatabaseEngine.ts b/src/types/DatabaseEngine.ts index 43955a2..73eb6b6 100644 --- a/src/types/DatabaseEngine.ts +++ b/src/types/DatabaseEngine.ts @@ -1,7 +1,6 @@ import EventEmitter from 'events'; import { DatabaseOptions } from './DatabaseOptions'; -import { SupportedApplications } from './SupportedApplications'; import { SupportedDatabaseDrivers } from './SupportedDatabaseDrivers'; import { SupportedDatabaseEngines } from './SupportedDatabaseEngines'; @@ -10,8 +9,7 @@ export interface DatabaseEngine extends EventEmitter { url: string; driver: SupportedDatabaseDrivers; options: DatabaseOptions; - start(): Promise; - start(application: SupportedApplications, version: string): Promise; - stop(): Promise; + start(clean?: boolean): Promise; + stop(prune?: boolean): Promise; run(sql: string | { query: string; values: unknown[] }): Promise<[unknown[], unknown]|null>; } \ No newline at end of file diff --git a/src/types/DatabaseOptions.ts b/src/types/DatabaseOptions.ts index 0ed6745..db95b76 100644 --- a/src/types/DatabaseOptions.ts +++ b/src/types/DatabaseOptions.ts @@ -5,5 +5,7 @@ export type DatabaseOptions = { database: string; username: string; password: string; + clean?: boolean; + prune?: boolean; logging?: boolean; } \ No newline at end of file