Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade oclif core pacakges #222

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [16, 18, 20]
node-version: [18, 20]

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"extension": ["ts"],
"reporter": "spec",
"recursive": true,
"timeout": 30000
"timeout": 5000
}
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,44 +55,43 @@
"doc:update": "oclif-dev readme && prettier --write README.md"
},
"dependencies": {
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^3",
"@oclif/config": "^1.18.16",
"@oclif/core": "^2.11.8",
"@oclif/plugin-help": "^5.2.16",
"chalk": "^4.0.0",
"debug": "^4.1.1",
"esm": "^3.2.25",
"globby": "^10.0.2",
"knex": "^2.4.2",
"ramda": "^0.29.0",
"ts-node": "^8",
"tslib": "^1",
"ts-node": "^10.9.1",
"tslib": "^2.6.1",
"yamljs": "^0.3.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@oclif/dev-cli": "^1.26.0",
"@oclif/test": "^1",
"@oclif/test": "^2.4.4",
"@oclif/tslint": "^3",
"@types/chai": "^4.2.7",
"@types/chai-as-promised": "^7.1.2",
"@types/debug": "^4.1.4",
"@types/mocha": "^5",
"@types/node": "^10",
"@types/mocha": "^10.0.1",
"@types/ramda": "^0.29.0",
"@types/yamljs": "^0.2.30",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codecov": "^3.8.3",
"execa": "^4.0.0",
"get-bin-path": "^5.0.1",
"execa": "^7.2.0",
"get-bin-path": "^10.0.0",
"mocha": "^10.2.0",
"nyc": "^15.0.0",
"prettier": "2.0.2",
"prettier": "3.0.1",
"tslint": "^6.1.3",
"tslint-config-leapfrog": "^1.0.3",
"typescript": "^5.0.2"
},
"engines": {
"node": ">= 14.15.0"
"node": ">= 18.12.0"
}
}
1 change: 0 additions & 1 deletion src/@types/get-bin-path/index.d.ts

This file was deleted.

129 changes: 67 additions & 62 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,25 @@ export async function synchronize(
});

const connections = filterConnectionsAsRequired(mapToConnectionReferences(conn), params.only);
const processes = connections.map(connection => () =>
withTransaction(
connection,
trx =>
runSynchronize(trx, {
config,
params,
connectionId: connection.id,
migrateFunc: t =>
invokeMigrationApi(t, KnexMigrationAPI.MIGRATE_LATEST, {
config,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id),
params: { ...invokeParams, onSuccess: params.onMigrationSuccess, onFailed: params.onMigrationFailed }
})
}),
params['dry-run']
)
const processes = connections.map(
connection => () =>
withTransaction(
connection,
trx =>
runSynchronize(trx, {
config,
params,
connectionId: connection.id,
migrateFunc: t =>
invokeMigrationApi(t, KnexMigrationAPI.MIGRATE_LATEST, {
config,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id),
params: { ...invokeParams, onSuccess: params.onMigrationSuccess, onFailed: params.onMigrationFailed }
})
}),
params['dry-run']
)
);

return executeProcesses(processes, config);
Expand Down Expand Up @@ -106,17 +107,18 @@ export async function prune(
await init.prepare(config, { loadSqlSources: true });

const connections = filterConnectionsAsRequired(mapToConnectionReferences(conn), params.only);
const processes = connections.map(connection => () =>
withTransaction(
connection,
trx =>
runPrune(trx, {
config,
params,
connectionId: connection.id
}),
params['dry-run']
)
const processes = connections.map(
connection => () =>
withTransaction(
connection,
trx =>
runPrune(trx, {
config,
params,
connectionId: connection.id
}),
params['dry-run']
)
);

return executeProcesses(processes, config);
Expand Down Expand Up @@ -144,18 +146,19 @@ export async function migrateLatest(
});

const connections = filterConnectionsAsRequired(mapToConnectionReferences(conn), params.only);
const processes = connections.map(connection => () =>
withTransaction(
connection,
trx =>
invokeMigrationApi(trx, KnexMigrationAPI.MIGRATE_LATEST, {
config,
params,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id)
}),
params['dry-run']
)
const processes = connections.map(
connection => () =>
withTransaction(
connection,
trx =>
invokeMigrationApi(trx, KnexMigrationAPI.MIGRATE_LATEST, {
config,
params,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id)
}),
params['dry-run']
)
);

return executeProcesses(processes, config);
Expand Down Expand Up @@ -183,18 +186,19 @@ export async function migrateRollback(
});

const connections = filterConnectionsAsRequired(mapToConnectionReferences(conn), params.only);
const processes = connections.map(connection => () =>
withTransaction(
connection,
trx =>
invokeMigrationApi(trx, KnexMigrationAPI.MIGRATE_ROLLBACK, {
config,
params,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id)
}),
params['dry-run']
)
const processes = connections.map(
connection => () =>
withTransaction(
connection,
trx =>
invokeMigrationApi(trx, KnexMigrationAPI.MIGRATE_ROLLBACK, {
config,
params,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id)
}),
params['dry-run']
)
);

return executeProcesses(processes, config);
Expand Down Expand Up @@ -222,15 +226,16 @@ export async function migrateList(
});

