-
Notifications
You must be signed in to change notification settings - Fork 4
SP-957: move Team-to-Team Copy commands to 't2tc package' group #370
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b804c13
SP-874: add 'config package import' command for single-package import
ZgjimHaziri c01de65
SP-874: address Sonar code smells (readonly members, node: import pre…
ZgjimHaziri c3212a5
SP-957: move Team-to-Team Copy package commands to 't2tc package' group
ZgjimHaziri a459dfc
SP-957: keep agentic dev guide on config export/import commands
ZgjimHaziri ec58421
SP-957: extract t2tc module and split config batch services by domain
ZgjimHaziri 2e38590
SP-957: add CODEOWNERS entry for t2tc command group
ZgjimHaziri 4e040e2
SP-874: address PR feedback on wording and package description
ZgjimHaziri 8962ebf
Merge branch 'SP-874-add-single-package-import-command' into SP-957-t…
ZgjimHaziri 7cc6ae0
Merge branch 'main' into SP-957-t2tc-command-group
ZgjimHaziri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,211 @@ | ||
| # Team-to-Team Copy (T2TC) Commands | ||
|
|
||
| The `t2tc package` command group moves whole packages — and, optionally, their dependencies and variables — between teams and realms. These commands power the **Team-to-Team Copy** feature: the T2TC backend drives the copy by exporting from a source team and importing into a target team through this CLI. | ||
|
|
||
| These commands are a **self-contained, batch-specific set**. `t2tc package export` produces a multi-package **batch archive**, and only the other `t2tc package` commands (`import`, `diff`) understand that archive. It is **not** interchangeable with the package format used by [`config package import`](./config-commands.md#package-commands-config-package) (see [Batch archive vs. package format](#batch-archive-vs-package-format)). | ||
|
|
||
| > **Migrating from `config`?** `t2tc package list/export/import/diff` replace the deprecated `config list/export/import/diff` commands. The flags and behaviour are identical — only the command path changed. | ||
|
|
||
| | Old (deprecated) | New | | ||
| |---|---| | ||
| | `config list` | `t2tc package list` | | ||
| | `config export` | `t2tc package export` | | ||
| | `config import` | `t2tc package import` | | ||
| | `config diff` | `t2tc package diff` | | ||
|
|
||
| ## Permissions | ||
|
|
||
| `t2tc package` commands run against the Pacman API and are subject to the same permission checks the platform applies in the UI. The required permission depends on the **flavor** of the target package: | ||
|
|
||
| | Package flavor | Required permission | | ||
| |---|---| | ||
| | **Studio** (Studio packages and their assets) | **Edit package** permission on the package | | ||
| | **OCDM** (OCDM packages and their assets) | **Edit** (admin) permission on the **data pool** the OCDM package is connected to | | ||
|
|
||
| `t2tc package list` is the one exception: instead of failing, it **filters out packages the profile does not have permission to access**. If a package you expect to see is missing from the list, the most likely cause is missing edit permission on the package (Studio) or on its connected data pool (OCDM). | ||
|
|
||
| ## Batch archive vs. package format | ||
|
|
||
| `t2tc package export` produces a multi-package **batch archive** — a top-level `manifest.json`, `variables.json`, `studio.json`, and one nested `<packageKey>_<version>.zip` per package — that is produced and consumed **only** by the `t2tc package` commands. [`config package import`](./config-commands.md#package-commands-config-package), by contrast, works with a plain **package zip** (a `package.json`, an optional `variables.json`, and a `nodes/` folder). The two formats are **not interchangeable**: | ||
|
|
||
| - An archive from `t2tc package export` can be imported with `t2tc package import` or inspected with `t2tc package diff` — but **not** with `config package import`. | ||
| - A package zip used by `config package import` **cannot** be imported with `t2tc package import` or diffed with `t2tc package diff`. | ||
|
|
||
| Reach for `t2tc package` only for its specific bulk use-case — moving a set of packages together (for example, a migration between teams). To work with a single package, use [`config package import`](./config-commands.md#package-commands-config-package). | ||
|
|
||
| ## List Packages | ||
|
|
||
| Packages can be listed using the following command: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package list -p <sourceProfile> | ||
| ``` | ||
|
|
||
| The result will be printed in the console containing only the package name and key: | ||
|
|
||
| ```bash | ||
| info: Package1 - Key: "package-1" | ||
| ``` | ||
|
|
||
| By using the `--json` option, packages can be exported (saved) in an extended form as a json file in the current working directory. | ||
|
|
||
| ```bash | ||
| content-cli t2tc package list -p <sourceProfile> --json | ||
| ``` | ||
|
|
||
| The name of the file will be printed in the console with the following format: | ||
|
|
||
| ```bash | ||
| info: File downloaded successfully. New filename: 9560f81f-f746-4117-83ee-dd1f614ad624.json | ||
| ``` | ||
|
|
||
| By using the `--flavors` option, you can filter which packages to list. The available flavors are: **STUDIO** and **OCDM**. | ||
|
|
||
| To list staging packages instead of deployed packages use the `--staging` option. Please note that this flag is not compatible with the below options. | ||
|
|
||
| > For day-to-day staging listing outside the copy workflow, prefer [`config package list`](./config-commands.md#list-packages-config-package-list), which lists staging packages by default. | ||
|
|
||
| ### List Packages with Dependencies | ||
|
|
||
| When using the listing command with the `--json` option, two additional options are available: | ||
|
|
||
| - **--withDependencies**: This option will include the dependencies of the packages in the output. | ||
|
|
||
| ```bash | ||
| content-cli t2tc package list -p <sourceProfile> --withDependencies | ||
| ``` | ||
|
|
||
| - **--packageKeys**: This option allows you to filter the packages by their keys. You can specify multiple package keys separated by spaces. | ||
|
|
||
| ```bash | ||
| content-cli t2tc package list -p <sourceProfile> --packageKeys key1 ... keyN | ||
| [optional] --withDependencies | ||
| ``` | ||
|
|
||
| ## Export Packages | ||
|
|
||
| Packages can be exported using the following command: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package export -p <sourceProfile> --packageKeys key1 ... keyN | ||
| ``` | ||
|
|
||
| The `--keysByVersion` option can be used to export packages by specific version. You can specify multiple packages with version separated by spaces, in the format of 'packageKey.version'. | ||
| The `--withDependencies` option can be used to also export dependencies of the given packages. | ||
| The `--unzip` option can be used to unzip the exported packages into the current working directory. | ||
|
|
||
| Depending on the `--unzip` option used, a zip file, or a directory containing the exported packages, will be created in the current working directory containing: | ||
|
|
||
| ```bash | ||
| exported_package_random_uuid/ | ||
| ├─ manifest.json | ||
| ├─ variable.json | ||
| ├─ studio.json | ||
| ├─ package_key1-version.zip | ||
| ├─ ... | ||
| ├─ package_keyN-version.zip | ||
| ``` | ||
|
|
||
| ### Git Integration for Export | ||
|
|
||
| The following **Git options** are available: | ||
|
|
||
| - `--gitProfile <gitProfileName>` – specifies the Git profile to use for exporting directly to a repository. | ||
| If not specified, the default profile will be used. | ||
| - `--gitBranch <branchName>` – specifies the branch in the Github repository where the export will be pushed. | ||
|
|
||
| Example exporting to Git: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package export -p <sourceProfile> --packageKeys key1 key2 --gitProfile myGitProfile --gitBranch feature-branch | ||
| ``` | ||
|
|
||
| ### Export Directory Structure | ||
|
|
||
| - manifest.json - File which contains the metadata of the exported packages. | ||
| - studio.json - File which contains the metadata of the exported packages in a format compatible with Studio. | ||
| - variables.json - File which contains the variables of the exported packages. | ||
| - exported packages directories - Directories containing the exported package files, each directory is named after the package key and the version. | ||
|
|
||
| Inside each exported package directory, the following files will be present: | ||
|
|
||
| - package.json - File which contains the configuration of the exported package. | ||
| - nodes/ - Directory containing the nodes of the exported package. | ||
|
|
||
| Inside the nodes directory, a file for each node will be present: | ||
|
|
||
| - node_key.json - File which contains the configuration of the exported node. | ||
|
|
||
| ## Import Packages | ||
|
|
||
| Packages can be imported using the following commands, if importing from a zip file: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package import -p <sourceProfile> -f <relative exported zip file path> | ||
| ``` | ||
|
|
||
| Where `-f` is the short hand operation for `--file`. | ||
| If importing from a directory containing the exported packages, the following command can be used: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package import -p <sourceProfile> -d <relative exported directory file path> | ||
| ``` | ||
|
|
||
| Where `-d` is the shorthand operation for `--directory`. | ||
| When packages with the same keys exist in the target team, the `--overwrite` option can be used for allowing overwriting of those packages. If the package in target environment contains unpublished changes, they are automatically saved under a new version. This allows you to audit, compare, or roll back to your previous state via the version history if needed. | ||
|
|
||
| ```bash | ||
| content-cli t2tc package import -p <sourceProfile> -f <file path> --overwrite | ||
| ``` | ||
|
|
||
| ### Git Integration for Import | ||
|
|
||
| The following **Git options** are available: | ||
|
|
||
| - `--gitProfile <gitProfileName>` – specifies the Git profile to use for importing directly from a repository. | ||
| If not specified, the default profile will be used. | ||
| - `--gitBranch <branchName>` – specifies the branch in the Github repository from which to import. | ||
|
|
||
| Example importing from Git: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package import -p <sourceProfile> --gitProfile myGitProfile --gitBranch feature-branch | ||
| ``` | ||
|
|
||
| Finally, the result of this command will be a list of PostPackageImportData exported as a json file. The file name will be printed with the following message format: | ||
|
|
||
| ```bash | ||
| info: Config import report file: 9560f81f-f746-4117-83ee-dd1f614ad624.json | ||
| ``` | ||
|
|
||
| ### Validate During Import | ||
|
|
||
| Add `--validate` to `t2tc package import` to run validation against each node **before** the import is committed: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package import -p <sourceProfile> -d <export_dir> --validate --overwrite | ||
| ``` | ||
|
|
||
| `t2tc package import --validate` runs the **SCHEMA** layer only. It does **not** run BUSINESS-layer checks (PQL parsing, data-model availability, KPI uniqueness, etc.) or PACKAGE_SETTINGS checks (package dependencies, variables, and flavor-specific package settings). To run those validations, use [`config package validate`](./config-commands.md#validate-package-configurations-config-package-validate) after the import. | ||
|
|
||
| ## Diff local zip with deployed version/specific version/staging | ||
|
|
||
| To compare local zipped packages with online packages use: | ||
|
|
||
| ```bash | ||
| content-cli t2tc package diff --file <file> | ||
| ``` | ||
|
|
||
| As with other commands, use `--json` to export the diff to a file. | ||
| To diff against a specific version use the `--baseVersion` parameter. When omitted it will diff against the current deployed version. | ||
| To diff against staging use `--baseVersion STAGING`. | ||
|
|
||
| ```bash | ||
| content-cli t2tc package diff --file <file> --baseVersion <version> | ||
| ``` | ||
|
|
||
| To diff against the current deployed version and only return whether there are any changes, use the `--hasChanges` flag. | ||
|
|
||
| ```bash | ||
| content-cli t2tc package diff --file <file> --hasChanges | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { PackageMetadataExportTransport } from "../interfaces/package-export.interfaces"; | ||
| import { FatalError } from "../../../core/utils/logger"; | ||
| import { HttpClient } from "../../../core/http/http-client"; | ||
| import { Context } from "../../../core/command/cli-context"; | ||
|
|
||
| export class MetadataApi { | ||
|
|
||
| private readonly httpClient: () => HttpClient; | ||
|
|
||
| constructor(context: Context) { | ||
| this.httpClient = () => context.httpClient; | ||
| } | ||
|
|
||
| public async exportPackagesMetadata(packageKeys: string[]): Promise<PackageMetadataExportTransport[]> { | ||
| const queryParams = new URLSearchParams(); | ||
| packageKeys.forEach(packageKey => queryParams.append("packageKeys", packageKey)); | ||
|
|
||
| return this.httpClient().get(`/package-manager/api/core/packages/metadata/export?${queryParams.toString()}`).catch(e => { | ||
| throw new FatalError(`Problem exporting packages metadata: ${e}`); | ||
| }) | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/commands/configuration-management/api/staging-package-api.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { PackageExportTransport } from "../interfaces/package-export.interfaces"; | ||
| import { FatalError } from "../../../core/utils/logger"; | ||
| import { HttpClient } from "../../../core/http/http-client"; | ||
| import { Context } from "../../../core/command/cli-context"; | ||
|
|
||
| export class StagingPackageApi { | ||
|
|
||
| private readonly httpClient: () => HttpClient; | ||
|
|
||
| constructor(context: Context) { | ||
| this.httpClient = () => context.httpClient; | ||
| } | ||
|
|
||
| public async findAllStagingPackages(flavors: string[], includeBranches: boolean = false): Promise<PackageExportTransport[]> { | ||
| const queryParams = new URLSearchParams(); | ||
|
|
||
| queryParams.set("includeBranches", includeBranches.toString()); | ||
| flavors.forEach(flavor => queryParams.append("flavors", flavor)); | ||
|
|
||
| return this.httpClient().get(`/pacman/api/core/staging/packages/export/list?${queryParams.toString()}`).catch(e => { | ||
| throw new FatalError(`Problem getting staging packages: ${e}`); | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { PackageKeyAndVersionPair, VariableManifestTransport } from "../interfaces/package-export.interfaces"; | ||
| import { FatalError } from "../../../core/utils/logger"; | ||
| import { HttpClient } from "../../../core/http/http-client"; | ||
| import { Context } from "../../../core/command/cli-context"; | ||
|
|
||
| export class VariableApi { | ||
|
|
||
| private readonly httpClient: () => HttpClient; | ||
|
|
||
| constructor(context: Context) { | ||
| this.httpClient = () => context.httpClient; | ||
| } | ||
|
|
||
| public async findVariablesWithValuesByPackageKeysAndVersion(packagesByKeyAndVersion: PackageKeyAndVersionPair[]): Promise<VariableManifestTransport[]> { | ||
| return this.httpClient().post("/package-manager/api/core/packages/export/batch/variables-with-assignments", packagesByKeyAndVersion).catch(e => { | ||
| throw new FatalError(`Problem exporting package variables: ${e}`); | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.