@arc-e-tect/api-only-publisher 0.14.2 → 0.14.3

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 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.14.2
9
+ :api-only-publisher-version: 0.14.3
10
10
 
11
11
  [NOTE]
12
12
  .About this documentation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arc-e-tect/api-only-publisher",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "description": "Builds, packs and publishes API description documents from a library of reusable fragments.",
5
5
  "license": "MIT",
6
6
  "author": "Arc-E-Tect",
package/src/channels.js CHANGED
@@ -350,24 +350,31 @@ function publishMavenRemote(archive, manifest, options, log) {
350
350
  `${options.groupId.split(".").join("/")}/${artifactId}/${version}/${artifactId}-${version}`;
351
351
 
352
352
  const work = (async () => {
353
- // Idempotent: an artifact the repository already has is left alone when it is
354
- // the same bytes, and refused when it is not.
355
- const bytes = fs.readFileSync(archive);
356
- const existing = await getFile(`${base}.${extension}`, token);
357
- if (existing) {
358
- if (existing.equals(bytes)) return true;
359
- throw new ChannelError(
360
- `${options.repository} already has ${options.groupId}:${artifactId}:${version}, and it is not this archive. ` +
361
- "A published version is never replaced; publish the change as a new version.");
353
+ // Idempotent, file by file: each file the repository already has is left alone when
354
+ // it is the same bytes, and refuses the whole version when it is not. Every file is
355
+ // read back before any is uploaded, so a run interrupted after the artifact is
356
+ // completed by the next one, and a version that differs anywhere is not touched.
357
+ const files = [
358
+ { url: `${base}.${extension}`, bytes: fs.readFileSync(archive), type: "application/octet-stream" },
359
+ { url: `${base}.pom`, type: "application/xml",
360
+ bytes: Buffer.from(pom(options.groupId, artifactId, version, extension, pomDescription(options, manifest)), "utf8") },
361
+ { url: `${base}-manifest.json`, type: "application/json",
362
+ bytes: Buffer.from(JSON.stringify(manifest, null, 2) + "\n", "utf8") },
363
+ ];
364
+ const missing = [];
365
+ for (const file of files) {
366
+ const existing = await getFile(file.url, token);
367
+ if (!existing) {
368
+ missing.push(file);
369
+ } else if (!existing.equals(file.bytes)) {
370
+ throw new ChannelError(
371
+ `${options.repository} already has ${options.groupId}:${artifactId}:${version}, ` +
372
+ `and its ${file.url.split("/").pop()} is not this one. ` +
373
+ "A published version is never replaced; publish the change as a new version.");
374
+ }
362
375
  }
363
- await putFile(`${base}.${extension}`, bytes, token, "application/octet-stream");
364
- await putFile(`${base}.pom`,
365
- Buffer.from(pom(options.groupId, artifactId, version, extension, pomDescription(options, manifest)), "utf8"),
366
- token, "application/xml");
367
- await putFile(`${base}-manifest.json`,
368
- Buffer.from(JSON.stringify(manifest, null, 2) + "\n", "utf8"),
369
- token, "application/json");
370
- return false;
376
+ for (const file of missing) await putFile(file.url, file.bytes, token, file.type);
377
+ return missing.length === 0;
371
378
  })();
372
379
 
373
380
  // The CLI is synchronous throughout; surfacing the promise here would make