mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-14 15:23:16 +00:00
Upgrade commander
Adjust imports for commander
This commit is contained in:
committed by
Addison Beck
parent
5144f4d629
commit
c803cd832f
10
package-lock.json
generated
10
package-lock.json
generated
@@ -69,7 +69,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "5.62.0",
|
"@typescript-eslint/eslint-plugin": "5.62.0",
|
||||||
"@typescript-eslint/parser": "5.62.0",
|
"@typescript-eslint/parser": "5.62.0",
|
||||||
"clean-webpack-plugin": "4.0.0",
|
"clean-webpack-plugin": "4.0.0",
|
||||||
"commander": "7.2.0",
|
"commander": "11.1.0",
|
||||||
"concurrently": "8.2.2",
|
"concurrently": "8.2.2",
|
||||||
"copy-webpack-plugin": "11.0.0",
|
"copy-webpack-plugin": "11.0.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
@@ -8122,12 +8122,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/commander": {
|
"node_modules/commander": {
|
||||||
"version": "7.2.0",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||||
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
|
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">=16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/common-tags": {
|
"node_modules/common-tags": {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "5.62.0",
|
"@typescript-eslint/eslint-plugin": "5.62.0",
|
||||||
"@typescript-eslint/parser": "5.62.0",
|
"@typescript-eslint/parser": "5.62.0",
|
||||||
"clean-webpack-plugin": "4.0.0",
|
"clean-webpack-plugin": "4.0.0",
|
||||||
"commander": "7.2.0",
|
"commander": "11.1.0",
|
||||||
"concurrently": "8.2.2",
|
"concurrently": "8.2.2",
|
||||||
"copy-webpack-plugin": "11.0.0",
|
"copy-webpack-plugin": "11.0.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import * as chalk from "chalk";
|
import * as chalk from "chalk";
|
||||||
import * as program from "commander";
|
import { Command, OptionValues } from "commander";
|
||||||
|
|
||||||
import { Utils } from "@/jslib/common/src/misc/utils";
|
import { Utils } from "@/jslib/common/src/misc/utils";
|
||||||
import { BaseProgram } from "@/jslib/node/src/cli/baseProgram";
|
import { BaseProgram } from "@/jslib/node/src/cli/baseProgram";
|
||||||
@@ -33,7 +33,7 @@ export class Program extends BaseProgram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run() {
|
async run() {
|
||||||
program
|
const program = new Command()
|
||||||
.option("--pretty", "Format output. JSON is tabbed with two spaces.")
|
.option("--pretty", "Format output. JSON is tabbed with two spaces.")
|
||||||
.option("--raw", "Return raw output instead of a descriptive message.")
|
.option("--raw", "Return raw output instead of a descriptive message.")
|
||||||
.option("--response", "Return a JSON formatted version of response output.")
|
.option("--response", "Return a JSON formatted version of response output.")
|
||||||
@@ -90,7 +90,7 @@ export class Program extends BaseProgram {
|
|||||||
clientId: "Client_id part of your organization's API key",
|
clientId: "Client_id part of your organization's API key",
|
||||||
clientSecret: "Client_secret part of your organization's API key",
|
clientSecret: "Client_secret part of your organization's API key",
|
||||||
})
|
})
|
||||||
.action(async (clientId: string, clientSecret: string, options: program.OptionValues) => {
|
.action(async (clientId: string, clientSecret: string, options: OptionValues) => {
|
||||||
await this.exitIfAuthed();
|
await this.exitIfAuthed();
|
||||||
const command = new LoginCommand(
|
const command = new LoginCommand(
|
||||||
this.main.authService,
|
this.main.authService,
|
||||||
@@ -104,7 +104,7 @@ export class Program extends BaseProgram {
|
|||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.policyService,
|
this.main.policyService,
|
||||||
this.main.twoFactorService,
|
this.main.twoFactorService,
|
||||||
"connector"
|
"connector",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!Utils.isNullOrWhitespace(clientId)) {
|
if (!Utils.isNullOrWhitespace(clientId)) {
|
||||||
@@ -133,7 +133,7 @@ export class Program extends BaseProgram {
|
|||||||
const command = new LogoutCommand(
|
const command = new LogoutCommand(
|
||||||
this.main.authService,
|
this.main.authService,
|
||||||
this.main.i18nService,
|
this.main.i18nService,
|
||||||
async () => await this.main.logout()
|
async () => await this.main.logout(),
|
||||||
);
|
);
|
||||||
const response = await command.run();
|
const response = await command.run();
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
@@ -150,7 +150,7 @@ export class Program extends BaseProgram {
|
|||||||
writeLn(" bwdc test --last");
|
writeLn(" bwdc test --last");
|
||||||
writeLn("", true);
|
writeLn("", true);
|
||||||
})
|
})
|
||||||
.action(async (options: program.OptionValues) => {
|
.action(async (options: OptionValues) => {
|
||||||
await this.exitIfNotAuthed();
|
await this.exitIfNotAuthed();
|
||||||
const command = new TestCommand(this.main.syncService, this.main.i18nService);
|
const command = new TestCommand(this.main.syncService, this.main.i18nService);
|
||||||
const response = await command.run(options);
|
const response = await command.run(options);
|
||||||
@@ -223,11 +223,11 @@ export class Program extends BaseProgram {
|
|||||||
writeLn(" bwdc config onelogin.secret <secret>");
|
writeLn(" bwdc config onelogin.secret <secret>");
|
||||||
writeLn("", true);
|
writeLn("", true);
|
||||||
})
|
})
|
||||||
.action(async (setting: string, value: string, options: program.OptionValues) => {
|
.action(async (setting: string, value: string, options: OptionValues) => {
|
||||||
const command = new ConfigCommand(
|
const command = new ConfigCommand(
|
||||||
this.main.environmentService,
|
this.main.environmentService,
|
||||||
this.main.i18nService,
|
this.main.i18nService,
|
||||||
this.main.stateService
|
this.main.stateService,
|
||||||
);
|
);
|
||||||
const response = await command.run(setting, value, options);
|
const response = await command.run(setting, value, options);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
@@ -244,7 +244,7 @@ export class Program extends BaseProgram {
|
|||||||
})
|
})
|
||||||
.action(() => {
|
.action(() => {
|
||||||
this.processResponse(
|
this.processResponse(
|
||||||
Response.success(new StringResponse(path.join(this.main.dataFilePath, "data.json")))
|
Response.success(new StringResponse(path.join(this.main.dataFilePath, "data.json"))),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ export class Program extends BaseProgram {
|
|||||||
writeLn(" bwdc clear-cache");
|
writeLn(" bwdc clear-cache");
|
||||||
writeLn("", true);
|
writeLn("", true);
|
||||||
})
|
})
|
||||||
.action(async (options: program.OptionValues) => {
|
.action(async (options: OptionValues) => {
|
||||||
const command = new ClearCacheCommand(this.main.i18nService, this.main.stateService);
|
const command = new ClearCacheCommand(this.main.i18nService, this.main.stateService);
|
||||||
const response = await command.run(options);
|
const response = await command.run(options);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
@@ -285,7 +285,7 @@ export class Program extends BaseProgram {
|
|||||||
this.main.i18nService,
|
this.main.i18nService,
|
||||||
"directory-connector",
|
"directory-connector",
|
||||||
"bwdc",
|
"bwdc",
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
const response = await command.run();
|
const response = await command.run();
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
@@ -305,7 +305,7 @@ export class Program extends BaseProgram {
|
|||||||
const id = await this.stateService.getEntityId();
|
const id = await this.stateService.getEntityId();
|
||||||
this.processResponse(
|
this.processResponse(
|
||||||
Response.error("You are already logged in as " + type + "." + id + "."),
|
Response.error("You are already logged in as " + type + "." + id + "."),
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user