@samebase/alchemy-convex 0.19.1 → 0.21.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/README.md +25 -3
- package/lib/{HubClient-NUvPkolM.js → HubClient-B6hjkbjW.js} +15 -11
- package/lib/HubClient-B6hjkbjW.js.map +1 -0
- package/lib/cli.js +19 -5
- package/lib/cli.js.map +1 -1
- package/lib/index.d.ts +31 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +131 -4
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/HubClient.ts +10 -5
- package/src/Providers.ts +13 -2
- package/src/Push.ts +9 -5
- package/src/SharedHubClient.ts +271 -0
- package/src/StackComment.ts +8 -0
- package/src/cli.ts +5 -4
- package/src/index.ts +5 -0
- package/lib/HubClient-NUvPkolM.js.map +0 -1
package/README.md
CHANGED
|
@@ -308,6 +308,22 @@ call.
|
|
|
308
308
|
the `Convex.Deployment` writes to the deployment. Another `redirectUri` is a new client, and a
|
|
309
309
|
destroy deletes the client.
|
|
310
310
|
|
|
311
|
+
- `Convex.SharedHubClient`: `{ app, deployment, deploymentType, softwareVersion? }` gets a client of
|
|
312
|
+
the central identity hub through samebase.com, for an app that deploys in its own GitHub Actions
|
|
313
|
+
run. The workflow needs `permissions: id-token: write` and no Samebase key. Outputs `status`,
|
|
314
|
+
`issuer`, `clientId`, `clientSecret`, `registrationAccessToken`, `registrationClientUri`,
|
|
315
|
+
`deployment`, `deploymentType`, and `redirectUri`.
|
|
316
|
+
- Each deploy reads the saved client on the hub with its own token. A client that is gone gets a
|
|
317
|
+
new one, and a client on another deployment too.
|
|
318
|
+
- No failure stops a deploy or a destroy. A failed renewal keeps the saved values. Without saved
|
|
319
|
+
values, `status` is `off`, and `issuer`, `clientId`, and `clientSecret` are the `no-hub` values
|
|
320
|
+
of a checkout without a hub. A run without a GitHub OIDC token, such as on a laptop, does the
|
|
321
|
+
same, and logs no warning.
|
|
322
|
+
- `status` is `suspended` when the hub suspended the client. The client keeps its values.
|
|
323
|
+
- A destroy deletes a preview client. It does nothing to a production client, because the
|
|
324
|
+
production deployment can stay.
|
|
325
|
+
- `SAMEBASE_URL` replaces `https://samebase.com`.
|
|
326
|
+
|
|
311
327
|
A development deployment has no stack, so the package has a command for it. Run it in the directory
|
|
312
328
|
of the app, before the first push: it registers the deployment of that directory with
|
|
313
329
|
`CONVEX_ACCESS_TOKEN` or the Convex CLI login, and writes `HUB_ISSUER`, `HUB_CLIENT_ID`, and
|
|
@@ -317,12 +333,18 @@ of the app, before the first push: it registers the deployment of that directory
|
|
|
317
333
|
npx alchemy-convex hub-client --team my-team --app scout --callback-path /auth/hub/callback
|
|
318
334
|
```
|
|
319
335
|
|
|
336
|
+
For a separate API-connection callback, register another client with
|
|
337
|
+
`--callback-path /oauth/hub/callback --env-prefix RESOURCE_HUB`. This writes `RESOURCE_HUB_ISSUER`,
|
|
338
|
+
`RESOURCE_HUB_CLIENT_ID`, and `RESOURCE_HUB_CLIENT_SECRET`, preserving the sign-in client's
|
|
339
|
+
variables. Each callback remains one exact registered URI.
|
|
340
|
+
|
|
320
341
|
## Pull request comment
|
|
321
342
|
|
|
322
343
|
`alchemy-convex stack-comment` keeps one comment on a pull request. The comment has a card for each
|
|
323
|
-
stack of the repository at the stage `pr-<number>`: the folder, the address, the last run,
|
|
324
|
-
Convex deployments, Workers, and R2 buckets
|
|
325
|
-
declares cannot show
|
|
344
|
+
stack of the repository at the stage `pr-<number>`: the folder, the address, the last run, the
|
|
345
|
+
Convex deployments, Workers, and R2 buckets, and the Google sign-in status of a
|
|
346
|
+
`Convex.SharedHubClient`. A stack sees only itself, so a comment that a stack declares cannot show
|
|
347
|
+
this.
|
|
326
348
|
|
|
327
349
|
Run it after every deploy of the workflow. The run record gives the repository and the pull request,
|
|
328
350
|
so the command needs no argument with a team access token:
|
|
@@ -304,7 +304,7 @@ rootDir: Schema.String }) {
|
|
|
304
304
|
var CodePushFailed = class extends Schema.TaggedError()("CodePushFailed", {
|
|
305
305
|
/** Exit code of the CLI. Undefined when it did not start or a signal stopped it. */
|
|
306
306
|
exitCode: Schema.UndefinedOr(Schema.Number),
|
|
307
|
-
/** The last lines of the CLI output, with the deploy key removed. */
|
|
307
|
+
/** The last lines of the CLI output, with the deploy key and the `Redacted` values of `env` removed. */
|
|
308
308
|
outputTail: Schema.String
|
|
309
309
|
}) {
|
|
310
310
|
get message() {
|
|
@@ -597,7 +597,11 @@ const push = (spawner, key, options) => Effect.gen(function* () {
|
|
|
597
597
|
const runPush = (spawner, key, options) => Effect.gen(function* () {
|
|
598
598
|
const { cwd, program } = options;
|
|
599
599
|
const secret = Redacted.value(key);
|
|
600
|
-
const secrets = [
|
|
600
|
+
const secrets = [
|
|
601
|
+
secret,
|
|
602
|
+
secret.slice(secret.indexOf("|") + 1),
|
|
603
|
+
...Object.values(options.env).flatMap((value) => Redacted.isRedacted(value) ? [Redacted.value(value)] : [])
|
|
604
|
+
].filter((value) => value.length >= 8);
|
|
601
605
|
const result = yield* withKeyFile(secret, ({ envFile, home }) => Effect.gen(function* () {
|
|
602
606
|
const [command, ...programArgs] = program;
|
|
603
607
|
const args = options.command === void 0 ? [
|
|
@@ -1906,12 +1910,6 @@ const HubClientProvider = () => Provider.effect(HubClient, Effect.gen(function*
|
|
|
1906
1910
|
delete: ({ olds, output }) => unregister(api, olds.team, output.clientId).pipe(Effect.asVoid)
|
|
1907
1911
|
};
|
|
1908
1912
|
}));
|
|
1909
|
-
/** The variables that a deployment reads to sign in through the hub. */
|
|
1910
|
-
const HUB_VARIABLES = [
|
|
1911
|
-
"HUB_ISSUER",
|
|
1912
|
-
"HUB_CLIENT_ID",
|
|
1913
|
-
"HUB_CLIENT_SECRET"
|
|
1914
|
-
];
|
|
1915
1913
|
/**
|
|
1916
1914
|
* `alchemy-convex hub-client`: a stack deploys production and previews, and this covers the
|
|
1917
1915
|
* development deployment, which no stack deploys. A deployment with all three variables keeps
|
|
@@ -1920,12 +1918,18 @@ const HUB_VARIABLES = [
|
|
|
1920
1918
|
*/
|
|
1921
1919
|
const registerDevelopmentClient = (options) => Effect.gen(function* () {
|
|
1922
1920
|
const { convex } = options;
|
|
1921
|
+
const envPrefix = options.envPrefix ?? "HUB";
|
|
1922
|
+
const variables = [
|
|
1923
|
+
`${envPrefix}_ISSUER`,
|
|
1924
|
+
`${envPrefix}_CLIENT_ID`,
|
|
1925
|
+
`${envPrefix}_CLIENT_SECRET`
|
|
1926
|
+
];
|
|
1923
1927
|
const names = convex([
|
|
1924
1928
|
"env",
|
|
1925
1929
|
"list",
|
|
1926
1930
|
"--names-only"
|
|
1927
1931
|
]).split("\n");
|
|
1928
|
-
if (
|
|
1932
|
+
if (variables.every((name) => names.includes(name))) return void 0;
|
|
1929
1933
|
const siteUrl = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.String))(convex([
|
|
1930
1934
|
"run",
|
|
1931
1935
|
"--inline-query",
|
|
@@ -1947,10 +1951,10 @@ const registerDevelopmentClient = (options) => Effect.gen(function* () {
|
|
|
1947
1951
|
"env",
|
|
1948
1952
|
"set",
|
|
1949
1953
|
"--force"
|
|
1950
|
-
],
|
|
1954
|
+
], `${envPrefix}_ISSUER='${client.issuer}'\n${envPrefix}_CLIENT_ID='${client.clientId}'\n${envPrefix}_CLIENT_SECRET='${Redacted.value(client.clientSecret)}'\n`);
|
|
1951
1955
|
return callbackUrl;
|
|
1952
1956
|
});
|
|
1953
1957
|
//#endregion
|
|
1954
1958
|
export { PushTargetMismatch as A, DEPLOY_KEY_ENV as B, DeploymentProvider as C, ConvexAppNotFound as D, CodePushFailed as E, ManagementApi as F, fromValues as H, ManagementApiLive as I, ACCESS_TOKEN_ENV as L, installedCli as M, parseDeployOutput as N, ConvexCliNotFound as O, ConvexApiError as P, Credentials as R, DeploymentIdentityChange as S, ProductionDeploymentNotFound as T, fromConfig as V, ProjectProvider as _, registerDevelopmentClient as a, AmbiguousDeployment as b, RUN_RECORD_KEY as c, withRunRecord as d, AmbiguousProject as f, ProjectNotFound as g, ProjectDeploymentChange as h, HubClientProvider as i, VariablesOwnedBySomeoneElse as j, EnvironmentNeedsDeployKey as k, RunRecordError as l, Project as m, HubClient as n, STORE_PROJECT_NAME as o, CreatedProjectNotFound as p, HubClientFailed as r, state as s, HUB_PROJECT_NAME as t, runRecord as u, ProjectTeamChange as v, DeploymentResource as w, Deployment as x, AbsoluteRootDir as y, CredentialsError as z };
|
|
1955
1959
|
|
|
1956
|
-
//# sourceMappingURL=HubClient-
|
|
1960
|
+
//# sourceMappingURL=HubClient-B6hjkbjW.js.map
|