Skip to content

SP-874: Add single package import command#369

Open
Zgjim Haziri (ZgjimHaziri) wants to merge 3 commits into
mainfrom
SP-874-add-single-package-import-command
Open

SP-874: Add single package import command#369
Zgjim Haziri (ZgjimHaziri) wants to merge 3 commits into
mainfrom
SP-874-add-single-package-import-command

Conversation

@ZgjimHaziri
Copy link
Copy Markdown
Contributor

Description

Adds a new config package import command for importing a single package — the CLI counterpart to the new pacman single-package import API (POST /pacman/api/core/staging/packages/import-file).

How it was done:

  • Added it under a new config package subgroup instead of overloading the existing batch config import. The two use different, non-interchangeable archive formats (the batch archive has nested per-package zips + manifest; the single-package format is a flat package.json + nodes/), so keeping them separate avoids confusing the workflows.
  • The command imports from a package zip (--file) or a directory (--directory, which the CLI flat-zips before upload), with an --overwrite flag and optional --json output. A 4 GB uncompressed guard is enforced on the archive.
  • Reframed the config docs and CLI help so the package commands read as the default for working with a package, and the batch commands are presented as their own batch-specific set whose artifacts don't mix with the single-package format.

Relevant links

Checklist

  • I have self-reviewed this PR
  • I have tested the change and proved that it works in different scenarios (unit tests cover file/directory imports, overwrite, JSON output, and the validation/error paths; full suite green)
  • I have updated docs if needed

Includes-AI-Code: true

Made with Cursor

Adds the CLI counterpart to the new pacman single-package import API. The
command lives under a new 'config package' subgroup, separate from the existing
batch 'config import', because the two use different, non-interchangeable
archive formats. Supports importing from a package zip (--file) or a directory
(--directory, flat-zipped by the CLI), with --overwrite and optional --json
output. Config docs and CLI help updated to frame the batch commands as their
own batch-specific set.

Includes-AI-Code: true
Co-authored-by: Cursor <cursoragent@cursor.com>
@ZgjimHaziri Zgjim Haziri (ZgjimHaziri) changed the title SP-874: add 'config package import' command for single-package import SP-874: Add single package import command Jun 4, 2026
@ZgjimHaziri Zgjim Haziri (ZgjimHaziri) marked this pull request as ready for review June 5, 2026 12:09
…fixes)

Mark injected members as readonly and use node: import prefixes for built-in
modules. The single-package-import test mocks node:fs explicitly so the temp
file cleanup is intercepted (the global fs mock only covers the bare specifier).

Includes-AI-Code: true
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment on lines +70 to +71
.option("-f, --file <file>", "Package zip file (relative path)")
.option("-d, --directory <directory>", "Package directory (relative path)")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that could make the interface a bit simpler, could be a source paramter that replaces both file and directory, and could be either a zip file or a directory and is resolved internally by the tool to determine its type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the explicit options a bit more, since it's more clear what the options are. Let's see what the others think, and we can decide based on that.

Comment thread docs/user-guide/config-commands.md Outdated

`config package import` imports a package from a package zip (or directory). Unlike [`config import`](#batch-import-packages) — which performs a **batch** import and expects the multi-package batch archive (`manifest.json`, a top-level `variables.json`, `studio.json`, and a nested `<packageKey>_<version>.zip` per package) — `config package import` takes a plain, flat package layout and imports it on its own.

> A zip produced by `config export` is a **batch archive** and cannot be imported with `config package import`. Likewise, a package zip cannot be imported with `config import`. Use the command that matches how the artifact was produced.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A zip produced by config export is a batch archive and cannot be imported with config package import.

I'm not sure I understand what this means? Can you explain?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Batch artifact, would be the right word. This means that if you export via config export, you cannot import via config package import. Because the structure of the former batch one, is different from the latter single import.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change it then.

Comment thread docs/user-guide/config-commands.md Outdated
content-cli config package import -p <sourceProfile> -f <file path> --overwrite
```

When overwriting, variable assignments whose key is no longer declared in the imported `package.json` are pruned, keeping declarations and assignments consistent.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When overwriting, variable assignments whose key is no longer declared in the imported package.json are pruned

Can we say ingored, instead of pruned?

.action(this.batchImportPackages);

const packageCommand = configCommand.command("package")
.description("Commands for working with a package.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.description("Commands for working with a package.");
.description("Commands for working with a single package.");

- Rename "batch archive" to "batch artifact" in config-commands docs
- Describe overwritten, undeclared variable assignments as "ignored"
- Clarify the 'config package' group description (single package)

Includes-AI-Code: true
Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 8, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants