@arc-e-tect/api-only-publisher 0.18.0 → 0.18.1
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.adoc +5 -3
- package/package.json +1 -1
- package/src/channels.js +20 -9
package/README.adoc
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
:source-highlighter: rouge
|
|
7
7
|
// The released version of this component: its snippets use it. The release
|
|
8
8
|
// workflow updates it; do not change it by hand.
|
|
9
|
-
:api-only-publisher-version: 0.18.
|
|
9
|
+
:api-only-publisher-version: 0.18.1
|
|
10
10
|
|
|
11
11
|
[NOTE]
|
|
12
12
|
.About this documentation
|
|
@@ -691,7 +691,8 @@ Configured portfolio: paths=none, location=portfolios
|
|
|
691
691
|
|`file`
|
|
692
692
|
|A local directory, laid out as `<directory>/<target>/<version>/`.
|
|
693
693
|
Not a distribution mechanism between repositories: it makes the pipeline testable end to end with no infrastructure, lets a library share one build with the projects that implement it, and is a local-iteration escape hatch.
|
|
694
|
-
Like a registry, it never replaces a version it holds with other documents (<<idempotent,Publishing the same version again §>>)
|
|
694
|
+
Like a registry, it never replaces a version it holds with other documents (<<idempotent,Publishing the same version again §>>).
|
|
695
|
+
With `clean: true` the directory is a build output rather than a record of releases: only the version being published is kept, and it holds the last build, so a version built again with other documents replaces it.
|
|
695
696
|
|
|
696
697
|
|`maven`
|
|
697
698
|
|A path publishes into a repository layout on disk; an `http(s)` URL deploys to a remote repository with an HTTP `PUT` per file, and keeps its `maven-metadata.xml` (<<maven-remote,Publishing to a remote Maven repository §>>).
|
|
@@ -776,7 +777,8 @@ What happens when the destination already has the version:
|
|
|
776
777
|
|The same documents: nothing is written or sent, and the log says `already published, identical`, or `with the same documents` when the copy came from another commit.
|
|
777
778
|
Other documents: the version is not published to that channel, and the run warns, naming the version -- a published version is never replaced, so publish the change as a new version (<<channel-problems,When a channel cannot take a version §>>).
|
|
778
779
|
A copy that cannot be read, so there is nothing to compare, is treated as one with other documents, saying why it `cannot be compared`.
|
|
779
|
-
`file` compares the `manifest.json` in the version's directory
|
|
780
|
+
`file` compares the `manifest.json` in the version's directory.
|
|
781
|
+
With `clean: true`, a build output, it replaces a version with other documents instead, logging `Replaced`, and removes the other versions; what guards a release there is the check before `publish` (<<version-guard,A changed target needs a new version §>>), and a subscriber's lockfile after it.
|
|
780
782
|
`maven` and `gitlab-package` read back every file before uploading any, so a run interrupted half-way is completed by the next one; a GitLab registry that allows duplicate packages, as it does by default, would otherwise replace a version.
|
|
781
783
|
A version completed beside an archive from another commit gets that archive's `manifest.json`, so the two agree on where the version came from; a POM carries no documents, and one already there is left as it is.
|
|
782
784
|
`github-release` reads the manifest in the asset the release has, and never overwrites one.
|
package/package.json
CHANGED
package/src/channels.js
CHANGED
|
@@ -34,7 +34,10 @@ function format(template, manifest) {
|
|
|
34
34
|
* Not a real distribution mechanism. It exists so the pipeline is testable end
|
|
35
35
|
* to end before any remote exists, and as a local-iteration escape hatch
|
|
36
36
|
* afterwards. Like the registries, it never replaces a version: one it holds with
|
|
37
|
-
* the same documents is left alone, and one with other documents is refused
|
|
37
|
+
* the same documents is left alone, and one with other documents is refused --
|
|
38
|
+
* unless `clean: true` declares the directory a build output, not a record of
|
|
39
|
+
* releases, where the last build is what it holds. What guards a release is then
|
|
40
|
+
* the git check before `publish`, and a subscriber's lockfile after it.
|
|
38
41
|
*/
|
|
39
42
|
function publishFile(archive, manifest, options, log) {
|
|
40
43
|
// Relative to the library root, not to wherever the CLI happened to be run.
|
|
@@ -44,21 +47,29 @@ function publishFile(archive, manifest, options, log) {
|
|
|
44
47
|
const manifestDest = path.join(targetDir, "manifest.json");
|
|
45
48
|
const files = [archiveDest, manifestDest];
|
|
46
49
|
|
|
50
|
+
const buildOutput = options.clean === true;
|
|
47
51
|
const held = fs.existsSync(manifestDest) ? judgeHeld(fs.readFileSync(manifestDest), "json", manifest) : null;
|
|
48
|
-
|
|
52
|
+
const replaced = held && held.verdict !== "same";
|
|
53
|
+
if (replaced && !buildOutput) {
|
|
49
54
|
throw new ChannelConflict(`${dir} already has ${manifest.target} ${manifest.version}, and it ` +
|
|
50
55
|
`${held.verdict === "different" ? "is not this one" : `cannot be compared: ${held.reason}`}; ` +
|
|
51
56
|
"a published version is never replaced, so publish the change as a new version");
|
|
52
57
|
}
|
|
53
|
-
// `clean: true` keeps only the version being published
|
|
54
|
-
// directory is a build output rather than a record of releases: an
|
|
55
|
-
// version is published again from the commit that declared it.
|
|
56
|
-
if (
|
|
58
|
+
// `clean: true` keeps only the version being published, and the last build of it.
|
|
59
|
+
// Used where the directory is a build output rather than a record of releases: an
|
|
60
|
+
// older version is published again from the commit that declared it.
|
|
61
|
+
if (buildOutput && fs.existsSync(path.join(dir, manifest.target))) {
|
|
57
62
|
for (const version of fs.readdirSync(path.join(dir, manifest.target))) {
|
|
58
|
-
if (version !== manifest.version
|
|
63
|
+
if (version !== manifest.version || replaced) {
|
|
64
|
+
fs.rmSync(path.join(dir, manifest.target, version), { recursive: true, force: true });
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
|
-
if (
|
|
68
|
+
if (replaced) {
|
|
69
|
+
log(`-- Replaced ${manifest.target} ${manifest.version} in ${dir}, which clean: true makes a build output: it held ` +
|
|
70
|
+
(held.verdict === "different" ? "other documents" : `a copy that cannot be compared (${held.reason})`));
|
|
71
|
+
}
|
|
72
|
+
if (held && !replaced && fs.existsSync(archiveDest)) {
|
|
62
73
|
const identical = fs.readFileSync(archiveDest).equals(fs.readFileSync(archive));
|
|
63
74
|
log(`-- ${manifest.target} ${manifest.version} is already published, ` +
|
|
64
75
|
`${identical ? "identical" : "with the same documents"}, in ${dir}; nothing to do`);
|
|
@@ -68,7 +79,7 @@ function publishFile(archive, manifest, options, log) {
|
|
|
68
79
|
fs.copyFileSync(archive, archiveDest);
|
|
69
80
|
fs.writeFileSync(manifestDest, JSON.stringify(manifest, null, 2) + "\n");
|
|
70
81
|
|
|
71
|
-
log(`-- Published ${manifest.target} ${manifest.version} to ${archiveDest}`);
|
|
82
|
+
if (!replaced) log(`-- Published ${manifest.target} ${manifest.version} to ${archiveDest}`);
|
|
72
83
|
return { location: archiveDest, files };
|
|
73
84
|
}
|
|
74
85
|
|