Metadata-Version: 2.5
Name: make-marketplace
Version: 0.1.0
Summary: VS Code Marketplace tasks for mkrun -- package an extension, check what is published, and cut a release.
Project-URL: Homepage, https://make.optersoft.com
Author-email: "Optersoft, S.L." <david@optersoft.com>
License-Expression: MIT OR Apache-2.0
Keywords: extension,marketplace,mk,mkrun,release,vsce,vscode
Requires-Python: >=3.11
Requires-Dist: mkrun>=0.4
Description-Content-Type: text/markdown

# make-marketplace

VS Code Marketplace tasks for [`mkrun`](https://pypi.org/project/mkrun/):
build an extension's `.vsix`, see what is already published, check that this machine is
allowed to publish at all, and cut a release that ends on the Marketplace.

Three extensions ship through it — `optersoft.kotlin-toolchain`, `optersoft.frontage` and
`optersoft.make`, from three repositories with three different builds — which is what has
shaped it: everything an extension has of its own is a hook, and everything else is here
because it was identical in all three.

⚠ `make-marketplace` is **not on PyPI yet**, and there is no git source to name instead:
the repository it lived in is local only. Until it is released, a consumer reaches it
through a `path` in a gitignored `.make/sources.toml` pointing at a checkout beside its own.

```python
# Makefile.py
# /// script
# requires-python = ">=3.11"
# dependencies = ["mkrun>=0.4", "make-marketplace>=0.1"]
#
# ///
from make import task
from make_marketplace import marketplace

marketplace.Marketplace.configure(
    root="editors",                   # the directory holding extension directories
    paths=["editors/vscode"],         # what must be committed to release
    tag_prefix="editor-v",            # only if `v*` already belongs to something else
    entra_tenant="…",                 # required tenant; a token from another is refused
    entra_object_id="…",
)


@task(name="gate", group="marketplace", override=True)
def gate(ext: str = "") -> None:
    """The repo's own tests. `release` runs this, and refuses to guess what it is."""
    test(ext)
```

```
mk marketplace.entra                can this machine publish? (sends nothing)
mk marketplace.package [EXT]        build the .vsix
mk marketplace.published [EXT]      what is already on the Marketplace
mk marketplace.deploy [VERSION]     publish what is built — NOT undoable
mk marketplace.release VERSION      version, changelog, build, tag, publish
```

## The one design decision

**No token exists anywhere**, and that is the point. `vsce publish --azure-credential`
signs in as the person at the keyboard: reading `vsce`'s own `src/auth.ts` settles what
every write-up leaves vague — it builds a **ChainedTokenCredential** of Environment →
**AzureCli** → ManagedIdentity → AzurePowerShell → AzureDeveloperCli for the Azure DevOps
resource, so an `az login` is the whole credential. No PAT, no secret in a repository, no
subscription, no managed identity, no federated credential; all of that CI-shaped setup in
Microsoft's documentation exists to give a *machine* an identity, which is a different
problem. And it is the only route that survives **2026-12-01**, when global Azure DevOps
PATs retire.

⚠ **The cost is real and is not hidden: a laptop can send a version that can never be
undone.** This package used to refuse to publish at all — the credential was a `VSCE_PAT`
on a GitHub environment and a release was a *push*, so no laptop could. That design went
with the repositories it rested on: two of the three extensions here have no remote now.
What replaces it is a preflight that refuses, cheapest check first, and a `release` that
does everything recoverable *before* the one irreversible step:

| | |
|---|---|
| the version | semver, or the Marketplace rejects it after the work is done |
| the tree | clean, in `paths` |
| the branch | `branch`, because the listing should describe it |
| the tag | unused, here and on a remote that answers |
| `marketplace.preflight` | the repo's own refusals, if it has any |
| the changelog | has a `## [Unreleased]` section — checked **before** anything is written |
| the version, again | not already on the Marketplace |
| the identity | `az` resolves a token **and** the publisher accepts it |
| `marketplace.gate` | the repo's tests |

Then: the version, the changelog, the build, the commit, the tag — and only then the send.
A failed publish therefore leaves a tree that says exactly what was meant to ship, and
`mk marketplace.deploy` retries it; the other order leaves a published version with
nothing in the history describing it.

`publish="ci"` keeps the old design for a repository that still has CI and prefers it: the
tag is the release, a job holds the `VSCE_PAT`, and `marketplace.verify-token` asks that
job whether its token works. Nothing in the fleet uses it today.

## Three things that are not obvious

**A published version is permanent.** It cannot be replaced, withdrawn or
re-uploaded — only superseded by a higher one. `0.2.0` is the one and only shot
at `0.2.0`. That single sentence is why the preflight is as long as it is, and
why `published_versions` spends one HTTP call rather than letting CI find out.

**Identity and authorization fail separately, and only one of them is about you.**
`az account get-access-token` answering proves who you are; it says nothing about whether
the publisher accepts you, and a publish that gets that far fails with `Access Denied ...
Publish new extensions to an existing publisher`. ⚠ `vsce verify-pat` takes
`--azure-credential` and is the one read-only way to ask the second question — `vsce ls`
does **not** take the flag, which is what sends people hunting for one. And ⚠ an Azure
DevOps ORGANISATION named X grants nothing on the Marketplace PUBLISHER named X, while
adding a member by an address two identities share throws `TF14045: identity could not be
found` — add by user id. `marketplace.entra` runs both halves and writes nothing.

**One address can be two accounts, and the CLI default can be the wrong tenant.** A company
address that is both a personal Microsoft account and a work (Entra) one can make an `az`
token request ambiguous because the CLI's cache is keyed on the username
(Azure/azure-cli#20168). Even when token resolution succeeds, the selected default can belong
to another tenant; `vsce --azure-credential` then uses that identity too. `entra_tenant` is
therefore checked against the tenant that issued the token *before* publisher membership is
tested. The remedy preserves other login state: copy the Azure CLI config to a private
`AZURE_CONFIG_DIR`, select the intended account there with `az account set`, and run the check
and release with that same environment. Do not globally clear the shared cache.

**An environment secret is invisible to `gh secret list --repo`** (`publish="ci"` only).
It prints an empty list, which reads exactly like "no token configured" — a false negative
that once blocked a release whose token was there all along. `secret_names` asks both
scopes.

## Hooks

`marketplace.build` is what a release ships: one untargeted `.vsix` by default. The Kotlin
extension overrides it to build **six**, one per platform, each carrying a `kotlin-lsp`
binary; frontage's overrides it to `npm install` first, because its `node_modules` ships
inside the VSIX. (⚠ That last one is decided from `package.json`: an extension that
declares a runtime dependency is packaged **without** `--no-dependencies`, or it installs
cleanly and then fails at activation with `Cannot find module` — a VSIX that is built,
valid and broken.)

`marketplace.gate` is `abstract=True`: it lists as unimplemented and refuses to
run with a message saying what to write, rather than this package deciding what
"tested" means for a repo it knows nothing about.

`marketplace.preflight` does nothing by default and exists for refusals that are
nobody else's business. `optersoft/kotlin` uses it to require a tree that has
been run on a real Windows desktop — Node cannot start a `.bat` since the fix
for CVE-2024-27980, which shipped two broken releases with every test green.

## Scope

The Visual Studio Marketplace only. **Open VSX** — what VSCodium, Cursor, Gitpod and the
other non-Microsoft builds read — is not published from here: a different registry, a
different tool (`ovsx`), a different credential, and a namespace that has to be claimed
first. When a second extension wants it, it belongs here beside the rest.
