ref0-git 0.7.0 → 0.9.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/app/apps/github/generated/git-rest.ts +8 -11
- package/app/apps/github/src/components/signin/device-card.tsx +2 -2
- package/app/apps/github/src/seed/seed.ts +59 -36
- package/app/apps/github/src/signin/device-code.ts +2 -2
- package/app/apps/github/src/signin/device-prompt.ts +6 -6
- package/app/pnpm-workspace.yaml +2 -2
- package/dist/cli/events.mjs +10 -13
- package/dist/cli/failure.mjs +4 -10
- package/dist/cli/hosts.mjs +2 -2
- package/dist/cli/queue.mjs +14 -23
- package/dist/cli/repos.mjs +10 -19
- package/dist/cli/resources.mjs +2 -2
- package/dist/cli/setup.mjs +33 -40
- package/dist/cli/sign-in.mjs +4 -4
- package/dist/cli/tokens.mjs +7 -11
- package/dist/cli/vendor.mjs +21 -1
- package/dist/init/app.mjs +6 -4
- package/dist/init/astro.mjs +2 -2
- package/dist/init/cloudflare.mjs +95 -50
- package/dist/init/detect.mjs +4 -4
- package/dist/init/git-module.mjs +89 -30
- package/dist/init/metadata.mjs +7 -2
- package/dist/init/mounts.mjs +12 -20
- package/dist/init/next.mjs +1 -1
- package/dist/init/node.mjs +24 -35
- package/dist/init/nuxt.mjs +6 -7
- package/dist/init/react-router.mjs +2 -2
- package/dist/init/routes.mjs +13 -22
- package/dist/init/sveltekit.mjs +3 -3
- package/dist/init/template.mjs +6 -13
- package/dist/init/templates.mjs +31 -48
- package/dist/init/vercel.mjs +18 -22
- package/dist/init/versions.mjs +32 -4
- package/package.json +5 -5
package/dist/cli/resources.mjs
CHANGED
|
@@ -22,7 +22,7 @@ const remoteFor = (host) => Effect.flatMap(chosenHost(host), remoteOf);
|
|
|
22
22
|
/** The host's answer to `call`, made with its client: its refusal as the CLI's failure. */
|
|
23
23
|
const called = /* @__PURE__ */ Effect.fnUntraced(function* (host, call) {
|
|
24
24
|
const remote = yield* remoteFor(host);
|
|
25
|
-
const value = yield* answered(remote.host,
|
|
25
|
+
const value = yield* answered(remote.host, call(remote.client));
|
|
26
26
|
return {
|
|
27
27
|
...remote,
|
|
28
28
|
value
|
|
@@ -62,7 +62,7 @@ const pagesOf = /* @__PURE__ */ Effect.fnUntraced(function* (from, choice, comma
|
|
|
62
62
|
if (wanted !== void 0) page.limit = wanted - items.length;
|
|
63
63
|
if (after !== void 0) page.after = after;
|
|
64
64
|
const resumeAt = after;
|
|
65
|
-
const listing = yield* answered(remote.host,
|
|
65
|
+
const listing = yield* answered(remote.host, call(remote.client, page)).pipe(Effect.catch((failed) => withRows(failed, (rows) => resumable(failed, rows, resumeAt, command(remote.host), wanted))));
|
|
66
66
|
items.push(...listing.items);
|
|
67
67
|
after = listing.next;
|
|
68
68
|
if (wanted === void 0 || after === void 0 || items.length >= wanted) return {
|
package/dist/cli/setup.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { pnpmManual, withPnpmOverrides, wroteOf } from "../init/files.mjs";
|
|
|
7
7
|
import { keepsData, mainOrigin, nodeNeeds, routed, routedFindings } from "../init/node.mjs";
|
|
8
8
|
import { detect } from "../init/detect.mjs";
|
|
9
9
|
import { outputOf as outputOf$1, secretFilesOf } from "../init/output.mjs";
|
|
10
|
+
import { appPackages, peerPackages, release } from "../init/metadata.mjs";
|
|
10
11
|
import { detectFrameworks, frameworkFor, newFramework, othersRow } from "../init/frameworks.mjs";
|
|
11
12
|
import { creatable, createCommand, createFailed, createPlatforms, created, creatorFolder, creators } from "../init/create.mjs";
|
|
12
13
|
import { nuxtFindings, nuxtJobsPlugin } from "../init/nuxt.mjs";
|
|
@@ -15,13 +16,13 @@ import { svelteBodyLimit, svelteStart } from "../init/sveltekit.mjs";
|
|
|
15
16
|
import { variablesOf, vercelProblems } from "../init/vercel.mjs";
|
|
16
17
|
import { addedTo, plan } from "../init/plan.mjs";
|
|
17
18
|
import { dropInPrefixes } from "../init/routes.mjs";
|
|
18
|
-
import {
|
|
19
|
+
import { contentNamed, published, unpacked } from "../init/versions.mjs";
|
|
19
20
|
import { catalogOf } from "../init/workspace.mjs";
|
|
20
21
|
import { doctorJson, initJson, verifyJson } from "./documents.mjs";
|
|
21
22
|
import { CliFailure, cancelled, diskFailed, failure, leftBehind, refused, usageFailure } from "./failure.mjs";
|
|
22
23
|
import { chosenHost, hostFlag, remoteOf } from "./hosts.mjs";
|
|
23
24
|
import { runChild, stopMs } from "./child.mjs";
|
|
24
|
-
import { vendored } from "./vendor.mjs";
|
|
25
|
+
import { outdated, vendored } from "./vendor.mjs";
|
|
25
26
|
import { Folders } from "./folders.mjs";
|
|
26
27
|
import { gitRun } from "./git.mjs";
|
|
27
28
|
import { node } from "./node.mjs";
|
|
@@ -38,8 +39,8 @@ import * as Option from "effect/Option";
|
|
|
38
39
|
import * as Command from "effect/cli/Command";
|
|
39
40
|
import * as Schema from "effect/Schema";
|
|
40
41
|
import * as Flag from "effect/cli/Flag";
|
|
41
|
-
import * as Argument from "effect/cli/Argument";
|
|
42
42
|
import { shortTarget } from "@ref0/git";
|
|
43
|
+
import * as Argument from "effect/cli/Argument";
|
|
43
44
|
import * as Clock from "effect/Clock";
|
|
44
45
|
import * as FileSystem from "effect/FileSystem";
|
|
45
46
|
import * as Path from "effect/Path";
|
|
@@ -234,11 +235,6 @@ const sourceOf = /* @__PURE__ */ Effect.fnUntraced(function* (fromCheckout, appC
|
|
|
234
235
|
checkout: void 0
|
|
235
236
|
};
|
|
236
237
|
});
|
|
237
|
-
/**
|
|
238
|
-
* A version npm publishes: semver 2.0.0's own, `MAJOR.MINOR.PATCH` with an optional prerelease and
|
|
239
|
-
* build, no leading `v` or `=` and no space, as `semver.valid` takes one without `loose`.
|
|
240
|
-
*/
|
|
241
|
-
const published = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/u;
|
|
242
238
|
/** The tarball `pnpm pack --json` says it made: its package's name and version, and its file. */
|
|
243
239
|
const readPacked = /* @__PURE__ */ Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Struct({
|
|
244
240
|
name: Schema.String,
|
|
@@ -257,7 +253,8 @@ const lastObject = (printed) => {
|
|
|
257
253
|
const readVersion = /* @__PURE__ */ Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Struct({ version: Schema.String })));
|
|
258
254
|
/**
|
|
259
255
|
* The tarballs a pack of `checkout` would make, from its own manifests' versions, named as `pnpm
|
|
260
|
-
* pack` names them: what a dry run, which packs
|
|
256
|
+
* pack` names them, with `unpacked` for the hash of bytes it never made: what a dry run, which packs
|
|
257
|
+
* nothing, says `init` would write.
|
|
261
258
|
*/
|
|
262
259
|
const plannedVendor = /* @__PURE__ */ Effect.fnUntraced(function* (checkout) {
|
|
263
260
|
const fs = yield* FileSystem.FileSystem;
|
|
@@ -265,7 +262,8 @@ const plannedVendor = /* @__PURE__ */ Effect.fnUntraced(function* (checkout) {
|
|
|
265
262
|
for (const each of vendorPacks) {
|
|
266
263
|
const at = `${checkout}/packages/${each.folder}/package.json`;
|
|
267
264
|
const { version } = yield* readVersion(yield* fs.readFileString(at)).pipe(Effect.mapError(() => usageFailure("invalid_manifest", `${printable(at)} has no version init can read`)));
|
|
268
|
-
|
|
265
|
+
const file = `${each.name.replace("@", "").replace("/", "-")}-${version}.tgz`;
|
|
266
|
+
vendor.set(each.name, `${each.into}/${contentNamed(file, unpacked)}`);
|
|
269
267
|
}
|
|
270
268
|
return vendor;
|
|
271
269
|
}, (reading, checkout) => Effect.catchTag(reading, "PlatformError", (error) => Effect.fail(diskFailed(`read the package manifests in ${printable(checkout)}`)(error))));
|
|
@@ -357,7 +355,11 @@ const packedInto = /* @__PURE__ */ Effect.fnUntraced(function* (checkout, folder
|
|
|
357
355
|
kind: "failed",
|
|
358
356
|
why: `pnpm pack in ${where} made ${file} at version ${made.value.version}, which isn't a version npm publishes: npm takes semver's MAJOR.MINOR.PATCH, with no leading v or =`
|
|
359
357
|
};
|
|
360
|
-
|
|
358
|
+
const bytes = yield* fs.readFile(`${destination}/${file}`).pipe(Effect.mapError(diskFailed(`read ${printable(`${destination}/${file}`)}`)));
|
|
359
|
+
const sha256 = yield* Effect.promise(() => crypto.subtle.digest("SHA-256", new Uint8Array(bytes)));
|
|
360
|
+
const named = contentNamed(file, new Uint8Array(sha256));
|
|
361
|
+
yield* fs.rename(`${destination}/${file}`, `${destination}/${named}`).pipe(Effect.mapError(diskFailed(`name ${printable(`${destination}/${file}`)}`)));
|
|
362
|
+
vendor.set(each.name, `${each.into}/${named}`);
|
|
361
363
|
}
|
|
362
364
|
return {
|
|
363
365
|
kind: "packed",
|
|
@@ -564,6 +566,7 @@ const finish = /* @__PURE__ */ Effect.fnUntraced(function* (flags, folder, proje
|
|
|
564
566
|
run: [asRun()]
|
|
565
567
|
});
|
|
566
568
|
const wrote = yield* written(folder.path, steps);
|
|
569
|
+
if (packed !== void 0) yield* outdated(packed, folder.path);
|
|
567
570
|
const kept = wroteOf(wrote, settled.app.value === "ref0");
|
|
568
571
|
const installStep = {
|
|
569
572
|
says: `Run \`${manager} install\` in ${printable(folder.path)}, then check it`,
|
|
@@ -862,7 +865,8 @@ const init = Command.make("init", {
|
|
|
862
865
|
}, made.project, source, vendor, pnpm);
|
|
863
866
|
const steps = plan(output.files, held?.files, made.view.read);
|
|
864
867
|
const links = [];
|
|
865
|
-
|
|
868
|
+
const vendorFolders = new Set([...vendor?.values() ?? []].map((at) => at.slice(0, at.lastIndexOf("/"))));
|
|
869
|
+
for (const at of [...steps.map((step) => step.path), ...vendorFolders]) if (yield* linked(folder.path, at)) links.push(at);
|
|
866
870
|
if (links.length > 0) return yield* failure("file_is_link", `${links.join(", ")} ${links.length === 1 ? "is a link" : "are links"}, and init reads and writes only the folder's own files`, {
|
|
867
871
|
says: "Replace each with the file itself, then run init again",
|
|
868
872
|
run: [asRun()]
|
|
@@ -890,11 +894,10 @@ const leftoversShown = 50;
|
|
|
890
894
|
* leaves, so a host that's run `--verify` often still names what's left. The check has passed by
|
|
891
895
|
* the time it lists them, so a listing that fails is said, not the run's failure.
|
|
892
896
|
*/
|
|
893
|
-
const leftovers = (host, client) => cutAnswer(host,
|
|
897
|
+
const leftovers = (host, client) => cutAnswer(host, client.repos.list({
|
|
894
898
|
prefix: scratchPrefix,
|
|
895
899
|
order: "newest",
|
|
896
|
-
page: { limit: leftoversShown }
|
|
897
|
-
signal
|
|
900
|
+
page: { limit: leftoversShown }
|
|
898
901
|
})).pipe(Effect.match({
|
|
899
902
|
onSuccess: (page) => {
|
|
900
903
|
const names = page.items.map(printable);
|
|
@@ -931,17 +934,14 @@ const leftoversRow = (host, found) => {
|
|
|
931
934
|
};
|
|
932
935
|
/**
|
|
933
936
|
* The host's answer to `call`, given up after `callMs` on Effect's `Clock` as well as on the
|
|
934
|
-
* run's cancel, or its failure as the CLI's: a cut interrupts
|
|
935
|
-
*
|
|
936
|
-
*
|
|
937
|
+
* run's cancel, or its failure as the CLI's: a cut interrupts the call and fails
|
|
938
|
+
* `deadline_exceeded`, a refusal is the host's own, and a defect `unreachable`, so every
|
|
939
|
+
* `--verify` call says a stalled host in the same words.
|
|
937
940
|
*/
|
|
938
|
-
const cutAnswer = (host, call) => Effect.
|
|
939
|
-
try: (signal) => call(signal),
|
|
940
|
-
catch: () => failure("unreachable", `Couldn't reach ${host}`)
|
|
941
|
-
}).pipe(Effect.timeoutOrElse({
|
|
941
|
+
const cutAnswer = (host, call) => call.pipe(Effect.mapError((error) => refused(error, host)), Effect.catchDefect(() => Effect.fail(failure("unreachable", `Couldn't reach ${host}`))), Effect.timeoutOrElse({
|
|
942
942
|
duration: callMs,
|
|
943
943
|
orElse: () => Effect.fail(failure("deadline_exceeded", `${host} didn't answer in ${callMs / 1e3}s`))
|
|
944
|
-
})
|
|
944
|
+
}));
|
|
945
945
|
/** A create's failures that don't say the host made nothing: no answer, or its own failure. */
|
|
946
946
|
const unsettled = /^(unreachable|unavailable|deadline_exceeded|internal|data_loss)$/;
|
|
947
947
|
/**
|
|
@@ -971,18 +971,14 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (hostOption) {
|
|
|
971
971
|
}), (ran) => ran.status === 0 ? Effect.succeed(ran.stdout) : Effect.fail(failure("verify_git", `git ${args[0] ?? ""} failed against ${host}`)));
|
|
972
972
|
const work = Effect.gen(function* () {
|
|
973
973
|
made.repo = true;
|
|
974
|
-
const created = yield* cutAnswer(host, (
|
|
975
|
-
name: repo,
|
|
976
|
-
signal
|
|
977
|
-
})).pipe(Effect.tapError((failed) => Effect.sync(() => made.repo = unsettled.test(failed.reason))));
|
|
974
|
+
const created = yield* cutAnswer(host, client.repos.create({ name: repo })).pipe(Effect.tapError((failed) => Effect.sync(() => made.repo = unsettled.test(failed.reason))));
|
|
978
975
|
made.created = true;
|
|
979
976
|
steps.push("Created");
|
|
980
977
|
made.tokenSent = true;
|
|
981
|
-
const token = yield* cutAnswer(host,
|
|
978
|
+
const token = yield* cutAnswer(host, client.tokens.create(repo, {
|
|
982
979
|
scope: "write",
|
|
983
980
|
subject: { id: "ref0-git-verify" },
|
|
984
|
-
expiresAt: now + 36e5
|
|
985
|
-
signal
|
|
981
|
+
expiresAt: now + 36e5
|
|
986
982
|
})).pipe(Effect.tapError((failed) => Effect.sync(() => made.tokenSent = unsettled.test(failed.reason))));
|
|
987
983
|
made.token = token.id;
|
|
988
984
|
secrets.hide(token.secret);
|
|
@@ -1042,10 +1038,7 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (hostOption) {
|
|
|
1042
1038
|
"rev-parse",
|
|
1043
1039
|
"HEAD"
|
|
1044
1040
|
])).trim();
|
|
1045
|
-
const read = yield* cutAnswer(host,
|
|
1046
|
-
ref: target,
|
|
1047
|
-
signal
|
|
1048
|
-
}));
|
|
1041
|
+
const read = yield* cutAnswer(host, client.refs.get(repo, { ref: target }));
|
|
1049
1042
|
if (read.oid !== head) return yield* failure("verify_read", `${host} read back ${printable(read.oid)}, not the pushed ${head}`);
|
|
1050
1043
|
steps.push("read");
|
|
1051
1044
|
yield* run([
|
|
@@ -1064,19 +1057,19 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (hostOption) {
|
|
|
1064
1057
|
steps.push("cloned");
|
|
1065
1058
|
});
|
|
1066
1059
|
/** Whether `call` removed `what` in time, or found it gone where `gone` says that's settled. */
|
|
1067
|
-
const removed = (what, call, gone = true) => Effect.
|
|
1060
|
+
const removed = (what, call, gone = true) => call.pipe(Effect.as(true), Effect.catch((error) => Effect.succeed(gone && error.code === "NOT_FOUND")), Effect.catchDefect(() => Effect.succeed(false)), Effect.timeoutOrElse({
|
|
1068
1061
|
duration: callMs,
|
|
1069
1062
|
orElse: () => Effect.succeed(false)
|
|
1070
|
-
}), Effect.
|
|
1063
|
+
}), Effect.tap((done) => done ? Effect.void : Effect.sync(() => left.push(what))));
|
|
1071
1064
|
const cleanUpFailed = (headline) => failure("cleanup_failed", `${headline}, and may have left ${left.join(" and ")}`, {
|
|
1072
1065
|
says: `Check ${host} for it: a later \`doctor --verify\` lists scratch repos under Leftovers`,
|
|
1073
1066
|
run: []
|
|
1074
1067
|
});
|
|
1075
1068
|
const cleanUp = Effect.gen(function* () {
|
|
1076
1069
|
const token = made.token;
|
|
1077
|
-
if (token !== "") yield* removed(`token ${token}`,
|
|
1070
|
+
if (token !== "") yield* removed(`token ${token}`, client.tokens.revoke(token, {}));
|
|
1078
1071
|
else if (made.tokenSent) left.push(`the token on ${repo}, which ends within the hour`);
|
|
1079
|
-
const deleted =
|
|
1072
|
+
const deleted = client.repos.delete(repo, {});
|
|
1080
1073
|
if (made.repo && (yield* removed(repo, deleted, made.created))) steps.push("deleted");
|
|
1081
1074
|
yield* fs.remove(folder, {
|
|
1082
1075
|
recursive: true,
|
|
@@ -1258,7 +1251,7 @@ const nodeFindings = (view, project, chosen, disk, source) => {
|
|
|
1258
1251
|
const { sources } = disk;
|
|
1259
1252
|
const entry = sources.find((file) => {
|
|
1260
1253
|
const text = file === "git.ts" ? "" : view.read(`src/${file}`) ?? "";
|
|
1261
|
-
return /from ['"]\.\/git\.ts['"]/.test(text) && /\b(?:toNode(?:Handler|Middleware)|
|
|
1254
|
+
return /from ['"]\.\/git\.ts['"]/.test(text) && /\b(?:toNode(?:Handler|Middleware)|toFetch)\(/.test(text) && /\btoJobRunner\(/.test(text);
|
|
1262
1255
|
});
|
|
1263
1256
|
const framework = project.framework;
|
|
1264
1257
|
const starter = framework === void 0 ? void 0 : startersOf(framework);
|
|
@@ -1402,7 +1395,7 @@ const findingsOf = (view, project, chosen, disk, source) => {
|
|
|
1402
1395
|
const classesBound = gitClasses.every((each) => bindings.includes(each.name) && made.includes(each.class_name));
|
|
1403
1396
|
const entry = main === void 0 ? "" : view.read(main) ?? "";
|
|
1404
1397
|
const exported = gitClasses.every(({ class_name: name }) => new RegExp(`export\\s+(const|class|\\{[^}]*)\\s*\\b${name}\\b`).test(entry));
|
|
1405
|
-
const routed = /from ['"]\.\/git\.ts['"]/.test(entry) && /\
|
|
1398
|
+
const routed = /from ['"]\.\/git\.ts['"]/.test(entry) && /\bGit\.(?:toFetch|route)\(|\bingressOf\(\{[^}]*\bgit\b/.test(entry);
|
|
1406
1399
|
const packs = chosen.objects === "packs";
|
|
1407
1400
|
const bucketBound = buckets.includes("PACKS");
|
|
1408
1401
|
const vars = devVars(view);
|
package/dist/cli/sign-in.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import * as Schema from "effect/Schema";
|
|
|
14
14
|
import * as Duration from "effect/Duration";
|
|
15
15
|
import * as DateTime from "effect/DateTime";
|
|
16
16
|
import * as Flag from "effect/cli/Flag";
|
|
17
|
-
import {
|
|
17
|
+
import { RestClient } from "@ref0/git";
|
|
18
18
|
import * as Argument from "effect/cli/Argument";
|
|
19
19
|
import * as Clock from "effect/Clock";
|
|
20
20
|
import * as Result from "effect/Result";
|
|
@@ -127,10 +127,10 @@ const tokenFromStdin = /* @__PURE__ */ Effect.fnUntraced(function* (host) {
|
|
|
127
127
|
return Result.isSuccess(read) ? read.success : yield* usageFailure("token_unreadable", read.failure.message, "Pipe in one token, on one line");
|
|
128
128
|
});
|
|
129
129
|
/** Who `token` signs in on the host, as `GET /me` answers. */
|
|
130
|
-
const meWith = (host, token) => answered(hostName(host), (
|
|
130
|
+
const meWith = (host, token) => answered(hostName(host), Effect.flatMap(RestClient.make({
|
|
131
131
|
url: host.endpoint,
|
|
132
132
|
credentials: { token: Redacted.value(token) }
|
|
133
|
-
}).me(
|
|
133
|
+
}), (client) => client.me()));
|
|
134
134
|
/** A token's coverage and scope, as a person reads it. */
|
|
135
135
|
const coverage = (token) => token.repo !== void 0 ? `${token.scope} on ${printable(token.repo)}` : token.prefix === "" ? `${token.scope} on every repo` : `${token.scope} on ${printable(token.prefix)}*`;
|
|
136
136
|
/** The sign-in group's commands, at the top of the tree. */
|
|
@@ -185,7 +185,7 @@ const signInCommands = [
|
|
|
185
185
|
})).pipe(Command.withDescription("Remove the stored token (experimental)")),
|
|
186
186
|
Command.make("whoami", { host: hostFlag }, /* @__PURE__ */ Effect.fnUntraced(function* ({ host }) {
|
|
187
187
|
const remote = yield* remoteOf(yield* chosenHost(host));
|
|
188
|
-
const me = yield* answered(remote.host,
|
|
188
|
+
const me = yield* answered(remote.host, remote.client.me());
|
|
189
189
|
if ((yield* CliModes).json) return yield* document(me);
|
|
190
190
|
const token = me.token;
|
|
191
191
|
const rows = [
|
package/dist/cli/tokens.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import * as Redacted from "effect/Redacted";
|
|
|
7
7
|
import * as Option from "effect/Option";
|
|
8
8
|
import * as Command from "effect/cli/Command";
|
|
9
9
|
import * as Flag from "effect/cli/Flag";
|
|
10
|
-
import { tokenScopes, tokenStates } from "@ref0/git
|
|
10
|
+
import { tokenScopes, tokenStates } from "@ref0/git";
|
|
11
11
|
import * as Argument from "effect/cli/Argument";
|
|
12
12
|
import * as Clock from "effect/Clock";
|
|
13
13
|
// src/cli/tokens.ts
|
|
@@ -32,7 +32,7 @@ const create = Command.make("create", {
|
|
|
32
32
|
...coverageFlags,
|
|
33
33
|
host: hostFlag,
|
|
34
34
|
subject: Flag.String("subject").pipe(Flag.withDescription("Who the token is for: the actor it signs in as"), Flag.withMetavar("ID")),
|
|
35
|
-
scope: Flag.Literals("scope", tokenScopes).pipe(Flag.withDescription("What it may do: read, report a check, or
|
|
35
|
+
scope: Flag.Literals("scope", tokenScopes).pipe(Flag.withDescription("What it may do: read, report a check, write, or admin, every repo with --prefix ''"), Flag.withDefault("read")),
|
|
36
36
|
expires: Flag.String("expires").pipe(Flag.withDescription("How long until it expires, as 12h or 90d"), Flag.withMetavar("DURATION"), Flag.withDefault("30d")),
|
|
37
37
|
showToken: Flag.Boolean("show-token").pipe(Flag.withDescription("Print the token on stdout, the only way to get it"), Flag.withDefault(false))
|
|
38
38
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
@@ -65,11 +65,10 @@ const create = Command.make("create", {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
const now = yield* Clock.currentTimeMillis;
|
|
68
|
-
const made = yield* called(flags.host, (client
|
|
68
|
+
const made = yield* called(flags.host, (client) => client.tokens.create(target, {
|
|
69
69
|
scope: flags.scope,
|
|
70
70
|
expiresAt: now + lasts,
|
|
71
|
-
subject: { id: flags.subject }
|
|
72
|
-
signal
|
|
71
|
+
subject: { id: flags.subject }
|
|
73
72
|
}));
|
|
74
73
|
const { secret: received, ...record } = made.value;
|
|
75
74
|
const secret = Redacted.make(received);
|
|
@@ -111,11 +110,8 @@ const list = Command.make("list", {
|
|
|
111
110
|
...["--host", host],
|
|
112
111
|
...state === void 0 ? [] : ["--state", state]
|
|
113
112
|
];
|
|
114
|
-
const read = yield* pagesOf(flags.host, flags, command, tokenLine, (client, page
|
|
115
|
-
const input = {
|
|
116
|
-
page,
|
|
117
|
-
signal
|
|
118
|
-
};
|
|
113
|
+
const read = yield* pagesOf(flags.host, flags, command, tokenLine, (client, page) => {
|
|
114
|
+
const input = { page };
|
|
119
115
|
if (state !== void 0) input.state = state;
|
|
120
116
|
return client.tokens.list(target, input);
|
|
121
117
|
});
|
|
@@ -130,7 +126,7 @@ const revoke = Command.make("revoke", {
|
|
|
130
126
|
token: Argument.String("TOKEN").pipe(Argument.withDescription("The token's ID, as tokens list prints it")),
|
|
131
127
|
host: hostFlag
|
|
132
128
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
133
|
-
const done = yield* called(flags.host, (client
|
|
129
|
+
const done = yield* called(flags.host, (client) => client.tokens.revoke(flags.token, {}));
|
|
134
130
|
yield* changed({}, flags.token, { done: `Revoked token ${printable(flags.token)} on ${done.host}` });
|
|
135
131
|
})).pipe(Command.withDescription("Revoke a token, so it signs nothing in again"));
|
|
136
132
|
const tokensCommand = Command.make("tokens").pipe(Command.withDescription("The host's tokens (experimental)"), Command.withSubcommands([
|
package/dist/cli/vendor.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { initPacked } from "../init/versions.mjs";
|
|
1
2
|
import { forget, leftBehind, notPutBack } from "./failure.mjs";
|
|
2
3
|
import * as Effect from "effect/Effect";
|
|
3
4
|
import * as Predicate from "effect/Predicate";
|
|
@@ -120,4 +121,23 @@ const vendored = /* @__PURE__ */ Effect.fnUntraced(function* (packed, folder, ta
|
|
|
120
121
|
yield* removed(own).pipe(Effect.catch((error) => leftBehind(own, error)));
|
|
121
122
|
return { kind: "placed" };
|
|
122
123
|
}, Effect.uninterruptible);
|
|
123
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Removes each tarball in `folder`'s `vendor/` and `vendor/cli/` that `init` wrote for one of
|
|
126
|
+
* `packed`'s packages, by `initPacked`'s names, other than `packed`'s own: once `package.json` names
|
|
127
|
+
* this run's, an older run's are no one's, and a rerun leaves none of them behind. One it can't
|
|
128
|
+
* remove is recorded as left, for the run's end to name.
|
|
129
|
+
*/
|
|
130
|
+
const outdated = /* @__PURE__ */ Effect.fnUntraced(function* (packed, folder) {
|
|
131
|
+
const fs = yield* FileSystem.FileSystem;
|
|
132
|
+
const names = [...packed.vendor.keys()];
|
|
133
|
+
const kept = new Set(packed.vendor.values());
|
|
134
|
+
for (const under of ["vendor", "vendor/cli"]) {
|
|
135
|
+
const entries = yield* fs.readDirectory(`${folder}/${under}`).pipe(Effect.orElseSucceed(() => []));
|
|
136
|
+
for (const entry of entries) {
|
|
137
|
+
const at = `${under}/${entry}`;
|
|
138
|
+
if (kept.has(at) || !names.some((name) => initPacked(name, at))) continue;
|
|
139
|
+
yield* fs.remove(`${folder}/${at}`).pipe(Effect.catch((error) => leftBehind(`${folder}/${at}`, error)));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
export { outdated, vendored };
|
package/dist/init/app.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { bucketLine, bucketName, devVars, looseInfraImport, mergePackage, secretFiles } from "./cloudflare.mjs";
|
|
1
|
+
import { bucketLine, bucketName, devVars, limitsLine, looseInfraImport, mergePackage, secretFiles } from "./cloudflare.mjs";
|
|
2
2
|
import { ignoring, importLine, lines, listed, withCli } from "./files.mjs";
|
|
3
3
|
import { bucketLines, firstImports, infraImports, partsOf, storeLines } from "./node.mjs";
|
|
4
4
|
import { specOf } from "./versions.mjs";
|
|
5
|
-
import { looseSays } from "./git-module.mjs";
|
|
5
|
+
import { lfsLines, looseSays, writtenCpu } from "./git-module.mjs";
|
|
6
6
|
import { jsonString, manifestText } from "./jsonc.mjs";
|
|
7
7
|
import { filled, platforms, templates, unless } from "./template.mjs";
|
|
8
8
|
import { blockOf, catalogOf } from "./workspace.mjs";
|
|
@@ -119,8 +119,7 @@ const bodySlots = (choices) => {
|
|
|
119
119
|
queueMerge: unless(queue, ""),
|
|
120
120
|
queue: unless(queue, ""),
|
|
121
121
|
objects: unless(packs, looseObjects),
|
|
122
|
-
releases: unless(packs, "")
|
|
123
|
-
lfs: unless(packs, "")
|
|
122
|
+
releases: unless(packs, "")
|
|
124
123
|
};
|
|
125
124
|
};
|
|
126
125
|
/** The app's `src/git.ts` on Cloudflare: `apps/github`'s own, its store's and queue's slots filled. */
|
|
@@ -135,6 +134,7 @@ const cloudflareGit = (choices) => {
|
|
|
135
134
|
bucket: unless(packs, ""),
|
|
136
135
|
adapter: unless(packs, "/** The records and job objects. */\nconst adapter = layer({ records: env.RECORDS, jobs: env.JOBS });"),
|
|
137
136
|
uploads: unless(packs, ""),
|
|
137
|
+
lfs: packs ? `${lfsLines(" ", writtenCpu)}\n` : "",
|
|
138
138
|
...bodySlots(choices)
|
|
139
139
|
});
|
|
140
140
|
};
|
|
@@ -161,6 +161,7 @@ const nodeHead = (choices) => {
|
|
|
161
161
|
/** The app's `src/git.ts` on Node: `apps/github`'s own past its head, Node's head and parts in Cloudflare's place. */
|
|
162
162
|
const nodeGit = (choices) => filled(templates.appGitNode, {
|
|
163
163
|
head: `${nodeHead(choices)}\n`,
|
|
164
|
+
lfs: choices.objects === "packs" ? `${lfsLines(" ", void 0)}\n` : "",
|
|
164
165
|
adapter: choices.objects === "packs" ? "/** The records, the jobs and the bucket. */\nconst adapter = Layer.merge(store, bucket);" : "/** The records and the jobs. */\nconst adapter = store;",
|
|
165
166
|
uploads: choices.bucket === "s3" ? lines(" // A push past 64 MiB may upload its pack, once the bucket signs parts.", " Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), bucket),", "") : "",
|
|
166
167
|
xdiff: " Layer.provideMerge(Merges.layer({ xdiff: await xdiff() })),",
|
|
@@ -191,6 +192,7 @@ const appWrangler = (choices, name) => {
|
|
|
191
192
|
name: ` "name": ${jsonString(name)},`,
|
|
192
193
|
vars: packs ? ` "vars": { "APP_ORIGIN": "${devOrigin}", "PACKS_BUCKET": "${bucketName(name)}" },` : ` "vars": { "APP_ORIGIN": "${devOrigin}" },`,
|
|
193
194
|
bucket: bucketLine(choices, name),
|
|
195
|
+
limits: limitsLine,
|
|
194
196
|
database: ` { "binding": "AUTH_DB", "database_name": "${name}-auth", "migrations_dir": "migrations/sql" },`
|
|
195
197
|
});
|
|
196
198
|
};
|
package/dist/init/astro.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lines } from "./files.mjs";
|
|
2
|
-
import { fileRoutes,
|
|
2
|
+
import { fileRoutes, routeHandler, routeImports } from "./routes.mjs";
|
|
3
3
|
// src/init/astro.ts
|
|
4
4
|
/**
|
|
5
5
|
* What `init` writes in an Astro project on Node: an endpoint for each route, rendered on request
|
|
@@ -24,7 +24,7 @@ const endpoint = (choices, route, module) => {
|
|
|
24
24
|
return {
|
|
25
25
|
path,
|
|
26
26
|
kind: "whole",
|
|
27
|
-
text: lines(`// ${route.says} Written by \`ref0-git init\`.`, "import type { APIRoute } from 'astro';", "",
|
|
27
|
+
text: lines(`// ${route.says} Written by \`ref0-git init\`.`, "import type { APIRoute } from 'astro';", "", ...routeImports(choices), "", "// Loaded on the first request, so `astro build` opens no database and needs no secret.", ...routeHandler(choices, path, module), "", "export const prerender = false;", "", "export const ALL: APIRoute = ({ request }) => git(request);", "")
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
/** Astro's endpoints for `choices`, over `framework`'s server module. */
|