@git.zone/cli 8.11.0 → 9.0.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.
Files changed (61) hide show
  1. package/assets/templates/{asset_deno_binary_installer → asset_binary_installer}/install.sh +2 -2
  2. package/assets/templates/{asset_deno_binary_postinstall → asset_binary_postinstall}/bin/wrapper.js +2 -2
  3. package/assets/templates/{asset_deno_binary_postinstall → asset_binary_postinstall}/scripts/install-binary.js +2 -2
  4. package/assets/templates/asset_binary_release_gitea/.gitea/workflows/release.yml +180 -0
  5. package/assets/templates/asset_tspack_release_gitea/.gitea/workflows/release.yml +7 -4
  6. package/dist_ts/00_commitinfo_data.js +2 -2
  7. package/dist_ts/helpers.managedassets.d.ts +44 -0
  8. package/dist_ts/helpers.managedassets.js +166 -0
  9. package/dist_ts/helpers.ownerscopes.d.ts +3 -15
  10. package/dist_ts/helpers.ownerscopes.js +4 -16
  11. package/dist_ts/helpers.packagefiles.d.ts +2 -1
  12. package/dist_ts/helpers.packagefiles.js +7 -4
  13. package/dist_ts/helpers.sealedrelease.js +3 -3
  14. package/dist_ts/helpers.tssea.d.ts +11 -0
  15. package/dist_ts/helpers.tssea.js +81 -0
  16. package/dist_ts/helpers.workflow.d.ts +0 -3
  17. package/dist_ts/helpers.workflow.js +7 -19
  18. package/dist_ts/index.d.ts +1 -1
  19. package/dist_ts/index.js +2 -2
  20. package/dist_ts/mod_commit/mod.helpers.d.ts +8 -21
  21. package/dist_ts/mod_commit/mod.helpers.js +32 -83
  22. package/dist_ts/mod_commit/mod.ui.js +1 -5
  23. package/dist_ts/mod_config/index.js +41 -33
  24. package/dist_ts/mod_format/formatters/assets.formatter.js +42 -92
  25. package/dist_ts/mod_format/formatters/packagejson.formatter.js +3 -3
  26. package/dist_ts/mod_format/index.js +30 -11
  27. package/dist_ts/mod_format/interfaces.format.js +1 -2
  28. package/dist_ts/mod_release/helpers.releasepreparation.d.ts +6 -14
  29. package/dist_ts/mod_release/helpers.releasepreparation.js +27 -53
  30. package/dist_ts/mod_release/index.js +9 -10
  31. package/dist_ts/mod_services/classes.serviceconfiguration.d.ts +2 -2
  32. package/dist_ts/mod_services/classes.serviceoptions.d.ts +2 -2
  33. package/dist_ts/plugins.d.ts +3 -1
  34. package/dist_ts/plugins.js +4 -2
  35. package/package.json +3 -2
  36. package/readme.md +54 -63
  37. package/ts/00_commitinfo_data.ts +1 -1
  38. package/ts/helpers.managedassets.ts +215 -0
  39. package/ts/helpers.ownerscopes.ts +3 -15
  40. package/ts/helpers.packagefiles.ts +6 -3
  41. package/ts/helpers.sealedrelease.ts +2 -2
  42. package/ts/helpers.tssea.ts +102 -0
  43. package/ts/helpers.workflow.ts +6 -28
  44. package/ts/index.ts +1 -1
  45. package/ts/mod_commit/mod.helpers.ts +33 -94
  46. package/ts/mod_commit/mod.ui.ts +0 -4
  47. package/ts/mod_config/index.ts +47 -35
  48. package/ts/mod_format/formatters/assets.formatter.ts +47 -108
  49. package/ts/mod_format/formatters/packagejson.formatter.ts +2 -2
  50. package/ts/mod_format/index.ts +36 -10
  51. package/ts/mod_format/interfaces.format.ts +0 -1
  52. package/ts/mod_release/helpers.releasepreparation.ts +36 -69
  53. package/ts/mod_release/index.ts +6 -16
  54. package/ts/mod_services/classes.serviceconfiguration.ts +2 -2
  55. package/ts/mod_services/classes.serviceoptions.ts +2 -2
  56. package/ts/plugins.ts +4 -0
  57. package/assets/templates/asset_deno_binary_release_gitea/.gitea/workflows/release.yml +0 -154
  58. package/assets/templates/multienv/deno.json +0 -8
  59. package/dist_ts/mod_format/formatters/deno.formatter.d.ts +0 -18
  60. package/dist_ts/mod_format/formatters/deno.formatter.js +0 -175
  61. package/ts/mod_format/formatters/deno.formatter.ts +0 -219
package/readme.md CHANGED
@@ -232,8 +232,7 @@ Consequences worth knowing before upgrading:
232
232
  pushed. Commit the lockfile, or run `pnpm install` and commit it, then release
233
233
  again. The version bump only changes `version`, which never changes a
234
234
  dependency specifier, so a lockfile accepted in preflight is still accepted in
235
- the release commit. A project with both a `package.json` and a `deno.json` is
236
- an npm project here and owes the same proof.
235
+ the release commit.
237
236
  - Pnpm commands use the scope carried by the release commit. A repository that
238
237
  tracks its own root `pnpm-workspace.yaml` retains that workspace's settings
239
238
  and member validation. Otherwise, lockfile verification and checkout
@@ -246,15 +245,9 @@ Consequences worth knowing before upgrading:
246
245
  independent fixture installs are not supported in that mode. Both modes
247
246
  exclude an unrelated enclosing workspace from release lockfile validation
248
247
  and installation.
