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

PAD-2120: added packageKeys parameter to listing command #142

Merged
merged 2 commits into from
Aug 10, 2023
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
4 changes: 3 additions & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,12 @@ The command takes your permissions into consideration and only lists the
packages you have access to. 

- It is also possible to download packages in JSON format by adding '--json' option.
- It is also possible to include package dependencies by adding '--includeDependencies' flag
- When the JSON format option is used, also possible to include package dependencies by adding '--includeDependencies' flag
- When the JSON format option is used, also possible to filter packages by adding '--packageKeys' parameter

```
content-cli list packages -p <your-chosen-profile>
content-cli list packages -p <profileName> --json --packageKeys <package1> <package2>
```

### List all data pools of the team
Expand Down
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.4.4",
"version": "0.4.5",
"description": "CLI Tool to help manage content in Celonis EMS",
"main": "content-cli.js",
"bin": {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export class PackageCommand {
await this.contentService.batchPush(profile, this.packageManagerFactory.createPushManagers(spaceKey));
}

public async listPackages(jsonResponse: boolean, includeDependencies: boolean): Promise<void> {
public async listPackages(jsonResponse: boolean, includeDependencies: boolean, packageKeys:string[]): Promise<void> {
if (jsonResponse) {
await packageService.findAndExportListOfAllPackages(includeDependencies);
await packageService.findAndExportListOfAllPackages(includeDependencies, packageKeys ?? []);
} else {
await packageService.listPackages();
}
Expand Down
3 changes: 2 additions & 1 deletion src/content-cli-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export class List {
.option("-p, --profile <profile>", "Profile which you want to use to list packages")
.option("--json", "Return response as json type", "")
.option("--includeDependencies", "Include variables and dependencies", "")
.option("--packageKeys <packageKeys...>", "Lists only given package keys")
.action(async cmd => {
await new PackageCommand().listPackages(cmd.json, cmd.includeDependencies)
await new PackageCommand().listPackages(cmd.json, cmd.includeDependencies, cmd.packageKeys)
process.exit();
});

Expand Down
7 changes: 6 additions & 1 deletion src/services/package-manager/package-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ class PackageService {
});
}

public async findAndExportListOfAllPackages(includeDependencies: boolean): Promise<void> {
public async findAndExportListOfAllPackages(includeDependencies: boolean, packageKeys:string[]): Promise<void> {
const fieldsToInclude = ["key", "name", "changeDate", "activatedDraftId", "spaceId"];

let nodesListToExport: BatchExportNodeTransport[] = await packageApi.findAllPackages();
if (packageKeys.length > 0) {
nodesListToExport = nodesListToExport.filter(node => {
return packageKeys.includes(node.rootNodeKey);
})
}

if (includeDependencies) {
fieldsToInclude.push("type", "value", "dependencies", "id", "updateAvailable", "version", "poolId", "node", "dataModelId", "dataPool", "datamodels");
Expand Down
Loading