Skip to content

Commit b6103af

Browse files
authored
Update @oclif/core to v2 (#486)
* Remove CLA github action * Bump @oclif/core * Migrate CLI args * Migrate CliUx class * Migrate oclif types * Remove unnecessary flag name
1 parent 0f32013 commit b6103af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+347
-448
lines changed

.github/workflows/cla-check.yml

-35
This file was deleted.

packages/cli/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"@nestjs/common": "9.4.0",
2828
"@nestjs/config": "2.3.1",
2929
"@nestjs/core": "9.4.0",
30-
"@oclif/core": "1.26.2",
31-
"@oclif/plugin-autocomplete": "1.4.6",
30+
"@oclif/core": "2.8.4",
31+
"@oclif/plugin-autocomplete": "2.1.9",
3232
"@oclif/plugin-help": "5.2.9",
3333
"@relate/common": "workspace:*",
3434
"@relate/types": "workspace:*",
@@ -39,12 +39,12 @@
3939
"graphql": "16.6.0",
4040
"lodash": "4.17.21",
4141
"node-fetch": "2.6.9",
42+
"open": "9.1.0",
4243
"rxjs": "7.8.1",
4344
"semver": "7.5.0",
4445
"tslib": "2.5.0"
4546
},
4647
"devDependencies": {
47-
"oclif": "3.9.0",
4848
"@oclif/test": "2.3.17",
4949
"@types/fs-extra": "9.0.13",
5050
"@types/jest": "29.5.1",
@@ -56,6 +56,7 @@
5656
"globby": "10.0.2",
5757
"jest": "29.5.0",
5858
"npm-run-all": "4.1.5",
59+
"oclif": "3.9.0",
5960
"ts-jest": "29.1.0",
6061
"ts-node": "10.9.1",
6162
"typescript": "4.9.5"

packages/cli/src/base.command.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Command, Interfaces, Errors} from '@oclif/core';
1+
import {Command, Errors, Parser} from '@oclif/core';
22
import {INestApplicationContext, Type} from '@nestjs/common';
33
import {NestFactory} from '@nestjs/core';
44
import {ISystemModuleConfig, SystemModule, registerHookListener, HOOK_EVENTS} from '@relate/common';
@@ -7,17 +7,18 @@ import {ConfigModule} from '@nestjs/config';
77
import {IS_DEVELOPMENT_ENV, IS_TEST_ENV} from './constants';
88