249
- - A Deno-only project — a commit with a `deno.json` and no `package.json` —
250
- neither needs a pnpm lockfile nor installs anything: its checkout runs the
251
- configured build and test commands against the committed tree, and pinning
252
- dependencies stays the project's `deno.lock` or import map. The plan of such a
253
- release has no `preflight.lockfile` step. Preflight and the checkout both read
254
- the release commit rather than the working folder, so an ignored
255
- `package.json` never makes a release demand a lockfile its checkout would not
256
- install; in that one case the plan, which reads the working folder, still
257
- lists the step, and the step then does nothing.
248
+ - The release commit must carry a `package.json`: it holds the version
249
+ gitzone releases. A commit without one is refused before anything is
250
+ created.
258
251
  - The checkout holds only committed files, so a gitignored project-level
259
252
  `.npmrc` is not in it. A project that authenticates private dependencies
260
253
  through such a file now fails its checkout install after the local commit and
@@ -354,7 +347,7 @@ Release flags:
354
347
  }
355
348
  ```
356
349
 
357
- GitZone first infers the version as usual. It starts from the current `package.json` or `deno.json` version and applies the level from the Pending changelog or from `--major`, `--minor` or `--patch`. The release version is then the higher of that inferred version and the floor. The floor is committed configuration, so the plain `gitzone release -y` honours it without a flag, and nobody has to hand-edit `package.json` to a version that was never published.
350
+ GitZone first infers the version as usual. It starts from the current `package.json` version and applies the level from the Pending changelog or from `--major`, `--minor` or `--patch`. The release version is then the higher of that inferred version and the floor. The floor is committed configuration, so the plain `gitzone release -y` honours it without a flag, and nobody has to hand-edit `package.json` to a version that was never published.
358
351
 
359
352
  `gitzone release --plan` states the outcome:
360
353
 
@@ -381,15 +374,15 @@ When the floor decides the version, the release journal records that decision wi
381
374
 
382
375
  `gitzone release inspect` and `gitzone release resume` print the same `version floor: ... applied` line. The record is part of the journal's immutable identity. `resume` always publishes the journaled version and never resolves a new one. This matters because after the release commit the floor is inert, and a fresh resolution would infer `32.0.1`. `recover` takes its version from the existing tag and writes no floor record, because the failed run did not record its level override.
383
376
 
384
- The floor must be a canonical `x.y.z` string whose components do not exceed `9007199254740991`, except for a matching [prerelease channel](#prerelease-channels-on-main). Every rejection throws `ReleaseVersionError`, and its `code` names the rule that failed. `malformed-version-floor` and `unsupported-prerelease-floor` are configuration errors that `--plan` and `gitzone config doctor` report. `--plan` and the release raise `noncanonical-version` when the current `package.json` or `deno.json` version is not canonical. `current-version-changed` is raised only while the release runs:
377
+ The floor must be a canonical `x.y.z` string whose components do not exceed `9007199254740991`, except for a matching [prerelease channel](#prerelease-channels-on-main). Every rejection throws `ReleaseVersionError`, and its `code` names the rule that failed. `malformed-version-floor` and `unsupported-prerelease-floor` are configuration errors that `--plan` and `gitzone config doctor` report. `--plan` and the release raise `noncanonical-version` when the current `package.json` version is not canonical. `current-version-changed` is raised only while the release runs:
385
378
 
386
379
  | Code | Cause |
387
380
  | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
388
381
  | `malformed-version-floor` | Anything else, such as `"32"`, `"v32.0.0"`, `null`, a number, or a component above `9007199254740991` |
389
382
  | `unsupported-prerelease-floor` | A prerelease or build suffix without a matching configured prerelease channel |
390
383
  | `invalid-prerelease-config` | A malformed channel, mismatched or missing prerelease floor, forbidden dist-tag or version-level override |
391
- | `noncanonical-version` | A floor is configured but the current `package.json` or `deno.json` version is not a canonical `x.y.z` version to compare against |
392
- | `current-version-changed` | The release checkout's `package.json` or `deno.json` version differs from the version the release was resolved from |
384
+ | `noncanonical-version` | A floor is configured but the current `package.json` version is not a canonical `x.y.z` version to compare against |
385
+ | `current-version-changed` | The release checkout's `package.json` version differs from the version the release was resolved from |
393
386
 
394
387
  `gitzone config show` lists the configured floor.
395
388
 
@@ -1611,7 +1604,7 @@ project that needs different contents describes them in `.smartconfig.json`:
1611
1604
  | `cli` | `cli.js` |
1612
1605
  | `config` | `.smartconfig.json` |
1613
1606
  | `docs` | `readme.md` |
1614
- | `binary` | With managed `denoBinaryCli` assets: the installer (`install.sh` or `assets.installer.file`) and, with the npm wrapper, `bin/` and its postinstall script; empty otherwise |
1607
+ | `binary` | With managed `binaryCli` assets: the installer (`install.sh` or `assets.installer.file`) and, with the npm wrapper, `bin/` and its postinstall script; empty otherwise |
1615
1608
 
1616
1609
  The list carries the entries of the selected sets in this order, then
1617
1610
  `include`, then every exclusion: those of the sets first, then `exclude`, each
@@ -1653,7 +1646,7 @@ Then fix the package and release again. `gitzone config doctor` validates
1653
1646
 
1654
1647
  ### Managed Assets
1655
1648
 
1656
- Projects can opt into generated, updateable repository assets through `@git.zone/cli.assets`. The first supported kind is `denoBinaryCli`, which manages installer scripts, npm binary wrappers, postinstall downloaders, and Gitea release workflows for Deno-compiled CLI binaries.
1649
+ Projects can opt into generated, updateable repository assets through `@git.zone/cli.assets`. The kind `binaryCli` manages installer scripts, npm binary wrappers, postinstall downloaders, and Gitea release workflows for CLI executables that [`@git.zone/tssea`](https://code.foss.global/git.zone/tssea) builds as Node.js single executable applications.
1657
1650
 
1658
1651
  ```json
