@wtf/release-oci 2.1.0 → 3.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.
package/dist/errors.js CHANGED
@@ -1,27 +1,28 @@
1
1
  /**
2
- * What the release of OCI images throws: {@link OciError}, a `ReleaseError` of
3
- * `@wtf/release-system/errors` of the codes of {@link OCI_ERRORS}, which semantic-release prints by
4
- * its mark, beside the codes of the options of a plugin, its `SYSTEM_ERRORS` (`EOPTIONS`). What is
5
- * the same of every ecosystem, as a package of two trains, is the trains' own, `TRAINS_ERRORS` of
6
- * `@wtf/release-trains/errors`.
2
+ * What the release of OCI images throws: {@link OciError}, a `ReleaseError` of `@wtf/release/errors`
3
+ * of the codes of {@link OCI_ERRORS}, beside the codes of the options of a plugin, its
4
+ * `RELEASE_ERRORS` (`EOPTIONS`). What is the same of every ecosystem, as the plan of a release, is
5
+ * its driver's own.
7
6
  *
8
7
  * @packageDocumentation
9
8
  * @module @wtf/release-oci/errors
10
9
  */
11
- import { ReleaseError } from '@wtf/release-system/errors';
10
+ import { ReleaseError } from '@wtf/release/errors';
12
11
  /** The codes of the errors of the OCI images, each with what it means. */
13
12
  export const OCI_ERRORS = {
14
13
  EOCIECOSYSTEM: 'The `ecosystems` of the config lists neither `@wtf/semantic-release-oci/ecosystem` nor `@wtf/release-oci`, so the trains read no image.',
15
14
  EOCIIMAGE: 'The repository of an image cannot be named: neither the option `image` nor `CI_REGISTRY_IMAGE` of the environment gives one.',
16
- EOCISOURCE: 'The tested image of a release cannot be named: neither the option `sourceTag` nor `CI_COMMIT_REF_SLUG` of the environment gives its tag.',
15
+ EOCISOURCE: 'The tested image of a release cannot be named: neither the option `sourceTag` nor `CI_COMMIT_REF_SLUG` of the environment gives its tag, or the options of the ecosystem give no `source`.',
16
+ EOCIVERSION: 'The version of a release, or a tag that moves with it, is no tag of an image, or a tag is given twice.',
17
17
  EOCISMOKE: 'The registry has not the tested image of a release, or crane cannot ask it: there is nothing to copy to the tags of the release.',
18
18
  EOCIRETAG: 'The registry has the full version of a release already, at another digest: a released version is never moved.',
19
19
  EOCITAG: 'crane cannot copy the tested image to a tag of the release.',
20
+ EOCIMOVE: 'The registry has not the version of a release, so the tags that move with it have nothing to point at.',
20
21
  EOCILINK: 'The container registry of GitLab cannot be asked the page of an image, or lists none.'
21
22
  };
22
23
  /**
23
24
  * An error of the OCI images, or of the options of the plugin over them: a stable `code`, of
24
- * {@link OCI_ERRORS} or of `SYSTEM_ERRORS` of `@wtf/release-system/errors`, its `message` what is
25
+ * {@link OCI_ERRORS} or of `RELEASE_ERRORS` of `@wtf/release/errors`, its `message` what is
25
26
  * wrong, and its `details` how to fix it.
26
27
  */
27
28
  export class OciError extends ReleaseError {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,aAAa,EACX,yIAAyI;IAC3I,SAAS,EACP,8HAA8H;IAChI,UAAU,EACR,0IAA0I;IAC5I,SAAS,EACP,kIAAkI;IACpI,SAAS,EACP,+GAA+G;IACjH,OAAO,EAAE,6DAA6D;IACtE,QAAQ,EAAE,uFAAuF;CACzF,CAAA;AAKV;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;CAAG"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,aAAa,EACX,yIAAyI;IAC3I,SAAS,EACP,8HAA8H;IAChI,UAAU,EACR,4LAA4L;IAC9L,WAAW,EACT,wGAAwG;IAC1G,SAAS,EACP,kIAAkI;IACpI,SAAS,EACP,+GAA+G;IACjH,OAAO,EAAE,6DAA6D;IACtE,QAAQ,EACN,wGAAwG;IAC1G,QAAQ,EAAE,uFAAuF;CACzF,CAAA;AAKV;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;CAAG"}
package/dist/images.d.ts CHANGED
@@ -8,19 +8,19 @@
8
8
  * the images of a project.
9
9
  *