const connections = filterConnectionsAsRequired(mapToConnectionReferences(conn), params.only);
const processes = connections.map(connection => () =>
withTransaction(connection, trx =>
invokeMigrationApi(trx, KnexMigrationAPI.MIGRATE_LIST, {
config,
params,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id)
})
)
const processes = connections.map(
connection => () =>
withTransaction(connection, trx =>
invokeMigrationApi(trx, KnexMigrationAPI.MIGRATE_LIST, {
config,
params,
connectionId: connection.id,
knexMigrationConfig: knexMigrationConfig(connection.id)
})
)
);

return executeProcesses(processes, config);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { run } from '@oclif/command';
export { run } from '@oclif/core';
6 changes: 3 additions & 3 deletions src/commands/make-publish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { grey, cyan } from 'chalk';
import { Command, flags } from '@oclif/command';
import { Command, Flags } from '@oclif/core';

import { loadConfig } from '../config';
import { printInfo, printLine } from '../util/io';
Expand All @@ -8,7 +8,7 @@ import * as fileMakerService from '../service/fileMaker';
class MakePublish extends Command {
static description = 'Publish migration templates files.';
static flags = {
config: flags.string({
config: Flags.string({
char: 'c',
description: 'Custom configuration file.'
})
Expand All @@ -20,7 +20,7 @@ class MakePublish extends Command {
* @returns {Promise<void>}
*/
async run(): Promise<void> {
const { flags: parsedFlags } = this.parse(MakePublish);
const { flags: parsedFlags } = await this.parse(MakePublish);
const config = await loadConfig(parsedFlags.config);

await printLine();
Expand Down
16 changes: 8 additions & 8 deletions src/commands/make.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { loadConfig } from '../config';
import { printLine } from '../util/io';
import { Command, flags } from '@oclif/command';
import MakeOptions from '../domain/MakeOptions';
import { Command, Args, Flags } from '@oclif/core';
import Configuration from '../domain/Configuration';
import * as fileMakerService from '../service/fileMaker';

class Make extends Command {
static description = 'Make migration files from the template.';
static description = 'Create migration files using a template.';

static args = [{ name: 'name', description: 'Object or filename to generate.', required: true }];
static args = { name: Args.string({ description: 'Object or filename to generate.', required: true }) };
static flags = {
'object-name': flags.string({
'object-name': Flags.string({
description: 'Name of table/view/routine to migrate.'
}),
create: flags.boolean({
create: Flags.boolean({
default: false,
description: 'Generate create table stub.'
}),
config: flags.string({
config: Flags.string({
char: 'c',
description: 'Custom configuration file.'
}),
type: flags.string({
type: Flags.string({
char: 't',
helpValue: 'TYPE',
description: 'Type of file to generate.',
Expand All @@ -36,7 +36,7 @@ class Make extends Command {
* @returns {Promise<void>}
*/
async run(): Promise<void> {
const { args, flags: parsedFlags } = this.parse(Make);
const { args, flags: parsedFlags } = await this.parse(Make);
const config = await loadConfig(parsedFlags.config);
const list = await this.makeFiles(config, args.name, parsedFlags.type, {
create: parsedFlags.create,
Expand Down
12 changes: 6 additions & 6 deletions src/commands/migrate-latest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, flags } from '@oclif/command';
import { Command, Flags } from '@oclif/core';
import { bold, red, cyan, magenta } from 'chalk';

import { migrateLatest } from '../api';
Expand All @@ -11,16 +11,16 @@ class MigrateLatest extends Command {
static description = 'Run the migrations up to the latest changes.';

static flags = {
'dry-run': flags.boolean({ description: 'Dry run migration.', default: false }),
only: flags.string({
'dry-run': Flags.boolean({ description: 'Dry run migration.', default: false }),
only: Flags.string({
helpValue: 'CONNECTION_ID',
description: 'Filter only a single connection.'
}),
'connection-resolver': flags.string({
'connection-resolver': Flags.string({
helpValue: 'PATH',
description: 'Path to the connection resolver.'
}),
config: flags.string({
config: Flags.string({
char: 'c',
description: 'Custom configuration file.'
})
Expand Down Expand Up @@ -74,7 +74,7 @@ class MigrateLatest extends Command {
* @returns {Promise<void>}
*/
async run(): Promise<void> {
const { flags: parsedFlags } = this.parse(MigrateLatest);
const { flags: parsedFlags } = await this.parse(MigrateLatest);
const isDryRun = parsedFlags['dry-run'];
const config = await loadConfig(parsedFlags.config);

Expand Down
10 changes: 5 additions & 5 deletions src/commands/migrate-list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, flags } from '@oclif/command';
import { Command, Flags } from '@oclif/core';
import { bold, grey, red, cyan, yellow } from 'chalk';

import { migrateList } from '../api';
Expand All @@ -10,15 +10,15 @@ class MigrateList extends Command {
static description = 'List all the migrations.';

static flags = {
only: flags.string({
only: Flags.string({
helpValue: 'CONNECTION_ID',
description: 'Filter only a single connection.'
}),
'connection-resolver': flags.string({
'connection-resolver': Flags.string({
helpValue: 'PATH',
description: 'Path to the connection resolver.'
}),
config: flags.string({
config: Flags.string({
char: 'c',
description: 'Custom configuration file.'
})
Expand Down Expand Up @@ -72,7 +72,7 @@ class MigrateList extends Command {
* @returns {Promise<void>}
*/
async run(): Promise<void> {
const { flags: parsedFlags } = this.parse(MigrateList);
const { flags: parsedFlags } = await this.parse(MigrateList);
const config = await loadConfig(parsedFlags.config);
const connections = await resolveConnections(config, parsedFlags['connection-resolver']);

Expand Down
Loading
Loading