1659
1652
  {
@@ -1661,7 +1654,7 @@ Projects can opt into generated, updateable repository assets through `@git.zone
1661
1654
  "schemaVersion": 2,
1662
1655
  "assets": {
1663
1656
  "schemaVersion": 1,
1664
- "kind": "denoBinaryCli",
1657
+ "kind": "binaryCli",
1665
1658
  "cliName": "onebox",
1666
1659
  "displayName": "Onebox",
1667
1660
  "repository": {
@@ -1696,36 +1689,27 @@ Projects can opt into generated, updateable repository assets through `@git.zone
1696
1689
  },
1697
1690
  "releaseWorkflow": {
1698
1691
  "compileCommand": "pnpm run build:binary",
1699
- "packNpmArtifact": true,
1700
- "assetGlobs": ["dist/binaries/*", "dist/package/*"]
1692
+ "packNpmArtifact": true
1701
1693
  }
1702
1694
  }
1703
1695
  },
1704
- "@git.zone/tsdeno": {
1705
- "compileTargets": [
1706
- {
1707
- "name": "onebox-linux-x64",
1708
- "entryPoint": "binary/onebox.ts",
1709
- "outDir": "dist/binaries",
1710
- "target": "x86_64-unknown-linux-gnu",
1711
- "permissions": ["--allow-all"],
1712
- "noCheck": true,
1713
- "selfExtracting": true
1714
- },
1715
- {
1716
- "name": "onebox-linux-arm64",
1717
- "entryPoint": "binary/onebox.ts",
1718
- "outDir": "dist/binaries",
1719
- "target": "aarch64-unknown-linux-gnu",
1720
- "permissions": ["--allow-all"],
1721
- "noCheck": true,
1722
- "selfExtracting": true
1723
- }
1696
+ "@git.zone/tssea": {
1697
+ "nodeVersion": "26.11.1",
1698
+ "bundle": "./dist_node/main.mjs",
1699
+ "outDir": "./dist/binaries",
1700
+ "targets": [
1701
+ { "target": "linux-x64", "name": "onebox-linux-x64" },
1702
+ { "target": "linux-arm64", "name": "onebox-linux-arm64" }
1724
1703
  ]
1725
1704
  }
1726
1705
  }
1727
1706
  ```
1728
1707
 
1708
+ The executables come from the project's `@git.zone/tssea` configuration; GitZone keeps no target list of its own. It reads that configuration through `@git.zone/tssea/config` from the project's own install, so the project's tssea version interprets its own configuration and GitZone has no runtime dependency on tssea. The project must declare `@git.zone/tssea` ^1.1.0 in `dependencies` or `devDependencies` and have it installed (`pnpm install --save-dev @git.zone/tssea`, then `pnpm install`); `gitzone format` and `gitzone config doctor` say which step is missing, and they refuse an installed tssea outside ^1.1.0 and an `outDir` outside the project.
1709
+
1710
+ - **Asset names:** each target's `name` is the executable's file name and its release asset name, used exactly as given. A Windows name carries its `.exe`. The installer maps `uname` to `linux`, `macos` or `windows` and `x64` or `arm64`; the npm wrapper maps `process.platform:process.arch`; both download `releases/download/<version>/<name>`.
1711
+ - **Release workflow:** `releaseWorkflow.compileCommand` defaults to `pnpm exec tsbundle && pnpm exec tssea build`, tssea's documented build. The workflow sets up Node.js, installs dependencies, checks that the `package.json` version equals the tag, builds, and then checksums and uploads exactly the configured executables, the notice files tssea writes next to each, the staged installer (with `installer.distribution: "releaseAsset"`) and `SHA256SUMS.txt`. A missing file or a Gitea API error fails the job, and a re-run replaces the assets of the same name; nothing else in the output directory is uploaded. With `packNpmArtifact` it also packs and uploads the npm tarball.
1712
+
1729
1713
  `@git.zone/cli.schemaVersion` remains the CLI config schema. `@git.zone/cli.assets.schemaVersion` is scoped to the managed asset model.
1730
1714
 
1731
1715
  Managed assets are applied through the existing formatter workflow:
@@ -1742,6 +1726,25 @@ Set `installer.distribution` to `"releaseAsset"` when the installer itself shoul
1742
1726
 
1743
1727
  Set `installer.service.removeLegacyUnits` to a list of systemd unit names when an installer must disable and remove older service units during upgrades.
1744
1728
 
1729
+ #### Migrating from `denoBinaryCli`
1730
+
1731
+ GitZone 9 refuses the removed keys with an error that names the replacement:
1732
+
1733
+ | Removed | Replacement |
1734
+ | --- | --- |
1735
+ | `kind: "denoBinaryCli"` | `kind: "binaryCli"` |
1736
+ | `@git.zone/tsdeno.compileTargets` | `@git.zone/tssea.targets` (see "Migrating from tsdeno" in the tssea readme); keep each `name`, and write the `.exe` of a Windows name |
1737
+ | `binary.targets`, `binary.outDir` | `@git.zone/tssea.targets`, `@git.zone/tssea.outDir` |
1738
+ | `releaseWorkflow.assetGlobs`, `releaseWorkflow.include` | none: the workflow uploads exactly the tssea executables, their notice files and `SHA256SUMS.txt` |
1739
+ | `releaseAssets` | `releaseWorkflow` |
1740
+ | `rawBranch`, `repository.rawBranch` | `repository.branch` |
1741
+ | `installer.delivery` | `installer.distribution` |
1742
+ | `installer.defaultMode` | `installer.modes.default` |
1743
+ | `installer.source` | `installer.modes.source` |
1744
+ | `installer.modes.source.validateCommand` | `installer.modes.source.validate` |
1745
+ | `installer.service.legacyUnitNames` | `installer.service.removeLegacyUnits` |
1746
+ | managed templates `asset_deno_binary_installer`, `asset_deno_binary_postinstall`, `asset_deno_binary_release_gitea` | `asset_binary_installer`, `asset_binary_postinstall`, `asset_binary_release_gitea` |
1747
+
1745
1748
  ### Sealed TsPack releases on Gitea
1746
1749
 
1747
1750
  For a component that already builds and packages with `@git.zone/tspack`, select
@@ -1753,9 +1756,11 @@ Pin pnpm 11 or later in `package.json` using `packageManager`. The workflow inst
1753
1756
  that version directly with the pinned official `pnpm/setup` action before the
1754
1757
  explicit frozen dependency install. This avoids an older container-provided pnpm
1755
1758
  launcher rewriting the lockfile while selecting the project's package manager.
1756
- The image's Deno CLI installs `sealedRelease.denoVersion` with `deno upgrade --force`.
1757
- The next command verifies the effective compiler version before dependency installation;
1758
- this setup does not require a separate Deno action.
1759
+ `sealedRelease.nodeVersion` is the exact Node.js release (`x.y.z`) that installs the
1760
+ dependencies and runs the prepare and verify commands. The workflow installs it with the
1761
+ SHA-pinned official `actions/setup-node` v4.4.0 and checks `node --version` before
1762
+ anything else runs. It is independent of the Node.js release a SEA build tool embeds.
1763
+ GitZone 9 refuses the former `sealedRelease.denoVersion` with a migration error.
1759
1764
 
1760
1765
  ```json
1761
1766
  {
@@ -1764,7 +1769,7 @@ this setup does not require a separate Deno action.
1764
1769
  "schemaVersion": 1,
1765
1770
  "kind": "tspackRelease",
1766
1771
  "sealedRelease": {
1767
- "denoVersion": "2.9.4",
1772
+ "nodeVersion": "24.13.0",
1768
1773
  "outputDirectory": "dist_control_release",
1769
1774
  "prepareCommand": ["node", "scripts/release-control.mjs"],
1770
1775
  "verifyCommand": ["node", "scripts/package-control.mjs", "--release", "--reuse"]
@@ -1875,32 +1880,18 @@ gitzone format --write --yes
1875
1880
  gitzone format fix
1876
1881
  ```
1877
1882
 
1878
- Formatters include cleanup, smartconfig normalization, dependency license checks, package metadata normalization, template updates, `.gitignore`, TypeScript config, Deno dependency-age exclusions, Prettier, README existence checks, and configured copy operations.
1883
+ Formatters include cleanup, smartconfig normalization, dependency license checks, package metadata normalization, template updates, `.gitignore`, TypeScript config, Prettier, README existence checks, and configured copy operations.
1879
1884
 
1880
1885
  The `packagejson` formatter writes the `files` list of `package.json`. It ships the `ts/` and `ts_web/` sources without their `tsconfig.json`: `@git.zone/tsbuild` reads a folder's compiler options from `<folder>/tsconfig.json`, which extends the root `tsconfig.json`, and the package does not ship the root file. The list therefore ends with `!ts/tsconfig.json` and `!ts_web/tsconfig.json`; pnpm 10 and 12 apply an exclusion only after the entries that include the file.
1881
1886
 
1882
- The `deno` formatter keeps Deno's minimum dependency age (24 hours by default since Deno 2.9) from holding back our own freshly published packages. When the project has a root `deno.json` or `deno.jsonc`, it makes `minimumDependencyAge.exclude` contain `npm:<scope>/*` for every owner scope and sets the owner's age when the project sets none (list shortened here):
1883
-
1884
- ```json
1885
- {
1886
- "minimumDependencyAge": {
1887
- "age": "P7D",
1888
- "exclude": ["npm:@api.global/*", "npm:@git.zone/*", "npm:@push.rocks/*", "npm:zod"]
1889
- }
1890
- }
1891
- ```
1892
-
1893
- The owner scopes and the owner's age are exported constants, so no repository keeps a hand-copied list:
1887
+ The owner npm scopes are an exported constant, so no repository keeps a hand-copied list:
1894
1888
 
1895
1889
  ```typescript
1896
- import { ownerMinimumDependencyAge, ownerNpmScopes } from '@git.zone/cli';
1890
+ import { ownerNpmScopes } from '@git.zone/cli';
1897
1891
  // ownerNpmScopes: ['@api.global', '@apiclient.xyz', ..., '@push.rocks', '@serve.zone', ...]
1898
- // ownerMinimumDependencyAge: 'P7D'
1899
1892
  ```
1900
1893
 
1901
- Project-specific entries stay, and the list is deduplicated and sorted. `ownerMinimumDependencyAge` is 7 days and mirrors the owner's pnpm `minimumReleaseAge` of 10080 minutes, so third-party packages wait as long under Deno as under pnpm (Deno's own default is 24 hours). It is written only when the age is missing or `null`; an age the project sets is kept as it is, `false` and `0` included. A scalar `"minimumDependencyAge": "P1D"` becomes `{ "age": "P1D", "exclude": [...] }`, and the object always lists `age` before `exclude`. Deno reads the setting from the workspace root only, so workspace members are never written: a member that sets it is reported as a warning, and a run inside a member plans nothing. A project without a Deno config gets none. A config that is not plain JSON (comments, trailing commas) is reported as an error and left untouched, so its comments are never dropped.
1902
-
1903
- Tools must never pass `--min-dep-age` or `--minimum-dependency-age` to Deno: the flag replaces the whole setting and discards the exclusions in `deno.json`. `.npmrc` (`min-release-age`) and `NPM_CONFIG_MIN_RELEASE_AGE` set only the age; the exclusions stay in effect.
1894
+ `--only`, `--skip` and `@git.zone/cli.format.modules.only`/`skip` accept the module names `cleanup`, `smartconfig`, `license`, `packagejson`, `templates`, `assets`, `gitignore`, `tsconfig`, `prettier`, `readme` and `copy`; any other name is refused with that list. `gitzone format --write` writes nothing while the plan carries an error.
1904
1895
 
1905
1896
  The template formatter owns `.vscode/settings.json` and `.vscode/launch.json` in every project, and the Gitea workflows, CLI entry points and HTML entry files of the project types that declare them. Workflow and entry files are written from the template as a whole. The formatter never creates or changes a `Dockerfile` or `.dockerignore`: they describe the project's own image. `gitzone template service` and `gitzone template website` scaffold a first pnpm-based Dockerfile.
1906
1897
 
@@ -2300,7 +2291,7 @@ machine-wide prune leaves them untouched.
2300
2291
  NoSQLDB runs with SCRAM-SHA-256 authentication enabled; the root user is
2301
2292
  `MONGODB_USER`/`MONGODB_PASS` in the `admin` database. Authentication can be
2302
2293
  disabled per project for
2303
- runtimes whose `node:crypto` cannot complete a SCRAM handshake (notably Deno):
2294
+ clients that cannot complete a SCRAM handshake:
2304
2295
 
2305
2296
  ```bash
2306
2297
  gitzone services auth mongodb off
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/cli',
6
- version: '8.11.0',
6
+ version: '9.0.0',
7
7
  description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
8
8
  }
@@ -0,0 +1,215 @@
1
+ import * as plugins from './plugins.js';
2
+ import { isPlainObject } from './helpers.objects.js';
3
+ import { resolveProjectTsseaOutputs, type ITsseaOutput } from './helpers.tssea.js';
4
+
5
+ /** The managed asset kinds `@git.zone/cli.assets.kind` accepts. */
6
+ export const managedAssetKinds = ['binaryCli', 'tspackRelease'] as const;
7
+ export type TManagedAssetKind = (typeof managedAssetKinds)[number];
8
+
9
+ /** The operating system names the installer uses. */
10
+ export type TBinaryTargetOs = 'linux' | 'macos' | 'windows';
11
+
12
+ /** One executable `@git.zone/tssea` builds, as the managed installer, npm wrapper and release workflow address it. */
13
+ export interface IBinaryTarget {
14
+ /** The tssea target, e.g. `linux-x64`. */
15
+ target: ITsseaOutput['target'];
16
+ /** The exact executable file name, which is also its release asset name. */
17
+ name: string;
18
+ /** The installer's operating system label (`uname -s` mapped). */
19
+ os: TBinaryTargetOs;
20
+ arch: ITsseaOutput['arch'];
21
+ /** `<process.platform>:<process.arch>`, the npm wrapper's lookup key. */
22
+ nodeKey: string;
23
+ /** Human-readable platform, e.g. `macOS ARM64`. */
24
+ label: string;
25
+ /** The notice files tssea writes next to the executable. */
26
+ noticeFiles: string[];
27
+ }
28
+
29
+ /** The executables of a `binaryCli` project. */
30
+ export interface IBinaryBuild {
31
+ /** tssea's output directory, relative to the project, `/`-separated. */
32
+ outDir: string;
33
+ targets: IBinaryTarget[];
34
+ }
35
+
36
+ const osOfPlatform = (platformArg: ITsseaOutput['platform']): TBinaryTargetOs => {
37
+ switch (platformArg) {
38
+ case 'linux':
39
+ return 'linux';
40
+ case 'darwin':
41
+ return 'macos';
42
+ case 'win32':
43
+ return 'windows';
44
+ default: {
45
+ const unknownPlatform: never = platformArg;
46
+ throw new Error(`Unknown tssea platform: ${String(unknownPlatform)}`);
47
+ }
48
+ }
49
+ };
50
+
51
+ const osLabel = (osArg: TBinaryTargetOs): string => {
52
+ switch (osArg) {
53
+ case 'linux':
54
+ return 'Linux';
55
+ case 'macos':
56
+ return 'macOS';
57
+ case 'windows':
58
+ return 'Windows';
59
+ default: {
60
+ const unknownOs: never = osArg;
61
+ throw new Error(`Unknown operating system: ${String(unknownOs)}`);
62
+ }
63
+ }
64
+ };
65
+
66
+ const archLabel = (archArg: ITsseaOutput['arch']): string => {
67
+ switch (archArg) {
68
+ case 'x64':
69
+ return 'x64';
70
+ case 'arm64':
71
+ return 'ARM64';
72
+ default: {
73
+ const unknownArch: never = archArg;
74
+ throw new Error(`Unknown tssea architecture: ${String(unknownArch)}`);
75
+ }
76
+ }
77
+ };
78
+
79
+ /**
80
+ * The executables of the project's `@git.zone/tssea` configuration, resolved by the tssea
81
+ * the project installs. The output directory must lie inside the project, because the
82
+ * release workflow addresses it from the checkout.
83
+ */
84
+ export const readBinaryBuild = async (
85
+ projectDirArg: string,
86
+ smartconfigDataArg: Record<string, unknown>,
87
+ ): Promise<IBinaryBuild> => {
88
+ const resolved = await resolveProjectTsseaOutputs(projectDirArg, smartconfigDataArg);
89
+ const relativeOutDir = plugins.path.relative(plugins.path.resolve(projectDirArg), resolved.outDir);
90
+ if (!relativeOutDir || relativeOutDir.startsWith('..') || plugins.path.isAbsolute(relativeOutDir)) {
91
+ throw new Error(
92
+ `@git.zone/tssea.outDir resolves to ${resolved.outDir}, which is not a directory inside the project: binaryCli releases its executables from the project checkout.`,
93
+ );
94
+ }
95
+ return {
96
+ outDir: relativeOutDir.split(plugins.path.sep).join('/'),
97
+ targets: resolved.outputs.map((outputArg) => {
98
+ const os = osOfPlatform(outputArg.platform);
99
+ return {
100
+ target: outputArg.target,
101
+ name: outputArg.name,
102
+ os,
103
+ arch: outputArg.arch,
104
+ nodeKey: `${outputArg.platform}:${outputArg.arch}`,
105
+ label: `${osLabel(os)} ${archLabel(outputArg.arch)}`,
106
+ noticeFiles: [...outputArg.noticeFiles],
107
+ };
108
+ }),
109
+ };
110
+ };
111
+
112
+ const removedIn = 'was removed in @git.zone/cli 9';
113
+
114
+ /** The value at a key path inside `@git.zone/cli.assets`; undefined when any segment is missing. */
115
+ const valueAt = (rootArg: Record<string, unknown>, pathArg: string[]): unknown => {
116
+ let value: unknown = rootArg;
117
+ for (const segment of pathArg) {
118
+ if (!isPlainObject(value)) {
119
+ return undefined;
120
+ }
121
+ value = value[segment];
122
+ }
123
+ return value;
124
+ };
125
+
126
+ /** Keys of the binary asset model that @git.zone/cli 9 removed, with the key that replaces each. */
127
+ const removedBinaryCliKeys: ReadonlyArray<{ path: string[]; replacement: string }> = [
128
+ {
129
+ path: ['binary', 'targets'],
130
+ replacement: 'binaryCli builds the targets of @git.zone/tssea.targets',
131
+ },
132
+ {
133
+ path: ['binary', 'outDir'],
134
+ replacement: 'binaryCli reads the output directory from @git.zone/tssea.outDir',
135
+ },
136
+ { path: ['releaseAssets'], replacement: 'use @git.zone/cli.assets.releaseWorkflow' },
137
+ { path: ['rawBranch'], replacement: 'use @git.zone/cli.assets.repository.branch' },
138
+ { path: ['repository', 'rawBranch'], replacement: 'use @git.zone/cli.assets.repository.branch' },
139
+ { path: ['installer', 'delivery'], replacement: 'use @git.zone/cli.assets.installer.distribution' },
140
+ { path: ['installer', 'defaultMode'], replacement: 'use @git.zone/cli.assets.installer.modes.default' },
141
+ { path: ['installer', 'source'], replacement: 'use @git.zone/cli.assets.installer.modes.source' },
142
+ {
143
+ path: ['installer', 'modes', 'source', 'validateCommand'],
144
+ replacement: 'use @git.zone/cli.assets.installer.modes.source.validate',
145
+ },
146
+ {
147
+ path: ['installer', 'service', 'legacyUnitNames'],
148
+ replacement: 'use @git.zone/cli.assets.installer.service.removeLegacyUnits',
149
+ },
150
+ {
151
+ path: ['releaseWorkflow', 'assetGlobs'],
152
+ replacement: 'the release workflow uploads exactly the @git.zone/tssea executables, their notice files and SHA256SUMS.txt',
153
+ },
154
+ {
155
+ path: ['releaseWorkflow', 'include'],
156
+ replacement: 'the release workflow uploads exactly the @git.zone/tssea executables, their notice files and SHA256SUMS.txt',
157
+ },
158
+ ];
159
+
160
+ /** The binary asset templates @git.zone/cli 9 renamed. */
161
+ const renamedTemplates: Readonly<Record<string, string>> = {
162
+ asset_deno_binary_installer: 'asset_binary_installer',
163
+ asset_deno_binary_postinstall: 'asset_binary_postinstall',
164
+ asset_deno_binary_release_gitea: 'asset_binary_release_gitea',
165
+ };
166
+
167
+ /**
168
+ * The configuration errors of an enabled `@git.zone/cli.assets` object that come from
169
+ * keys @git.zone/cli 9 removed or renamed. Each message names the migration.
170
+ */
171
+ export const getManagedAssetsMigrationErrors = (assetsArg: Record<string, unknown>): string[] => {
172
+ const errors: string[] = [];
173
+ if (assetsArg.kind === 'denoBinaryCli') {
174
+ errors.push(
175
+ `Managed asset kind "denoBinaryCli" ${removedIn}: set @git.zone/cli.assets.kind to "binaryCli" and move @git.zone/tsdeno.compileTargets to @git.zone/tssea.targets (see "Migrating from tsdeno" in the @git.zone/tssea readme).`,
176
+ );
177
+ }
178
+ if (assetsArg.kind === 'binaryCli' || assetsArg.kind === 'denoBinaryCli') {
179
+ for (const removed of removedBinaryCliKeys) {
180
+ if (valueAt(assetsArg, removed.path) !== undefined) {
181
+ errors.push(`@git.zone/cli.assets.${removed.path.join('.')} ${removedIn}: ${removed.replacement}.`);
182
+ }
183
+ }
184
+ }
185
+ if (isPlainObject(assetsArg.sealedRelease) && assetsArg.sealedRelease.denoVersion !== undefined) {
186
+ errors.push(
187
+ `@git.zone/cli.assets.sealedRelease.denoVersion ${removedIn}: set sealedRelease.nodeVersion to the exact Node.js release (x.y.z) that runs the prepare and verify commands.`,
188
+ );
189
+ }
190
+ if (Array.isArray(assetsArg.managed)) {
191
+ for (const entry of assetsArg.managed) {
192
+ const template = isPlainObject(entry) ? entry.template : undefined;
193
+ if (typeof template === 'string' && renamedTemplates[template]) {
194
+ errors.push(
195
+ `Managed asset template "${template}" was renamed in @git.zone/cli 9: use "${renamedTemplates[template]}".`,
196
+ );
197
+ }
198
+ }
199
+ }
200
+ return errors;
201
+ };
202
+
203
+ /**
204
+ * Throws the migration errors of an enabled `@git.zone/cli.assets` object, so every
205
+ * reader of the asset model refuses a removed key the same way.
206
+ */
207
+ export const assertManagedAssetsCurrent = (assetsArg: unknown): void => {
208
+ if (!isPlainObject(assetsArg) || assetsArg.enabled === false) {
209
+ return;
210
+ }
211
+ const errors = getManagedAssetsMigrationErrors(assetsArg);
212
+ if (errors.length > 0) {
213
+ throw new Error(errors.join('\n'));
214
+ }
215
+ };
@@ -1,12 +1,8 @@
1
1
  /**
2
2
  * The npm scopes the owner publishes under. A release-age rule (pnpm
3
- * `minimumReleaseAge`, Deno `minimumDependencyAge`) holds back freshly
4
- * published third-party versions; it must never hold back our own packages,
5
- * which are consumed right after their release.
6
- *
7
- * This list is the single source for those exemptions. `gitzone format`
8
- * writes it into the root `deno.json` as `minimumDependencyAge.exclude`
9
- * (`npm:<scope>/*` per scope), so no repository keeps a hand-copied list.
3
+ * `minimumReleaseAge`) holds back freshly published third-party versions; it
4
+ * must never hold back our own packages, which are consumed right after their
5
+ * release. This list is the single source for those exemptions.
10
6
  */
11
7
  export const ownerNpmScopes = [
12
8
  '@api.global',
@@ -74,11 +70,3 @@ export const ownerNpmScopes = [
74
70
  '@workspace.global_private',
75
71
  ] as const;
76
72
 
77
- /**
78
- * The minimum dependency age `gitzone format` writes into a root `deno.json`
79
- * that sets none (a missing or `null` age): 7 days, as an ISO 8601 duration.
80
- * It mirrors the owner's pnpm `minimumReleaseAge` of 10080 minutes, so
81
- * third-party packages wait as long under Deno as under pnpm. An age a project
82
- * already sets is never changed.
83
- */
84
- export const ownerMinimumDependencyAge = 'P7D';
@@ -1,6 +1,7 @@
1
1
  import * as plugins from "./plugins.js";
2
2
  import { getCliNamespaceConfig, readSmartconfigFile } from "./helpers.smartconfig.js";
3
3
  import { isPlainObject } from "./helpers.objects.js";
4
+ import { assertManagedAssetsCurrent } from "./helpers.managedassets.js";
4
5
 
5
6
  /**
6
7
  * The named groups of package.json `files` entries, in the order the generated
@@ -62,17 +63,19 @@ const configPath = "@git.zone/cli.packageFiles";
62
63
 
63
64
  /**
64
65
  * The sets as they stand for one project. `binary` carries the installer and
65
- * npm wrapper of managed `denoBinaryCli` assets and is empty otherwise.
66
+ * npm wrapper of managed `binaryCli` assets and is empty otherwise. Assets that
67
+ * use a key @git.zone/cli 9 removed are refused with the migration.
66
68
  */
67
69
  export const getPackageFileSets = (
68
70
  assetsArg: IPackageFilesAssetsConfig | undefined,
69
71
  ): Record<TPackageFileSetName, IPackageFileSet> => {
72
+ assertManagedAssetsCurrent(assetsArg);
70
73
  const assets = assetsArg?.enabled === false ? undefined : assetsArg;
71
74
  const binary: string[] = [];
72
- if (assets?.kind === "denoBinaryCli" && assets.installer?.enabled !== false) {
75
+ if (assets?.kind === "binaryCli" && assets.installer?.enabled !== false) {
73
76
  binary.push(assets.installer?.file || "install.sh");
74
77
  }
75
- if (assets?.kind === "denoBinaryCli" && assets.npmWrapper?.enabled) {
78
+ if (assets?.kind === "binaryCli" && assets.npmWrapper?.enabled) {
76
79
  binary.push("bin/");
77
80
  binary.push(assets.npmWrapper.postinstallFile || "scripts/install-binary.js");
78
81
  }
@@ -2,12 +2,12 @@
2
2
  export const getSealedReleaseConfigError = (value: unknown): string | undefined => {
3
3
  const config = value as Record<string, unknown> | null;
4
4
  if (!config || typeof config !== 'object' || Array.isArray(config) ||
5
- typeof config.denoVersion !== 'string' || !/^\d+\.\d+\.\d+$/.test(config.denoVersion) ||
5
+ typeof config.nodeVersion !== 'string' || !/^\d+\.\d+\.\d+$/.test(config.nodeVersion) ||
6
6
  typeof config.outputDirectory !== 'string' || !/^dist_[a-zA-Z0-9_-]+$/.test(config.outputDirectory) ||
7
7
  config.outputDirectory === 'dist_gitzone_retained' ||
8
8
  !['prepareCommand', 'verifyCommand'].every((key) => Array.isArray(config[key]) && config[key].length > 0 &&
9
9
  config[key].every((item: unknown) => typeof item === 'string' && item.length > 0 && !item.includes('\0')))) {
10
- return 'tspackRelease requires a pinned Deno version, a dist_ output directory and explicit prepare/verify command arrays.';
10
+ return 'tspackRelease requires an exact Node.js version (sealedRelease.nodeVersion, x.y.z), a dist_ output directory and explicit prepare/verify command arrays.';
11
11
  }
12
12
  return undefined;
13
13
  };
@@ -0,0 +1,102 @@
1
+ import type { ITsseaOutputs, resolveOutputs } from '@git.zone/tssea/config';
2
+ import * as plugins from './plugins.js';
3
+ import { isPlainObject } from './helpers.objects.js';
4
+
5
+ export type { ITsseaOutput, ITsseaOutputs } from '@git.zone/tssea/config';
6
+
7
+ /** The tssea package whose `./config` export resolves a project's executables. */
8
+ export const tsseaPackageName = '@git.zone/tssea';
9
+
10
+ /** The `@git.zone/tssea` versions whose `./config` export this CLI reads: `^1.1.0`. */
11
+ export const supportedTsseaRange = '^1.1.0';
12
+
13
+ /** The `./config` module of the project's tssea; loaded at run time from the project, typed from the CLI's devDependency. */
14
+ interface ITsseaConfigModule {
15
+ resolveOutputs: typeof resolveOutputs;
16
+ }
17
+
18
+ /** A tssea failure, recognized by shape: `instanceof` fails across package copies. */
19
+ const isTsseaError = (errorArg: unknown): errorArg is Error & { code: string } =>
20
+ errorArg instanceof Error &&
21
+ errorArg.name === 'TsseaError' &&
22
+ typeof (errorArg as Error & { code?: unknown }).code === 'string';
23
+
24
+ /** Whether an exact `x.y.z` version satisfies `^1.1.0`; prereleases do not. */
25
+ const isSupportedTsseaVersion = (versionArg: string): boolean => {
26
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(versionArg);
27
+ if (!match) {
28
+ return false;
29
+ }
30
+ const [major, minor] = [Number(match[1]), Number(match[2])];
31
+ return major === 1 && minor >= 1;
32
+ };
33
+
34
+ const readProjectManifest = async (projectDirArg: string): Promise<Record<string, unknown>> => {
35
+ const manifestPath = plugins.path.join(projectDirArg, 'package.json');
36
+ let content: string;
37
+ try {
38
+ content = await plugins.fs.readFile(manifestPath, 'utf8');
39
+ } catch (error) {
40
+ throw new Error(`binaryCli assets need the project's package.json: ${manifestPath} cannot be read.`, {
41
+ cause: error,
42
+ });
43
+ }
44
+ const manifest: unknown = JSON.parse(content);
45
+ if (!isPlainObject(manifest)) {
46
+ throw new Error(`${manifestPath} does not hold a JSON object.`);
47
+ }
48
+ return manifest;
49
+ };
50
+
51
+ const declaresDependency = (manifestArg: Record<string, unknown>, nameArg: string): boolean =>
52
+ ['dependencies', 'devDependencies'].some((fieldArg) => {
53
+ const field = manifestArg[fieldArg];
54
+ return isPlainObject(field) && typeof field[nameArg] === 'string';
55
+ });
56
+
57
+ /**
58
+ * Resolves the executables of the project's `@git.zone/tssea` configuration with the tssea
59
+ * the project itself installs, so the project's tssea version interprets its own config.
60
+ */
61
+ export const resolveProjectTsseaOutputs = async (
62
+ projectDirArg: string,
63
+ smartconfigDataArg: Record<string, unknown>,
64
+ ): Promise<ITsseaOutputs> => {
65
+ const manifest = await readProjectManifest(projectDirArg);
66
+ if (!declaresDependency(manifest, tsseaPackageName)) {
67
+ throw new Error(
68
+ `binaryCli builds with ${tsseaPackageName}; \`pnpm install --save-dev ${tsseaPackageName}\`, then rerun.`,
69
+ );
70
+ }
71
+ // The project's own direct link, never one an ancestor folder would resolve.
72
+ const installPath = plugins.path.join(projectDirArg, 'node_modules', ...tsseaPackageName.split('/'));
73
+ try {
74
+ await plugins.fs.lstat(installPath);
75
+ } catch {
76
+ throw new Error(`${tsseaPackageName} is declared but not installed in ${projectDirArg}: run \`pnpm install\`, then rerun.`);
77
+ }
78
+ const projectRequire = plugins.nodeModule.createRequire(plugins.path.join(projectDirArg, 'package.json'));
79
+ const installedManifest: unknown = projectRequire(`${tsseaPackageName}/package.json`);
80
+ const installedVersion =
81
+ isPlainObject(installedManifest) && typeof installedManifest.version === 'string'
82
+ ? installedManifest.version
83
+ : 'unknown';
84
+ if (!isSupportedTsseaVersion(installedVersion)) {
85
+ const newerMajor = /^(\d+)\./.exec(installedVersion);
86
+ throw new Error(
87
+ newerMajor && Number(newerMajor[1]) > 1
88
+ ? `The project installs ${tsseaPackageName} ${installedVersion}, but this @git.zone/cli supports ${supportedTsseaRange}: update @git.zone/cli.`
89
+ : `The project installs ${tsseaPackageName} ${installedVersion}, but this @git.zone/cli supports ${supportedTsseaRange}: upgrade ${tsseaPackageName} in the project.`,
90
+ );
91
+ }
92
+ const configModuleUrl = plugins.nodeUrl.pathToFileURL(projectRequire.resolve(`${tsseaPackageName}/config`)).href;
93
+ const configModule = (await import(configModuleUrl)) as ITsseaConfigModule;
94
+ try {
95
+ return configModule.resolveOutputs(smartconfigDataArg[tsseaPackageName], projectDirArg);
96
+ } catch (error) {
97
+ if (isTsseaError(error)) {
98
+ throw new Error(`${tsseaPackageName}: ${error.message} [${error.code}]`, { cause: error });
99
+ }
100
+ throw error;
101
+ }
102
+ };