@alchemy.run/pkg 2.0.0-beta.83 → 2.0.0-beta.85
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/Registry/Bindings.d.ts +1 -1
- package/dist/Registry/Bindings.d.ts.map +1 -1
- package/dist/Registry/Bindings.js +1 -1
- package/dist/Registry/Bindings.js.map +1 -1
- package/dist/Registry/GitHub.d.ts +6 -6
- package/dist/Registry/GitHub.d.ts.map +1 -1
- package/dist/Registry/GitHub.js +6 -2
- package/dist/Registry/GitHub.js.map +1 -1
- package/dist/Registry/Handler.d.ts +1 -1
- package/dist/Registry/Handler.d.ts.map +1 -1
- package/dist/Registry/Handler.js +6 -4
- package/dist/Registry/Handler.js.map +1 -1
- package/dist/Registry/KVCache.d.ts +1 -1
- package/dist/Registry/KVCache.d.ts.map +1 -1
- package/dist/Registry/KVCache.js +3 -3
- package/dist/Registry/KVCache.js.map +1 -1
- package/dist/Registry/Sweep.d.ts +1 -1
- package/dist/Registry/Sweep.d.ts.map +1 -1
- package/dist/Registry/Sweep.js +1 -1
- package/dist/Registry/Sweep.js.map +1 -1
- package/dist/Registry.d.ts +12 -2
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Registry.js +2 -2
- package/dist/Registry.js.map +1 -1
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +7 -8
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/publish.d.ts.map +1 -1
- package/dist/cli/publish.js +23 -10
- package/dist/cli/publish.js.map +1 -1
- package/package.json +10 -9
- package/src/Registry/Bindings.ts +1 -1
- package/src/Registry/GitHub.ts +8 -2
- package/src/Registry/Handler.ts +6 -4
- package/src/Registry/KVCache.ts +4 -4
- package/src/Registry/Sweep.ts +1 -1
- package/src/Registry.ts +2 -2
- package/src/cli/pack.ts +7 -8
- package/src/cli/publish.ts +40 -14
package/src/cli/publish.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as Config from "effect/Config";
|
|
2
|
-
import * as Console from "effect/Console";
|
|
3
2
|
import * as Data from "effect/Data";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
5
4
|
import * as FileSystem from "effect/FileSystem";
|
|
6
5
|
import * as HttpApiClient from "effect/http-api/HttpApiClient";
|
|
7
6
|
import * as Path from "effect/Path";
|
|
7
|
+
import * as Schedule from "effect/Schedule";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
9
|
import { MANIFEST_FILE, ManifestJson, type Manifest } from "../Manifest.ts";
|
|
10
10
|
import { PkgApi, type TarballRef } from "../Protocol.ts";
|
|
@@ -42,6 +42,28 @@ const failed = (what: string) => (e: { readonly _tag: string; readonly message?:
|
|
|
42
42
|
message: `${what}: ${e.message ? `${e._tag}: ${e.message}` : e._tag}`,
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* GitHub reports a run as queued, or as its previous attempt, for a few
|
|
47
|
+
* seconds after a job starts, and for minutes while Actions is degraded.
|
|
48
|
+
* The registry answers `RunNotInProgress` until GitHub catches up, so a
|
|
49
|
+
* request from inside the job waits that out, for up to three minutes.
|
|
50
|
+
*/
|
|
51
|
+
const whileRunCatchesUp = <A, E extends { readonly _tag: string }, R>(
|
|
52
|
+
effect: Effect.Effect<A, E, R>,
|
|
53
|
+
) =>
|
|
54
|
+
effect.pipe(
|
|
55
|
+
Effect.tapError((e) =>
|
|
56
|
+
e._tag === "RunNotInProgress"
|
|
57
|
+
? Effect.logInfo("GitHub does not report this run as in progress yet; retrying")
|
|
58
|
+
: Effect.void,
|
|
59
|
+
),
|
|
60
|
+
Effect.retry({
|
|
61
|
+
while: (e) => e._tag === "RunNotInProgress",
|
|
62
|
+
schedule: Schedule.spaced("5 seconds"),
|
|
63
|
+
times: 36,
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
|
|
45
67
|
/**
|
|
46
68
|
* Publish a `pkg pack` directory from the current GitHub Actions job. The
|
|
47
69
|
* workflow must first have uploaded the manifest as an artifact of the run
|
|
@@ -58,7 +80,7 @@ export const publish = Effect.fn("publish")(function* (options: PublishOptions)
|
|
|
58
80
|
|
|
59
81
|
const dir = path.resolve(options.cwd, options.dir);
|
|
60
82
|
const manifestText = yield* fs.readFileString(path.join(dir, MANIFEST_FILE));
|
|
61
|
-
const manifest = yield* Schema.
|
|
83
|
+
const manifest = yield* Schema.decodeEffect(ManifestJson)(manifestText);
|
|
62
84
|
if (manifest.registry !== registry) {
|
|
63
85
|
return yield* new PublishError({
|
|
64
86
|
message: `artifact was packed for ${manifest.registry}, not ${registry}`,
|
|
@@ -66,26 +88,28 @@ export const publish = Effect.fn("publish")(function* (options: PublishOptions)
|
|
|
66
88
|
}
|
|
67
89
|
|
|
68
90
|
if (manifest.packages.length === 0) {
|
|
69
|
-
yield*
|
|
91
|
+
yield* Effect.logInfo("No affected packages to publish.");
|
|
70
92
|
return { packages: [] };
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
const upload = (pkg: Manifest["packages"][number]) =>
|
|
74
96
|
Effect.gen(function* () {
|
|
75
97
|
const bytes = yield* fs.readFile(path.join(dir, pkg.file));
|
|
76
|
-
const result = yield*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
const result = yield* whileRunCatchesUp(
|
|
99
|
+
client.Registry.uploadTarball({
|
|
100
|
+
params: { name: pkg.name, sha256: pkg.sha256 },
|
|
101
|
+
query: run,
|
|
102
|
+
payload: bytes,
|
|
103
|
+
}),
|
|
104
|
+
).pipe(Effect.mapError(failed(`upload ${pkg.name}`)));
|
|
105
|
+
yield* Effect.logInfo(
|
|
82
106
|
`${result.uploaded ? "Uploaded" : "Reused"} ${pkg.name} (${pkg.sha256.slice(0, 12)}, ${pkg.size} bytes)`,
|
|
83
107
|
);
|
|
84
108
|
});
|
|
85
109
|
|
|
86
110
|
const uploadMissing = (missing: ReadonlyArray<TarballRef>) => {
|
|
87
111
|
const wanted = new Set(missing.map((ref) => `${ref.name}@${ref.sha256}`));
|
|
88
|
-
return
|
|
112
|
+
return Effect.logInfo(
|
|
89
113
|
`${missing.length} of ${manifest.packages.length} tarball(s) to upload`,
|
|
90
114
|
).pipe(
|
|
91
115
|
Effect.andThen(
|
|
@@ -98,9 +122,11 @@ export const publish = Effect.fn("publish")(function* (options: PublishOptions)
|
|
|
98
122
|
);
|
|
99
123
|
};
|
|
100
124
|
|
|
101
|
-
const attempt =
|
|
102
|
-
|
|
103
|
-
|
|
125
|
+
const attempt = whileRunCatchesUp(
|
|
126
|
+
client.Registry.publish({
|
|
127
|
+
payload: { run, manifest: manifestText },
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
104
130
|
const published = yield* attempt.pipe(
|
|
105
131
|
// The first answer is usually the tarballs to upload; publish once more
|
|
106
132
|
// after uploading them.
|
|
@@ -116,7 +142,7 @@ export const publish = Effect.fn("publish")(function* (options: PublishOptions)
|
|
|
116
142
|
);
|
|
117
143
|
|
|
118
144
|
for (const pkg of published.packages) {
|
|
119
|
-
yield*
|
|
145
|
+
yield* Effect.logInfo(`${pkg.name}: ${pkg.url} [${pkg.tags.join(", ")}]`);
|
|
120
146
|
}
|
|
121
147
|
return published;
|
|
122
148
|
});
|