Skip to content
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
12 changes: 7 additions & 5 deletions docs/user-guide/config-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ content-cli config versions get --packageKey <packageKey> --packageVersion <pack
To create a new version for a package, use the following command:

```bash
content-cli config versions create --packageKey <packageKey> --version <version>
content-cli config versions create --packageKey <packageKey> --packageVersion <packageVersion>
```

For example, to create version 1.2.0 with a summary of changes:

```bash
content-cli config versions create --packageKey my-package --version 1.2.0 --summaryOfChanges "Added new analysis views"
content-cli config versions create --packageKey my-package --packageVersion 1.2.0 --summaryOfChanges "Added new analysis views"
```

The command will display the created version details in the console:
Expand All @@ -263,22 +263,24 @@ Instead of specifying an explicit version, you can use `--versionBumpOption PATC
content-cli config versions create --packageKey my-package --versionBumpOption PATCH --summaryOfChanges "Bug fixes"
```

When using `--versionBumpOption PATCH`, the `--version` option is ignored and the patch version is automatically incremented. The default value for `--versionBumpOption` is `NONE`, which requires the `--version` option to be provided.
When using `--versionBumpOption PATCH`, the `--packageVersion` option is ignored and the patch version is automatically incremented. The default value for `--versionBumpOption` is `NONE`, which requires the `--packageVersion` option to be provided.

Note: You must provide either `--packageVersion` or `--versionBumpOption PATCH`, but not both.

#### Node Filter

By default, all nodes in the package are included in the created version. To selectively include only specific nodes, use the `--nodeFilterKeys` option:

```bash
content-cli config versions create --packageKey my-package --version 2.0.0 --nodeFilterKeys node-key-1 node-key-2
content-cli config versions create --packageKey my-package --packageVersion 2.0.0 --nodeFilterKeys node-key-1 node-key-2
```

#### Export Created Version as JSON

To export the created version response as a JSON file instead of displaying it in the console, use the `--json` option:

```bash
content-cli config versions create --packageKey <packageKey> --version <version> --json
content-cli config versions create --packageKey <packageKey> --packageVersion <packageVersion> --json
```

## Finding Nodes
Expand Down
10 changes: 5 additions & 5 deletions src/commands/configuration-management/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Module extends IModule {
configVersionCommand.command("create")
.description("Create a new version for a package")
.requiredOption("--packageKey <packageKey>", "Identifier of the package")
.option("--version <version>", "Version string (required if versionBumpOption is NONE)")
.option("--packageVersion <packageVersion>", "Version string (required if versionBumpOption is NONE)")
.option("--versionBumpOption <versionBumpOption>", "Version bump option: NONE or PATCH", "NONE")
.option("--summaryOfChanges <summaryOfChanges>", "Summary of changes for this version")
.option("--nodeFilterKeys <nodeFilterKeys...>", "Node keys to include in the version. If omitted, all nodes of the package are included.")
Expand Down Expand Up @@ -171,19 +171,19 @@ class Module extends IModule {
}

private async createPackageVersion(context: Context, command: Command, options: OptionValues): Promise<void> {
const hasExplicitVersion = !!options.version;
const hasExplicitVersion = !!options.packageVersion;
const hasVersionBump = options.versionBumpOption && options.versionBumpOption !== "NONE";

if (hasExplicitVersion && hasVersionBump) {
throw new Error("Please provide either --version or --versionBumpOption, but not both.");
throw new Error("Please provide either --packageVersion or --versionBumpOption, but not both.");
}
if (!hasExplicitVersion && !hasVersionBump) {
throw new Error("Please provide either --version or --versionBumpOption PATCH.");
throw new Error("Please provide either --packageVersion or --versionBumpOption PATCH.");
}

await new PackageVersionCommandService(context).createPackageVersion(
options.packageKey,
options.version,
options.packageVersion,
options.versionBumpOption,
options.summaryOfChanges,
options.nodeFilterKeys,
Expand Down
18 changes: 9 additions & 9 deletions tests/commands/configuration-management/module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,49 +417,49 @@ describe("Configuration Management Module - Action Validations", () => {
(PackageVersionCommandService as jest.MockedClass<typeof PackageVersionCommandService>).mockImplementation(() => mockPackageVersionCommandService);
});

it("should throw error when both --version and --versionBumpOption PATCH are provided", async () => {
it("should throw error when both --packageVersion and --versionBumpOption PATCH are provided", async () => {
const options: OptionValues = {
packageKey: "my-package",
version: "1.2.0",
packageVersion: "1.2.0",
versionBumpOption: "PATCH",
};

await expect(
(module as any).createPackageVersion(testContext, mockCommand, options)
).rejects.toThrow("Please provide either --version or --versionBumpOption, but not both.");
).rejects.toThrow("Please provide either --packageVersion or --versionBumpOption, but not both.");

expect(mockPackageVersionCommandService.createPackageVersion).not.toHaveBeenCalled();
});

it("should throw error when neither --version nor --versionBumpOption PATCH are provided", async () => {
it("should throw error when neither --packageVersion nor --versionBumpOption PATCH are provided", async () => {
const options: OptionValues = {
packageKey: "my-package",
versionBumpOption: "NONE",
};

await expect(
(module as any).createPackageVersion(testContext, mockCommand, options)
).rejects.toThrow("Please provide either --version or --versionBumpOption PATCH.");
).rejects.toThrow("Please provide either --packageVersion or --versionBumpOption PATCH.");

expect(mockPackageVersionCommandService.createPackageVersion).not.toHaveBeenCalled();
});

it("should throw error when --version is missing and --versionBumpOption is not provided (defaults to NONE)", async () => {
it("should throw error when --packageVersion is missing and --versionBumpOption is not provided (defaults to NONE)", async () => {
const options: OptionValues = {
packageKey: "my-package",
};

await expect(
(module as any).createPackageVersion(testContext, mockCommand, options)
).rejects.toThrow("Please provide either --version or --versionBumpOption PATCH.");
).rejects.toThrow("Please provide either --packageVersion or --versionBumpOption PATCH.");

expect(mockPackageVersionCommandService.createPackageVersion).not.toHaveBeenCalled();
});

it("should pass validation when only --version is provided", async () => {
it("should pass validation when only --packageVersion is provided", async () => {
const options: OptionValues = {
packageKey: "my-package",
version: "1.2.0",
packageVersion: "1.2.0",
versionBumpOption: "NONE",
summaryOfChanges: "New features",
};
Expand Down
Loading