@vite-hub/workspace 0.0.3 → 0.1.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/LICENSE +201 -0
- package/README.md +236 -58
- package/dist/{ai-nmHdzjCM.d.ts → ai-BW2ZhizI.d.ts} +22 -7
- package/dist/{ai-Ce3PtWFW.js → ai-BZyLwULx.js} +147 -66
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{asset-registry-CaG9b7tf.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +19 -0
- package/dist/blob-database.d.ts +521 -0
- package/dist/blob-database.js +601 -0
- package/dist/cloudflare.d.ts +5 -6
- package/dist/cloudflare.js +1 -1
- package/dist/config-B7dmzDX3.js +1112 -0
- package/dist/{config-3I1BnsdO.d.ts → config-DLKdaFWN.d.ts} +1 -2
- package/dist/error-diagnostics-A_8Kp-48.js +116 -0
- package/dist/error-diagnostics-DY5GP47p.js +96 -0
- package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +354 -0
- package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +214 -0
- package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +527 -0
- package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +248 -0
- package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +179 -0
- package/dist/file-C0_aPWSS.js +26 -0
- package/dist/file-metadata-CxDy-E2H.js +58 -0
- package/dist/{files-QRV55OCx.js → files-C7Px8uaC.js} +21 -10
- package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +2278 -0
- package/dist/{github-CfA5vpJ5.js → github-CPxHtFB7.js} +36 -34
- package/dist/github-DtncTfmv-Du2S8lGF.js +4159 -0
- package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +2530 -0
- package/dist/glob--XcLlcml.js +22 -0
- package/dist/glob--kNYDbfU.js +30 -0
- package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +489 -0
- package/dist/host-CFnrTXTK.js +1086 -0
- package/dist/{hosted-C1-tTTTf.js → hosted-acMA5XyL.js} +216 -43
- package/dist/hosted-vercel-blob-DKntsHaf.js +12603 -0
- package/dist/hosted-vercel-blob.d.ts +5 -6
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +6 -7
- package/dist/hosted.js +1 -1
- package/dist/index.d.ts +76 -64
- package/dist/index.js +162 -457
- package/dist/inspect-BoObD2cJ.js +167 -0
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-BwZ7c9hb.js +596 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-BREFCmtn.js +39 -0
- package/dist/memory-BbwOqDXl.js +248 -0
- package/dist/metadata-target-DZEZQGHA.js +1588 -0
- package/dist/mountx.d.ts +4 -6
- package/dist/mountx.js +10 -8
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.d.ts +13 -12
- package/dist/nuxt.js +10 -8
- package/dist/operations-BcpWr41m.js +159 -0
- package/dist/operations-CGqY1XeG.js +965 -0
- package/dist/operations-DnOwKsJT.d.ts +136 -0
- package/dist/operations.d.ts +53 -0
- package/dist/operations.js +2 -0
- package/dist/{path-CNI6wKIU.js → path-CNAwN7pw.js} +34 -35
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-DqQ8b4T5.d.ts +10 -0
- package/dist/provider-kXjfli9u.js +1457 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-Bp-8UUfG.js +129 -0
- package/dist/{registry-BIQVCBWI.d.ts → registry-Cg1TJVVZ.d.ts} +3 -4
- package/dist/{request-execution-u9mgUXKX.js → request-execution-Dk9rY-Yh.js} +24 -20
- package/dist/rolldown-runtime-B4iAMlE-.js +35 -0
- package/dist/runtime/assets.d.ts +3 -5
- package/dist/runtime/assets.js +9 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -2
- package/dist/runtime/empty-registry.d.ts +1 -2
- package/dist/runtime/state.d.ts +4 -4
- package/dist/runtime/state.js +10 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +84 -15
- package/dist/runtime.js +561 -108
- package/dist/{search-C4REyHj9.js → search-CrTmXj5h.js} +10 -9
- package/dist/server-BNQ-Nbjj.js +290 -0
- package/dist/server.d.ts +22 -34
- package/dist/server.js +2 -355
- package/dist/shared-DalXdP0i.js +2158 -0
- package/dist/source-metadata.d.ts +7 -1
- package/dist/source-metadata.js +34 -2
- package/dist/{state-TTqa3x3Y.d.ts → state-B8zbLi5t.d.ts} +14 -13
- package/dist/store-CXgmu-uw.js +1729 -0
- package/dist/{sync-DiuDmSGk.js → sync-CN6ec-5M.js} +62 -41
- package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +125 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/token-CO62GglH.js +61 -0
- package/dist/{types-60Yn149G.d.ts → types-DeK9GIxy.d.ts} +348 -49
- package/dist/{use-CsV3oIxH.js → use-BQj7nSz6.js} +200 -45
- package/dist/{use-CUFSnFCS.d.ts → use-DhwhbAVV.d.ts} +34 -12
- package/dist/utils-Blrh4N2n.js +545 -0
- package/dist/vite-BEvgU2GY.js +20909 -0
- package/dist/vite-CcZmMQ7S.d.ts +476 -0
- package/dist/vite.d.ts +2 -50
- package/dist/vite.js +2 -2
- package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +1565 -0
- package/dist/workspace-6pxkOuxr.js +1286 -0
- package/dist/workspace-BWJQBK1u.d.ts +7 -0
- package/package.json +90 -59
- package/dist/chunk-8H4AJuhK.js +0 -14
- package/dist/collections/client.d.ts +0 -39
- package/dist/collections/client.js +0 -137
- package/dist/collections.d.ts +0 -59
- package/dist/collections.js +0 -159
- package/dist/config-CDoyls2X.js +0 -30
- package/dist/config-CZLO0m9h.js +0 -7811
- package/dist/file-CHfsZpso.js +0 -23
- package/dist/glob-D0vD_wRY.js +0 -17
- package/dist/host-CAnbugpI.js +0 -370
- package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
- package/dist/lifecycle-BYoa9hVb.js +0 -176
- package/dist/provider-C3_elpEh.js +0 -599
- package/dist/publish.d.ts +0 -35
- package/dist/publish.js +0 -112
- package/dist/registry-CqyDTW9Y.js +0 -74
- package/dist/runtime-options-BsPSv5O7.js +0 -13
- package/dist/shared-jfogBrd5.js +0 -273
- package/dist/store-Bs1SLh55.js +0 -414
- package/dist/vite-tbfDxtlu.js +0 -2191
- package/dist/workspace-66SKyiec.d.ts +0 -6
- package/dist/workspace-C4k92Ow8.js +0 -1460
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
1
|
+
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
2
|
+
import { f as sha256, n as contentStreamToBytes } from "./path-CNAwN7pw.js";
|
|
3
|
+
import { a as normalizeWorkspaceSources, f as prepareWorkspaceSource, n as createSourceContext, s as sourceMountContainsPath } from "./config-B7dmzDX3.js";
|
|
4
|
+
import { d as sourceSyncPathClaims, f as workspaceSourceSyncStateEquals, l as readWorkspaceSourceSyncState, u as sourceSyncMetaKey } from "./workspace-6pxkOuxr.js";
|
|
5
|
+
import { C as withWorkspaceStoreMutation, E as normalizeSourceFileMetadata, S as sourceMountOwnsPath, T as normalizeMetadataValue, w as normalizeSourceItemPath, x as createWorkspaceSourceMountAuthority } from "./metadata-target-DZEZQGHA.js";
|
|
4
6
|
//#region src/sources/sync.ts
|
|
5
7
|
const sourceSyncLocks = /* @__PURE__ */ new Map();
|
|
8
|
+
const sourceSyncGrants = createWorkspaceSourceMountAuthority("Source Sync");
|
|
6
9
|
function zeroCounts() {
|
|
7
10
|
return {
|
|
8
11
|
added: 0,
|
|
@@ -50,12 +53,15 @@ function selectedSyncSources(definition, options) {
|
|
|
50
53
|
if (options.sources === "all") return sources;
|
|
51
54
|
return [...new Set(options.sources)].map((key) => {
|
|
52
55
|
const source = sources.find((item) => item.key === key);
|
|
53
|
-
if (!source)
|
|
56
|
+
if (!source) {
|
|
57
|
+
const defined = normalizeWorkspaceSources(definition.sources).some((item) => item.key === key);
|
|
58
|
+
throw workspaceError(defined ? `[vitehub] Workspace source ${JSON.stringify(key)} is not configured for Source Sync. Add sync: true to the source binding.` : `[vitehub] Workspace source ${JSON.stringify(key)} does not exist.`);
|
|
59
|
+
}
|
|
54
60
|
return source;
|
|
55
61
|
});
|
|
56
62
|
}
|
|
57
63
|
async function getSourceItems(source, ctx) {
|
|
58
|
-
await source.source
|
|
64
|
+
await prepareWorkspaceSource(source.source, ctx);
|
|
59
65
|
if (source.source.getItems) return await source.source.getItems(ctx);
|
|
60
66
|
return await Promise.all((await source.source.getKeys(ctx)).map(async (key) => await source.source.getItem(key, ctx)));
|
|
61
67
|
}
|
|
@@ -67,7 +73,7 @@ async function shouldRemoveStalePath(store, path, metadata) {
|
|
|
67
73
|
async function planSourceSync(definition, store, source) {
|
|
68
74
|
const ctx = createSourceContext(definition, source);
|
|
69
75
|
const [previousState, configHash, items] = await Promise.all([
|
|
70
|
-
store.getMeta?.(sourceSyncMetaKey(source.key)).then(readWorkspaceSourceSyncState),
|
|
76
|
+
store.getMeta?.(sourceSyncMetaKey(source.key, definition.name)).then(readWorkspaceSourceSyncState),
|
|
71
77
|
sourceConfigHash(source),
|
|
72
78
|
getSourceItems(source, ctx)
|
|
73
79
|
]);
|
|
@@ -80,9 +86,14 @@ async function planSourceSync(definition, store, source) {
|
|
|
80
86
|
if (nextPaths[path]) throw workspaceError(`[vitehub] Workspace Source Sync produced duplicate path: ${path}.`);
|
|
81
87
|
const content = await contentFromItem(item);
|
|
82
88
|
const digest = await sha256(content);
|
|
89
|
+
const metadata = normalizeSourceFileMetadata({
|
|
90
|
+
...normalizeSourceFileMetadata(item.metadata || {}),
|
|
91
|
+
source: source.key,
|
|
92
|
+
sourcePath
|
|
93
|
+
});
|
|
83
94
|
const existing = await store.readFile(path);
|
|
84
|
-
const
|
|
85
|
-
const status = existing ?
|
|
95
|
+
const unchanged = (existing ? await sha256(existing.content) : void 0) === digest && existing?.mediaType === item.mediaType && JSON.stringify(normalizeMetadataValue(existing?.metadata)) === JSON.stringify(normalizeMetadataValue(metadata));
|
|
96
|
+
const status = existing ? unchanged ? "unchanged" : "updated" : "added";
|
|
86
97
|
countPath(counts, status);
|
|
87
98
|
paths.push({
|
|
88
99
|
path,
|
|
@@ -92,22 +103,23 @@ async function planSourceSync(definition, store, source) {
|
|
|
92
103
|
nextPaths[path] = {
|
|
93
104
|
digest,
|
|
94
105
|
mediaType: item.mediaType,
|
|
106
|
+
mountPath: source.mountPath,
|
|
95
107
|
sourcePath
|
|
96
108
|
};
|
|
97
109
|
files.push({
|
|
98
110
|
path,
|
|
99
111
|
content,
|
|
100
112
|
mediaType: item.mediaType,
|
|
101
|
-
metadata
|
|
102
|
-
...item.metadata,
|
|
103
|
-
source: source.key,
|
|
104
|
-
sourcePath
|
|
105
|
-
}
|
|
113
|
+
metadata
|
|
106
114
|
});
|
|
107
115
|
}
|
|
108
116
|
const removals = [];
|
|
109
|
-
if (source.sync && source.sync.stale === "remove" && previousState) for (const
|
|
117
|
+
if (source.sync && source.sync.stale === "remove" && previousState) for (const path of Object.keys(previousState.paths)) {
|
|
110
118
|
if (nextPaths[path]) continue;
|
|
119
|
+
const claims = sourceSyncPathClaims(previousState, path);
|
|
120
|
+
const metadata = claims.find((claim) => claim.mountPath === source.mountPath);
|
|
121
|
+
if (!metadata || claims.length > 1) continue;
|
|
122
|
+
if (!sourceMountOwnsPath(source, path)) continue;
|
|
111
123
|
if (!await shouldRemoveStalePath(store, path, metadata)) continue;
|
|
112
124
|
const removal = {
|
|
113
125
|
path,
|
|
@@ -118,28 +130,46 @@ async function planSourceSync(definition, store, source) {
|
|
|
118
130
|
paths.push(removal);
|
|
119
131
|
countPath(counts, "removed");
|
|
120
132
|
}
|
|
121
|
-
const nextState = {
|
|
122
|
-
configHash,
|
|
123
|
-
mountPath: source.mountPath,
|
|
124
|
-
paths: nextPaths,
|
|
125
|
-
source: source.key
|
|
126
|
-
};
|
|
127
133
|
return {
|
|
128
134
|
counts,
|
|
129
135
|
files,
|
|
130
|
-
nextState
|
|
136
|
+
nextState: {
|
|
137
|
+
configHash,
|
|
138
|
+
mountPath: source.mountPath,
|
|
139
|
+
paths: nextPaths,
|
|
140
|
+
source: source.key
|
|
141
|
+
},
|
|
131
142
|
paths,
|
|
132
143
|
removals,
|
|
133
144
|
source,
|
|
134
|
-
|
|
145
|
+
definitionName: definition.name
|
|
135
146
|
};
|
|
136
147
|
}
|
|
137
148
|
async function applySourceSyncPlan(store, plan) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
const sourceStore = sourceSyncGrants.store(sourceSyncGrants.grant(plan.source), store);
|
|
150
|
+
const current = await store.getMeta?.(sourceSyncMetaKey(plan.source.key, plan.definitionName)).then(readWorkspaceSourceSyncState);
|
|
151
|
+
if (plan.source.mountPath) await sourceStore.mkdir(plan.source.mountPath, { recursive: true });
|
|
152
|
+
for (const file of plan.files) await sourceStore.writeFile(file.path, file);
|
|
153
|
+
for (const removal of plan.removals) await sourceStore.rm(removal.path, { force: true });
|
|
154
|
+
await pruneEmptySourceDirectories(sourceStore, plan.source, plan.removals);
|
|
155
|
+
const paths = {};
|
|
156
|
+
const claims = {};
|
|
157
|
+
for (const path of /* @__PURE__ */ new Set([...Object.keys(current?.paths ?? {}), ...Object.keys(plan.nextState.paths)])) {
|
|
158
|
+
const retained = current?.paths[path] ? sourceSyncPathClaims(current, path).filter((claim) => claim.mountPath !== plan.source.mountPath).map((claim) => ({ ...claim })) : [];
|
|
159
|
+
const next = plan.nextState.paths[path];
|
|
160
|
+
if (next) retained.push(next);
|
|
161
|
+
if (retained.length === 0) continue;
|
|
162
|
+
const digest = next?.digest ?? current.paths[path].digest;
|
|
163
|
+
for (const claim of retained) claim.digest = digest;
|
|
164
|
+
paths[path] = retained[retained.length - 1];
|
|
165
|
+
if (retained.length > 1) claims[path] = retained.sort((left, right) => left.mountPath.localeCompare(right.mountPath));
|
|
166
|
+
}
|
|
167
|
+
const nextState = {
|
|
168
|
+
...plan.nextState,
|
|
169
|
+
paths
|
|
170
|
+
};
|
|
171
|
+
if (Object.keys(claims).length) nextState.claims = claims;
|
|
172
|
+
if (!workspaceSourceSyncStateEquals(current, nextState)) await store.setMeta?.(sourceSyncMetaKey(plan.source.key, plan.definitionName), nextState);
|
|
143
173
|
}
|
|
144
174
|
async function pruneEmptySourceDirectories(store, source, removals) {
|
|
145
175
|
const directories = /* @__PURE__ */ new Set();
|
|
@@ -172,15 +202,10 @@ function statusFromPlan(plan, details) {
|
|
|
172
202
|
status: "ready"
|
|
173
203
|
};
|
|
174
204
|
}
|
|
175
|
-
async function snapshotSyncedWorkspace(
|
|
176
|
-
if (!
|
|
205
|
+
async function snapshotSyncedWorkspace(store, options) {
|
|
206
|
+
if (!options.snapshot) return;
|
|
177
207
|
const snapshotOptions = typeof options.snapshot === "object" ? options.snapshot : {};
|
|
178
|
-
|
|
179
|
-
if (options.publish) {
|
|
180
|
-
const { publishWorkspaceSnapshot } = await import("./lifecycle-BYoa9hVb.js").then((n) => n.t);
|
|
181
|
-
await publishWorkspaceSnapshot(definition, store, snapshot);
|
|
182
|
-
}
|
|
183
|
-
return snapshot;
|
|
208
|
+
return await store.snapshot(normalizeSnapshotOptions(snapshotOptions));
|
|
184
209
|
}
|
|
185
210
|
function normalizeSnapshotOptions(options) {
|
|
186
211
|
if (!options || typeof options !== "object") return { name: "source-sync" };
|
|
@@ -202,7 +227,6 @@ async function syncWorkspaceSourcesUnlocked(definition, store, options, sources,
|
|
|
202
227
|
}
|
|
203
228
|
if (statuses.some((status) => status.status === "error") && !options.publishPartial) return {
|
|
204
229
|
durationMs: Date.now() - started,
|
|
205
|
-
published: false,
|
|
206
230
|
sources: [...statuses, ...plans.map((plan) => ({
|
|
207
231
|
counts: plan.counts,
|
|
208
232
|
mountPath: plan.source.mountPath,
|
|
@@ -215,10 +239,9 @@ async function syncWorkspaceSourcesUnlocked(definition, store, options, sources,
|
|
|
215
239
|
for (const plan of plans) await applySourceSyncPlan(store, plan);
|
|
216
240
|
const planStatuses = plans.map((plan) => statusFromPlan(plan, options.details));
|
|
217
241
|
const resultSources = [...statuses, ...planStatuses];
|
|
218
|
-
const snapshot = resultStatus(resultSources) === "ready" || options.publishPartial && planStatuses.length > 0 ? await snapshotSyncedWorkspace(
|
|
242
|
+
const snapshot = resultStatus(resultSources) === "ready" || options.publishPartial && planStatuses.length > 0 ? await snapshotSyncedWorkspace(store, options) : void 0;
|
|
219
243
|
return {
|
|
220
244
|
durationMs: Date.now() - started,
|
|
221
|
-
published: !!options.publish && !!snapshot,
|
|
222
245
|
snapshot,
|
|
223
246
|
sources: resultSources,
|
|
224
247
|
status: resultStatus(resultSources)
|
|
@@ -231,7 +254,6 @@ async function syncWorkspaceSources(definition, store, options) {
|
|
|
231
254
|
const sources = selectedSyncSources(definition, options);
|
|
232
255
|
if (sources.length === 0) return {
|
|
233
256
|
durationMs: 0,
|
|
234
|
-
published: false,
|
|
235
257
|
sources: [],
|
|
236
258
|
status: "skipped"
|
|
237
259
|
};
|
|
@@ -252,12 +274,11 @@ async function syncWorkspaceSources(definition, store, options) {
|
|
|
252
274
|
}
|
|
253
275
|
if (runnableSources.length === 0) return {
|
|
254
276
|
durationMs: Date.now() - started,
|
|
255
|
-
published: false,
|
|
256
277
|
sources: statuses,
|
|
257
278
|
status: resultStatus(statuses)
|
|
258
279
|
};
|
|
259
280
|
const lockKeys = runnableSources.map((source) => sourceLockKey(definition, source)).sort();
|
|
260
|
-
const promise = syncWorkspaceSourcesUnlocked(definition, store, options, runnableSources, statuses, started);
|
|
281
|
+
const promise = withWorkspaceStoreMutation(store, () => syncWorkspaceSourcesUnlocked(definition, store, options, runnableSources, statuses, started));
|
|
261
282
|
for (const key of lockKeys) sourceSyncLocks.set(key, promise);
|
|
262
283
|
try {
|
|
263
284
|
return await promise;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { F as NotFoundError, pt as mapConcurrent } from "./shared-DalXdP0i.js";
|
|
2
|
+
//#region ../forge/dist/templates-Bn8a-pd2-D9DhJEVD.js
|
|
3
|
+
/** Where GitHub looks for a pull request template and the legacy issue template, in its order of precedence. */
|
|
4
|
+
const LOCATIONS = [
|
|
5
|
+
".github",
|
|
6
|
+
"",
|
|
7
|
+
"docs"
|
|
8
|
+
];
|
|
9
|
+
const ISSUE_TEMPLATE = /\.(?:md|ya?ml)$/i;
|
|
10
|
+
const ISSUE_FORM = /\.ya?ml$/i;
|
|
11
|
+
const CHOOSER_CONFIG = /^config\.ya?ml$/i;
|
|
12
|
+
const CONTENTS_OWNER = /\/repos\/([^/]+)\/[^/]+\/contents(?:[/?]|$)/;
|
|
13
|
+
/** No REST endpoint for templates, and GraphQL's `issueTemplates` skips issue forms, so this walks the folders GitHub reads. */
|
|
14
|
+
async function readTemplates(repo, kinds, reader) {
|
|
15
|
+
const root = await rootOf(repo, reader);
|
|
16
|
+
const own = await templatesOf(repo, root.entries, kinds, reader);
|
|
17
|
+
const missing = kinds.filter((kind) => kind === "issue" ? !own.ownsIssues : !own.templates.some((template) => template.kind === kind));
|
|
18
|
+
if (!missing.length || repo.name.toLowerCase() === ".github") return own.templates;
|
|
19
|
+
const source = {
|
|
20
|
+
forge: repo.forge,
|
|
21
|
+
instance: repo.instance,
|
|
22
|
+
owner: root.owner,
|
|
23
|
+
name: ".github"
|
|
24
|
+
};
|
|
25
|
+
const fallback = await fallbackOf(source, missing, reader);
|
|
26
|
+
return [...own.templates, ...fallback.map((template) => ({
|
|
27
|
+
...template,
|
|
28
|
+
source
|
|
29
|
+
}))];
|
|
30
|
+
}
|
|
31
|
+
/** The root of the default branch, and the owner the repository lives under now, which differs from `repo.owner` after a transfer. */
|
|
32
|
+
async function rootOf(repo, reader) {
|
|
33
|
+
try {
|
|
34
|
+
const entries = await reader.list(repo, "");
|
|
35
|
+
const owner = entries.map((entry) => entry.url && CONTENTS_OWNER.exec(new URL(entry.url).pathname)?.[1]).find(Boolean);
|
|
36
|
+
return {
|
|
37
|
+
entries,
|
|
38
|
+
owner: owner ? decodeURIComponent(owner) : repo.owner
|
|
39
|
+
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (!(error instanceof NotFoundError)) throw error;
|
|
42
|
+
return {
|
|
43
|
+
entries: [],
|
|
44
|
+
owner: (await reader.repository(repo)).owner?.login ?? repo.owner
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** The owner's `.github` repository serves defaults only while it is public, or internal in an enterprise. */
|
|
49
|
+
async function fallbackOf(source, kinds, reader) {
|
|
50
|
+
let detail;
|
|
51
|
+
try {
|
|
52
|
+
detail = await reader.repository(source);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (error instanceof NotFoundError) return [];
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
if (detail.visibility ? detail.visibility === "private" : detail.private) return [];
|
|
58
|
+
return (await templatesOf(source, await orEmpty(reader.list(source, "")), kinds, reader)).templates;
|
|
59
|
+
}
|
|
60
|
+
/** A chooser `config.yml` alone still makes issue templates the repository's own, while any other file there doesn't. */
|
|
61
|
+
async function templatesOf(repo, root, kinds, reader) {
|
|
62
|
+
const locations = await Promise.all(LOCATIONS.map((directory) => !directory ? root : root.some((entry) => entry.type === "dir" && entry.name === directory) ? orEmpty(reader.list(repo, directory)) : []));
|
|
63
|
+
const folder = async (entries, name) => {
|
|
64
|
+
const found = entries.find((entry) => entry.type === "dir" && entry.name.toLowerCase() === name);
|
|
65
|
+
return found ? (await orEmpty(reader.list(repo, found.path))).filter((entry) => entry.type === "file") : [];
|
|
66
|
+
};
|
|
67
|
+
const [issueFiles, pullFiles] = await Promise.all([kinds.includes("issue") ? folder(locations[0], "issue_template") : [], kinds.includes("pull_request") ? folder(locations.flat(), "pull_request_template") : []]);
|
|
68
|
+
const found = [];
|
|
69
|
+
let ownsIssues = false;
|
|
70
|
+
if (kinds.includes("issue")) {
|
|
71
|
+
const templates = issueFiles.filter((entry) => ISSUE_TEMPLATE.test(entry.name) && !CHOOSER_CONFIG.test(entry.name));
|
|
72
|
+
const legacy = firstFile(locations, "issue_template");
|
|
73
|
+
if (templates.length) {
|
|
74
|
+
const forms = templates.filter((entry) => ISSUE_FORM.test(entry.name));
|
|
75
|
+
found.push(...forms.map((entry) => ({
|
|
76
|
+
kind: "issue",
|
|
77
|
+
format: "form",
|
|
78
|
+
entry
|
|
79
|
+
})), ...templates.filter((entry) => !forms.includes(entry)).map((entry) => ({
|
|
80
|
+
kind: "issue",
|
|
81
|
+
format: "markdown",
|
|
82
|
+
entry
|
|
83
|
+
})));
|
|
84
|
+
} else if (legacy) found.push({
|
|
85
|
+
kind: "issue",
|
|
86
|
+
format: "markdown",
|
|
87
|
+
entry: legacy
|
|
88
|
+
});
|
|
89
|
+
ownsIssues = templates.length > 0 || issueFiles.some((entry) => CHOOSER_CONFIG.test(entry.name)) || legacy !== void 0;
|
|
90
|
+
}
|
|
91
|
+
if (kinds.includes("pull_request")) {
|
|
92
|
+
const single = firstFile(locations, "pull_request_template");
|
|
93
|
+
found.push(...[...single ? [single] : [], ...pullFiles].map((entry) => ({
|
|
94
|
+
kind: "pull_request",
|
|
95
|
+
format: "markdown",
|
|
96
|
+
entry
|
|
97
|
+
})));
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
templates: await mapConcurrent(found, 4, async ({ kind, format, entry }) => ({
|
|
101
|
+
kind,
|
|
102
|
+
name: entry.name,
|
|
103
|
+
path: entry.path,
|
|
104
|
+
format,
|
|
105
|
+
body: await reader.read(repo, entry.path),
|
|
106
|
+
raw: entry
|
|
107
|
+
})),
|
|
108
|
+
ownsIssues
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** The first file named `name`, with any extension and in any case, across the locations in their order. */
|
|
112
|
+
function firstFile(locations, name) {
|
|
113
|
+
return locations.flat().find((entry) => entry.type === "file" && entry.name.toLowerCase().replace(/\.[^.]*$/, "") === name);
|
|
114
|
+
}
|
|
115
|
+
/** A listing of a directory that may not exist, or of a repository that is empty. */
|
|
116
|
+
async function orEmpty(listing) {
|
|
117
|
+
try {
|
|
118
|
+
return await listing;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (error instanceof NotFoundError) return [];
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { readTemplates };
|
package/dist/test.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as registerWorkspace } from "./registry-
|
|
1
|
+
import { n as registerWorkspace } from "./registry-Cg1TJVVZ.js";
|
|
2
2
|
export { registerWorkspace };
|
package/dist/test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as registerWorkspace } from "./registry-
|
|
1
|
+
import { n as registerWorkspace } from "./registry-Bp-8UUfG.js";
|
|
2
2
|
export { registerWorkspace };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./rolldown-runtime-B4iAMlE-.js";
|
|
2
|
+
import { a as require_token_error, i as require_dist, r as require_token_util } from "./hosted-vercel-blob-DKntsHaf.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@vercel+oidc@3.8.10/node_modules/@vercel/oidc/dist/token.js
|
|
4
|
+
var require_token = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var token_exports = {};
|
|
26
|
+
__export(token_exports, { refreshToken: () => refreshToken });
|
|
27
|
+
module.exports = __toCommonJS(token_exports);
|
|
28
|
+
var import_cli_config = require_dist();
|
|
29
|
+
var import_token_error = require_token_error();
|
|
30
|
+
var import_token_util = require_token_util();
|
|
31
|
+
async function refreshToken(options) {
|
|
32
|
+
let projectId = options?.project;
|
|
33
|
+
let teamId = options?.team;
|
|
34
|
+
if (!projectId && !teamId) {
|
|
35
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
36
|
+
projectId = projectInfo.projectId;
|
|
37
|
+
teamId = projectInfo.teamId;
|
|
38
|
+
} else if (!projectId || !teamId) {
|
|
39
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
40
|
+
projectId = projectId ?? projectInfo.projectId;
|
|
41
|
+
teamId = teamId ?? projectInfo.teamId;
|
|
42
|
+
}
|
|
43
|
+
if (!projectId) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");
|
|
44
|
+
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
45
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token), options?.expirationBufferMs)) {
|
|
46
|
+
const configDir = (0, import_cli_config.getGlobalPathConfig)();
|
|
47
|
+
if ((0, import_cli_config.getLikelyEffectiveCredStorage)(configDir) === "keyring") maybeToken = await (0, import_token_util.getVercelOidcTokenFromCli)(projectId, teamId);
|
|
48
|
+
else {
|
|
49
|
+
const authToken = await (0, import_token_util.getVercelToken)({ expirationBufferMs: options?.expirationBufferMs });
|
|
50
|
+
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
51
|
+
}
|
|
52
|
+
if (!maybeToken) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
53
|
+
(0, import_token_util.saveToken)(maybeToken, projectId);
|
|
54
|
+
}
|
|
55
|
+
process.env.VERCEL_OIDC_TOKEN = maybeToken.token;
|
|
56
|
+
}
|
|
57
|
+
0 && (module.exports = { refreshToken });
|
|
58
|
+
}));
|
|
59
|
+
//#endregion
|
|
60
|
+
export default require_token();
|
|
61
|
+
export {};
|