10
10
  * ```ts
11
+ * import type { RepoPlatform } from '@wtf/release'
11
12
  * import { readImages } from '@wtf/release-oci/images'
12
- * import type { System } from '@wtf/release-system'
13
13
  *
14
14
  * // The folders of the images of the repo.
15
- * export async function folders(system: System): Promise<string[]> {
16
- * return (await readImages({ system })).map(({ dir }) => dir)
15
+ * export async function folders(platform: RepoPlatform): Promise<string[]> {
16
+ * return (await readImages({ platform })).map(({ dir }) => dir)
17
17
  * }
18
18
  * ```
19
19
  *
20
20
  * @packageDocumentation
21
21
  * @module @wtf/release-oci/images
22
22
  */
23
- import { type GitContext } from '@wtf/release-system/git';
23
+ import { type GitContext } from '@wtf/release/git';
24
24
  import type { OciImage } from './index.ts';
25
25
  /**
26
26
  * The folder of the image `file` is built of: of a `Dockerfile` or a `Containerfile`, its folder; of
@@ -60,7 +60,7 @@ export declare function imagesOf(files: readonly string[], registryImage: string
60
60
  * The registry image of the project of `context`, as GitLab gives a pipeline it:
61
61
  * `CI_REGISTRY_IMAGE` of the environment; none of none.
62
62
  *
63
- * @param context - The environment of the run, of its system.
63
+ * @param context - The platform of the run, of its environment.
64
64
  * @returns The registry image, or none.
65
65
  */
66
66
  export declare function registryImageOf(context: GitContext): string | undefined;
@@ -68,7 +68,7 @@ export declare function registryImageOf(context: GitContext): string | undefined
68
68
  * The images of the repo of `context`: each folder of the working tree that git tracks a file an
69
69
  * image is built of in.
70
70
  *
71
- * @param context - The folder of the repo, its environment, and the system git runs by.
71
+ * @param context - The platform git runs by, of the folder of the repo.
72
72
  * @param registryImage - The registry image of the project: {@link registryImageOf} by default.
73
73
  * @returns The images, by their folders.
74
74
  */
