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

TA-2807: Batch export/import fixes and release #170

Merged
merged 4 commits into from
Mar 5, 2024
Merged
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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celonis/content-cli",
"version": "0.7.0",
"version": "0.8.0",
"description": "CLI Tool to help manage content in Celonis EMS",
"main": "content-cli.js",
"bin": {
Expand Down
12 changes: 5 additions & 7 deletions src/content-cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export class Config {

public static listVariables(program: CommanderStatic): CommanderStatic {
program
.command("listVariables")
.command("variables")
.description("Commands related to variable configs")
.command("list")
.description("Command to list versioned variables of packages")
.option("-p, --profile <profile>", "Profile which you want to use to list packages")
.option("--json", "Return response as json type", "")
Expand All @@ -43,7 +45,7 @@ export class Config {
program
.command("export")
.description("Command to export package configs")
.option("-p, --profile <profile>", "Profile which you want to use to list packages")
.option("-p, --profile <profile>", "Profile which you want to use to export packages")
.requiredOption("--packageKeys <packageKeys...>", "Keys of packages to export")
.option("--withDependencies", "Include variables and dependencies", "")
.action(async cmd => {
Expand All @@ -70,10 +72,6 @@ export class Config {
}
}

process.on("unhandledRejection", (e, promise) => {
logger.error(e.toString());
});

const loadAllCommands = () => {
Config.list(commander);
Config.listVariables(commander);
Expand All @@ -83,7 +81,7 @@ const loadAllCommands = () => {
};

ContextInitializer.initContext()
.then(loadAllCommands)
.then(loadAllCommands, loadAllCommands)
.catch(e => {
logger.error(e);
});
Expand Down
6 changes: 1 addition & 5 deletions src/content-cli-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ export class List {
}
}

process.on("unhandledRejection", (e, promise) => {
logger.error(e.toString());
});

const loadAllCommands = () => {
List.packages(commander);
List.spaces(commander);
Expand All @@ -115,7 +111,7 @@ const loadAllCommands = () => {
};

ContextInitializer.initContext()
.then(loadAllCommands)
.then(loadAllCommands, loadAllCommands)
.catch(e => {
logger.error(e);
});
Expand Down
10 changes: 6 additions & 4 deletions src/content-cli-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ class Set {
}
}

const loadAllCommands = () => {
Set.connection(commander);
commander.parse(process.argv);
};

ContextInitializer.initContext()
.then(() => {
Set.connection(commander);
commander.parse(process.argv);
})
.then(loadAllCommands, loadAllCommands)
.catch(e => {
logger.error(e);
});
Expand Down
2 changes: 1 addition & 1 deletion src/content-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ program.command("get", "Commands to get configuration properties.");

program.command("set", "Commands to set configuration properties.");

program.command("config", "Commands related to config management")
program.command("config", "Commands related to config management.")

program.version(VersionUtils.getCurrentCliVersion());
program.parse(process.argv);
Expand Down
4 changes: 2 additions & 2 deletions src/services/package-manager/variable-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class VariableService {
private async buildKeyVersionPairs(keysByVersion: string[], keysByVersionFile: string): Promise<PackageKeyAndVersionPair[]> {
let variablesExportRequest: PackageKeyAndVersionPair[] = [];

if (keysByVersion.length) {
if (keysByVersion.length !== 0) {
variablesExportRequest = this.buildKeyAndVersionPairsFromArrayInput(keysByVersion);
} else if (!keysByVersion.length && keysByVersionFile.length) {
} else if (keysByVersion.length === 0 && keysByVersionFile !== "") {
variablesExportRequest = await fileService.readFileToJson(keysByVersionFile);
} else {
throw new FatalError("Please provide keysByVersion mappings or file path!");
Expand Down
2 changes: 1 addition & 1 deletion tests/config/config-list-variables.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe("Config listVariables", () => {
expect(variableExportRequest).toEqual(packageKeyAndVersionPairs);
})

it("Should throw error if no mapping or file path is provided", async () => {
it("Should throw error if no mapping and no file path is provided", async () => {
try {
await new ConfigCommand().listVariables(true, [], "");
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions tests/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const mockWriteSync = jest.fn();
(fs.writeSync as jest.Mock).mockImplementation(mockWriteSync);

afterEach(() => {
mockWriteFileSync.mockClear();
mockWriteSync.mockClear();
jest.clearAllMocks();
})

beforeAll(() => {
Expand All @@ -25,6 +24,7 @@ beforeAll(() => {
let testTransport;

beforeEach(() => {
jest.clearAllMocks();
testTransport = new TestTransport({})
logger.add(testTransport);
})
Expand Down
Loading