@alchemy.run/pkg 0.0.0-placeholder → 2.0.0-beta.78
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/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +117 -0
- package/dist/Manifest.d.ts +107 -0
- package/dist/Manifest.d.ts.map +1 -0
- package/dist/Manifest.js +58 -0
- package/dist/Manifest.js.map +1 -0
- package/dist/Protocol.d.ts +186 -0
- package/dist/Protocol.d.ts.map +1 -0
- package/dist/Protocol.js +115 -0
- package/dist/Protocol.js.map +1 -0
- package/dist/Registry/Bindings.d.ts +134 -0
- package/dist/Registry/Bindings.d.ts.map +1 -0
- package/dist/Registry/Bindings.js +92 -0
- package/dist/Registry/Bindings.js.map +1 -0
- package/dist/Registry/GitHub.d.ts +96 -0
- package/dist/Registry/GitHub.d.ts.map +1 -0
- package/dist/Registry/GitHub.js +226 -0
- package/dist/Registry/GitHub.js.map +1 -0
- package/dist/Registry/Handler.d.ts +53 -0
- package/dist/Registry/Handler.d.ts.map +1 -0
- package/dist/Registry/Handler.js +375 -0
- package/dist/Registry/Handler.js.map +1 -0
- package/dist/Registry/KVCache.d.ts +24 -0
- package/dist/Registry/KVCache.d.ts.map +1 -0
- package/dist/Registry/KVCache.js +42 -0
- package/dist/Registry/KVCache.js.map +1 -0
- package/dist/Registry/Sweep.d.ts +12 -0
- package/dist/Registry/Sweep.d.ts.map +1 -0
- package/dist/Registry/Sweep.js +69 -0
- package/dist/Registry/Sweep.js.map +1 -0
- package/dist/Registry/Tags.d.ts +49 -0
- package/dist/Registry/Tags.d.ts.map +1 -0
- package/dist/Registry/Tags.js +80 -0
- package/dist/Registry/Tags.js.map +1 -0
- package/dist/Registry.d.ts +378 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +119 -0
- package/dist/Registry.js.map +1 -0
- package/dist/cli/bin.d.ts +18 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +33 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/pack.d.ts +169 -0
- package/dist/cli/pack.d.ts.map +1 -0
- package/dist/cli/pack.js +447 -0
- package/dist/cli/pack.js.map +1 -0
- package/dist/cli/publish.d.ts +33 -0
- package/dist/cli/publish.d.ts.map +1 -0
- package/dist/cli/publish.js +76 -0
- package/dist/cli/publish.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/migrations/0001_init.sql +19 -0
- package/package.json +89 -1
- package/src/Manifest.ts +76 -0
- package/src/Protocol.ts +163 -0
- package/src/Registry/Bindings.ts +134 -0
- package/src/Registry/GitHub.ts +365 -0
- package/src/Registry/Handler.ts +549 -0
- package/src/Registry/KVCache.ts +68 -0
- package/src/Registry/Sweep.ts +117 -0
- package/src/Registry/Tags.ts +117 -0
- package/src/Registry.ts +197 -0
- package/src/cli/bin.ts +101 -0
- package/src/cli/pack.ts +603 -0
- package/src/cli/publish.ts +129 -0
- package/src/index.ts +5 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
4
|
+
/**
|
|
5
|
+
* The `tags` table: one row per `(package, tag)` pointing at a tarball hash.
|
|
6
|
+
* A tarball lives in R2 for as long as any row points at it. Every query
|
|
7
|
+
* runs against the ambient `SqlClient`, which the Worker provides from its
|
|
8
|
+
* D1 binding.
|
|
9
|
+
*/
|
|
10
|
+
const LinkedPrs = Schema.fromJsonString(Schema.Array(Schema.String));
|
|
11
|
+
export const TagRow = Schema.Struct({
|
|
12
|
+
package: Schema.String,
|
|
13
|
+
tag: Schema.String,
|
|
14
|
+
sha256: Schema.String,
|
|
15
|
+
expires_at: Schema.Number,
|
|
16
|
+
/** Pull requests whose runs produced this tag, as `owner/repo#N`. */
|
|
17
|
+
linked_prs: LinkedPrs,
|
|
18
|
+
});
|
|
19
|
+
const TarballRow = Schema.Struct({
|
|
20
|
+
package: Schema.String,
|
|
21
|
+
sha256: Schema.String,
|
|
22
|
+
});
|
|
23
|
+
const decodeTags = Schema.decodeUnknownEffect(Schema.Array(TagRow));
|
|
24
|
+
const decodeTarballs = Schema.decodeUnknownEffect(Schema.Array(TarballRow));
|
|
25
|
+
export const get = Effect.fn("Tags.get")(function* (pkg, tag) {
|
|
26
|
+
const sql = yield* SqlClient.SqlClient;
|
|
27
|
+
const rows = yield* decodeTags(yield* sql `SELECT * FROM tags WHERE package = ${pkg} AND tag = ${tag}`);
|
|
28
|
+
return rows[0];
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Point `tag` at `sha256`, keeping the row alive for at least `expiresAt`
|
|
32
|
+
* and remembering every pull request that produced it. One statement, so
|
|
33
|
+
* concurrent publications of a shared tag merge rather than overwrite.
|
|
34
|
+
*/
|
|
35
|
+
export const upsert = Effect.fn("Tags.upsert")(function* (input) {
|
|
36
|
+
const sql = yield* SqlClient.SqlClient;
|
|
37
|
+
const prs = yield* Schema.encodeEffect(LinkedPrs)(input.prs);
|
|
38
|
+
yield* sql `
|
|
39
|
+
INSERT INTO tags (package, tag, sha256, expires_at, linked_prs)
|
|
40
|
+
VALUES (${input.package}, ${input.tag}, ${input.sha256}, ${input.expiresAt}, ${prs})
|
|
41
|
+
ON CONFLICT (package, tag) DO UPDATE SET
|
|
42
|
+
sha256 = excluded.sha256,
|
|
43
|
+
expires_at = max(tags.expires_at, excluded.expires_at),
|
|
44
|
+
linked_prs = (
|
|
45
|
+
SELECT json_group_array(value) FROM (
|
|
46
|
+
SELECT value FROM json_each(tags.linked_prs)
|
|
47
|
+
UNION
|
|
48
|
+
SELECT value FROM json_each(excluded.linked_prs)
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
`;
|
|
52
|
+
});
|
|
53
|
+
export const resolve = (pkg, tag) => Effect.map(get(pkg, tag), (row) => row?.sha256);
|
|
54
|
+
/** Rows tied to pull requests whose expiry falls before `before`. */
|
|
55
|
+
export const dueLinked = Effect.fn("Tags.dueLinked")(function* (before) {
|
|
56
|
+
const sql = yield* SqlClient.SqlClient;
|
|
57
|
+
return yield* decodeTags(yield* sql `
|
|
58
|
+
SELECT * FROM tags WHERE linked_prs != '[]' AND expires_at < ${before}
|
|
59
|
+
`);
|
|
60
|
+
});
|
|
61
|
+
export const setExpiry = Effect.fn("Tags.setExpiry")(function* (pkg, tag, expiresAt) {
|
|
62
|
+
const sql = yield* SqlClient.SqlClient;
|
|
63
|
+
yield* sql `
|
|
64
|
+
UPDATE tags SET expires_at = ${expiresAt} WHERE package = ${pkg} AND tag = ${tag}
|
|
65
|
+
`;
|
|
66
|
+
});
|
|
67
|
+
/** Delete every expired row and return the tarballs those rows pointed at. */
|
|
68
|
+
export const deleteExpired = Effect.fn("Tags.deleteExpired")(function* (now) {
|
|
69
|
+
const sql = yield* SqlClient.SqlClient;
|
|
70
|
+
return yield* decodeTarballs(yield* sql `
|
|
71
|
+
DELETE FROM tags WHERE expires_at < ${now} RETURNING package, sha256
|
|
72
|
+
`);
|
|
73
|
+
});
|
|
74
|
+
/** Every tarball some tag still points at, as `<package>/<sha256>`. */
|
|
75
|
+
export const referencedTarballs = Effect.fn("Tags.referencedTarballs")(function* () {
|
|
76
|
+
const sql = yield* SqlClient.SqlClient;
|
|
77
|
+
const rows = yield* decodeTarballs(yield* sql `SELECT DISTINCT package, sha256 FROM tags`);
|
|
78
|
+
return new Set(rows.map((row) => `${row.package}/${row.sha256}`));
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=Tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tags.js","sourceRoot":"","sources":["../../src/Registry/Tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO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,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,EACpE,GAAW;IAEX,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;IACvC,OAAO,KAAK,CAAC,CAAC,cAAc,CAC1B,KAAK,CAAC,CAAC,GAAG,CAAA;4CAC8B,GAAG;KAC1C,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,yBAAyB,CAAC,CACpE,QAAQ,CAAC;IACP,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,cAAc,CAChC,KAAK,CAAC,CAAC,GAAG,CAAA,2CAA2C,CACtD,CAAC;IACF,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import * as Cloudflare from "alchemy/Cloudflare";
|
|
2
|
+
import type * as ByteSize from "effect/ByteSize";
|
|
3
|
+
import * as Config from "effect/Config";
|
|
4
|
+
import type * as Duration from "effect/Duration";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import { type GitHubCredentials, type WorkerOverrides } from "./Registry/Bindings.ts";
|
|
8
|
+
export { Bucket, Cache, Database, Policy, RegistryConfig, Settings, } from "./Registry/Bindings.ts";
|
|
9
|
+
export interface RegistryOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Worker props forwarded verbatim: `domain`, `name`, `compatibility`,
|
|
12
|
+
* `observability`, `access`, and so on. `main`, `env`, and `crons` are
|
|
13
|
+
* owned by the registry.
|
|
14
|
+
*/
|
|
15
|
+
readonly worker?: WorkerOverrides;
|
|
16
|
+
/** GitHub App credentials, read at deploy time and bound to the Worker. */
|
|
17
|
+
readonly github: GitHubCredentials & {
|
|
18
|
+
/** @default "https://api.github.com" */
|
|
19
|
+
readonly apiUrl?: string;
|
|
20
|
+
};
|
|
21
|
+
readonly policy: {
|
|
22
|
+
/** Repositories allowed to publish, as `owner/name`. */
|
|
23
|
+
readonly repos: ReadonlyArray<string>;
|
|
24
|
+
/** @default Duration.weeks(1) */
|
|
25
|
+
readonly ttl?: Duration.Duration;
|
|
26
|
+
/** Upper bound on a single tarball. Absent means unlimited. */
|
|
27
|
+
readonly maxPackageSize?: ByteSize.ByteSize;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Hostname to package scope. Requests on an aliased host resolve an
|
|
31
|
+
* unscoped name under that scope, so `pkg.distilled.cloud/core/<sha>`
|
|
32
|
+
* serves `@distilled.cloud/core`.
|
|
33
|
+
*/
|
|
34
|
+
readonly aliases?: Readonly<Record<string, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* Cron expression for the expiry sweep.
|
|
37
|
+
* @default "0 * * * *"
|
|
38
|
+
*/
|
|
39
|
+
readonly cron?: string;
|
|
40
|
+
}
|
|
41
|
+
declare const Registry_base: Effect.Effect<import("effect/Pipeable").Pipeable & import("alchemy").ResourceLike<"Cloudflare.Worker", Cloudflare.WorkerProps<any, Cloudflare.WorkerAssetsConfig | undefined>, {
|
|
42
|
+
workerId: string;
|
|
43
|
+
workerName: string;
|
|
44
|
+
namespace: string | undefined;
|
|
45
|
+
logpush: boolean | undefined;
|
|
46
|
+
url: string | undefined;
|
|
47
|
+
urls: string[];
|
|
48
|
+
domain: {
|
|
49
|
+
name: string;
|
|
50
|
+
aliases: string[];
|
|
51
|
+
redirects: string[];
|
|
52
|
+
zone?: Cloudflare.Zone.Reference;
|
|
53
|
+
previews?: boolean;
|
|
54
|
+
} | undefined;
|
|
55
|
+
tags: string[] | undefined;
|
|
56
|
+
durableObjectNamespaces: Record<string, string>;
|
|
57
|
+
accountId: string;
|
|
58
|
+
routes: {
|
|
59
|
+
id: string;
|
|
60
|
+
pattern: string;
|
|
61
|
+
zoneId: string;
|
|
62
|
+
}[];
|
|
63
|
+
crons: string[];
|
|
64
|
+
tailConsumers?: {
|
|
65
|
+
service: string;
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
streamingTailConsumers?: {
|
|
68
|
+
service: string;
|
|
69
|
+
}[] | undefined;
|
|
70
|
+
versionOf?: string | undefined;
|
|
71
|
+
previewOf?: string | undefined;
|
|
72
|
+
previewId?: string | undefined;
|
|
73
|
+
previewName?: string | undefined;
|
|
74
|
+
previewSlug?: string | undefined;
|
|
75
|
+
previewDoClasses?: string[] | undefined;
|
|
76
|
+
versionId?: string | undefined;
|
|
77
|
+
versionAlias?: string | undefined;
|
|
78
|
+
deploymentId?: string | undefined;
|
|
79
|
+
affinityZoneIds?: string[] | undefined;
|
|
80
|
+
hash?: {
|
|
81
|
+
assets: string | undefined;
|
|
82
|
+
bundle: string | undefined;
|
|
83
|
+
input: string | undefined;
|
|
84
|
+
additionalWorkspaces: string[] | undefined;
|
|
85
|
+
metadata?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
}, {
|
|
88
|
+
bindings?: Cloudflare.WorkerBinding[];
|
|
89
|
+
env?: Record<string, any>;
|
|
90
|
+
cache?: Cloudflare.WorkerCache;
|
|
91
|
+
observability?: Pick<Cloudflare.WorkerObservability, "traces">;
|
|
92
|
+
containers?: {
|
|
93
|
+
className: string;
|
|
94
|
+
dev: Cloudflare.DevContainerImage | undefined;
|
|
95
|
+
hash: string | undefined;
|
|
96
|
+
}[];
|
|
97
|
+
crons?: string[];
|
|
98
|
+
hyperdrives?: Record<string, Required<Cloudflare.Hyperdrive.DevOrigin>>;
|
|
99
|
+
devRemote?: Record<string, boolean>;
|
|
100
|
+
}, Cloudflare.Providers> & {
|
|
101
|
+
bind(sid: import("alchemy").Input<string>, binding: import("alchemy").Input<{
|
|
102
|
+
bindings?: Cloudflare.WorkerBinding[];
|
|
103
|
+
env?: Record<string, any>;
|
|
104
|
+
cache?: Cloudflare.WorkerCache;
|
|
105
|
+
observability?: Pick<Cloudflare.WorkerObservability, "traces">;
|
|
106
|
+
containers?: {
|
|
107
|
+
className: string;
|
|
108
|
+
dev: Cloudflare.DevContainerImage | undefined;
|
|
109
|
+
hash: string | undefined;
|
|
110
|
+
}[];
|
|
111
|
+
crons?: string[];
|
|
112
|
+
hyperdrives?: Record<string, Required<Cloudflare.Hyperdrive.DevOrigin>>;
|
|
113
|
+
devRemote?: Record<string, boolean>;
|
|
114
|
+
}>): Effect.Effect<void>;
|
|
115
|
+
bind(template: TemplateStringsArray, ...args: any[]): (binding: import("alchemy").Input<{
|
|
116
|
+
bindings?: Cloudflare.WorkerBinding[];
|
|
117
|
+
env?: Record<string, any>;
|
|
118
|
+
cache?: Cloudflare.WorkerCache;
|
|
119
|
+
observability?: Pick<Cloudflare.WorkerObservability, "traces">;
|
|
120
|
+
containers?: {
|
|
121
|
+
className: string;
|
|
122
|
+
dev: Cloudflare.DevContainerImage | undefined;
|
|
123
|
+
hash: string | undefined;
|
|
124
|
+
}[];
|
|
125
|
+
crons?: string[];
|
|
126
|
+
hyperdrives?: Record<string, Required<Cloudflare.Hyperdrive.DevOrigin>>;
|
|
127
|
+
devRemote?: Record<string, boolean>;
|
|
128
|
+
}>) => Effect.Effect<void>;
|
|
129
|
+
} & {
|
|
130
|
+
workerId: import("alchemy").Output<string, never>;
|
|
131
|
+
workerName: import("alchemy").Output<string, never>;
|
|
132
|
+
namespace: import("alchemy").Output<string | undefined, never>;
|
|
133
|
+
logpush: import("alchemy").Output<boolean | undefined, never>;
|
|
134
|
+
url: import("alchemy").Output<string | undefined, never>;
|
|
135
|
+
urls: import("alchemy").Output<string[], never>;
|
|
136
|
+
domain: import("alchemy").Output<{
|
|
137
|
+
name: string;
|
|
138
|
+
aliases: string[];
|
|
139
|
+
redirects: string[];
|
|
140
|
+
zone?: Cloudflare.Zone.Reference;
|
|
141
|
+
previews?: boolean;
|
|
142
|
+
} | undefined, never>;
|
|
143
|
+
tags: import("alchemy").Output<string[] | undefined, never>;
|
|
144
|
+
durableObjectNamespaces: import("alchemy/Output").ObjectExpr<Record<string, string>, never>;
|
|
145
|
+
accountId: import("alchemy").Output<string, never>;
|
|
146
|
+
routes: import("alchemy").Output<{
|
|
147
|
+
id: string;
|
|
148
|
+
pattern: string;
|
|
149
|
+
zoneId: string;
|
|
150
|
+
}[], never>;
|
|
151
|
+
crons: import("alchemy").Output<string[], never>;
|
|
152
|
+
tailConsumers: import("alchemy").Output<{
|
|
153
|
+
service: string;
|
|
154
|
+
}[] | undefined, never>;
|
|
155
|
+
streamingTailConsumers: import("alchemy").Output<{
|
|
156
|
+
service: string;
|
|
157
|
+
}[] | undefined, never>;
|
|
158
|
+
versionOf: import("alchemy").Output<string | undefined, never>;
|
|
159
|
+
previewOf: import("alchemy").Output<string | undefined, never>;
|
|
160
|
+
previewId: import("alchemy").Output<string | undefined, never>;
|
|
161
|
+
previewName: import("alchemy").Output<string | undefined, never>;
|
|
162
|
+
previewSlug: import("alchemy").Output<string | undefined, never>;
|
|
163
|
+
previewDoClasses: import("alchemy").Output<string[] | undefined, never>;
|
|
164
|
+
versionId: import("alchemy").Output<string | undefined, never>;
|
|
165
|
+
versionAlias: import("alchemy").Output<string | undefined, never>;
|
|
166
|
+
deploymentId: import("alchemy").Output<string | undefined, never>;
|
|
167
|
+
affinityZoneIds: import("alchemy").Output<string[] | undefined, never>;
|
|
168
|
+
hash: import("alchemy").Output<{
|
|
169
|
+
assets: string | undefined;
|
|
170
|
+
bundle: string | undefined;
|
|
171
|
+
input: string | undefined;
|
|
172
|
+
additionalWorkspaces: string[] | undefined;
|
|
173
|
+
metadata?: string | undefined;
|
|
174
|
+
} | undefined, never>;
|
|
175
|
+
} & Cloudflare.Rpc<Registry> & import("alchemy").Dependencies<never>, never, Cloudflare.Providers | Registry> & import("alchemy").Named<"Worker"> & {
|
|
176
|
+
new (_: never): {
|
|
177
|
+
fetch?: Effect.Effect<import("alchemy/Http").HttpEffect<import("alchemy").RuntimeContext | import("alchemy").PlatformServices | Cloudflare.WorkerServices>, never, import("alchemy").PlatformServices | Cloudflare.WorkerServices> | import("alchemy/Http").HttpEffect<import("alchemy").RuntimeContext | import("alchemy").PlatformServices | Cloudflare.WorkerServices> | undefined;
|
|
178
|
+
} & import("alchemy").MainRpc<Cloudflare.WorkerServices> & import("alchemy").Named<"Worker"> & import("alchemy/Named").Tag<"Cloudflare.Worker">;
|
|
179
|
+
of(shape: {} & Cloudflare.WorkerShape<never>): {
|
|
180
|
+
fetch?: Effect.Effect<import("alchemy/Http").HttpEffect<import("alchemy").RuntimeContext | import("alchemy").PlatformServices | Cloudflare.WorkerServices>, never, import("alchemy").PlatformServices | Cloudflare.WorkerServices> | import("alchemy/Http").HttpEffect<import("alchemy").RuntimeContext | import("alchemy").PlatformServices | Cloudflare.WorkerServices> | undefined;
|
|
181
|
+
} & import("alchemy").MainRpc<Cloudflare.WorkerServices>;
|
|
182
|
+
make<PropsReq = never, InitReq = never>(props: Effect.Effect<import("alchemy").InputProps<Cloudflare.WorkerProps<any, Cloudflare.WorkerAssetsConfig | undefined>, never>, Config.ConfigError, PropsReq> | import("alchemy").InputProps<Cloudflare.WorkerProps<any, Cloudflare.WorkerAssetsConfig | undefined>, never>, impl: Effect.Effect<{}, Config.ConfigError, InitReq>): Layer.Layer<Registry, never, Cloudflare.Providers | Exclude<InitReq, Registry | import("alchemy/Named").Tag<"Cloudflare.Worker"> | Cloudflare.WorkerServices> | Exclude<PropsReq, Registry | import("alchemy/Named").Tag<"Cloudflare.Worker"> | Cloudflare.WorkerServices>>;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* The registry Worker. Its props are an Effect so the same declaration
|
|
186
|
+
* serves both sides of the bundle boundary: at plan time
|
|
187
|
+
* {@link RegistryConfig} is the caller's options, inside the isolate it is
|
|
188
|
+
* rebuilt from the Worker's bindings.
|
|
189
|
+
*/
|
|
190
|
+
export declare class Registry extends Registry_base {
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The bundle entry. `RegistryLive` names this file as `main`, so the
|
|
194
|
+
* generated Worker entry imports this default export and builds it once per
|
|
195
|
+
* isolate. User code never imports it; use {@link PkgRegistry}.
|
|
196
|
+
*/
|
|
197
|
+
declare const _default: Layer.Layer<Registry, never, Cloudflare.Providers | Cloudflare.WorkerEnvironment>;
|
|
198
|
+
export default _default;
|
|
199
|
+
/**
|
|
200
|
+
* A preview package registry: a Worker serving install URLs and the publish
|
|
201
|
+
* API, an R2 bucket of content-addressed tarballs, a D1 index of tags, and a
|
|
202
|
+
* KV namespace caching what the Worker learns from GitHub. They are declared
|
|
203
|
+
* under `id` as `<id>/Worker`, `<id>/Bucket`, `<id>/Database`, and
|
|
204
|
+
* `<id>/Cache`.
|
|
205
|
+
*
|
|
206
|
+
* ### Deploying a registry
|
|
207
|
+
* **Example:** Stack
|
|
208
|
+
* ```typescript
|
|
209
|
+
* // stacks/pkg.ts
|
|
210
|
+
* import { PkgRegistry } from "@alchemy.run/pkg/Registry";
|
|
211
|
+
* import * as Alchemy from "alchemy";
|
|
212
|
+
* import * as Cloudflare from "alchemy/Cloudflare";
|
|
213
|
+
* import * as ByteSize from "effect/ByteSize";
|
|
214
|
+
* import * as Config from "effect/Config";
|
|
215
|
+
* import * as Duration from "effect/Duration";
|
|
216
|
+
* import * as Effect from "effect/Effect";
|
|
217
|
+
*
|
|
218
|
+
* export default Alchemy.Stack(
|
|
219
|
+
* "Pkg",
|
|
220
|
+
* { providers: Cloudflare.providers(), state: Cloudflare.state() },
|
|
221
|
+
* Effect.gen(function* () {
|
|
222
|
+
* const registry = yield* PkgRegistry("Pkg", {
|
|
223
|
+
* worker: { domain: "pkg.alchemy.run" },
|
|
224
|
+
* github: {
|
|
225
|
+
* appId: Config.String("GH_APP_ID"),
|
|
226
|
+
* privateKey: Config.Redacted("GH_APP_PRIVATE_KEY"),
|
|
227
|
+
* },
|
|
228
|
+
* policy: {
|
|
229
|
+
* repos: ["alchemy-run/alchemy", "alchemy-run/distilled"],
|
|
230
|
+
* ttl: Duration.weeks(1),
|
|
231
|
+
* maxPackageSize: ByteSize.megabytes(100),
|
|
232
|
+
* },
|
|
233
|
+
* });
|
|
234
|
+
* return { url: registry.url.as<string>() };
|
|
235
|
+
* }),
|
|
236
|
+
* );
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @resource
|
|
240
|
+
* @product Workers
|
|
241
|
+
* @category Workers & Compute
|
|
242
|
+
*/
|
|
243
|
+
export declare const PkgRegistry: <const Id extends string>(id: Id, options: RegistryOptions) => Effect.Effect<import("effect/Pipeable").Pipeable & import("alchemy").ResourceLike<"Cloudflare.Worker", Cloudflare.WorkerProps<any, Cloudflare.WorkerAssetsConfig | undefined>, {
|
|
244
|
+
workerId: string;
|
|
245
|
+
workerName: string;
|
|
246
|
+
namespace: string | undefined;
|
|
247
|
+
logpush: boolean | undefined;
|
|
248
|
+
url: string | undefined;
|
|
249
|
+
urls: string[];
|
|
250
|
+
domain: {
|
|
251
|
+
name: string;
|
|
252
|
+
aliases: string[];
|
|
253
|
+
redirects: string[];
|
|
254
|
+
zone?: Cloudflare.Zone.Reference;
|
|
255
|
+
previews?: boolean;
|
|
256
|
+
} | undefined;
|
|
257
|
+
tags: string[] | undefined;
|
|
258
|
+
durableObjectNamespaces: Record<string, string>;
|
|
259
|
+
accountId: string;
|
|
260
|
+
routes: {
|
|
261
|
+
id: string;
|
|
262
|
+
pattern: string;
|
|
263
|
+
zoneId: string;
|
|
264
|
+
}[];
|
|
265
|
+
crons: string[];
|
|
266
|
+
tailConsumers?: {
|
|
267
|
+
service: string;
|
|
268
|
+
}[] | undefined;
|
|
269
|
+
streamingTailConsumers?: {
|
|
270
|
+
service: string;
|
|
271
|
+
}[] | undefined;
|
|
272
|
+
versionOf?: string | undefined;
|
|
273
|
+
previewOf?: string | undefined;
|
|
274
|
+
previewId?: string | undefined;
|
|
275
|
+
previewName?: string | undefined;
|
|
276
|
+
previewSlug?: string | undefined;
|
|
277
|
+
previewDoClasses?: string[] | undefined;
|
|
278
|
+
versionId?: string | undefined;
|
|
279
|
+
versionAlias?: string | undefined;
|
|
280
|
+
deploymentId?: string | undefined;
|
|
281
|
+
affinityZoneIds?: string[] | undefined;
|
|
282
|
+
hash?: {
|
|
283
|
+
assets: string | undefined;
|
|
284
|
+
bundle: string | undefined;
|
|
285
|
+
input: string | undefined;
|
|
286
|
+
additionalWorkspaces: string[] | undefined;
|
|
287
|
+
metadata?: string | undefined;
|
|
288
|
+
};
|
|
289
|
+
}, {
|
|
290
|
+
bindings?: Cloudflare.WorkerBinding[];
|
|
291
|
+
env?: Record<string, any>;
|
|
292
|
+
cache?: Cloudflare.WorkerCache;
|
|
293
|
+
observability?: Pick<Cloudflare.WorkerObservability, "traces">;
|
|
294
|
+
containers?: {
|
|
295
|
+
className: string;
|
|
296
|
+
dev: Cloudflare.DevContainerImage | undefined;
|
|
297
|
+
hash: string | undefined;
|
|
298
|
+
}[];
|
|
299
|
+
crons?: string[];
|
|
300
|
+
hyperdrives?: Record<string, Required<Cloudflare.Hyperdrive.DevOrigin>>;
|
|
301
|
+
devRemote?: Record<string, boolean>;
|
|
302
|
+
}, Cloudflare.Providers> & {
|
|
303
|
+
bind(sid: import("alchemy").Input<string>, binding: import("alchemy").Input<{
|
|
304
|
+
bindings?: Cloudflare.WorkerBinding[];
|
|
305
|
+
env?: Record<string, any>;
|
|
306
|
+
cache?: Cloudflare.WorkerCache;
|
|
307
|
+
observability?: Pick<Cloudflare.WorkerObservability, "traces">;
|
|
308
|
+
containers?: {
|
|
309
|
+
className: string;
|
|
310
|
+
dev: Cloudflare.DevContainerImage | undefined;
|
|
311
|
+
hash: string | undefined;
|
|
312
|
+
}[];
|
|
313
|
+
crons?: string[];
|
|
314
|
+
hyperdrives?: Record<string, Required<Cloudflare.Hyperdrive.DevOrigin>>;
|
|
315
|
+
devRemote?: Record<string, boolean>;
|
|
316
|
+
}>): Effect.Effect<void>;
|
|
317
|
+
bind(template: TemplateStringsArray, ...args: any[]): (binding: import("alchemy").Input<{
|
|
318
|
+
bindings?: Cloudflare.WorkerBinding[];
|
|
319
|
+
env?: Record<string, any>;
|
|
320
|
+
cache?: Cloudflare.WorkerCache;
|
|
321
|
+
observability?: Pick<Cloudflare.WorkerObservability, "traces">;
|
|
322
|
+
containers?: {
|
|
323
|
+
className: string;
|
|
324
|
+
dev: Cloudflare.DevContainerImage | undefined;
|
|
325
|
+
hash: string | undefined;
|
|
326
|
+
}[];
|
|
327
|
+
crons?: string[];
|
|
328
|
+
hyperdrives?: Record<string, Required<Cloudflare.Hyperdrive.DevOrigin>>;
|
|
329
|
+
devRemote?: Record<string, boolean>;
|
|
330
|
+
}>) => Effect.Effect<void>;
|
|
331
|
+
} & {
|
|
332
|
+
workerId: import("alchemy").Output<string, never>;
|
|
333
|
+
workerName: import("alchemy").Output<string, never>;
|
|
334
|
+
namespace: import("alchemy").Output<string | undefined, never>;
|
|
335
|
+
logpush: import("alchemy").Output<boolean | undefined, never>;
|
|
336
|
+
url: import("alchemy").Output<string | undefined, never>;
|
|
337
|
+
urls: import("alchemy").Output<string[], never>;
|
|
338
|
+
domain: import("alchemy").Output<{
|
|
339
|
+
name: string;
|
|
340
|
+
aliases: string[];
|
|
341
|
+
redirects: string[];
|
|
342
|
+
zone?: Cloudflare.Zone.Reference;
|
|
343
|
+
previews?: boolean;
|
|
344
|
+
} | undefined, never>;
|
|
345
|
+
tags: import("alchemy").Output<string[] | undefined, never>;
|
|
346
|
+
durableObjectNamespaces: import("alchemy/Output").ObjectExpr<Record<string, string>, never>;
|
|
347
|
+
accountId: import("alchemy").Output<string, never>;
|
|
348
|
+
routes: import("alchemy").Output<{
|
|
349
|
+
id: string;
|
|
350
|
+
pattern: string;
|
|
351
|
+
zoneId: string;
|
|
352
|
+
}[], never>;
|
|
353
|
+
crons: import("alchemy").Output<string[], never>;
|
|
354
|
+
tailConsumers: import("alchemy").Output<{
|
|
355
|
+
service: string;
|
|
356
|
+
}[] | undefined, never>;
|
|
357
|
+
streamingTailConsumers: import("alchemy").Output<{
|
|
358
|
+
service: string;
|
|
359
|
+
}[] | undefined, never>;
|
|
360
|
+
versionOf: import("alchemy").Output<string | undefined, never>;
|
|
361
|
+
previewOf: import("alchemy").Output<string | undefined, never>;
|
|
362
|
+
previewId: import("alchemy").Output<string | undefined, never>;
|
|
363
|
+
previewName: import("alchemy").Output<string | undefined, never>;
|
|
364
|
+
previewSlug: import("alchemy").Output<string | undefined, never>;
|
|
365
|
+
previewDoClasses: import("alchemy").Output<string[] | undefined, never>;
|
|
366
|
+
versionId: import("alchemy").Output<string | undefined, never>;
|
|
367
|
+
versionAlias: import("alchemy").Output<string | undefined, never>;
|
|
368
|
+
deploymentId: import("alchemy").Output<string | undefined, never>;
|
|
369
|
+
affinityZoneIds: import("alchemy").Output<string[] | undefined, never>;
|
|
370
|
+
hash: import("alchemy").Output<{
|
|
371
|
+
assets: string | undefined;
|
|
372
|
+
bundle: string | undefined;
|
|
373
|
+
input: string | undefined;
|
|
374
|
+
additionalWorkspaces: string[] | undefined;
|
|
375
|
+
metadata?: string | undefined;
|
|
376
|
+
} | undefined, never>;
|
|
377
|
+
} & Cloudflare.Rpc<Registry> & import("alchemy").Dependencies<never>, never, Cloudflare.Providers>;
|
|
378
|
+
//# sourceMappingURL=Registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../src/Registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,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IG;;;AAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,CAAC,EAAE,SAAS,MAAM,MAC7C,EAAE,WACG,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kGA2BvB,CAAC"}
|
package/dist/Registry.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as Cloudflare from "alchemy/Cloudflare";
|
|
2
|
+
import * as Namespace from "alchemy/Namespace";
|
|
3
|
+
import * as Config from "effect/Config";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import { APP_ID_ENV, DEFAULT_API_URL, DEFAULT_CRON, DEFAULT_TTL, PRIVATE_KEY_ENV, RegistryConfig, SETTINGS_ENV, Settings, } from "./Registry/Bindings.js";
|
|
8
|
+
import { handler } from "./Registry/Handler.js";
|
|
9
|
+
export { Bucket, Cache, Database, Policy, RegistryConfig, Settings, } from "./Registry/Bindings.js";
|
|
10
|
+
/**
|
|
11
|
+
* The registry Worker. Its props are an Effect so the same declaration
|
|
12
|
+
* serves both sides of the bundle boundary: at plan time
|
|
13
|
+
* {@link RegistryConfig} is the caller's options, inside the isolate it is
|
|
14
|
+
* rebuilt from the Worker's bindings.
|
|
15
|
+
*/
|
|
16
|
+
export class Registry extends Cloudflare.Worker()("Worker") {
|
|
17
|
+
}
|
|
18
|
+
const RegistryLive = Registry.make(Effect.gen(function* () {
|
|
19
|
+
const config = yield* RegistryConfig;
|
|
20
|
+
return {
|
|
21
|
+
...config.worker,
|
|
22
|
+
main: import.meta.url,
|
|
23
|
+
env: {
|
|
24
|
+
[SETTINGS_ENV]: yield* Schema.encodeEffect(Settings)({
|
|
25
|
+
policy: config.policy,
|
|
26
|
+
aliases: config.aliases,
|
|
27
|
+
cron: config.cron,
|
|
28
|
+
github: { apiUrl: config.github.apiUrl },
|
|
29
|
+
}).pipe(Effect.orDie),
|
|
30
|
+
[APP_ID_ENV]: config.github.appId,
|
|
31
|
+
[PRIVATE_KEY_ENV]: config.github.privateKey,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}), handler);
|
|
35
|
+
/**
|
|
36
|
+
* Runtime side of {@link RegistryConfig}: decode the settings binding and
|
|
37
|
+
* point the credentials at the bindings `RegistryLive` declared.
|
|
38
|
+
*/
|
|
39
|
+
const RegistryConfigFromEnv = Layer.effect(RegistryConfig, Effect.gen(function* () {
|
|
40
|
+
const env = yield* Cloudflare.Workers.WorkerEnvironment;
|
|
41
|
+
const settings = yield* Schema.decodeUnknownEffect(Settings)(env[SETTINGS_ENV]).pipe(Effect.orDie);
|
|
42
|
+
return {
|
|
43
|
+
...settings,
|
|
44
|
+
worker: {},
|
|
45
|
+
github: {
|
|
46
|
+
...settings.github,
|
|
47
|
+
appId: Config.String(APP_ID_ENV),
|
|
48
|
+
privateKey: Config.Redacted(PRIVATE_KEY_ENV),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}));
|
|
52
|
+
/**
|
|
53
|
+
* The bundle entry. `RegistryLive` names this file as `main`, so the
|
|
54
|
+
* generated Worker entry imports this default export and builds it once per
|
|
55
|
+
* isolate. User code never imports it; use {@link PkgRegistry}.
|
|
56
|
+
*/
|
|
57
|
+
export default RegistryLive.pipe(Layer.provide(RegistryConfigFromEnv));
|
|
58
|
+
/**
|
|
59
|
+
* A preview package registry: a Worker serving install URLs and the publish
|
|
60
|
+
* API, an R2 bucket of content-addressed tarballs, a D1 index of tags, and a
|
|
61
|
+
* KV namespace caching what the Worker learns from GitHub. They are declared
|
|
62
|
+
* under `id` as `<id>/Worker`, `<id>/Bucket`, `<id>/Database`, and
|
|
63
|
+
* `<id>/Cache`.
|
|
64
|
+
*
|
|
65
|
+
* ### Deploying a registry
|
|
66
|
+
* **Example:** Stack
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // stacks/pkg.ts
|
|
69
|
+
* import { PkgRegistry } from "@alchemy.run/pkg/Registry";
|
|
70
|
+
* import * as Alchemy from "alchemy";
|
|
71
|
+
* import * as Cloudflare from "alchemy/Cloudflare";
|
|
72
|
+
* import * as ByteSize from "effect/ByteSize";
|
|
73
|
+
* import * as Config from "effect/Config";
|
|
74
|
+
* import * as Duration from "effect/Duration";
|
|
75
|
+
* import * as Effect from "effect/Effect";
|
|
76
|
+
*
|
|
77
|
+
* export default Alchemy.Stack(
|
|
78
|
+
* "Pkg",
|
|
79
|
+
* { providers: Cloudflare.providers(), state: Cloudflare.state() },
|
|
80
|
+
* Effect.gen(function* () {
|
|
81
|
+
* const registry = yield* PkgRegistry("Pkg", {
|
|
82
|
+
* worker: { domain: "pkg.alchemy.run" },
|
|
83
|
+
* github: {
|
|
84
|
+
* appId: Config.String("GH_APP_ID"),
|
|
85
|
+
* privateKey: Config.Redacted("GH_APP_PRIVATE_KEY"),
|
|
86
|
+
* },
|
|
87
|
+
* policy: {
|
|
88
|
+
* repos: ["alchemy-run/alchemy", "alchemy-run/distilled"],
|
|
89
|
+
* ttl: Duration.weeks(1),
|
|
90
|
+
* maxPackageSize: ByteSize.megabytes(100),
|
|
91
|
+
* },
|
|
92
|
+
* });
|
|
93
|
+
* return { url: registry.url.as<string>() };
|
|
94
|
+
* }),
|
|
95
|
+
* );
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @resource
|
|
99
|
+
* @product Workers
|
|
100
|
+
* @category Workers & Compute
|
|
101
|
+
*/
|
|
102
|
+
export const PkgRegistry = (id, options) => Registry.pipe(Effect.provide(RegistryLive.pipe(Layer.provide(Layer.succeed(RegistryConfig, {
|
|
103
|
+
worker: options.worker ?? {},
|
|
104
|
+
policy: {
|
|
105
|
+
repos: options.policy.repos,
|
|
106
|
+
ttl: options.policy.ttl ?? DEFAULT_TTL,
|
|
107
|
+
...(options.policy.maxPackageSize !== undefined
|
|
108
|
+
? { maxPackageSize: options.policy.maxPackageSize }
|
|
109
|
+
: {}),
|
|
110
|
+
},
|
|
111
|
+
aliases: options.aliases ?? {},
|
|
112
|
+
cron: options.cron ?? DEFAULT_CRON,
|
|
113
|
+
github: {
|
|
114
|
+
apiUrl: options.github.apiUrl ?? DEFAULT_API_URL,
|
|
115
|
+
appId: options.github.appId,
|
|
116
|
+
privateKey: options.github.privateKey,
|
|
117
|
+
},
|
|
118
|
+
})))), Namespace.push(id));
|
|
119
|
+
//# sourceMappingURL=Registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Registry.js","sourceRoot":"","sources":["../src/Registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,UAAU,EACV,eAAe,EACf,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACd,YAAY,EACZ,QAAQ,GAGT,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,cAAc,EACd,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAmChC;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU,CAAC,MAAM,EAAgB,CAAC,QAAQ,CAAC;CAAG;AAE5E,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAChC,MAAM,CAAC,GAAG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|
+
import { CliError, Command } from "effect/unstable/cli";
|
|
4
|
+
export declare const packCommand: Command.Command<"pack", {
|
|
5
|
+
readonly group: readonly {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly pattern: string;
|
|
8
|
+
readonly collapsed: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
readonly registry: string;
|
|
11
|
+
readonly out: string;
|
|
12
|
+
}, {}, Config.ConfigError | import("./pack.ts").GitError | import("./pack.ts").PackError | import("effect/PlatformError").PlatformError | import("effect/Schema").SchemaError | import("./pack.ts").WorkspaceError, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
|
|
13
|
+
export declare const publishCommand: Command.Command<"publish", {
|
|
14
|
+
readonly registry: string;
|
|
15
|
+
readonly dir: string;
|
|
16
|
+
}, {}, import("effect/PlatformError").PlatformError | import("./publish.ts").PublishError | import("effect/Schema").SchemaError, import("effect/FileSystem").FileSystem | import("effect/unstable/http/HttpClient").HttpClient | import("effect/Path").Path>;
|
|
17
|
+
export declare const root: Command.Command<"pkg", {} | {}, {}, Config.ConfigError | import("./pack.ts").GitError | import("./pack.ts").PackError | import("effect/PlatformError").PlatformError | import("./publish.ts").PublishError | import("effect/Schema").SchemaError | CliError.ShowHelp | import("./pack.ts").WorkspaceError, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/unstable/http/HttpClient").HttpClient | import("effect/Path").Path>;
|
|
18
|
+
//# sourceMappingURL=bin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAEL,QAAQ,EACR,OAAO,EAGR,MAAM,qBAAqB,CAAC;AA2B7B,eAAO,MAAM,WAAW;;;;;;;;oWAkBvB,CAAC;AAOF,eAAO,MAAM,cAAc;;;4PAe1B,CAAC;AAEF,eAAO,MAAM,IAAI,ofAOhB,CAAC"}
|
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { PlatformServices, runMain } from "alchemy/Util/PlatformServices";
|
|
3
|
+
import * as Config from "effect/Config";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import { CliConfig, CliError, Command, Flag, GlobalFlag, } from "effect/unstable/cli";
|
|
7
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
8
|
+
import pkg from "../../package.json" with { type: "json" };
|
|
9
|
+
import { Group, pack } from "./pack.js";
|
|
10
|
+
import { publish } from "./publish.js";
|
|
11
|
+
const groupFlag = Flag.String("group").pipe(Flag.withDescription("Display group and directory glob, as NAME=GLOB or NAME[Collapsed]=GLOB (repeatable), e.g. --group Alchemy=./packages/*"), Flag.withSchema(Group), Flag.atLeast(1));
|
|
12
|
+
const registryFlag = Flag.String("registry").pipe(Flag.withDescription("Registry origin used for install URLs. Falls back to PKG_REGISTRY, then https://pkg.alchemy.run"), Flag.withFallbackConfig(Config.String("PKG_REGISTRY")), Flag.withDefault("https://pkg.alchemy.run"));
|
|
13
|
+
const outFlag = Flag.String("out").pipe(Flag.withDescription("Directory to write tarballs and the manifest into"), Flag.withDefault(".pkg"));
|
|
14
|
+
export const packCommand = Command.make("pack", { group: groupFlag, registry: registryFlag, out: outFlag }, ({ group, registry, out }) => Effect.gen(function* () {
|
|
15
|
+
const cwd = yield* Effect.sync(() => process.cwd());
|
|
16
|
+
yield* pack({ cwd, groups: group, registry, out });
|
|
17
|
+
})).pipe(Command.withDescription("Pack workspace packages into reproducible tarballs with dependencies rewritten to registry URLs"), Command.withExamples([
|
|
18
|
+
{
|
|
19
|
+
command: "pkg pack --group 'alchemy=./packages/alchemy' --group '@alchemy.run[Collapsed]=./packages/{better-auth,pkg}' --group '@distilled.cloud[Collapsed]=./submodules/distilled/packages/*'",
|
|
20
|
+
},
|
|
21
|
+
]));
|
|
22
|
+
const dirFlag = Flag.String("dir").pipe(Flag.withDescription("Directory written by pkg pack"), Flag.withDefault(".pkg"));
|
|
23
|
+
export const publishCommand = Command.make("publish", { registry: registryFlag, dir: dirFlag }, ({ registry, dir }) => Effect.gen(function* () {
|
|
24
|
+
const cwd = yield* Effect.sync(() => process.cwd());
|
|
25
|
+
yield* publish({ cwd, dir, registry });
|
|
26
|
+
})).pipe(Command.withDescription("Publish a pkg pack directory from the current GitHub Actions job, after its manifest artifact has been uploaded"), Command.withExamples([
|
|
27
|
+
{ command: "pkg publish --registry https://pkg.alchemy.run" },
|
|
28
|
+
]));
|
|
29
|
+
export const root = Command.make("pkg", {}, () => Effect.fail(new CliError.ShowHelp({ commandPath: ["pkg"], errors: [] }))).pipe(Command.withDescription("Pack and publish preview packages for pull requests."), Command.withSubcommands([packCommand, publishCommand]));
|
|
30
|
+
Command.run(root, { version: pkg.version }).pipe(Effect.provide(Layer.mergeAll(PlatformServices, FetchHttpClient.layer, CliConfig.layer({
|
|
31
|
+
builtIns: [GlobalFlag.Help, GlobalFlag.Version],
|
|
32
|
+
}))), runMain);
|
|
33
|
+
//# sourceMappingURL=bin.js.map
|