@wpelevator/wp-release 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -20
- package/dist/changeset-config.d.ts +8 -6
- package/dist/changeset-config.js +7 -5
- package/dist/changeset-packages.d.ts +12 -2
- package/dist/changeset-packages.js +13 -1
- package/dist/changeset-release.d.ts +5 -2
- package/dist/changeset-release.js +12 -6
- package/dist/cli.js +33 -9
- package/dist/commands/args.d.ts +0 -21
- package/dist/commands/args.js +1 -35
- package/dist/commands/changeset-add.d.ts +1 -1
- package/dist/commands/changeset-add.js +3 -2
- package/dist/commands/changeset-status.d.ts +1 -1
- package/dist/commands/changeset-status.js +2 -1
- package/dist/commands/changeset-tag.d.ts +1 -1
- package/dist/commands/changeset-tag.js +4 -2
- package/dist/commands/changeset-version.d.ts +1 -1
- package/dist/commands/changeset-version.js +2 -1
- package/dist/commands/checksums.js +2 -2
- package/dist/commands/command.d.ts +2 -0
- package/dist/commands/deploy-git.d.ts +1 -1
- package/dist/commands/deploy-git.js +2 -1
- package/dist/commands/deploy-svn.d.ts +1 -1
- package/dist/commands/deploy-svn.js +2 -1
- package/dist/commands/keygen.d.ts +3 -0
- package/dist/commands/keygen.js +6 -1
- package/dist/commands/package-deploys.d.ts +8 -0
- package/dist/commands/package-deploys.js +5 -0
- package/dist/commands/sign.d.ts +19 -1
- package/dist/commands/sign.js +47 -12
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.js +43 -24
- package/dist/commands/zip.d.ts +12 -8
- package/dist/commands/zip.js +135 -78
- package/dist/ed25519.d.ts +25 -0
- package/dist/ed25519.js +44 -0
- package/dist/file-selection.d.ts +21 -0
- package/dist/file-selection.js +35 -0
- package/dist/git.d.ts +17 -0
- package/dist/git.js +23 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +6 -3
- package/dist/minisign.d.ts +41 -0
- package/dist/minisign.js +128 -0
- package/dist/package-deploy.d.ts +28 -0
- package/dist/package-deploy.js +41 -6
- package/dist/package-zip.d.ts +52 -0
- package/dist/package-zip.js +78 -0
- package/dist/release-repository.d.ts +4 -3
- package/dist/release-repository.js +5 -4
- package/dist/signing.d.ts +64 -9
- package/dist/signing.js +113 -40
- package/dist/ssh-signature.d.ts +43 -0
- package/dist/ssh-signature.js +156 -0
- package/dist/summary.d.ts +3 -3
- package/dist/summary.js +2 -2
- package/dist/tag-format.d.ts +21 -12
- package/dist/tag-format.js +25 -39
- package/dist/version-files.d.ts +6 -7
- package/dist/version-files.js +10 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,8 +28,8 @@ npx wp-release --help
|
|
|
28
28
|
|---|---|
|
|
29
29
|
| `wp-release zip [<source-dir>] [options]` | Create a ZIP archive with a `{slug}/` root folder, respecting `.distignore`. |
|
|
30
30
|
| `wp-release checksums [<source-dir>] [options]` | Write the MD5 and SHA-256 hashes of every distributed file to a checksums manifest. |
|
|
31
|
-
| `wp-release sign <file>... [options]` | Sign files with Ed25519, writing a detached `<file>.sig` next to each
|
|
32
|
-
| `wp-release keygen` | Generate a base64 Ed25519 private seed and public key
|
|
31
|
+
| `wp-release sign <file>... [options]` | Sign files with Ed25519, writing a detached `<file>.sig` next to each, or minisign and SSH signatures with `--format`. |
|
|
32
|
+
| `wp-release keygen` | Generate a base64 Ed25519 private seed and its public key, also as minisign and SSH public keys. |
|
|
33
33
|
| `wp-release verify [<source-dir>] --checksums <file> [options]` | Check a plugin or theme directory, or a ZIP, against a checksums manifest. |
|
|
34
34
|
| `wp-release version-check [<source-dir>] [options]` | Check that the `Version` header, readme `Stable tag`, PHP constants and git tag agree. |
|
|
35
35
|
| `wp-release deploy-svn [<source-dir>] [options]` | Deploy a plugin to the WordPress.org plugin SVN repository. |
|
|
@@ -67,7 +67,7 @@ Each command also adds a section to the [job summary](https://docs.github.com/en
|
|
|
67
67
|
| `deploy-git` | Repository, release commit and the pushed branch and tag. |
|
|
68
68
|
| `zip` | ZIP, number of files and checksums manifest. |
|
|
69
69
|
| `checksums` | Manifest and number of files. |
|
|
70
|
-
| `sign` | Signature files and the public key. |
|
|
70
|
+
| `sign` | Signature files and the public key of each written format. |
|
|
71
71
|
| `verify` | That all files match, or the counts and a table of the changed, missing and extra files. |
|
|
72
72
|
| `version-check` | The matching version, or a table of the mismatches with their files and lines. |
|
|
73
73
|
| `changeset-status` | Each changed package with whether it has a changeset. |
|
|
@@ -76,7 +76,7 @@ Each command also adds a section to the [job summary](https://docs.github.com/en
|
|
|
76
76
|
|
|
77
77
|
A failed command adds its error to the summary, or a table of its problems with their files and lines, listing up to 100 and counting the rest. The Markdown of the summaries isn't part of the library API. File paths are relative to `GITHUB_WORKSPACE`, or the current directory without it. Files outside it, like those of an extracted ZIP, get an annotation without a file. Multi-line messages stay one annotation.
|
|
78
78
|
|
|
79
|
-
Use global `--config <path>` to select a config; relative paths resolve from the current directory. Otherwise, Changesets commands discover `wp-release.config.js`, `.mjs` or `.cjs` there.
|
|
79
|
+
Use global `--config <path>` to select a config; relative paths resolve from the current directory. Otherwise, Changesets commands discover `wp-release.config.js`, `.mjs` or `.cjs` there. Global `--tag-format <format>` replaces the `tagFormat` of the config for one command, see [Packages and tags](#packages-and-tags).
|
|
80
80
|
|
|
81
81
|
### Changesets support (experimental)
|
|
82
82
|
|
|
@@ -125,13 +125,32 @@ export default defineConfig( {
|
|
|
125
125
|
} );
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
`version.from` selects the current version; `version.to` lists release targets.
|
|
128
|
+
`version.from` selects the current version; `version.to` lists release targets. Use `phpConstantVersion( { file, constant } )` to sync a PHP constant.
|
|
129
|
+
|
|
130
|
+
#### Packages and tags
|
|
131
|
+
|
|
132
|
+
The config describes the repository, so wp-release assumes no directory structure or naming convention of its own:
|
|
133
|
+
|
|
134
|
+
- **Packages** are the directories that the `glob` of a `packages` entry matches under `root`, with `*`, `?` and `**`, like `plugins/*`, or `.` for a repository with one package at its root. The settings of an entry apply to each of its packages. Discovery never looks inside `.git`, `node_modules`, `vendor` or `dist` directories. A package is identified by its path, or with `idFrom` by the name in its `package.json` or `composer.json`, and commands that take a package accept either.
|
|
135
|
+
- **Templates** name the tags and the deploy targets of a package with these placeholders:
|
|
136
|
+
|
|
137
|
+
| Placeholder | Value | `plugins/alpha` | Root package |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| `{path}` | Package directory relative to `root`, empty for a package at the root | `plugins/alpha` | (empty) |
|
|
140
|
+
| `{name}` | Package identifier | `plugins/alpha`, or its manifest name with `idFrom` | the manifest name, or the directory name |
|
|
141
|
+
| `{version}` | Released version | `1.2.0` | `1.2.0` |
|
|
142
|
+
|
|
143
|
+
Deploy templates also have `{branch}`, `{ref}` and `{revision}` (see [Deploy configured packages](#deploy-configured-packages)), and any template can be a callback that receives the package, for names that the placeholders don't cover, like the last directory of the path.
|
|
144
|
+
- **`tagFormat`** names the release tags, `{path}/{version}` by default, like `plugins/alpha/1.2.0`. Empty placeholders leave no leading or repeated slashes in a tag, so a package at the root gets plain version tags, like `1.2.0`, from the same default. Deploy templates, like repository URLs, are filled in as they are. A `gitTagVersion()` version source reads the tags with its own `pattern`, also `{path}/{version}` by default, so set both when you change the format.
|
|
145
|
+
- **`--tag-format <format>`** replaces the `tagFormat` of the config for one command, for a workflow or job that names its tags differently, like `--tag-format '{name}@{version}'`. Every command that creates or reads the same tags needs the same format: `changeset-tag`, which creates them and finds the previous tag for the release notes, `changeset-version --prerelease`, which numbers pre-releases from them, and `deploy-git` and `deploy-svn --release-ref`, which read the package and version of a tag.
|
|
146
|
+
- **Slugs** are a WordPress concept: the folder of a plugin or theme. Only the commands that produce something for WordPress use one: the `{slug}/` root folder and name of a `zip`, the `checksums` manifest, the WordPress.org slug of `deploy-svn`, and `version-check`. Each takes `--slug`, which defaults to the name of the current directory, or of the package directory with `zip --package`, and an SVN deploy target takes `slug`, which defaults to the name of the package directory. Tags and Git deploy targets don't have a slug.
|
|
147
|
+
- **`remote`** is the git remote that `changeset-tag --push` pushes tags to and that the base branch is compared on, `origin` by default.
|
|
129
148
|
|
|
130
149
|
The default strategy bumps stable `x.y.z` versions with SemVer rules, and the `x.y` and `x.y.z.w` versions common in WordPress plugins the same way: the bumped part is raised, the parts after it reset to `0`, and the version keeps its number of parts. A minor bump of `2.1` is `2.2` and a major bump is `3.0`, while a patch bump adds the third part, `2.1.1`. A patch bump of `1.2.3.4` is `1.2.4.0`, so raising only the fourth part needs a custom strategy. Configure `nextVersion( { package, bump, currentVersion, changesets } )` for other formats; changeset bumps remain `patch`, `minor` or `major`. Pre-releases are added to the next version with `--prerelease`, described below.
|
|
131
150
|
|
|
132
|
-
Without `--since`, `changeset-status` compares against `origin
|
|
151
|
+
Without `--since`, `changeset-status` compares against `<remote>/<baseBranch>`, where `remote` in the config defaults to `origin` and is also the remote that `changeset-tag --push` pushes tags to; fetch that ref or pass `--since` when using a fork or different upstream. `loadChangesetConfig()` discovers a conventional config at the repository root, unless `--config <path>` selects one explicitly.
|
|
133
152
|
|
|
134
|
-
Add release notes in a feature PR with `npx wp-release changeset-add`. In a terminal, it lists the packages, marks the ones that changed since
|
|
153
|
+
Add release notes in a feature PR with `npx wp-release changeset-add`. In a terminal, it lists the packages, marks the ones that changed since `<remote>/<baseBranch>` (or `--since <ref>`) without a changeset, and asks for the packages to release, a `patch`, `minor` or `major` bump for each, and the release note. Choose packages by number, identifier or path, or press Enter to release the changed ones; `none` adds an empty changeset. Changed files include uncommitted and untracked ones, since changesets are usually added before committing.
|
|
135
154
|
|
|
136
155
|
Without a terminal, or for scripts, pass the changeset as options: `npx wp-release changeset-add --package @vendor/plugin --bump patch --summary "Fix the checkout validation."`. Repeat package and bump flags for multiple packages, or use `--empty` when no release is needed. A package can also be named by its path under `root`, like `plugins/alpha`, and the changeset records its identifier; `changeset-version --package` and `changeset-tag --package` accept paths too. A single `--bump` without `--package` releases every changed package without a changeset, like `changeset-add --bump patch --summary "…"` to fix a failing `changeset-status` check. `--json` and `--github-output` never ask.
|
|
137
156
|
|
|
@@ -310,6 +329,7 @@ wp-release zip dist --slug my-plugin --checksums
|
|
|
310
329
|
- Entries are sorted and use a fixed timestamp and file mode, so the same files always give the same ZIP.
|
|
311
330
|
- `--checksums` also writes the [checksums manifest](#checksums) of the archived files next to the ZIP, with `.checksums.json` instead of `.zip`.
|
|
312
331
|
- An existing ZIP or manifest isn't overwritten without `--force`. A ZIP or manifest written inside the source directory is never archived.
|
|
332
|
+
- `--package <name>` zips a package of the [configured packages](#deploy-configured-packages), by identifier or path under the configured root like `plugins/alpha`, instead of a source directory: its directory with the `files` config of its package group, the same files that its deploys select. The slug defaults to the directory name and the version to the `Version` header, and `--slug` and `--version` still set them. Any package of the config works, with or without a version or deploy targets. To zip what a deploy just released, pass the `package` and `version` of the `deploy-git --release-ref` result, in the same job and from the same build, so the ZIP has exactly the files of the release tag in the release repository. It can't be combined with `<source-dir>` or the file selection options. The `--json` result has the `package`, `slug` and `version`. `zipPackage()` builds the same ZIP from a script, with `getPackageFiles()` for the directory and the files of a package.
|
|
313
333
|
|
|
314
334
|
### Checksums
|
|
315
335
|
|
|
@@ -352,9 +372,9 @@ wp-release verify wp-content/plugins/my-plugin --checksums my-plugin.1.2.0.check
|
|
|
352
372
|
- Manifest paths outside the package folder (absolute or with `..`) are rejected.
|
|
353
373
|
- `--zip <file|url>` checks the files of a ZIP instead of a directory. The ZIP can be a URL, such as the one that WordPress.org builds for a release, and its single root folder is found automatically (or set `--root-folder`). The ZIP is extracted to a temporary directory after the same safety checks as `deploy-svn --from-zip`.
|
|
354
374
|
- The version in the manifest must match the `Version` header of the checked files, so that an older release with its own valid manifest can't pass as a newer one.
|
|
355
|
-
- A manifest can't list itself. A copy of the manifest and of its
|
|
375
|
+
- A manifest can't list itself. A copy of the manifest and of its signature inside the checked files, at the root with the same names as the `--checksums` file or at the path of `--embedded`, is skipped when comparing files, but it must be identical to the `--checksums` file and its signature. The signature is the `.sig` file, or the file of `--signature-format`. A path that the manifest lists is never skipped, and a file that isn't a matching copy is reported as not in the checksums. See [Manifest inside the plugin](#manifest-inside-the-plugin).
|
|
356
376
|
|
|
357
|
-
A checksums manifest proves only that the files match the manifest. With `--public-key <key>`, `verify` first checks `<checksums>.sig` against the
|
|
377
|
+
A checksums manifest proves only that the files match the manifest. With `--public-key <key>`, `verify` first checks `<checksums>.sig` against the Ed25519 public key and fails with exit code `2` before comparing any file when the signature is missing or invalid, so that the manifest itself can be trusted. `--signature-format minisign` or `ssh` checks `<checksums>.minisig` or `<checksums>.sshsig` instead. The key can be the base64 key, the minisign public key or the `ssh-ed25519` public key, since they're forms of the same key. See [Sign](#sign).
|
|
358
378
|
|
|
359
379
|
### Manifest inside the plugin
|
|
360
380
|
|
|
@@ -367,7 +387,7 @@ wp-release zip build --slug my-plugin
|
|
|
367
387
|
wp-release deploy-svn build --trunk --svn-tag 1.2.0
|
|
368
388
|
```
|
|
369
389
|
|
|
370
|
-
- Write the manifest into the directory that is zipped and deployed. It lists every file except itself, and `checksums`, `zip` and `verify` also skip its `<name>.sig`, so running `checksums` again on a build that already has the pair gives the same manifest. Sign it last, since the signature covers the exact bytes of the manifest.
|
|
390
|
+
- Write the manifest into the directory that is zipped and deployed. It lists every file except itself, and `checksums`, `zip` and `verify` also skip its signatures (`<name>.sig`, `<name>.minisig` and `<name>.sshsig`), so running `checksums` again on a build that already has the pair gives the same manifest. Sign it last, since the signature covers the exact bytes of the manifest.
|
|
371
391
|
- `zip` and `deploy-svn` carry the pair like any other file. Don't use `zip --checksums` here, since it would write a second manifest that lists the first one. Attach `build/checksums.json` and `build/checksums.json.sig` to the GitHub release as they are.
|
|
372
392
|
- The signature covers file hashes and not a ZIP, so it stays valid for the ZIP that WordPress.org builds from SVN. Check what WordPress.org serves after a deploy, with the manifest and public key from your build:
|
|
373
393
|
|
|
@@ -376,7 +396,7 @@ wp-release deploy-svn build --trunk --svn-tag 1.2.0
|
|
|
376
396
|
--checksums build/checksums.json --public-key "$PUBLIC_KEY"
|
|
377
397
|
```
|
|
378
398
|
|
|
379
|
-
- The manifest can have any name and location, for example `--output build/includes/signatures/checksums.json`, and missing folders are created. Tell `verify` where the shipped copy is with `--embedded <path>`, like `--embedded includes/signatures/checksums.json`. Both the `--checksums` file and its
|
|
399
|
+
- The manifest can have any name and location, for example `--output build/includes/signatures/checksums.json`, and missing folders are created. Tell `verify` where the shipped copy is with `--embedded <path>`, like `--embedded includes/signatures/checksums.json`. Both the `--checksums` file and its signature must then exist, both copies must be shipped, and they're skipped when comparing files and must be identical to the originals. The manifest can't list the embedded path. Without `--embedded`, `verify` looks for the manifest name at the root, and skips a file only when it exists, the matching original exists and the manifest doesn't list it. Otherwise it's checked like any other file, so a listed file that has the name of the manifest can't be deleted unnoticed, and a shipped `.sig` without an original is reported as not in the checksums.
|
|
380
400
|
|
|
381
401
|
The public key has to come from somewhere other than the plugin that it checks, because someone who can overwrite the plugin files can also replace a key and a signature inside them. A copy of the manifest also doesn't prevent a downgrade to an older release that was signed too, so the installing side has to enforce a minimum version.
|
|
382
402
|
|
|
@@ -392,10 +412,28 @@ WP_RELEASE_SIGNING_KEY=… wp-release sign my-plugin.1.2.0.zip my-plugin.1.2.0.c
|
|
|
392
412
|
|
|
393
413
|
- The signature is the one WordPress core's `verify_file_signature()` checks: a base64 Ed25519 signature of the raw SHA-384 digest of the file. The tests check it against `sodium_crypto_sign_verify_detached()` in PHP. A `.sig` file can hold several signatures, one per line, and a file is valid when any of them match, which allows a key rotation window.
|
|
394
414
|
- The key is read from the `WP_RELEASE_SIGNING_KEY` environment variable only, as a base64 32-byte Ed25519 seed or a 64-byte libsodium secret key, the formats that `sodium_crypto_sign_seed_keypair()` and the update-pilot-server package signing key take. There's no flag for it, since it would show in the process list, and it's never logged.
|
|
395
|
-
- `--verbose` prints the public key of the signing key
|
|
396
|
-
- An existing
|
|
415
|
+
- `--verbose` prints the public key of the signing key in the form of each written format. `--json` returns it as `publicKey`, and in every form as `publicKeys`. Pass it to `verify --public-key` and to the plugin that checks the signatures.
|
|
416
|
+
- An existing signature file isn't overwritten without `--force`.
|
|
417
|
+
|
|
418
|
+
#### Signature formats
|
|
419
|
+
|
|
420
|
+
The same key can also sign in formats that tools outside WordPress check, for people who download a release by hand or verify it in other pipelines. Pick them with `--format`, comma-separated or repeated; the default is `wordpress`:
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
wp-release sign my-plugin.1.2.0.zip --format wordpress,minisign,ssh
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
| Format | File | Checked by |
|
|
427
|
+
|---|---|---|
|
|
428
|
+
| `wordpress` | `<file>.sig` | WordPress core's `verify_file_signature()`, update-client and `wp-release verify` |
|
|
429
|
+
| `minisign` | `<file>.minisig` | [minisign](https://jedisct1.github.io/minisign/) and compatible tools: `minisign -Vm <file> -P <minisign public key>` |
|
|
430
|
+
| `ssh` | `<file>.sshsig` | OpenSSH 8.1 or later: `ssh-keygen -Y verify -f allowed_signers -I <identity> -n file -s <file>.sshsig < <file>` |
|
|
397
431
|
|
|
398
|
-
|
|
432
|
+
- `minisign` signs the BLAKE2b-512 digest of the file, like `minisign -S` does by default, and adds a trusted comment with the signing time and file name that a second signature covers. minisign generates a random key ID for its keys, but the key here is a plain Ed25519 seed, so wp-release derives the key ID from the public key. `wp-release verify` doesn't compare key IDs, so signatures of keys that minisign generated verify too.
|
|
433
|
+
- `ssh` is the armored `SSHSIG` format that `ssh-keygen -Y sign` writes, with a SHA-512 digest and the `file` namespace, so that the signature can't pass as one for commits or another namespace. It's written to `.sshsig` instead of the `.sig` of `ssh-keygen`, which the `wordpress` format uses. Put the SSH public key in an `allowed_signers` file as `<identity> ssh-ed25519 AAAA…`.
|
|
434
|
+
- All formats are Ed25519 signatures by the same key, so one key and one secret cover all of them. The tests check each format with `minisign`, `ssh-keygen` and libsodium, and check the signatures that `minisign` and `ssh-keygen` write with `wp-release verify`.
|
|
435
|
+
|
|
436
|
+
Generate a key pair with `wp-release keygen`. It prints the private seed once as `WP_RELEASE_SIGNING_KEY=…` and the matching public key, also as a minisign public key and an `ssh-ed25519` public key. Store the private seed securely; never commit it or put it in a workflow log. Don't run `keygen` in CI or with `--github-output`, since those outputs can expose the private seed. The public key can be distributed to verifiers.
|
|
399
437
|
|
|
400
438
|
### Version check
|
|
401
439
|
|
|
@@ -508,11 +546,11 @@ packages: [
|
|
|
508
546
|
deploy: {
|
|
509
547
|
git: [
|
|
510
548
|
// The release repository of each plugin, with its history.
|
|
511
|
-
{ repository:
|
|
549
|
+
{ repository: ( { package: pkg } ) => `https://github.com/me/${ pkg.path.split( '/' ).pop() }.git`, message: 'Release {path} {ref} from {revision}' },
|
|
512
550
|
// A mirror that only gets release tags, named v1.2.0.
|
|
513
551
|
{ repository: ( { package: pkg } ) => `https://gitlab.com/me/${ pkg.path }.git`, branches: false, tag: 'v{version}' },
|
|
514
552
|
],
|
|
515
|
-
svn: { slug:
|
|
553
|
+
svn: { slug: ( { package: pkg } ) => `me-${ pkg.path.split( '/' ).pop() }`, assetsDir: '.wordpress-org' },
|
|
516
554
|
},
|
|
517
555
|
},
|
|
518
556
|
// A package that isn't versioned, like a Docker image, only deploys branches.
|
|
@@ -530,12 +568,13 @@ packages: [
|
|
|
530
568
|
`deploy-svn` has the same modes. `--release-ref` can't be combined with the options of a single target, like `--git-url`, `--tag` or `--svn-tag`, which come from the config.
|
|
531
569
|
|
|
532
570
|
- **Git targets** take a `repository` and release both branches and tags by default. `branches` limits the branches, like `[ 'main' ]`, or turns them off with `false`, and `tag` is the tag template in the repository, `{version}` by default, or `false` to not release tags. A release tag is created on top of the default branch of the repository, and a branch is released to the same branch. `history: false` uses the source commit instead of the package history from `git subtree split`, and `message` sets the release commit message, `Release {ref} from {revision}` by default.
|
|
533
|
-
- **SVN targets** only deploy release tags: a stable release syncs `trunk/`, creates its tag and syncs the `assetsDir`, and a pre-release only creates its tag. `slug
|
|
571
|
+
- **SVN targets** only deploy release tags: a stable release syncs `trunk/`, creates its tag and syncs the `assetsDir`, and a pre-release only creates its tag. `slug`, the WordPress.org plugin slug, defaults to the name of the package directory, `url` to the WordPress.org plugin repository, and `message` sets the commit message. Credentials come from `SVN_USERNAME` and `SVN_PASSWORD`, or `--svn-username`.
|
|
534
572
|
- **Several targets**: `git` and `svn` each take one target or a list, like a release repository and a mirror on another host. Each target is a separate deploy.
|
|
535
573
|
- **Credentials**: a GitHub repository URL needs no token in it, since `GITHUB_TOKEN` is sent as an authorization header (see above). A callback can still add credentials for other hosts.
|
|
536
|
-
- **Templates and callbacks**: `repository`, `slug` and `message` are templates with `{name}
|
|
574
|
+
- **Templates and callbacks**: `repository`, `slug` and `message` are templates with `{name}` and `{path}`, like the `tagFormat`, and `{version}`, `{branch}`, `{ref}` (the tag or branch that the deploy writes in the target) and `{revision}` (the source commit), or callbacks that receive `{ package, version, branch, ref, revision }`, where `package` has the `name`, `directory`, `path` and `type`. A callback can name a target after the package directory, choose another host for some packages, read the environment, or return nothing to skip the target for that package or ref; an empty `message` uses the default one. Credentials in URLs are never printed or listed.
|
|
575
|
+
- **Results**: with `--json` or `--github-output`, the result lists each deploy in `deploys` with its `package`, `label`, `target` (the repository or WordPress.org plugin, with credentials redacted), `targetRef` (the tag or branch written there), `version` or `branch`, and its `result` or `error`. A remote target repository also has its `targetHost`, like `github.com`, and `targetPath`, like `me/my-plugin`, without credentials, for a workflow step that calls the API of the forge that hosts it, such as to create the release of the deployed tag. The targets of `--list` have the same `host` and `path`, and `parseRepositoryUrl()` reads them from an HTTP(S), SSH or scp-like URL. `wp-release` doesn't call forge APIs itself.
|
|
537
576
|
- **Packages without a version**: a package entry without `version`, like a single directory with a `glob` of its path, isn't released with changesets, so changes to it don't need one, and it only deploys branches, since it has no release tags.
|
|
538
|
-
- **Files**: `files.exclude` adds gitignore-style patterns relative to the package directory, and `files.distignore` sets the ignore file relative to it or turns it off with `false`. A `files` at the root of the config applies to every package group, for the rules that all packages share, and the `files` of a group add their patterns after it and can replace its ignore file. Without `files`, each package's `.distignore` applies, like for `zip`; there's no repository-wide `.distignore`, since each one is relative to its package. `
|
|
577
|
+
- **Files**: `files.exclude` adds gitignore-style patterns relative to the package directory, and `files.distignore` sets the ignore file relative to it or turns it off with `false`. A `files` at the root of the config applies to every package group, for the rules that all packages share, and the `files` of a group add their patterns after it and can replace its ignore file. Without `files`, each package's `.distignore` applies, like for `zip`; there's no repository-wide `.distignore`, since each one is relative to its package. `zip --package <name>` zips a package with the same files, `getPackageFiles()` returns the directory and the file selection of any configured package, and `getDeployPackages()` lists the packages with deploy targets and their file selection.
|
|
539
578
|
|
|
540
579
|
A deploy releases the files of the working tree, so build the packages first. One job that builds once and runs `deploy-git --release-ref "$GITHUB_REF"` is the simplest setup, also for a branch that releases every package. A matrix with a job for each package from `--list` would build every package in every job, so build once and pass the built tree to the jobs as an artifact if you need one, for example for separate credentials.
|
|
541
580
|
|
|
@@ -710,6 +749,13 @@ The `wpelevator-source` export condition points at `src/index.ts`. The tests and
|
|
|
710
749
|
|
|
711
750
|
### Architecture
|
|
712
751
|
|
|
752
|
+
wp-release has two layers, so that it fits any repository layout:
|
|
753
|
+
|
|
754
|
+
- **Primitives** work on the directory, file or values they're given and know nothing about the repository: `zip <dir>`, `checksums`, `sign`, `verify`, `version-check`, `deploy-git <dir>` and `deploy-svn <dir>`.
|
|
755
|
+
- **The config layer** reads `wp-release.config.js` for everything about the repository: where packages are (`root` and the package globs), how their versions and tags are named (`version`, `tagFormat`), which files they ship (`files`), where they deploy (`deploy`) and the git `remote`. The changeset commands, `deploy-git` and `deploy-svn --release-ref`, and `zip --package` belong to it, and the global `--config` and `--tag-format` options select or adjust the config. Only `--release-ref` reads which package and version a ref releases. A primitive with a config mode, like `deploy-git --release-ref` beside `deploy-git <dir>` or `zip --package` beside `zip <dir>`, only takes the package directory, its files and its targets from the config there, and otherwise works the same.
|
|
756
|
+
|
|
757
|
+
Nothing assumes a directory structure or naming convention that the config doesn't set.
|
|
758
|
+
|
|
713
759
|
The package uses ES modules as its unit of encapsulation, like most Node.js CLI tools: a module exports a few functions and keeps its helpers private, so there's no class to wrap them in. A class is used only when it holds state across steps or binds dependencies, so that callers and tests can replace them:
|
|
714
760
|
|
|
715
761
|
- **Workflows with steps** are classes, so that their steps share state and dependencies on the instance: `SvnDeploy` shares the temporary working copy across `prepare()`, `checkout()`, `sync()` and `commit()`, `GitDeploy` binds the options and the git runner to its steps, and `ChangesetRelease` binds the repository and the runners to `add()`, `version()` and `tag()`.
|
|
@@ -732,7 +778,8 @@ The changeset release modules, from the entry point down:
|
|
|
732
778
|
| `changelog.ts` | Changelog entries, and the `CHANGELOG.md` and readme changelog sections. |
|
|
733
779
|
| `release-tags.ts` | Choosing the version and previous tag of a release, and building its release notes. |
|
|
734
780
|
| `tag-format.ts` | Formatting tag names from the tag format. |
|
|
735
|
-
| `package-deploy.ts` | Resolving the configured deploys of a ref: the released packages, their targets and file selections, for `deploy-git` and `deploy-svn`. |
|
|
781
|
+
| `package-deploy.ts` | Resolving the configured deploys of a ref: the released packages, their targets and file selections, for `deploy-git` and `deploy-svn`, and the file selection of a package for `zip --package`. |
|
|
782
|
+
| `package-zip.ts` | `zipPackage()`, the ZIP and checksums manifest of the selected files of a package, for `zip` and the snapshot builds of a monorepo. |
|
|
736
783
|
| `release-repository.ts` | `ReleaseRepository`, the git commands of a release: tags, commits and changed files. |
|
|
737
784
|
| `file-journal.ts` | `FileJournal`, which restores every file a failed `changeset-version` run changed. |
|
|
738
785
|
| `versions.ts` | Version checks and SemVer precedence. |
|
|
@@ -62,8 +62,6 @@ export interface ChangesetPackageGroup {
|
|
|
62
62
|
glob: string;
|
|
63
63
|
/** Package paths excluded from this group, relative to root. */
|
|
64
64
|
exclude?: string[];
|
|
65
|
-
/** Optional type used by the {type} tag template. */
|
|
66
|
-
tagType?: string;
|
|
67
65
|
/** Manifest field used as the changeset name; defaults to `path`. */
|
|
68
66
|
idFrom?: PackageIdSource;
|
|
69
67
|
/**
|
|
@@ -107,7 +105,7 @@ export interface DeployPackage {
|
|
|
107
105
|
type: ChangesetPackage['type'];
|
|
108
106
|
}
|
|
109
107
|
/**
|
|
110
|
-
* A deploy setting: a template with {name}, {
|
|
108
|
+
* A deploy setting: a template with {name}, {path},
|
|
111
109
|
* {version}, {branch}, {ref} and {revision}, or a callback that receives the
|
|
112
110
|
* package and its release. An empty repository or slug skips the target, and
|
|
113
111
|
* an empty message uses the default one.
|
|
@@ -115,7 +113,7 @@ export interface DeployPackage {
|
|
|
115
113
|
export type DeployTemplate = string | ((input: DeployTargetInput) => string | undefined | Promise<string | undefined>);
|
|
116
114
|
/** A Git repository that `deploy-git` releases a package to. */
|
|
117
115
|
export interface GitDeployTarget {
|
|
118
|
-
/** Repository URL, like `https://github.com/me/{
|
|
116
|
+
/** Repository URL, like `https://github.com/me/{path}.git`. */
|
|
119
117
|
repository: DeployTemplate;
|
|
120
118
|
/** Branches released to the same branch of the repository: all with true (the default), none with false, or the listed ones. */
|
|
121
119
|
branches?: boolean | string[];
|
|
@@ -128,7 +126,7 @@ export interface GitDeployTarget {
|
|
|
128
126
|
}
|
|
129
127
|
/** A WordPress.org plugin that `deploy-svn` releases a package to. */
|
|
130
128
|
export interface SvnDeployTarget {
|
|
131
|
-
/**
|
|
129
|
+
/** WordPress.org plugin slug, defaults to the name of the package directory. */
|
|
132
130
|
slug?: DeployTemplate;
|
|
133
131
|
/** SVN repository URL with {slug}, defaults to WordPress.org. */
|
|
134
132
|
url?: string;
|
|
@@ -221,11 +219,13 @@ export interface DependentsConfig {
|
|
|
221
219
|
export interface ChangesetConfig {
|
|
222
220
|
/** Branch receiving ordinary changes. */
|
|
223
221
|
baseBranch?: string;
|
|
222
|
+
/** Git remote that tags are pushed to and the base branch is compared on, origin by default. */
|
|
223
|
+
remote?: string;
|
|
224
224
|
/** Directory containing Markdown changesets, relative to the repository root. */
|
|
225
225
|
changesets?: string;
|
|
226
226
|
/** Package groups to discover and release. */
|
|
227
227
|
packages: ChangesetPackageGroup[];
|
|
228
|
-
/** Git tag template supporting {name}, {
|
|
228
|
+
/** Git tag template supporting {name}, {path} and {version}. */
|
|
229
229
|
tagFormat?: string;
|
|
230
230
|
/** Directory against which package paths in tag formats are calculated. */
|
|
231
231
|
root?: string;
|
|
@@ -358,6 +358,8 @@ export declare function defineConfig(config: ChangesetConfig): ChangesetConfig;
|
|
|
358
358
|
export interface LoadChangesetConfigInput {
|
|
359
359
|
cwd?: string;
|
|
360
360
|
configFile?: string;
|
|
361
|
+
/** Tag format that replaces the tagFormat of the config, like from --tag-format. */
|
|
362
|
+
tagFormat?: string;
|
|
361
363
|
}
|
|
362
364
|
/**
|
|
363
365
|
* Load and validate the repository's JavaScript wp-release configuration.
|
package/dist/changeset-config.js
CHANGED
|
@@ -138,7 +138,12 @@ export async function loadChangesetConfig(input = {}) {
|
|
|
138
138
|
? loaded.default
|
|
139
139
|
: undefined;
|
|
140
140
|
validateChangesetConfig(config, configFile);
|
|
141
|
-
return {
|
|
141
|
+
return {
|
|
142
|
+
config: input.tagFormat
|
|
143
|
+
? { ...config, tagFormat: input.tagFormat }
|
|
144
|
+
: config,
|
|
145
|
+
file: configFile,
|
|
146
|
+
};
|
|
142
147
|
}
|
|
143
148
|
async function findConfigFile(cwd) {
|
|
144
149
|
for (const fileName of CONFIG_FILES) {
|
|
@@ -171,6 +176,7 @@ function validateChangesetConfig(config, configFile) {
|
|
|
171
176
|
}
|
|
172
177
|
for (const [key, value] of Object.entries({
|
|
173
178
|
baseBranch: candidate.baseBranch,
|
|
179
|
+
remote: candidate.remote,
|
|
174
180
|
changesets: candidate.changesets,
|
|
175
181
|
changelogInsertAfter: candidate.changelogInsertAfter,
|
|
176
182
|
root: candidate.root,
|
|
@@ -268,10 +274,6 @@ function validateChangesetConfig(config, configFile) {
|
|
|
268
274
|
if ('string' !== typeof group.glob || !group.glob.trim()) {
|
|
269
275
|
throw new ValidationError(`wp-release config ${configFile} packages[${index}].glob must be a non-empty string.`);
|
|
270
276
|
}
|
|
271
|
-
if ('string' !== typeof group.tagType &&
|
|
272
|
-
undefined !== group.tagType) {
|
|
273
|
-
throw new ValidationError(`wp-release config ${configFile} packages[${index}].tagType must be a string.`);
|
|
274
|
-
}
|
|
275
277
|
if (undefined !== group.exclude &&
|
|
276
278
|
(!Array.isArray(group.exclude) ||
|
|
277
279
|
group.exclude.some((item) => 'string' !== typeof item))) {
|
|
@@ -9,8 +9,8 @@ export interface ConfiguredPackage extends ChangesetPackage {
|
|
|
9
9
|
versionConfig: PackageVersionConfig;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* A discovered package
|
|
13
|
-
* version configuration.
|
|
12
|
+
* A discovered package with the configuration of its group, without reading
|
|
13
|
+
* its version, which may have no version or deploy configuration.
|
|
14
14
|
*/
|
|
15
15
|
export interface ConfiguredDeployPackage extends DeployPackage {
|
|
16
16
|
group: ChangesetPackageGroup;
|
|
@@ -32,6 +32,16 @@ export interface ChangedPackages {
|
|
|
32
32
|
* @throws {ValidationError} For a glob without matches or a duplicate package name.
|
|
33
33
|
*/
|
|
34
34
|
export declare function discoverPackages(repository: ReleaseRepository, config: ChangesetConfig): Promise<ConfiguredPackage[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Find the packages of every package group, with or without a version or
|
|
37
|
+
* deploy configuration, without reading their versions.
|
|
38
|
+
*
|
|
39
|
+
* @param repository Repository the packages are in.
|
|
40
|
+
* @param config Repository release configuration.
|
|
41
|
+
* @return Packages in the configured order.
|
|
42
|
+
* @throws {ValidationError} For a glob without matches or a duplicate package name.
|
|
43
|
+
*/
|
|
44
|
+
export declare function discoverConfiguredPackages(repository: ReleaseRepository, config: ChangesetConfig): Promise<ConfiguredDeployPackage[]>;
|
|
35
45
|
/**
|
|
36
46
|
* Find the packages of the package groups with deploy targets, including the
|
|
37
47
|
* groups without a version configuration, without reading their versions.
|
|
@@ -22,12 +22,24 @@ export async function discoverPackages(repository, config) {
|
|
|
22
22
|
const versionConfig = pkg.group.version;
|
|
23
23
|
packages.push({
|
|
24
24
|
...pkg,
|
|
25
|
-
currentVersion: await readVersion(repository, pkg.directory, versionConfig.from, pkg
|
|
25
|
+
currentVersion: await readVersion(repository, pkg.directory, versionConfig.from, pkg),
|
|
26
26
|
versionConfig,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
return packages;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Find the packages of every package group, with or without a version or
|
|
33
|
+
* deploy configuration, without reading their versions.
|
|
34
|
+
*
|
|
35
|
+
* @param repository Repository the packages are in.
|
|
36
|
+
* @param config Repository release configuration.
|
|
37
|
+
* @return Packages in the configured order.
|
|
38
|
+
* @throws {ValidationError} For a glob without matches or a duplicate package name.
|
|
39
|
+
*/
|
|
40
|
+
export async function discoverConfiguredPackages(repository, config) {
|
|
41
|
+
return findGroupPackages(repository, config, config.packages);
|
|
42
|
+
}
|
|
31
43
|
/**
|
|
32
44
|
* Find the packages of the package groups with deploy targets, including the
|
|
33
45
|
* groups without a version configuration, without reading their versions.
|
|
@@ -4,6 +4,8 @@ import { ReleaseRepository } from './release-repository.ts';
|
|
|
4
4
|
export interface ChangesetRepository {
|
|
5
5
|
cwd: string;
|
|
6
6
|
configFile?: string;
|
|
7
|
+
/** Tag format that replaces the tagFormat of the config. */
|
|
8
|
+
tagFormat?: string;
|
|
7
9
|
}
|
|
8
10
|
export interface ChangesetReleaseOptions extends ChangesetRepository {
|
|
9
11
|
/** Git runner, spawning git by default. */
|
|
@@ -71,7 +73,7 @@ export interface ChangesetTagResult {
|
|
|
71
73
|
}>;
|
|
72
74
|
}
|
|
73
75
|
export interface ChangesetStatusOptions {
|
|
74
|
-
/** Base ref to diff against,
|
|
76
|
+
/** Base ref to diff against, <remote>/<baseBranch> by default. */
|
|
75
77
|
since?: string;
|
|
76
78
|
/** Whether to include uncommitted and untracked files, like before adding a changeset. */
|
|
77
79
|
uncommitted?: boolean;
|
|
@@ -97,6 +99,7 @@ export interface ChangesetStatusResult {
|
|
|
97
99
|
export declare class ChangesetRelease {
|
|
98
100
|
readonly cwd: string;
|
|
99
101
|
readonly configFile: string | undefined;
|
|
102
|
+
readonly tagFormat: string | undefined;
|
|
100
103
|
readonly repository: ReleaseRepository;
|
|
101
104
|
/**
|
|
102
105
|
* @param options Repository root, config file and git runner.
|
|
@@ -134,7 +137,7 @@ export declare class ChangesetRelease {
|
|
|
134
137
|
*/
|
|
135
138
|
version(options?: ChangesetVersionOptions): Promise<VersionChangesetsResult>;
|
|
136
139
|
/**
|
|
137
|
-
* Create missing release tags, optionally pushing them to the
|
|
140
|
+
* Create missing release tags, optionally pushing them to the configured
|
|
138
141
|
* remote. Each tag comes with the title and notes of its release, for a
|
|
139
142
|
* workflow step to create the GitHub Release.
|
|
140
143
|
*
|
|
@@ -9,7 +9,7 @@ import { ValidationError } from "./errors.js";
|
|
|
9
9
|
import { FileJournal } from "./file-journal.js";
|
|
10
10
|
import { getPreviousTag, getReleaseNotes, getTagVersion, selectTagPackages, } from "./release-tags.js";
|
|
11
11
|
import { ReleaseRepository } from "./release-repository.js";
|
|
12
|
-
import { formatTag } from "./tag-format.js";
|
|
12
|
+
import { DEFAULT_TAG_FORMAT, formatTag } from "./tag-format.js";
|
|
13
13
|
import { verifyVersionTargets, writeVersion } from "./version-files.js";
|
|
14
14
|
import { getPrereleaseVersion, getSnapshotVersion, isPrerelease, } from "./versions.js";
|
|
15
15
|
const MISSING_CONFIG = 'No wp-release config found. Add wp-release.config.js or pass --config <path>.';
|
|
@@ -24,6 +24,7 @@ const MISSING_CONFIG = 'No wp-release config found. Add wp-release.config.js or
|
|
|
24
24
|
export class ChangesetRelease {
|
|
25
25
|
cwd;
|
|
26
26
|
configFile;
|
|
27
|
+
tagFormat;
|
|
27
28
|
repository;
|
|
28
29
|
/**
|
|
29
30
|
* @param options Repository root, config file and git runner.
|
|
@@ -31,6 +32,7 @@ export class ChangesetRelease {
|
|
|
31
32
|
constructor(options) {
|
|
32
33
|
this.cwd = options.cwd;
|
|
33
34
|
this.configFile = options.configFile;
|
|
35
|
+
this.tagFormat = options.tagFormat;
|
|
34
36
|
this.repository = new ReleaseRepository({
|
|
35
37
|
cwd: options.cwd,
|
|
36
38
|
runner: options.git,
|
|
@@ -144,7 +146,7 @@ export class ChangesetRelease {
|
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
147
|
-
* Create missing release tags, optionally pushing them to the
|
|
149
|
+
* Create missing release tags, optionally pushing them to the configured
|
|
148
150
|
* remote. Each tag comes with the title and notes of its release, for a
|
|
149
151
|
* workflow step to create the GitHub Release.
|
|
150
152
|
*
|
|
@@ -163,7 +165,7 @@ export class ChangesetRelease {
|
|
|
163
165
|
: selected;
|
|
164
166
|
const results = [];
|
|
165
167
|
const dryRun = options.dryRun || options.untagged;
|
|
166
|
-
const tagFormat = context.config.tagFormat ??
|
|
168
|
+
const tagFormat = context.config.tagFormat ?? DEFAULT_TAG_FORMAT;
|
|
167
169
|
for (const pkg of packages) {
|
|
168
170
|
const version = await getTagVersion(pkg, options.version);
|
|
169
171
|
if (undefined !== options.version &&
|
|
@@ -196,7 +198,7 @@ export class ChangesetRelease {
|
|
|
196
198
|
// tags when more than three are pushed at once.
|
|
197
199
|
if (options.push && !dryRun) {
|
|
198
200
|
for (const item of results.filter((result) => result.created)) {
|
|
199
|
-
await this.repository.pushTag(item.tag);
|
|
201
|
+
await this.repository.pushTag(item.tag, context.config.remote ?? 'origin');
|
|
200
202
|
}
|
|
201
203
|
}
|
|
202
204
|
return {
|
|
@@ -216,7 +218,9 @@ export class ChangesetRelease {
|
|
|
216
218
|
const { config, packages, plan } = await this.requireContext();
|
|
217
219
|
const { changesets, releases } = plan;
|
|
218
220
|
const since = options.since ??
|
|
219
|
-
(config.baseBranch
|
|
221
|
+
(config.baseBranch
|
|
222
|
+
? `${config.remote ?? 'origin'}/${config.baseBranch}`
|
|
223
|
+
: undefined);
|
|
220
224
|
const changed = since
|
|
221
225
|
? await getChangedPackages(this.repository, packages, since, options.uncommitted)
|
|
222
226
|
: { packages: [], filesByPackage: {} };
|
|
@@ -266,7 +270,7 @@ export class ChangesetRelease {
|
|
|
266
270
|
* @throws {ValidationError} For an invalid pre-release or an existing version.
|
|
267
271
|
*/
|
|
268
272
|
async toPrereleases(context, releases, prerelease) {
|
|
269
|
-
const tagFormat = context.config.tagFormat ??
|
|
273
|
+
const tagFormat = context.config.tagFormat ?? DEFAULT_TAG_FORMAT;
|
|
270
274
|
return Promise.all(releases.map(async (release) => {
|
|
271
275
|
const configured = context.packages.find((pkg) => pkg.name === release.package.name);
|
|
272
276
|
const versions = configured
|
|
@@ -364,6 +368,7 @@ export class ChangesetRelease {
|
|
|
364
368
|
const loaded = await loadChangesetConfig({
|
|
365
369
|
cwd: this.cwd,
|
|
366
370
|
...(this.configFile ? { configFile: this.configFile } : {}),
|
|
371
|
+
...(this.tagFormat ? { tagFormat: this.tagFormat } : {}),
|
|
367
372
|
});
|
|
368
373
|
if (!loaded) {
|
|
369
374
|
return undefined;
|
|
@@ -429,6 +434,7 @@ export class ChangesetRelease {
|
|
|
429
434
|
const loaded = await loadChangesetConfig({
|
|
430
435
|
cwd: this.cwd,
|
|
431
436
|
...(this.configFile ? { configFile: this.configFile } : {}),
|
|
437
|
+
...(this.tagFormat ? { tagFormat: this.tagFormat } : {}),
|
|
432
438
|
});
|
|
433
439
|
if (!loaded) {
|
|
434
440
|
throw new ValidationError(MISSING_CONFIG);
|
package/dist/cli.js
CHANGED
|
@@ -43,6 +43,7 @@ const globalArgs = {
|
|
|
43
43
|
json: { type: 'boolean' },
|
|
44
44
|
'github-output': { type: 'boolean' },
|
|
45
45
|
config: { type: 'string' },
|
|
46
|
+
'tag-format': { type: 'string' },
|
|
46
47
|
};
|
|
47
48
|
const globalOptions = `Global options:
|
|
48
49
|
-h, --help Show help for the command
|
|
@@ -55,7 +56,32 @@ const globalOptions = `Global options:
|
|
|
55
56
|
--json Print the result as JSON
|
|
56
57
|
--github-output Set the result as JSON to the "result" output of
|
|
57
58
|
the GitHub Actions step
|
|
58
|
-
--config <path> Path to a JavaScript release config file
|
|
59
|
+
--config <path> Path to a JavaScript release config file
|
|
60
|
+
--tag-format <format>
|
|
61
|
+
Tag format with {name}, {path} and {version} that
|
|
62
|
+
replaces the tagFormat of the config, like
|
|
63
|
+
{path}/{version}`;
|
|
64
|
+
/**
|
|
65
|
+
* Get the config file and the tag format from the global options.
|
|
66
|
+
*
|
|
67
|
+
* @param values Parsed CLI values.
|
|
68
|
+
* @return The --config and --tag-format values.
|
|
69
|
+
* @throws {ValidationError} For an empty --config or --tag-format.
|
|
70
|
+
*/
|
|
71
|
+
function getConfigArgs(values) {
|
|
72
|
+
const configFile = getString(values, 'config');
|
|
73
|
+
const tagFormat = getString(values, 'tag-format');
|
|
74
|
+
if ('' === configFile?.trim()) {
|
|
75
|
+
throw new ValidationError('--config <path> must not be empty.');
|
|
76
|
+
}
|
|
77
|
+
if ('' === tagFormat?.trim()) {
|
|
78
|
+
throw new ValidationError('--tag-format <format> must not be empty.');
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
...(configFile ? { configFile } : {}),
|
|
82
|
+
...(tagFormat ? { tagFormat } : {}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
59
85
|
/**
|
|
60
86
|
* Get the top-level help text listing all commands.
|
|
61
87
|
*
|
|
@@ -188,10 +214,7 @@ async function runCommand(command, args, io) {
|
|
|
188
214
|
options: { ...globalArgs, ...command.options },
|
|
189
215
|
allowPositionals: true,
|
|
190
216
|
});
|
|
191
|
-
const configFile =
|
|
192
|
-
if ('' === configFile?.trim()) {
|
|
193
|
-
throw new ValidationError('--config <path> must not be empty.');
|
|
194
|
-
}
|
|
217
|
+
const { configFile, tagFormat } = getConfigArgs(values);
|
|
195
218
|
const githubOutputFile = getGitHubOutputFile(values);
|
|
196
219
|
logger = new Logger({
|
|
197
220
|
writer: createLogWriter(values, { stdout, stderr }),
|
|
@@ -208,6 +231,7 @@ async function runCommand(command, args, io) {
|
|
|
208
231
|
positionals,
|
|
209
232
|
cwd,
|
|
210
233
|
...(configFile ? { configFile } : {}),
|
|
234
|
+
...(tagFormat ? { tagFormat } : {}),
|
|
211
235
|
logger,
|
|
212
236
|
...(interactive
|
|
213
237
|
? { terminal: { input: stdin, output: stdout } }
|
|
@@ -251,16 +275,16 @@ export async function execute(name, args, context) {
|
|
|
251
275
|
options: { ...globalArgs, ...command.options },
|
|
252
276
|
allowPositionals: true,
|
|
253
277
|
});
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
278
|
+
const configArgs = getConfigArgs(values);
|
|
279
|
+
const configFile = configArgs.configFile ?? context.configFile;
|
|
280
|
+
const { tagFormat } = configArgs;
|
|
258
281
|
// The command table is keyed by name, so the result matches CommandResults.
|
|
259
282
|
return command.run({
|
|
260
283
|
values,
|
|
261
284
|
positionals,
|
|
262
285
|
...context,
|
|
263
286
|
...(configFile ? { configFile } : {}),
|
|
287
|
+
...(tagFormat ? { tagFormat } : {}),
|
|
264
288
|
});
|
|
265
289
|
}
|
|
266
290
|
/**
|
package/dist/commands/args.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ParseArgsOptionsConfig } from 'node:util';
|
|
2
|
-
import type { FileRules } from '../file-selection.ts';
|
|
3
2
|
import type { ParsedValues } from './command.ts';
|
|
4
3
|
/**
|
|
5
4
|
* Options shared by the commands that select files with .distignore and
|
|
@@ -40,26 +39,6 @@ export declare function checkDirectory(path: string): Promise<void>;
|
|
|
40
39
|
* @return Whether the path is a directory.
|
|
41
40
|
*/
|
|
42
41
|
export declare function isDirectory(path: string): Promise<boolean>;
|
|
43
|
-
/**
|
|
44
|
-
* Ignore a file that the command writes or reads, such as the checksums
|
|
45
|
-
* manifest, when it's inside the selected directory.
|
|
46
|
-
*
|
|
47
|
-
* @param rules Matcher from loadFileRules().
|
|
48
|
-
* @param sourceDir Selected directory.
|
|
49
|
-
* @param path Absolute file path.
|
|
50
|
-
* @return The same matcher.
|
|
51
|
-
*/
|
|
52
|
-
export declare function ignoreOwnFile(rules: FileRules, sourceDir: string, path: string): FileRules;
|
|
53
|
-
/**
|
|
54
|
-
* Ignore the signature file that "wp-release sign" writes next to a file the
|
|
55
|
-
* command writes, when it's inside the selected directory.
|
|
56
|
-
*
|
|
57
|
-
* @param rules Matcher from loadFileRules().
|
|
58
|
-
* @param sourceDir Selected directory.
|
|
59
|
-
* @param path Absolute path of the signed file.
|
|
60
|
-
* @return The same matcher.
|
|
61
|
-
*/
|
|
62
|
-
export declare function ignoreOwnSignature(rules: FileRules, sourceDir: string, path: string): FileRules;
|
|
63
42
|
/**
|
|
64
43
|
* Option for the source directory, which can also be the first positional
|
|
65
44
|
* argument.
|