99
export default abstract class BaseCommand extends Command {
10-
protected abstract commandClass: Interfaces.Input<Interfaces.FlagOutput, Interfaces.FlagOutput>;
10+
protected abstract commandClass: Parameters<typeof Parser.parse>[1];
1111

1212
// Any nestjs module should be a valid command module.
1313
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1414
protected abstract commandModule: Type<any>;
1515

1616
static flags = {};
1717

18-
static globalFlags = {};
18+
static baseFlags = {};
1919

2020
async run(): Promise<INestApplicationContext> {
21+
this.parse();
2122
const parsed = await this.parse(this.commandClass);
2223
const utils = {
2324
debug: this.debug.bind(this),

packages/cli/src/commands/backup/create.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {Flags} from '@oclif/core';
2-
import {ENTITY_TYPES} from '@relate/common';
1+
import {Args, Flags} from '@oclif/core';
32

43
import BaseCommand from '../../base.command';
54
import {FLAGS, REQUIRED_FOR_SCRIPTS, VALID_BACKUP_TYPES} from '../../constants';
@@ -18,17 +17,16 @@ export default class CreateCommand extends BaseCommand {
1817
'$ relate backup:create <entity-id> -t dbms',
1918
];
2019

21-
static args = [
22-
{
23-
name: 'entityNameOrId',
20+
static args = {
21+
entityNameOrId: Args.string({
2422
description: 'Entity id',
2523
required: REQUIRED_FOR_SCRIPTS,
26-
},
27-
];
24+
}),
25+
};
2826

2927
static flags = {
3028
...FLAGS.ENVIRONMENT,
31-
type: Flags.enum<ENTITY_TYPES>({
29+
type: Flags.string({
3230
char: 't',
3331
options: VALID_BACKUP_TYPES,
3432
description: 'The relate entity type',

packages/cli/src/commands/backup/list.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {CliUx, Flags} from '@oclif/core';
2-
import {ENTITY_TYPES} from '@relate/common';
1+
import {ux, Flags} from '@oclif/core';
32

43
import BaseCommand from '../../base.command';
54
import {FLAGS, VALID_BACKUP_TYPES} from '../../constants';
@@ -21,8 +20,8 @@ export default class ListCommand extends BaseCommand {
2120

2221
static flags = {
2322
...FLAGS.ENVIRONMENT,
24-
...CliUx.ux.table.flags({except: ['extended', 'csv']}),
25-
type: Flags.enum<ENTITY_TYPES>({
23+
...ux.table.flags({except: ['extended', 'csv']}),
24+
type: Flags.string({
2625
char: 't',
2726
options: VALID_BACKUP_TYPES,
2827
description: 'The relate entity type',

packages/cli/src/commands/backup/remove.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {Args} from '@oclif/core';
12
import BaseCommand from '../../base.command';
23
import {FLAGS} from '../../constants';
34
import {RemoveModule} from '../../modules/backup/remove.module';
@@ -11,13 +12,12 @@ export default class RemoveCommand extends BaseCommand {
1112

1213
static examples = ['$ relate backup:remove <backup-id-or-path>', '$ relate backup:remove -e environment-name'];
1314

14-
static args = [
15-
{
16-
name: 'backupId',
15+
static args = {
16+
backupId: Args.string({
1717
description: 'Backup ID',
1818
required: true,
19-
},
20-
];
19+
}),
20+
};
2121

2222
static flags = {
2323
...FLAGS.ENVIRONMENT,

packages/cli/src/commands/backup/restore.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {Args} from '@oclif/core';
12
import BaseCommand from '../../base.command';
23
import {FLAGS} from '../../constants';
34
import {RestoreModule} from '../../modules/backup/restore.module';
@@ -15,17 +16,15 @@ export default class RestoreCommand extends BaseCommand {
1516
'$ relate backup:restore <backup-id-or-path> <output-path>',
1617
];
1718

18-
static args = [
19-
{
20-
name: 'backupIdOrPath',
19+
static args = {
20+
backupIdOrPath: Args.string({
2121
description: 'Backup ID or path',
2222
required: true,
23-
},
24-
{
25-
name: 'outputPath',
23+
}),
24+
outputPath: Args.string({
2625
description: 'destination of backup',
27-
},
28-
];
26+
}),
27+
};
2928

3029
static flags = {
3130
...FLAGS.ENVIRONMENT,

packages/cli/src/commands/db/create.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Flags} from '@oclif/core';
1+
import {Args, Flags} from '@oclif/core';
22

33
import BaseCommand from '../../base.command';
44
import {FLAGS, REQUIRED_FOR_SCRIPTS} from '../../constants';
@@ -18,13 +18,12 @@ export default class CreateCommand extends BaseCommand {
1818
'$ relate db:create my-new-db -D started-dbms -u dbms-user-with-system-db-access',
1919
];
2020

21-
static args = [
22-
{
23-
name: 'name',
21+
static args = {
22+
name: Args.string({
2423
description: 'database name',
25-
required: REQUIRED_FOR_SCRIPTS,
26-
},
27-
];
24+
reuqired: REQUIRED_FOR_SCRIPTS,
25+
}),
26+
};
2827

2928
static flags = {
3029
...FLAGS.ENVIRONMENT,

packages/cli/src/commands/db/drop.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Flags} from '@oclif/core';
1+
import {Args, Flags} from '@oclif/core';
22

33
import BaseCommand from '../../base.command';
44
import {FLAGS, REQUIRED_FOR_SCRIPTS} from '../../constants';
@@ -18,13 +18,12 @@ export default class DropCommand extends BaseCommand {
1818
'$ relate db:drop my-new-db -D started-dbms -u dbms-user-with-system-db-access',
1919
];
2020

21-
static args = [
22-
{
23-
name: 'name',
21+
static args = {
22+
name: Args.string({
2423
description: 'database name',
2524
reuqired: REQUIRED_FOR_SCRIPTS,
26-
},
27-
];
25+
}),
26+
};
2827

2928
static flags = {
3029
...FLAGS.ENVIRONMENT,

packages/cli/src/commands/db/dump.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class DumpCommand extends BaseCommand {
1818
'$ relate db:dump dbms-containing-db-to-dump -d db-to-dump -t /path/to/save/dump/file/to',
1919
];
2020

21-
static args = [ARGS.DBMS];
21+
static args = {...ARGS.DBMS};
2222

2323
static strict = false;
2424

packages/cli/src/commands/db/exec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class ExecCommand extends BaseCommand {
1818
'$ relate db:exec dbms-containing-db-to-query -f /path/to/cypher/file -d db-to-query --force',
1919
];
2020

21-
static args = [ARGS.DBMS];
21+
static args = {...ARGS.DBMS};
2222

2323
static strict = false;
2424

packages/cli/src/commands/db/list.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CliUx, Flags} from '@oclif/core';
1+
import {ux, Flags} from '@oclif/core';
22

33
import BaseCommand from '../../base.command';
44
import {FLAGS, REQUIRED_FOR_SCRIPTS} from '../../constants';
@@ -22,7 +22,7 @@ export default class ListCommand extends BaseCommand {
2222

2323
static flags = {
2424
...FLAGS.ENVIRONMENT,
25-
...CliUx.ux.table.flags({except: ['extended', 'csv']}),
25+
...ux.table.flags({except: ['extended', 'csv']}),
2626
user: Flags.string({
2727
char: 'u',
2828
description: 'The Neo4j DBMS user to list databases with (needs to have access to the system database)',

packages/cli/src/commands/db/load.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class LoadCommand extends BaseCommand {
1818
'$ relate db:load dbms-containing-db-to-load-into -f /path/to/dump/file -d db-to-load-into --force',
1919
];
2020

21-
static args = [ARGS.DBMS];
21+
static args = {...ARGS.DBMS};
2222

2323
static strict = false;
2424

packages/cli/src/commands/dbms-plugin/add-sources.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CliUx} from '@oclif/core';
1+
import {Args, ux} from '@oclif/core';
22

33
import BaseCommand from '../../base.command';
44
import {FLAGS} from '../../constants';
@@ -22,15 +22,14 @@ export default class AddSourcesCommand extends BaseCommand {
2222

2323
static strict = false;
2424

25-
static args = [
26-
{
27-
name: 'sources',
25+
static args = {
26+
sources: Args.string({
2827
description: 'File path or URL to plugin sources',
29-
},
30-
];
28+
}),
29+
};
3130

3231
static flags = {
3332
...FLAGS.ENVIRONMENT,
34-
...CliUx.ux.table.flags({except: ['csv']}),
33+
...ux.table.flags({except: ['csv']}),
3534
};
3635
}

packages/cli/src/commands/dbms-plugin/install.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CliUx, Flags} from '@oclif/core';
1+
import {ux, Flags} from '@oclif/core';
22
import BaseCommand from '../../base.command';
33
import {ARGS, FLAGS, REQUIRED_FOR_SCRIPTS} from '../../constants';
44
import {InstallModule} from '../../modules/dbms-plugin/install.module';
@@ -21,11 +21,11 @@ export default class InstallCommand extends BaseCommand {
2121

2222
static strict = false;
2323

24-
static args = [ARGS.DBMSS];
24+
static args = {...ARGS.DBMSS};
2525

2626
static flags = {
2727
...FLAGS.ENVIRONMENT,
28-
...CliUx.ux.table.flags({except: ['csv']}),
28+
...ux.table.flags({except: ['csv']}),
2929
plugin: Flags.string({
3030
char: 'p',
3131
description: 'Name of the plugin to install',

packages/cli/src/commands/dbms-plugin/list-sources.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CliUx} from '@oclif/core';
1+
import {ux} from '@oclif/core';
22

33
import BaseCommand from '../../base.command';
44
import {FLAGS} from '../../constants';
@@ -23,6 +23,6 @@ export default class ListSourcesCommand extends BaseCommand {
2323

2424
static flags = {
2525
...FLAGS.ENVIRONMENT,
26-
...CliUx.ux.table.flags({except: ['csv']}),
26+
...ux.table.flags({except: ['csv']}),
2727
};
2828
}

packages/cli/src/commands/dbms-plugin/list.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CliUx} from '@oclif/core';
1+
import {ux} from '@oclif/core';
22

33
import BaseCommand from '../../base.command';
44
import {ARGS, FLAGS} from '../../constants';
@@ -21,10 +21,10 @@ export default class ListCommand extends BaseCommand {
2121
'$ relate dbms-plugin:list MyDbms --filter=name=my-dbms --output=json',
2222
];
2323

24-
static args = [ARGS.DBMS];
24+
static args = {...ARGS.DBMS};
2525

2626
static flags = {
2727
...FLAGS.ENVIRONMENT,
28-
...CliUx.ux.table.flags({except: ['csv']}),
28+
...ux.table.flags({except: ['csv']}),
2929
};
3030
}

packages/cli/src/commands/dbms-plugin/remove-sources.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {Args} from '@oclif/core';
12
import BaseCommand from '../../base.command';
23
import {FLAGS} from '../../constants';
34
import {RemoveSourcesModule} from '../../modules/dbms-plugin/remove-sources.module';
@@ -20,12 +21,11 @@ export default class RemoveSourcesCommand extends BaseCommand {
2021

2122
static strict = false;
2223

23-
static args = [
24-
{
25-
name: 'sources',
24+
static args = {
25+
sources: Args.string({
2626
description: 'Names of the plugin sources to remove',
27-
},
28-
];
27+
}),
28+
};
2929

3030
static flags = {
3131
...FLAGS.ENVIRONMENT,

packages/cli/src/commands/dbms-plugin/uninstall.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class UninstallCommand extends BaseCommand {
2121

2222
static strict = false;
2323

24-
static args = [ARGS.DBMSS];
24+
static args = {...ARGS.DBMSS};
2525

2626
static flags = {
2727
...FLAGS.ENVIRONMENT,

0 commit comments

Comments
 (0)