@@ -78,7 +78,7 @@ export declare function readImages(context: GitContext, registryImage?: string |
78
78
  * an image is built of, by `git ls-tree`.
79
79
  *
80
80
  * @param ref - The commit, as `HEAD` or the tag of a release.
81
- * @param context - The folder of the repo, its environment, and the system git runs by.
81
+ * @param context - The platform git runs by, of the folder of the repo.
82
82
  * @param registryImage - The registry image of the project: {@link registryImageOf} by default.
83
83
  * @returns The images, by their folders.
84
84
  * @throws `EGIT` of a commit git has not.
@@ -1 +1 @@
1
- {"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAO,KAAK,UAAU,EAAuB,MAAM,yBAAyB,CAAA;AAGnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAQ1C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK3D;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,OAAyC,CAAA;AAExF;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI/F;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,EAAE,CAShG;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAGvE;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,UAAU,EACnB,aAAa,GAAE,MAAM,GAAG,SAAoC,GAC3D,OAAO,CAAC,QAAQ,EAAE,CAAC,CAErB;AAED;;;;;;;;;GASG;AACH,wBAAs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+8,20 @@
8
8
  * the images of a project.
9
9
  *
10
10
  * ```ts
11
+ * import type { RepoPlatform } from '@wtf/release'
11
12
  * import { readImages } from '@wtf/release-oci/images'
12
- * import type { System } from '@wtf/release-system'
13
13
  *
14
14
  * // The folders of the images of the repo.
15
- * export async function folders(system: System): Promise<string[]> {
16
- * return (await readImages({ system })).map(({ dir }) => dir)
15
+ * export async function folders(platform: RepoPlatform): Promise<string[]> {
16
+ * return (await readImages({ platform })).map(({ dir }) => dir)
17
17
  * }
18
18
  * ```
19
19
  *
20
20
  * @packageDocumentation
21
21
  * @module @wtf/release-oci/images
22
22
  */
23
- import { git, gitOf, trackedFiles } from '@wtf/release-system/git';
24
- import { basenameOf, dirnameOf } from '@wtf/release-system/posix';
23
+ import { git, trackedFiles } from '@wtf/release/git';
24
+ import { basenameOf, dirnameOf } from '@wtf/release/posix';
25
25
  /** The names of the files an image is built of, at the root of its folder. */
26
26
  const BUILD_FILES = new Set(['Dockerfile', 'Containerfile']);
27
27
  /** The file of a devcontainer the devcontainer CLI builds, from the folder of its image. */
@@ -87,18 +87,18 @@ export function imagesOf(files, registryImage) {
87
87
  * The registry image of the project of `context`, as GitLab gives a pipeline it:
88
88
  * `CI_REGISTRY_IMAGE` of the environment; none of none.
89
89
  *
90
- * @param context - The environment of the run, of its system.
90
+ * @param context - The platform of the run, of its environment.
91
91
  * @returns The registry image, or none.
92
92
  */
93
93
  export function registryImageOf(context) {
94
- const value = gitOf(context).env['CI_REGISTRY_IMAGE'];
94
+ const value = context.platform.env['CI_REGISTRY_IMAGE'];
95
95
  return value === undefined || value === '' ? undefined : value;
96
96
  }
97
97
  /**
98
98
  * The images of the repo of `context`: each folder of the working tree that git tracks a file an
99
99
  * image is built of in.
100
100
  *
101
- * @param context - The folder of the repo, its environment, and the system git runs by.
101
+ * @param context - The platform git runs by, of the folder of the repo.
102
102
  * @param registryImage - The registry image of the project: {@link registryImageOf} by default.
103
103
  * @returns The images, by their folders.
104
104
  */
@@ -110,7 +110,7 @@ export async function readImages(context, registryImage = registryImageOf(contex
110
110
  * an image is built of, by `git ls-tree`.
111
111
  *
112
112
  * @param ref - The commit, as `HEAD` or the tag of a release.
113
- * @param context - The folder of the repo, its environment, and the system git runs by.
113
+ * @param context - The platform git runs by, of the folder of the repo.
114
114
  * @param registryImage - The registry image of the project: {@link registryImageOf} by default.
115
115
  * @returns The images, by their folders.
116
116
  * @throws `EGIT` of a commit git has not.
@@ -1 +1 @@
1
- {"version":3,"file":"images.js","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,GAAG,EAAmB,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAIjE,8EAA8E;AAC9E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAA;AAE5D,4FAA4F;AAC5F,MAAM,YAAY,GAAG,iCAAiC,CAAA;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;IAC7D,IAAI,IAAI,KAAK,YAAY;QAAE,OAAO,GAAG,CAAA;IACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,YAAY,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACrF,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS,CAAA;AAExF;;;;;;;;GAQG;AACH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GED
@@ -1,14 +1,16 @@
1
1
  /**
2
- * The OCI images of a repo released in trains, of no release tool and no rebuild. Its default export
3
- * is the ecosystem of OCI images, `ociEcosystem` of `./ecosystem`, which a config of the trains
4
- * names in `ecosystems` as `'@wtf/release-oci'`, so the trains read the images of the repo by it;
5
- * and this module holds the type of an image, which the modules of this package do with: the
6
- * images of the repo, each folder of a Dockerfile, a Containerfile or a
7
- * `.devcontainer/devcontainer.json` (`./images`), the tags of a release (`./tags`), the tested image
8
- * of each copied to them by crane (`./publish`), and the page of each in the container registry of
9
- * GitLab (`./registry`). An image is built and tested by its own pipeline; a release copies the
10
- * image it tested, by its digest, to the tags of its version, so the bytes released are the bytes
11
- * tested. Each function takes the `System` it runs by, and runs `git` and `crane` through it.
2
+ * The OCI images of a repo released, of no release tool and no rebuild. Its default export is the
3
+ * ecosystem of OCI images, `ociEcosystem` of `./ecosystem`, a `ReleasingEcosystem` of
4
+ * `@wtf/release/contract`, which a config names in `ecosystems` as `'@wtf/release-oci'`, and a driver
5
+ * runs the steps of; and this module holds the type of an image, which the modules of this package
6
+ * do with: the images of the repo, each folder of a Dockerfile, a Containerfile or a
7
+ * `.devcontainer/devcontainer.json` (`./images`), the tags of a release checked (`./tags`), the
8
+ * tested image of each copied to the tag of its version, and the tags that move pointed at it, by
9
+ * crane (`./publish`), and the page of each in the container registry of GitLab (`./registry`). An
10
+ * image is built and tested by its own pipeline; a release copies the image it tested, by its
11
+ * digest, to the tags of its version, so the bytes released are the bytes tested. Each function
12
+ * takes the platform it runs by, of the folder of the repo as its working folder, and runs `git`
13
+ * and `crane` by it.
12
14
  *
13
15
  * ```ts
14
16
  * import type { OciImage } from '@wtf/release-oci'
@@ -38,6 +40,6 @@ export interface OciImage {
38
40
  */
39
41
  readonly repository: string | undefined;
40
42
  }
41
- /** The ecosystem of OCI images, which a config of the trains names as `'@wtf/release-oci'`. */
43
+ /** The ecosystem of OCI images, which a config names as `'@wtf/release-oci'`. */
42
44
  export default ociEcosystem;
43
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,gFAAgF;IAChF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CACxC;AAED,+FAA+F;AAC/F,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,gFAAgF;IAChF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CACxC;AAED,iFAAiF;AACjF,eAAe,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  /**
2
- * The OCI images of a repo released in trains, of no release tool and no rebuild. Its default export
3
- * is the ecosystem of OCI images, `ociEcosystem` of `./ecosystem`, which a config of the trains
4
- * names in `ecosystems` as `'@wtf/release-oci'`, so the trains read the images of the repo by it;
5
- * and this module holds the type of an image, which the modules of this package do with: the
6
- * images of the repo, each folder of a Dockerfile, a Containerfile or a
7
- * `.devcontainer/devcontainer.json` (`./images`), the tags of a release (`./tags`), the tested image
8
- * of each copied to them by crane (`./publish`), and the page of each in the container registry of
9
- * GitLab (`./registry`). An image is built and tested by its own pipeline; a release copies the
10
- * image it tested, by its digest, to the tags of its version, so the bytes released are the bytes
11
- * tested. Each function takes the `System` it runs by, and runs `git` and `crane` through it.
2
+ * The OCI images of a repo released, of no release tool and no rebuild. Its default export is the
3
+ * ecosystem of OCI images, `ociEcosystem` of `./ecosystem`, a `ReleasingEcosystem` of
4
+ * `@wtf/release/contract`, which a config names in `ecosystems` as `'@wtf/release-oci'`, and a driver
5
+ * runs the steps of; and this module holds the type of an image, which the modules of this package
6
+ * do with: the images of the repo, each folder of a Dockerfile, a Containerfile or a
7
+ * `.devcontainer/devcontainer.json` (`./images`), the tags of a release checked (`./tags`), the
8
+ * tested image of each copied to the tag of its version, and the tags that move pointed at it, by
9
+ * crane (`./publish`), and the page of each in the container registry of GitLab (`./registry`). An
10
+ * image is built and tested by its own pipeline; a release copies the image it tested, by its
11
+ * digest, to the tags of its version, so the bytes released are the bytes tested. Each function
12
+ * takes the platform it runs by, of the folder of the repo as its working folder, and runs `git`
13
+ * and `crane` by it.
12
14
  *
13
15
  * ```ts
14
16
  * import type { OciImage } from '@wtf/release-oci'
@@ -22,6 +24,6 @@
22
24
  * @module @wtf/release-oci
23
25
  */
24
26
  import { ociEcosystem } from "./ecosystem.js";
25
- /** The ecosystem of OCI images, which a config of the trains names as `'@wtf/release-oci'`. */
27
+ /** The ecosystem of OCI images, which a config names as `'@wtf/release-oci'`. */
26
28
  export default ociEcosystem;
27
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAmB7C,+FAA+F;AAC/F,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAmB7C,iFAAiF;AACjF,eAAe,YAAY,CAAA"}
package/dist/publish.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type GitContext } from '@wtf/release-system/git';
1
+ import type { GitContext } from '@wtf/release/git';
2
2
  /** The tested image of a release: its repository and its tag, as the pipeline that tested it wrote it. */
3
3
  export interface OciSource {
4
4
  /** Its repository, as `registry.gitlab.com/acme/images/base/snapshot`. */
@@ -13,7 +13,10 @@ export interface ImageToPublish {
13
13
  /** The tested image, which the release copies. */
14
14
  readonly source: OciSource;
15
15
  }
16
- /** Where crane runs: the folder, the environment and the system, and the command of crane. */
16
+ /**
17
+ * Where crane runs: the platform, whose working folder, `dirs.cwd`, is the folder of the repo, and
18
+ * whose `env` crane is given; and the command of crane.
19
+ */
17
20
  export interface CraneContext extends GitContext {
18
21
  /** The command of crane, by its name on the path or its path: `crane` by default. */
19
22
  readonly crane?: string | undefined;
@@ -25,14 +28,12 @@ export interface SmokedImage extends ImageToPublish {
25
28
  /** The platforms it is of, as `linux/amd64`: none of an image of one manifest of no index. */
26
29
  readonly platforms: readonly string[];
27
30
  }
28
- /** An image of a release published: each tag copied, and each the registry had already. */
31
+ /** An image of a release published: the tag of its version copied, or found at its digest. */
29
32
  export interface PublishedImage extends SmokedImage {
30
- /** The version of the release, as `1.4.2`. */
33
+ /** The version of the release, its tag, as `1.4.2`. */
31
34
  readonly version: string;
32
- /** Each tag the release copied the source to, the version's first. */
33
- readonly tags: readonly string[];
34
- /** Each tag the registry had already at the digest of the source, and the release skipped. */
35
- readonly skipped: readonly string[];
35
+ /** Whether the registry had the version at the digest of the source already, and none was copied. */
36
+ readonly skipped: boolean;
36
37
  }
37
38
  /**
38
39
  * The digest of the image `ref`, as `crane digest` gives it: none of a repository or a tag the
@@ -77,13 +78,10 @@ export interface ImagesRelease {
77
78
  * version that is no semver, `12.12-wtf.1`. A tag of an image, `[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}`.
78
79
  */
79
80
  readonly version: string;
80
- /**
81
- * The tags that move to each release of their line, copied on every run, as `['1.4', '1']`, which
82
- * `releaseTagsOf` of `./tags` gives of a semver version, or `['12.12', 'latest']`: none of `[]`.
83
- */
84
- readonly moving: readonly string[];
85
81
  /** The platforms each source must be of: any by default. */
86
82
  readonly platforms?: readonly string[] | undefined;
83
+ /** Whether the release only says what it would copy, and copies nothing: `false` by default. */
84
+ readonly dryRun?: boolean | undefined;
87
85
  /**
88
86
  * Where the steps are said, a line each.
89
87
  *
@@ -93,13 +91,57 @@ export interface ImagesRelease {
93
91
  }
94
92
  /**
95
93
  * The images of a release published: each source smoked ({@link smokeImages}), then copied by its
96
- * digest to the tag of the version, of an image the registry has not at it, and to each moving tag:
97
- * the tags the release gives. Throws a `TypeError` of a tag an image cannot have, or of one given
98
- * twice, before it asks the registry anything; then, together, `EOCIRETAG` of each image whose version the registry has at another digest,
99
- * before anything is copied; and `EOCITAG` of a copy crane cannot make.
94
+ * digest to the tag of the version, of an image the registry has not at it. Throws `EOCIVERSION` of
95
+ * a version that is no tag of an image, before it asks the registry anything; then, together,
96
+ * `EOCIRETAG` of each image whose version the registry has at another digest, before anything is
97
+ * copied; and `EOCITAG` of a copy crane cannot make. A dry run asks the registry, and copies
98
+ * nothing.
100
99
  *
101
- * @param release - The images, the version and the tags that move, and where crane runs.
102
- * @returns Each image, of the tags copied and skipped.
100
+ * @param release - The images and the version, and where crane runs.
101
+ * @returns Each image, of its digest, and whether its version was there already.
103
102
  */
104
103
  export declare function publishImages(release: ImagesRelease): Promise<PublishedImage[]>;
104
+ /** What {@link moveImages} moves. */
105
+ export interface ImagesMove {
106
+ /** Where crane runs, and its command. */
107
+ readonly context: CraneContext;
108
+ /** The repository of each image of the release, as `registry.gitlab.com/acme/images/base`. */
109
+ readonly repositories: readonly string[];
110
+ /** The version of the release, its tag, which the registry has of each image. */
111
+ readonly version: string;
112
+ /**
113
+ * The tags that move to the version, as `['1.4', '1']` or `['12.12', 'latest']`: none of `[]`.
114
+ * A tag of an image each, and none the version's.
115
+ */
116
+ readonly moving: readonly string[];
117
+ /** Whether the release only says what it would copy, and copies nothing: `false` by default. */
118
+ readonly dryRun?: boolean | undefined;
119
+ /**
120
+ * Where the steps are said, a line each.
121
+ *
122
+ * @param line - The line.
123
+ */
124
+ readonly log?: ((line: string) => void) | undefined;
125
+ }
126
+ /** An image whose tags that move point at its version. */
127
+ export interface MovedImage {
128
+ /** The repository of the image, as `registry.gitlab.com/acme/images/base`. */
129
+ readonly repository: string;
130
+ /** The digest of its version, as `sha256:…`, which each tag that moves is copied of. */
131
+ readonly digest: string;
132
+ /** Each tag that moves, copied of the digest of the version. */
133
+ readonly tags: readonly string[];
134
+ }
135
+ /**
136
+ * Points the tags that move of each image at the version of the release: the digest the registry has
137
+ * of the version, copied to each, `crane copy <image>@<digest> <image>:<tag>`, every time. Throws
138
+ * `EOCIVERSION` of a tag that is no tag of an image, or given twice, before it asks the registry
139
+ * anything; then, together, `EOCIMOVE` of each image whose version the registry has not, before
140
+ * anything is copied; and `EOCITAG` of a copy crane cannot make. A dry run asks the registry, and
141
+ * copies nothing.
142
+ *
143
+ * @param move - The repositories, the version and the tags that move, and where crane runs.
144
+ * @returns Each image, of the digest of its version and the tags copied of it.
145
+ */
146
+ export declare function moveImages(move: ImagesMove): Promise<MovedImage[]>;
105
147
  //# sourceMappingURL=publish.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,KAAK,UAAU,EAAS,MAAM,yBAAyB,CAAA;AAKhE,0GAA0G;AAC1G,MAAM,WAAW,SAAS;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED,gGAAgG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AC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;CACpD;AA+BD;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAoCrF;AAED,qCAAqC;AACrC,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;IAC9B,8FAA8F;IAC9F,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,gGAAgG;IAChG,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACrC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;CACpD;AAED,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA6BxE"}
package/dist/publish.js CHANGED
@@ -1,33 +1,39 @@
1
1
  /**
2
2
  * The images of a release published, of no rebuild, by crane: {@link smokeImages} finds the tested
3
3
  * image of each, its source, by its digest, and the platforms it is of; {@link publishImages} copies
4
- * that digest to each tag of the release, `crane copy <source>@<digest> <image>:<tag>`, which mounts
5
- * each blob of the source's repository rather than moving it. The tag of the version is copied once:
6
- * a registry that has it at the same digest is skipped, so a release that stopped part way is
7
- * finished by running it again, and at another digest is refused (`EOCIRETAG`), as a released
8
- * version never moves. The moving tags the release gives, as `1.4` and `1`, of `releaseTagsOf` of
9
- * `./tags`, or `12.12` and `latest` of a version that is no semver, as `12.12-wtf.1`, are copied
10
- * every time.
4
+ * that digest to the tag of the version, `crane copy <source>@<digest> <image>:<version>`, which
5
+ * mounts each blob of the source's repository rather than moving it; and {@link moveImages} points
6
+ * the tags that move at the version, as `1.4` and `1` of `1.4.2`, or `12.12` and `latest` of
7
+ * `12.12-wtf.1`, by the digest the registry has of it. The tag of the version is copied once: a
8
+ * registry that has it at the same digest is skipped, so a release that stopped part way is finished
9
+ * by running it again, and at another digest is refused (`EOCIRETAG`), as a released version never
10
+ * moves. The tags that move are copied every time.
11
11
  *
12
- * crane runs by the `System` it is given, of the environment it is given: it reads the credentials
13
- * of the registry of its own config, as `crane auth login` writes it, or of the docker config.
12
+ * crane runs by the platform it is given, in the folder of the repo and of the platform's
13
+ * environment: it reads the credentials of the registry of its own config, as `crane auth login`
14
+ * writes it, or of the docker config.
14
15
  *
15
16
  * ```ts
16
- * import { publishImages } from '@wtf/release-oci/publish'
17
- * import { releaseTagsOf } from '@wtf/release-oci/tags'
18
- * import type { System } from '@wtf/release-system'
17
+ * import type { RepoPlatform } from '@wtf/release'
18
+ * import { moveImages, publishImages } from '@wtf/release-oci/publish'
19
19
  *
20
- * export async function release(system: System): Promise<void> {
20
+ * export async function release(platform: RepoPlatform): Promise<void> {
21
+ * const repository = 'registry.gitlab.com/acme/images/base'
21
22
  * await publishImages({
22
- * context: { system },
23
+ * context: { platform },
23
24
  * images: [
24
25
  * {
25
- * repository: 'registry.gitlab.com/acme/images/base',
26
- * source: { repository: 'registry.gitlab.com/acme/images/base/snapshot', tag: 'base-v1-4-2' }
26
+ * repository,
27
+ * source: { repository: `${repository}/snapshot`, tag: 'base-v1-4-2' }
27
28
  * }
28
29
  * ],
30
+ * version: '1.4.2'
31
+ * })
32
+ * await moveImages({
33
+ * context: { platform },
34
+ * repositories: [repository],
29
35
  * version: '1.4.2',
30
- * moving: releaseTagsOf('1.4.2').moving
36
+ * moving: ['1.4', '1']
31
37
  * })
32
38
  * }
33
39
  * ```
@@ -35,8 +41,8 @@
35
41
  * @packageDocumentation
36
42
  * @module @wtf/release-oci/publish
37
43
  */
38
- import { throwAll } from '@wtf/release-system/errors';
39
- import { gitOf } from '@wtf/release-system/git';
44
+ import { throwAll } from '@wtf/release/errors';
45
+ import { run } from '@wtf/release/process';
40
46
  import { OciError } from "./errors.js";
41
47
  import { checkReleaseTags } from "./tags.js";
42
48
  /** The reference of a source, of its repository and its tag. */
@@ -46,15 +52,14 @@ const isAbsent = (stderr) => /MANIFEST_UNKNOWN|NAME_UNKNOWN|NOT_FOUND|not found|
46
52
  /** The command of crane of `context`. */
47
53
  const craneOf = (context) => context.crane ?? 'crane';
48
54
  /**
49
- * Runs crane with `args`, in the folder and the environment of `context`.
55
+ * Runs crane with `args`, by the platform of `context`, in its folder and of its environment.
50
56
  *
51
57
  * @param args - The arguments of crane, as `['digest', 'registry.example/a:1']`.
52
58
  * @param context - Where crane runs, and its command.
53
59
  * @returns What crane wrote, and its exit code.
54
60
  */
55
61
  async function crane(args, context) {
56
- const { cwd, env, system } = gitOf(context);
57
- return system.exec(craneOf(context), args, { cwd, env });
62
+ return run(context.platform, craneOf(context), args);
58
63
  }
59
64
  /**
60
65
  * The digest of the image `ref`, as `crane digest` gives it: none of a repository or a tag the
@@ -133,52 +138,98 @@ export async function smokeImages(images, context, platforms = []) {
133
138
  throwAll(errors);
134
139
  return smoked;
135
140
  }
141
+ /**
142
+ * Copies `source` to `target` by crane, or of a dry run, says it would. Throws `EOCITAG` of a copy
143
+ * crane cannot make.
144
+ *
145
+ * @param source - The image copied, by its digest, as `registry.example/a/snapshot@sha256:…`.
146
+ * @param target - The tag it is copied to, as `registry.example/a:1.4.2`.
147
+ * @param context - Where crane runs, and its command.
148
+ * @param release - Whether it is a dry run, and where the copy is said.
149
+ */
150
+ async function copyImage(source, target, context, release) {
151
+ if (release.dryRun === true) {
152
+ release.log(`Would copy ${source} to ${target}.`);
153
+ return;
154
+ }
155
+ const { stderr, code } = await crane(['copy', source, target], context);
156
+ if (code !== 0)
157
+ throw new OciError('EOCITAG', `crane cannot copy ${source} to ${target}: ${stderr.trim() || `exit code ${code}`}`, 'Check that crane is logged in to the registry of a token that may write the repository, and run the release of the tag again: what is published is skipped.');
158
+ release.log(`Copied ${source.slice(source.lastIndexOf('@') + 1)} to ${target}.`);
159
+ }
136
160
  /**
137
161
  * The images of a release published: each source smoked ({@link smokeImages}), then copied by its
138
- * digest to the tag of the version, of an image the registry has not at it, and to each moving tag:
139
- * the tags the release gives. Throws a `TypeError` of a tag an image cannot have, or of one given
140
- * twice, before it asks the registry anything; then, together, `EOCIRETAG` of each image whose version the registry has at another digest,
141
- * before anything is copied; and `EOCITAG` of a copy crane cannot make.
162
+ * digest to the tag of the version, of an image the registry has not at it. Throws `EOCIVERSION` of
163
+ * a version that is no tag of an image, before it asks the registry anything; then, together,
164
+ * `EOCIRETAG` of each image whose version the registry has at another digest, before anything is
165
+ * copied; and `EOCITAG` of a copy crane cannot make. A dry run asks the registry, and copies
166
+ * nothing.
142
167
  *
143
- * @param release - The images, the version and the tags that move, and where crane runs.
144
- * @returns Each image, of the tags copied and skipped.
168
+ * @param release - The images and the version, and where crane runs.
169
+ * @returns Each image, of its digest, and whether its version was there already.
145
170
  */
146
171
  export async function publishImages(release) {
147
172
  const { context } = release;
148
173
  const log = release.log ?? (() => undefined);
149
- const tags = checkReleaseTags({ version: release.version, moving: release.moving });
174
+ const { version } = checkReleaseTags({ version: release.version, moving: [] });
150
175
  const smoked = await smokeImages(release.images, context, release.platforms ?? []);
151
176
  const errors = [];
152
177
  const has = new Map();
153
178
  for (const image of smoked) {
154
179
  // oxlint-disable-next-line no-await-in-loop -- crane asks the registry one image at a time
155
- const at = await digestOf(`${image.repository}:${tags.version}`, context);
180
+ const at = await digestOf(`${image.repository}:${version}`, context);
156
181
  has.set(image.repository, at);
157
182
  if (at !== undefined && at !== image.digest)
158
- errors.push(new OciError('EOCIRETAG', `${image.repository}:${tags.version} is ${at} already, not ${image.digest}, the tested image of the release.`, 'Release a new version: a released version is never moved. Delete the tag in the registry yourself only where nothing pulls it yet.'));
183
+ errors.push(new OciError('EOCIRETAG', `${image.repository}:${version} is ${at} already, not ${image.digest}, the tested image of the release.`, 'Release a new version: a released version is never moved. Delete the tag in the registry yourself only where nothing pulls it yet.'));
159
184
  }
160
185
  throwAll(errors);
161
186
  const published = [];
162
187
  for (const image of smoked) {
163
- const skipped = has.get(image.repository) === image.digest ? [tags.version] : [];
164
- const copy = skipped.length > 0 ? tags.moving : [tags.version, ...tags.moving];
165
- for (const tag of copy) {
166
- const target = `${image.repository}:${tag}`;
167
- // oxlint-disable-next-line no-await-in-loop -- one copy at a time, the version's first
168
- const { stderr, code } = await crane(['copy', `${image.source.repository}@${image.digest}`, target], context);
169
- if (code !== 0)
170
- throw new OciError('EOCITAG', `crane cannot copy ${image.source.repository}@${image.digest} to ${target}: ${stderr.trim() || `exit code ${code}`}`, 'Check that crane is logged in to the registry of a token that may write the repository, and run the release of the tag again: what is published is skipped.');
171
- log(`Copied ${image.digest} to ${target}.`);
172
- }
173
- for (const tag of skipped)
174
- log(`${image.repository}:${tag} is ${image.digest} already.`);
175
- published.push({
176
- ...image,
177
- version: tags.version,
178
- tags: [tags.version, ...tags.moving],
179
- skipped
180
- });
188
+ const skipped = has.get(image.repository) === image.digest;
189
+ if (skipped)
190
+ log(`${image.repository}:${version} is ${image.digest} already.`);
191
+ else
192
+ // oxlint-disable-next-line no-await-in-loop -- one copy at a time
193
+ await copyImage(`${image.source.repository}@${image.digest}`, `${image.repository}:${version}`, context, { dryRun: release.dryRun, log });
194
+ published.push({ ...image, version, skipped });
181
195
  }
182
196
  return published;
183
197
  }
198
+ /**
199
+ * Points the tags that move of each image at the version of the release: the digest the registry has
200
+ * of the version, copied to each, `crane copy <image>@<digest> <image>:<tag>`, every time. Throws
201
+ * `EOCIVERSION` of a tag that is no tag of an image, or given twice, before it asks the registry
202
+ * anything; then, together, `EOCIMOVE` of each image whose version the registry has not, before
203
+ * anything is copied; and `EOCITAG` of a copy crane cannot make. A dry run asks the registry, and
204
+ * copies nothing.
205
+ *
206
+ * @param move - The repositories, the version and the tags that move, and where crane runs.
207
+ * @returns Each image, of the digest of its version and the tags copied of it.
208
+ */
209
+ export async function moveImages(move) {
210
+ const { context } = move;
211
+ const log = move.log ?? (() => undefined);
212
+ const tags = checkReleaseTags({ version: move.version, moving: move.moving });
213
+ if (tags.moving.length === 0)
214
+ return [];
215
+ const errors = [];
216
+ const moved = [];
217
+ for (const repository of move.repositories) {
218
+ // oxlint-disable-next-line no-await-in-loop -- crane asks the registry one image at a time
219
+ const digest = await digestOf(`${repository}:${tags.version}`, context);
220
+ if (digest === undefined)
221
+ errors.push(new OciError('EOCIMOVE', `The registry has no ${repository}:${tags.version}, which the tags ${tags.moving.join(', ')} would point at.`, 'Publish the version first, then move its tags.'));
222
+ else
223
+ moved.push({ repository, digest, tags: tags.moving });
224
+ }
225
+ throwAll(errors);
226
+ for (const { repository, digest } of moved)
227
+ for (const tag of tags.moving)
228
+ // oxlint-disable-next-line no-await-in-loop -- one copy at a time
229
+ await copyImage(`${repository}@${digest}`, `${repository}:${tag}`, context, {
230
+ dryRun: move.dryRun,
231
+ log
232
+ });
233
+ return moved;
234
+ }
184
235
  //# sourceMappingURL=publish.js.map