@hitch42/applet 0.1.1-beta.20 → 0.1.1-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/client.d.ts +0 -2
- package/dist/_internal/client.js +3 -5
- package/dist/_internal/log-context.d.ts +0 -2
- package/dist/_internal/log-context.js +1 -2
- package/dist/_internal/server.d.ts +2 -10
- package/dist/_internal/server.js +9 -14
- package/dist/applet.js +64 -23
- package/dist/auth-DuMRqSGe.js +49 -0
- package/dist/{batch-_ZjAg-Kk.js → batch-DwyWmiaE.js} +3 -4
- package/dist/build-C7hi2yg4.js +1 -0
- package/dist/{build-D47vK5aa.js → build-FAQSHJgm.js} +4 -3
- package/dist/{ci-BTFTCBgy.js → ci-oWlUJKm9.js} +5 -6
- package/dist/client/hitch/client.d.ts +1 -1
- package/dist/client/hitch/client.js +1 -2
- package/dist/client/hitch/phone.d.ts +1 -1
- package/dist/client/hitch/phone.js +1 -2
- package/dist/client/hitch.d.ts +2 -2
- package/dist/client/hitch.js +2 -2
- package/dist/client/react/markdown-editor.d.ts +1 -1
- package/dist/client/react/markdown-editor.js +1 -2
- package/dist/client/react/markdown.d.ts +1 -1
- package/dist/client/react/markdown.js +1 -2
- package/dist/client/react.d.ts +2 -2
- package/dist/client/react.js +2 -2
- package/dist/client.d.ts +2 -4
- package/dist/client.js +3 -5
- package/dist/{contract-CJv-n1l3.d.ts → contract-CUc0B2rl.d.ts} +1 -3
- package/dist/{contract-BeKz1Qcs.js → contract-D9LCNGjD.js} +1 -2
- package/dist/{create-C2UrZYSK.d.ts → create-BJqLT8Uq.d.ts} +0 -4
- package/dist/{deploy-BbqyK5Ik.js → deploy-BM55ZoSp.js} +160 -152
- package/dist/{device-BgIfytaR.js → device-CZWWckCq.js} +54 -34
- package/dist/{email-protocol-B9u_dh2p.d.ts → email-protocol-BWja_v7c.d.ts} +16 -16
- package/dist/generate-DG9vVkBO.js +1 -0
- package/dist/{generate-BLD0DoCk.js → generate-DNgO44RO.js} +32 -37
- package/dist/generated-agents-BUnJ0FQA.js +215 -0
- package/dist/git-credential-CU7-Erzs.js +24 -0
- package/dist/git-deploy-C12nMNB6.js +290 -0
- package/dist/git-deploy-CNz6mxiF.js +1 -0
- package/dist/git-migration-CIq-sN61.js +629 -0
- package/dist/git-safety-Ck3X7jvA.js +13 -0
- package/dist/{headers-CeRX-Xji.js → headers-BcEMIVCo.js} +1 -2
- package/dist/{hitch-client-Cw-WZ_8v.js → hitch-client-CNN-dU6d.js} +5 -7
- package/dist/{hitch-client-DtyTZzP5.d.ts → hitch-client-k7_jIjPw.d.ts} +5 -7
- package/dist/{hitch-file-url-BPKj9zVG.js → hitch-file-url--AMjDOzP.js} +1 -2
- package/dist/index.d.ts +13 -17
- package/dist/index.js +33 -38
- package/dist/{init-BKUBf6i9.js → init-BD5mC_9L.js} +70 -18
- package/dist/{lazy-client-CwIzYAoE.js → lazy-client--QCL0wiu.js} +1 -2
- package/dist/{load-config-DGALUExv.js → load-config-Cffvj-aM.js} +24 -26
- package/dist/{log-context-DWznGjfz.js → log-context-BepwdjrR.js} +1 -2
- package/dist/login-BWZKo7Ui.js +21 -0
- package/dist/{logs-Cv5z1e2w.js → logs-glCVHI-8.js} +6 -6
- package/dist/{manifest-BBHD_EY9.d.ts → manifest-CpghlaJc.d.ts} +6 -7
- package/dist/manifest-patterns-BfxqImlp.js +4 -0
- package/dist/{markdown-CwlqzBtP.js → markdown-BA_XzFxq.js} +2 -3
- package/dist/{markdown-DSHOQIOb.d.ts → markdown-CnB35mjc.d.ts} +1 -3
- package/dist/{markdown-editor-C5mLHGqu.js → markdown-editor-CaUuphfc.js} +3 -5
- package/dist/{markdown-editor-BmEaBzd7.d.ts → markdown-editor-xF3uATBp.d.ts} +1 -5
- package/dist/parent-D52Kxp8U.js +1 -0
- package/dist/parent-Zx8Eg1Ki.js +75 -0
- package/dist/{project-CrxdZR0B.js → project-DZGk765E.js} +63 -54
- package/dist/{prompt-ChS-grYO.js → prompt-CW98R-Un.js} +1 -2
- package/dist/{query-cache-CXmAyLv3.js → query-cache-DQJy45RT.js} +1 -2
- package/dist/{query-utils-zz9pVjgp.d.ts → query-utils-okxIoKM3.d.ts} +0 -2
- package/dist/{schedules-Dajgni_z.js → schedules-CSUb84e2.js} +5 -5
- package/dist/server.d.ts +5 -13
- package/dist/server.js +17 -20
- package/dist/source-hash-BbvtRaus.js +107 -0
- package/dist/store-E5NhITHl.js +448 -0
- package/dist/{upload-DRbVhuDm.js → upload-D1mzpsSk.js} +4 -6
- package/dist/{upload-D_kkmne_.d.ts → upload-wp-Ilsv6.d.ts} +6 -10
- package/dist/{use-phone-ug4B5gQp.js → use-phone-CB_idmrz.js} +9 -13
- package/dist/{use-phone-M7c_HsB7.d.ts → use-phone-DBAkasPq.d.ts} +0 -4
- package/dist/{variables-B-CLu8cY.js → variables-CgZstC7I.js} +7 -8
- package/dist/vite.d.ts +1 -3
- package/dist/vite.js +41 -50
- package/dist/{workflow-DurM6Fwx.d.ts → workflow-BnBrJIzu.d.ts} +0 -2
- package/dist/{workflow-engine-BOTzURKM.js → workflow-engine-CyyaVENo.js} +2 -4
- package/dist/{workflow-CTo2kZF1.js → workflow-l2SlVePB.js} +2 -4
- package/dist/workspace-CtIKSgMD.js +76 -0
- package/package.json +6 -5
- package/scaffold/.agents/skills/hitch-applets/SKILL.md +27 -9
- package/scaffold/.agents/skills/hitch-applets/references/email-tracking.md +4 -4
- package/scaffold/.agents/skills/hitch-applets/references/files.md +2 -2
- package/scaffold/.agents/skills/hitch-applets/references/manifest.md +8 -6
- package/scaffold/.agents/skills/hitch-applets/references/performance.md +2 -2
- package/scaffold/.agents/skills/hitch-applets/references/records.md +8 -8
- package/scaffold/.agents/skills/hitch-cli/SKILL.md +52 -43
- package/scaffold/AGENTS.md +6 -0
- package/dist/auth-D3CrCtZq.js +0 -21
- package/dist/build-JtbY8q2p.js +0 -2
- package/dist/generate-COCRy1Bs.js +0 -2
- package/dist/login-CceGvlMi.js +0 -14
- package/dist/store-B8N_8JIN.js +0 -196
- package/dist/workspace-8yqXsvce.js +0 -31
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
import { n as generatedAgentContents, r as writeGeneratedAgents } from "./generated-agents-BUnJ0FQA.js";
|
|
2
|
+
import { a as findWorkspaceRoot, n as findAppletRoot, o as isRootLayout, s as readWorkspaceConfig } from "./workspace-CtIKSgMD.js";
|
|
3
|
+
import { r as orgUsesHitchGit, t as canCheckHitchGit } from "./auth-DuMRqSGe.js";
|
|
4
|
+
import { n as loadAppletSourceDefinition } from "./load-config-Cffvj-aM.js";
|
|
5
|
+
import { c as writeGitignore, r as loadPackageManifest } from "./project-DZGk765E.js";
|
|
6
|
+
import { n as stagedSecretPaths, t as StagedSecretsError } from "./git-safety-Ck3X7jvA.js";
|
|
7
|
+
import { o as gitLocal } from "./parent-Zx8Eg1Ki.js";
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import fs$1 from "node:fs/promises";
|
|
10
|
+
import { basename, dirname, posix, resolve, sep } from "node:path";
|
|
11
|
+
import { parseSync } from "vite";
|
|
12
|
+
// src/git-migration.ts
|
|
13
|
+
var MigrationError = class extends Error {};
|
|
14
|
+
function migrationPath(path, code) {
|
|
15
|
+
const prefix = `applets/${code}/`;
|
|
16
|
+
const migrated = path.startsWith(prefix) ? path.slice(prefix.length) : path;
|
|
17
|
+
if (migrated === "hitch.config.ts" || migrated === ".github/workflows/hitch.yml" || path.startsWith("applets/") && !path.startsWith(prefix)) return void 0;
|
|
18
|
+
return migrated;
|
|
19
|
+
}
|
|
20
|
+
function migratedImport(path, specifier, code, tracked) {
|
|
21
|
+
if (!specifier.startsWith("./") && !specifier.startsWith("../")) return specifier;
|
|
22
|
+
const prefix = `applets/${code}/`;
|
|
23
|
+
const suffixStart = specifier.search(/[?#]/);
|
|
24
|
+
const request = suffixStart < 0 ? specifier : specifier.slice(0, suffixStart);
|
|
25
|
+
const suffix = suffixStart < 0 ? "" : specifier.slice(suffixStart);
|
|
26
|
+
const target = posix.normalize(posix.join(posix.dirname(path), request));
|
|
27
|
+
if (target.startsWith(prefix)) return specifier;
|
|
28
|
+
const found = [
|
|
29
|
+
target,
|
|
30
|
+
...[
|
|
31
|
+
".ts",
|
|
32
|
+
".tsx",
|
|
33
|
+
".js",
|
|
34
|
+
".mjs",
|
|
35
|
+
".json"
|
|
36
|
+
].map((extension) => `${target}${extension}`),
|
|
37
|
+
...[
|
|
38
|
+
".ts",
|
|
39
|
+
".tsx",
|
|
40
|
+
".js",
|
|
41
|
+
".mjs"
|
|
42
|
+
].map((extension) => `${target}/index${extension}`),
|
|
43
|
+
...target.endsWith(".js") ? [target.slice(0, -3) + ".ts", target.slice(0, -3) + ".tsx"] : []
|
|
44
|
+
].find((candidate) => tracked.includes(candidate));
|
|
45
|
+
if (found === void 0 || found.startsWith("applets/") || migrationPath(found, code) !== found || tracked.some((path) => path.startsWith(prefix) && (path.slice(prefix.length) === found || found.startsWith(`${path.slice(prefix.length)}/`) || path.slice(prefix.length).startsWith(`${found}/`)))) throw new MigrationError(`${path}: ${specifier}`);
|
|
46
|
+
const rewritten = posix.relative(posix.dirname(migrationPath(path, code)), target);
|
|
47
|
+
return `${rewritten.startsWith(".") ? rewritten : `./${rewritten}`}${suffix}`;
|
|
48
|
+
}
|
|
49
|
+
function rewriteAppletImports(source, path, code, tracked) {
|
|
50
|
+
const parsed = parseSync(path, source);
|
|
51
|
+
if (parsed.errors.length > 0) throw new MigrationError(`Cannot scan imports in ${path}: syntax errors.`);
|
|
52
|
+
const replacements = [];
|
|
53
|
+
const errors = [];
|
|
54
|
+
const visit = (value) => {
|
|
55
|
+
if (value === null || typeof value !== "object") return;
|
|
56
|
+
if (Array.isArray(value)) {
|
|
57
|
+
value.forEach(visit);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const node = value;
|
|
61
|
+
let candidate = [
|
|
62
|
+
"ImportDeclaration",
|
|
63
|
+
"ExportNamedDeclaration",
|
|
64
|
+
"ExportAllDeclaration",
|
|
65
|
+
"ImportExpression",
|
|
66
|
+
"TSImportType",
|
|
67
|
+
"TSExternalModuleReference"
|
|
68
|
+
].includes(String(node.type)) ? node.source ?? node.argument ?? node.expression : node.type === "CallExpression" && typeof node.callee === "object" && node.callee !== null && "name" in node.callee && node.callee.name === "require" && Array.isArray(node.arguments) ? node.arguments[0] : void 0;
|
|
69
|
+
if (candidate !== null && typeof candidate === "object" && "type" in candidate && candidate.type === "TemplateLiteral" && "expressions" in candidate && Array.isArray(candidate.expressions) && candidate.expressions.length === 0 && "quasis" in candidate && Array.isArray(candidate.quasis)) {
|
|
70
|
+
const quasi = candidate.quasis[0];
|
|
71
|
+
if (quasi !== null && typeof quasi === "object" && "value" in quasi && quasi.value !== null && typeof quasi.value === "object" && "cooked" in quasi.value && typeof quasi.value.cooked === "string") candidate = {
|
|
72
|
+
...candidate,
|
|
73
|
+
value: quasi.value.cooked
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (candidate !== null && typeof candidate === "object" && "value" in candidate && typeof candidate.value === "string" && "start" in candidate && typeof candidate.start === "number" && "end" in candidate && typeof candidate.end === "number") try {
|
|
77
|
+
const text = migratedImport(path, candidate.value, code, tracked);
|
|
78
|
+
if (text !== candidate.value) {
|
|
79
|
+
const quote = source[candidate.start];
|
|
80
|
+
const escaped = JSON.stringify(text).slice(1, -1);
|
|
81
|
+
replacements.push({
|
|
82
|
+
start: candidate.start + 1,
|
|
83
|
+
end: candidate.end - 1,
|
|
84
|
+
text: quote === "'" ? escaped.replaceAll("\\\"", "\"").replaceAll("'", "\\'") : quote === "`" ? escaped.replaceAll("\\\"", "\"").replaceAll("`", "\\`").replaceAll("${", "\\${") : escaped
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (!(error instanceof MigrationError)) throw error;
|
|
89
|
+
errors.push(error.message);
|
|
90
|
+
}
|
|
91
|
+
Object.values(node).forEach(visit);
|
|
92
|
+
};
|
|
93
|
+
visit(parsed.program);
|
|
94
|
+
if (errors.length > 0) throw new MigrationError(errors.join("\n"));
|
|
95
|
+
return replacements.sort((a, b) => b.start - a.start).reduce((text, item) => text.slice(0, item.start) + item.text + text.slice(item.end), source);
|
|
96
|
+
}
|
|
97
|
+
function transformTree(entries, code) {
|
|
98
|
+
const files = /* @__PURE__ */ new Map();
|
|
99
|
+
const collisions = /* @__PURE__ */ new Set();
|
|
100
|
+
[...entries.filter((entry) => !entry.path.startsWith("applets/")), ...entries.filter((entry) => entry.path.startsWith(`applets/${code}/`))].forEach((entry) => {
|
|
101
|
+
const path = migrationPath(entry.path, code);
|
|
102
|
+
if (path === void 0) return;
|
|
103
|
+
[...files.keys()].forEach((existing) => {
|
|
104
|
+
if (path === existing || path.startsWith(`${existing}/`) || existing.startsWith(`${path}/`)) {
|
|
105
|
+
collisions.add(path);
|
|
106
|
+
files.delete(existing);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
files.set(path, {
|
|
110
|
+
...entry,
|
|
111
|
+
path
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
entries: [...files.values()],
|
|
116
|
+
collisions: [...collisions].sort()
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function keepMigratedCommit(tree, parentTree, emptyTree) {
|
|
120
|
+
return tree !== (parentTree ?? emptyTree);
|
|
121
|
+
}
|
|
122
|
+
function migrationPlan(root, codes, paths) {
|
|
123
|
+
const parent = codes.length !== 1;
|
|
124
|
+
const entries = [...new Set(paths.map((path) => path.split("/")[0]))].filter((path) => path !== ".git" && path !== ".hitch-backup").sort();
|
|
125
|
+
return {
|
|
126
|
+
parent,
|
|
127
|
+
targets: codes.map((code) => ({
|
|
128
|
+
code,
|
|
129
|
+
root: parent ? resolve(root, code) : root
|
|
130
|
+
})),
|
|
131
|
+
backupFiles: entries.filter(backupPath),
|
|
132
|
+
removeFiles: entries
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function backupPath(path) {
|
|
136
|
+
return !path.split("/").some((part) => [
|
|
137
|
+
"node_modules",
|
|
138
|
+
".hitch",
|
|
139
|
+
"dist",
|
|
140
|
+
".wrangler",
|
|
141
|
+
".tanstack",
|
|
142
|
+
"build",
|
|
143
|
+
"coverage",
|
|
144
|
+
".git",
|
|
145
|
+
".hitch-backup"
|
|
146
|
+
].includes(part));
|
|
147
|
+
}
|
|
148
|
+
function migratedManifest(source, org, sdk) {
|
|
149
|
+
const parsed = parseSync("applet.manifest.ts", source);
|
|
150
|
+
if (parsed.errors.length > 0) throw new MigrationError("The applet manifest has syntax errors.");
|
|
151
|
+
let name = "hitchMigratedManifest";
|
|
152
|
+
while (source.includes(name)) name += "_";
|
|
153
|
+
const exported = `export default { ...${name}, org: ${JSON.stringify(org)}, sdk: ${JSON.stringify(sdk)} };`;
|
|
154
|
+
const assignment = parsed.program.body.find((statement) => statement.type === "ExportDefaultDeclaration");
|
|
155
|
+
if (assignment !== void 0) {
|
|
156
|
+
let object = assignment.declaration;
|
|
157
|
+
while (object.type === "TSAsExpression" || object.type === "TSSatisfiesExpression" || object.type === "ParenthesizedExpression") object = object.expression;
|
|
158
|
+
if (object.type === "ObjectExpression") {
|
|
159
|
+
const start = object.start + 1;
|
|
160
|
+
const body = source.slice(start, object.end - 1);
|
|
161
|
+
const newline = body.includes("\r\n") ? "\r\n" : "\n";
|
|
162
|
+
const indent = /^[ \t]*\r?\n([ \t]*)\S/.exec(body)?.[1];
|
|
163
|
+
const properties = `org: ${JSON.stringify(org)},${indent === void 0 ? " " : `${newline}${indent}`}sdk: ${JSON.stringify(sdk)},`;
|
|
164
|
+
const insertion = indent === void 0 ? ` ${properties}` : `${newline}${indent}${properties}`;
|
|
165
|
+
return `${source.slice(0, start)}${insertion}${/^\s/.test(body) ? "" : " "}${source.slice(start)}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (assignment !== void 0) return `${source.slice(0, assignment.start)}const ${name} = ${source.slice(assignment.declaration.start, assignment.declaration.end)};\n${exported}${source.slice(assignment.end)}`;
|
|
169
|
+
const declaration = parsed.program.body.find((statement) => statement.type === "ExportNamedDeclaration" && statement.specifiers.some((element) => (element.exported.type === "Identifier" ? element.exported.name : element.exported.value) === "default"));
|
|
170
|
+
if (declaration === void 0 || declaration.type !== "ExportNamedDeclaration") throw new MigrationError("The manifest must have a default export before migration.");
|
|
171
|
+
const element = declaration.specifiers.find((item) => (item.exported.type === "Identifier" ? item.exported.name : item.exported.value) === "default");
|
|
172
|
+
const original = source.slice(element.local.start, element.local.end);
|
|
173
|
+
const from = declaration.source === null ? "" : ` from ${source.slice(declaration.source.start, declaration.end).replace(/;$/, "")}`;
|
|
174
|
+
const binding = declaration.source === null ? `const ${name} = ${original};` : `import { ${original} as ${name} }${from};`;
|
|
175
|
+
const remaining = declaration.specifiers.filter((item) => item !== element);
|
|
176
|
+
const retained = remaining.length === 0 ? "" : `export { ${remaining.map((item) => source.slice(item.start, item.end)).join(", ")} }${from};`;
|
|
177
|
+
return `${source.slice(0, declaration.start)}${retained}${source.slice(declaration.end)}\n${binding}\n${exported}\n`;
|
|
178
|
+
}
|
|
179
|
+
const MIGRATION_GIT_CONFIG = [
|
|
180
|
+
"-c",
|
|
181
|
+
"commit.gpgsign=false",
|
|
182
|
+
"-c",
|
|
183
|
+
"core.hooksPath=/dev/null"
|
|
184
|
+
];
|
|
185
|
+
async function migrationGit(root, args, input, env) {
|
|
186
|
+
return gitLocal(root, [...MIGRATION_GIT_CONFIG, ...args], input, {
|
|
187
|
+
...env,
|
|
188
|
+
GIT_OPTIONAL_LOCKS: "0"
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
async function refuseSymlink(path) {
|
|
192
|
+
try {
|
|
193
|
+
if ((await fs$1.lstat(path)).isSymbolicLink()) throw new MigrationError(`Migration cannot write through a symlink: ${path}`);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async function git(root, args, input, env) {
|
|
199
|
+
return (await migrationGit(root, args, input, env)).toString("utf8").trim();
|
|
200
|
+
}
|
|
201
|
+
function treeEntries(tree) {
|
|
202
|
+
return tree.toString("utf8").split("\0").filter(Boolean).map((line) => {
|
|
203
|
+
const tab = line.indexOf(" ");
|
|
204
|
+
const [mode, type, oid] = line.slice(0, tab).split(" ");
|
|
205
|
+
if (!mode || !type || !oid || tab < 0) throw new Error("Invalid git tree entry.");
|
|
206
|
+
return {
|
|
207
|
+
mode,
|
|
208
|
+
type,
|
|
209
|
+
oid,
|
|
210
|
+
path: line.slice(tab + 1)
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async function writeTree(root, entries, env) {
|
|
215
|
+
const groups = /* @__PURE__ */ new Map();
|
|
216
|
+
const files = [];
|
|
217
|
+
entries.forEach((entry) => {
|
|
218
|
+
const slash = entry.path.indexOf("/");
|
|
219
|
+
if (slash < 0) files.push(entry);
|
|
220
|
+
else {
|
|
221
|
+
const directory = entry.path.slice(0, slash);
|
|
222
|
+
const group = groups.get(directory) ?? [];
|
|
223
|
+
group.push({
|
|
224
|
+
...entry,
|
|
225
|
+
path: entry.path.slice(slash + 1)
|
|
226
|
+
});
|
|
227
|
+
groups.set(directory, group);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
const directories = await Promise.all([...groups].map(async ([path, children]) => ({
|
|
231
|
+
mode: "040000",
|
|
232
|
+
type: "tree",
|
|
233
|
+
oid: await writeTree(root, children, env),
|
|
234
|
+
path
|
|
235
|
+
})));
|
|
236
|
+
return git(root, ["mktree", "-z"], Buffer.from([...files, ...directories].map((entry) => `${entry.mode} ${entry.type} ${entry.oid}\t${entry.path}\0`).join("")), env);
|
|
237
|
+
}
|
|
238
|
+
function commitIdentity(line) {
|
|
239
|
+
const match = /^(?:author|committer) (.*) <([^>]*)> (\d+ [+-]\d{4})$/.exec(line);
|
|
240
|
+
if (!match) throw new Error("Invalid git commit identity.");
|
|
241
|
+
return {
|
|
242
|
+
name: match[1],
|
|
243
|
+
email: match[2],
|
|
244
|
+
date: `@${match[3]}`
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
async function rewriteHistory(source, target, head, code) {
|
|
248
|
+
await fs$1.mkdir(target, { recursive: true });
|
|
249
|
+
await git(target, [
|
|
250
|
+
"init",
|
|
251
|
+
"-b",
|
|
252
|
+
"main"
|
|
253
|
+
]);
|
|
254
|
+
const alternates = resolve(target, ".git", "objects", "info", "alternates");
|
|
255
|
+
const common = resolve(source, await git(target, [
|
|
256
|
+
"--git-dir",
|
|
257
|
+
source,
|
|
258
|
+
"rev-parse",
|
|
259
|
+
"--git-common-dir"
|
|
260
|
+
]));
|
|
261
|
+
await fs$1.writeFile(alternates, `${resolve(common, "objects")}\n`);
|
|
262
|
+
const env = {};
|
|
263
|
+
const commits = (await git(target, [
|
|
264
|
+
"--git-dir",
|
|
265
|
+
source,
|
|
266
|
+
"rev-list",
|
|
267
|
+
"--reverse",
|
|
268
|
+
"--topo-order",
|
|
269
|
+
head
|
|
270
|
+
])).split("\n");
|
|
271
|
+
const rewritten = /* @__PURE__ */ new Map();
|
|
272
|
+
const emptyTree = await writeTree(target, [], env);
|
|
273
|
+
const reported = /* @__PURE__ */ new Set();
|
|
274
|
+
for (const sha of commits) {
|
|
275
|
+
const raw = await migrationGit(target, [
|
|
276
|
+
"--git-dir",
|
|
277
|
+
source,
|
|
278
|
+
"cat-file",
|
|
279
|
+
"commit",
|
|
280
|
+
sha
|
|
281
|
+
]);
|
|
282
|
+
const separator = raw.indexOf("\n\n");
|
|
283
|
+
const headers = raw.subarray(0, separator).toString("latin1").split("\n");
|
|
284
|
+
const parents = headers.filter((line) => line.startsWith("parent ")).map((line) => rewritten.get(line.slice(7)));
|
|
285
|
+
const transformed = transformTree(treeEntries(await migrationGit(target, [
|
|
286
|
+
"--git-dir",
|
|
287
|
+
source,
|
|
288
|
+
"ls-tree",
|
|
289
|
+
"-rz",
|
|
290
|
+
sha
|
|
291
|
+
])), code);
|
|
292
|
+
transformed.collisions.filter((path) => !reported.has(path)).forEach((path) => {
|
|
293
|
+
reported.add(path);
|
|
294
|
+
console.warn(`[${code}] ${path} exists both at the old root and in applets/${code}; kept the applet's copy.`);
|
|
295
|
+
});
|
|
296
|
+
const tree = await writeTree(target, transformed.entries, env);
|
|
297
|
+
if (!keepMigratedCommit(tree, parents[0]?.tree, emptyTree) && parents.every((parent) => parent.tree === tree)) {
|
|
298
|
+
rewritten.set(sha, {
|
|
299
|
+
sha: parents[0]?.sha,
|
|
300
|
+
tree
|
|
301
|
+
});
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
const parentShas = [...new Set(parents.flatMap((parent) => parent.sha ? [parent.sha] : []))];
|
|
305
|
+
const metadata = headers.filter((line) => /^(author|committer|encoding) /.test(line));
|
|
306
|
+
const commit = await git(target, [
|
|
307
|
+
"hash-object",
|
|
308
|
+
"-t",
|
|
309
|
+
"commit",
|
|
310
|
+
"-w",
|
|
311
|
+
"--stdin"
|
|
312
|
+
], Buffer.concat([
|
|
313
|
+
Buffer.from(`tree ${tree}\n${parentShas.map((parent) => `parent ${parent}\n`).join("")}`),
|
|
314
|
+
Buffer.from(`${metadata.join("\n")}\n\n`, "latin1"),
|
|
315
|
+
raw.subarray(separator + 2)
|
|
316
|
+
]), env);
|
|
317
|
+
rewritten.set(sha, {
|
|
318
|
+
sha: commit,
|
|
319
|
+
tree
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
const newHead = rewritten.get(head)?.sha;
|
|
323
|
+
if (newHead === void 0) throw new MigrationError(`No history remains for ${code}.`);
|
|
324
|
+
await git(target, [
|
|
325
|
+
"update-ref",
|
|
326
|
+
"refs/heads/main",
|
|
327
|
+
newHead
|
|
328
|
+
], void 0, env);
|
|
329
|
+
await git(target, [
|
|
330
|
+
"repack",
|
|
331
|
+
"-a",
|
|
332
|
+
"-d"
|
|
333
|
+
], void 0, env);
|
|
334
|
+
await fs$1.rm(alternates);
|
|
335
|
+
await git(target, [
|
|
336
|
+
"reset",
|
|
337
|
+
"--hard",
|
|
338
|
+
"HEAD"
|
|
339
|
+
]);
|
|
340
|
+
}
|
|
341
|
+
async function migrateWorkspace(root, message) {
|
|
342
|
+
if (process.stdin.isTTY !== true) throw new MigrationError("Migration needs a terminal. Run applet bootstrap in an interactive terminal, then run this command again.");
|
|
343
|
+
if (await git(root, ["rev-parse", "--is-shallow-repository"]) === "true") throw new MigrationError("A shallow repository cannot migrate. Fetch the full history first.");
|
|
344
|
+
let head;
|
|
345
|
+
try {
|
|
346
|
+
head = await git(root, [
|
|
347
|
+
"rev-parse",
|
|
348
|
+
"--verify",
|
|
349
|
+
"HEAD"
|
|
350
|
+
]);
|
|
351
|
+
} catch (cause) {
|
|
352
|
+
throw new MigrationError("The repository has no HEAD. Make a commit before migration.", { cause });
|
|
353
|
+
}
|
|
354
|
+
const startingDir = process.cwd();
|
|
355
|
+
const config = readWorkspaceConfig(root);
|
|
356
|
+
if (config === void 0 || isRootLayout(root)) throw new MigrationError("Expected an old Hitch workspace.");
|
|
357
|
+
const roots = (await fs$1.readdir(resolve(root, "applets"), { withFileTypes: true }).catch((error) => {
|
|
358
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return [];
|
|
359
|
+
throw error;
|
|
360
|
+
})).filter((entry) => entry.isDirectory() && fs.existsSync(resolve(root, "applets", entry.name, "applet.manifest.ts"))).map((entry) => resolve(root, "applets", entry.name)).sort();
|
|
361
|
+
if (roots.length === 0) throw new MigrationError("No applets were found in this workspace.");
|
|
362
|
+
if (resolve(await git(root, ["rev-parse", "--show-toplevel"])) !== resolve(root)) throw new MigrationError("The git repository must start at the workspace root.");
|
|
363
|
+
if ((await Promise.all([
|
|
364
|
+
"rebase-merge",
|
|
365
|
+
"rebase-apply",
|
|
366
|
+
"MERGE_HEAD"
|
|
367
|
+
].map((name) => git(root, [
|
|
368
|
+
"rev-parse",
|
|
369
|
+
"--git-path",
|
|
370
|
+
name
|
|
371
|
+
])))).some((path) => fs.existsSync(resolve(root, path)))) throw new MigrationError("Finish or abort the current rebase or merge before migration.");
|
|
372
|
+
const sourcePaths = [
|
|
373
|
+
"--",
|
|
374
|
+
".",
|
|
375
|
+
":(exclude).hitch-backup",
|
|
376
|
+
":(exclude).hitch-migration-*"
|
|
377
|
+
];
|
|
378
|
+
const dirty = Boolean(await git(root, [
|
|
379
|
+
"status",
|
|
380
|
+
"--porcelain",
|
|
381
|
+
...sourcePaths
|
|
382
|
+
]));
|
|
383
|
+
if (dirty && !message) throw new MigrationError("Commit your changes or pass -m, then run the command again.");
|
|
384
|
+
const author = commitIdentity(`author ${await git(root, ["var", "GIT_AUTHOR_IDENT"])}`);
|
|
385
|
+
const tracked = (await migrationGit(root, [
|
|
386
|
+
"ls-files",
|
|
387
|
+
"-z",
|
|
388
|
+
"--cached"
|
|
389
|
+
])).toString("utf8").split("\0").filter(Boolean);
|
|
390
|
+
const imports = /* @__PURE__ */ new Map();
|
|
391
|
+
const importErrors = [];
|
|
392
|
+
for (const applet of roots) {
|
|
393
|
+
const code = basename(applet);
|
|
394
|
+
for (const path of tracked.filter((path) => path.startsWith(`applets/${code}/`) && /\.(?:ts|tsx|js|mjs)$/.test(path))) try {
|
|
395
|
+
const source = await fs$1.readFile(resolve(root, path), "utf8");
|
|
396
|
+
const rewritten = rewriteAppletImports(source, path, code, tracked);
|
|
397
|
+
if (rewritten !== source) imports.set(path, rewritten);
|
|
398
|
+
} catch (error) {
|
|
399
|
+
if (!(error instanceof MigrationError)) throw error;
|
|
400
|
+
importErrors.push(error.message);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (importErrors.length > 0) throw new MigrationError(`Imports leave the applet:\n${importErrors.join("\n")}`);
|
|
404
|
+
const cli = await loadPackageManifest();
|
|
405
|
+
const manifests = await Promise.all(roots.map(async (applet) => {
|
|
406
|
+
const definition = await loadAppletSourceDefinition(applet);
|
|
407
|
+
const code = basename(applet);
|
|
408
|
+
if (definition.code !== code) throw new MigrationError(`Applet code must match its folder: ${applet}.`);
|
|
409
|
+
return migratedManifest(await fs$1.readFile(resolve(applet, "applet.manifest.ts"), "utf8"), config.org, cli.version);
|
|
410
|
+
}));
|
|
411
|
+
const generatedAgents = await generatedAgentContents();
|
|
412
|
+
const ignored = (await git(root, [
|
|
413
|
+
"ls-files",
|
|
414
|
+
"--others",
|
|
415
|
+
"--ignored",
|
|
416
|
+
"--exclude-standard",
|
|
417
|
+
"-z"
|
|
418
|
+
])).split("\0").filter((path) => path && backupPath(path));
|
|
419
|
+
const branch = await git(root, [
|
|
420
|
+
"symbolic-ref",
|
|
421
|
+
"--short",
|
|
422
|
+
"-q",
|
|
423
|
+
"HEAD"
|
|
424
|
+
]).catch(() => "HEAD");
|
|
425
|
+
const branches = (await git(root, [
|
|
426
|
+
"for-each-ref",
|
|
427
|
+
"--format=%(refname:short)",
|
|
428
|
+
"refs/heads/"
|
|
429
|
+
])).split("\n").filter(Boolean);
|
|
430
|
+
const stashes = await git(root, ["stash", "list"]);
|
|
431
|
+
if (branches.some((name) => name !== branch) || stashes) console.warn(`Only ${branch} moved; other branches stay in the backup.`);
|
|
432
|
+
const plan = migrationPlan(root, roots.map((path) => basename(path)), [...tracked, ...(await fs$1.readdir(root, { withFileTypes: true })).map((entry) => entry.name)]);
|
|
433
|
+
if (plan.parent && plan.targets.some((target) => fs.existsSync(target.root))) throw new MigrationError("An applet destination already exists. Move it before migration.");
|
|
434
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "").replace(/\.\d+Z$/, "Z");
|
|
435
|
+
const backup = resolve(root, ".hitch-backup", stamp);
|
|
436
|
+
const staging = resolve(root, `.hitch-migration-${stamp}`);
|
|
437
|
+
const gitDir = await git(root, ["rev-parse", "--absolute-git-dir"]);
|
|
438
|
+
const commonDir = resolve(root, await git(root, ["rev-parse", "--git-common-dir"]));
|
|
439
|
+
await fs$1.mkdir(resolve(root, ".hitch-backup"), { recursive: true });
|
|
440
|
+
await fs$1.mkdir(backup);
|
|
441
|
+
console.log(`Hitch migration backup: ${backup}`);
|
|
442
|
+
try {
|
|
443
|
+
await Promise.all(plan.backupFiles.map(async (path) => {
|
|
444
|
+
await fs$1.mkdir(dirname(resolve(backup, path)), { recursive: true });
|
|
445
|
+
await fs$1.cp(resolve(root, path), resolve(backup, path), {
|
|
446
|
+
recursive: true,
|
|
447
|
+
dereference: false,
|
|
448
|
+
verbatimSymlinks: true,
|
|
449
|
+
filter: (source) => backupPath(source.slice(root.length + 1))
|
|
450
|
+
});
|
|
451
|
+
}));
|
|
452
|
+
const standardGit = (await fs$1.lstat(resolve(root, ".git"))).isDirectory();
|
|
453
|
+
let source = gitDir;
|
|
454
|
+
if (dirty) {
|
|
455
|
+
const snapshot = resolve(staging, ".source-repository");
|
|
456
|
+
await fs$1.mkdir(snapshot, { recursive: true });
|
|
457
|
+
await git(snapshot, [
|
|
458
|
+
"init",
|
|
459
|
+
"-b",
|
|
460
|
+
"main"
|
|
461
|
+
]);
|
|
462
|
+
await fs$1.writeFile(resolve(snapshot, ".git/objects/info/alternates"), `${resolve(commonDir, "objects")}\n`);
|
|
463
|
+
await git(snapshot, ["read-tree", head]);
|
|
464
|
+
await git(snapshot, [
|
|
465
|
+
"--work-tree",
|
|
466
|
+
root,
|
|
467
|
+
"add",
|
|
468
|
+
"-A",
|
|
469
|
+
...sourcePaths
|
|
470
|
+
]);
|
|
471
|
+
const secrets = stagedSecretPaths((await git(snapshot, [
|
|
472
|
+
"diff",
|
|
473
|
+
"--cached",
|
|
474
|
+
head,
|
|
475
|
+
"--name-only",
|
|
476
|
+
"-z",
|
|
477
|
+
"--diff-filter=ACMR"
|
|
478
|
+
])).split("\0").filter(Boolean));
|
|
479
|
+
if (secrets.length > 0) throw new StagedSecretsError(secrets);
|
|
480
|
+
head = await git(snapshot, [
|
|
481
|
+
"commit-tree",
|
|
482
|
+
await git(snapshot, ["write-tree"]),
|
|
483
|
+
"-p",
|
|
484
|
+
head,
|
|
485
|
+
"-m",
|
|
486
|
+
message
|
|
487
|
+
], void 0, {
|
|
488
|
+
GIT_AUTHOR_NAME: author.name,
|
|
489
|
+
GIT_AUTHOR_EMAIL: author.email,
|
|
490
|
+
GIT_COMMITTER_NAME: author.name,
|
|
491
|
+
GIT_COMMITTER_EMAIL: author.email
|
|
492
|
+
});
|
|
493
|
+
source = resolve(snapshot, ".git");
|
|
494
|
+
}
|
|
495
|
+
for (const [index, target] of plan.targets.entries()) {
|
|
496
|
+
const temporary = resolve(staging, target.code);
|
|
497
|
+
await rewriteHistory(source, temporary, head, target.code);
|
|
498
|
+
await Promise.all(["applet.manifest.ts", ".gitignore"].map((name) => refuseSymlink(resolve(temporary, name))));
|
|
499
|
+
if (fs.existsSync(resolve(temporary, ".hitch-backup"))) throw new MigrationError("The rewritten history contains .hitch-backup. The existing backup stays in place.");
|
|
500
|
+
for (const [path, text] of imports) if (path.startsWith(`applets/${target.code}/`)) {
|
|
501
|
+
const destination = resolve(temporary, migrationPath(path, target.code));
|
|
502
|
+
await refuseSymlink(destination);
|
|
503
|
+
await fs$1.writeFile(destination, text);
|
|
504
|
+
}
|
|
505
|
+
const manifestPath = `applets/${target.code}/applet.manifest.ts`;
|
|
506
|
+
await fs$1.writeFile(resolve(temporary, "applet.manifest.ts"), imports.has(manifestPath) ? migratedManifest(imports.get(manifestPath), config.org, cli.version) : manifests[index]);
|
|
507
|
+
const removableAgents = [];
|
|
508
|
+
for (const [name, expected] of generatedAgents) {
|
|
509
|
+
const path = resolve(temporary, name);
|
|
510
|
+
if (!fs.existsSync(path)) continue;
|
|
511
|
+
if ((await fs$1.readFile(path)).equals(expected)) removableAgents.push(name);
|
|
512
|
+
else console.warn(`${path} was edited; Hitch left it in place.`);
|
|
513
|
+
}
|
|
514
|
+
await writeGitignore(temporary, true);
|
|
515
|
+
await git(temporary, [
|
|
516
|
+
"rm",
|
|
517
|
+
"-f",
|
|
518
|
+
"-r",
|
|
519
|
+
"--ignore-unmatch",
|
|
520
|
+
"--",
|
|
521
|
+
...removableAgents,
|
|
522
|
+
"package.json",
|
|
523
|
+
"pnpm-lock.yaml",
|
|
524
|
+
"pnpm-workspace.yaml",
|
|
525
|
+
"vite.config.ts",
|
|
526
|
+
"tsconfig.json",
|
|
527
|
+
"index.html",
|
|
528
|
+
"tsr.config.json",
|
|
529
|
+
"components.json",
|
|
530
|
+
".node-version",
|
|
531
|
+
".oxlintrc.json",
|
|
532
|
+
".oxfmtrc.json"
|
|
533
|
+
]);
|
|
534
|
+
await git(temporary, ["add", "-A"]);
|
|
535
|
+
await git(temporary, [
|
|
536
|
+
"commit",
|
|
537
|
+
"-m",
|
|
538
|
+
"Move to Hitch git"
|
|
539
|
+
], void 0, {
|
|
540
|
+
GIT_AUTHOR_NAME: author.name,
|
|
541
|
+
GIT_AUTHOR_EMAIL: author.email,
|
|
542
|
+
GIT_COMMITTER_NAME: author.name,
|
|
543
|
+
GIT_COMMITTER_EMAIL: author.email
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
for (const target of plan.targets) {
|
|
547
|
+
const temporary = resolve(staging, target.code);
|
|
548
|
+
const localFiles = /* @__PURE__ */ new Map();
|
|
549
|
+
[...ignored.filter((path) => !path.startsWith("applets/")), ...ignored.filter((path) => path.startsWith(`applets/${target.code}/`))].forEach((path) => {
|
|
550
|
+
const destination = migrationPath(path, target.code);
|
|
551
|
+
if (destination !== void 0) localFiles.set(destination, path);
|
|
552
|
+
});
|
|
553
|
+
for (const [destination, path] of localFiles) {
|
|
554
|
+
const expected = generatedAgents.get(destination);
|
|
555
|
+
const source = resolve(backup, path);
|
|
556
|
+
if (expected !== void 0 && (await fs$1.readFile(source)).equals(expected)) continue;
|
|
557
|
+
const output = resolve(temporary, destination);
|
|
558
|
+
if (fs.existsSync(output)) continue;
|
|
559
|
+
await fs$1.mkdir(dirname(output), { recursive: true });
|
|
560
|
+
await fs$1.cp(source, output, {
|
|
561
|
+
dereference: false,
|
|
562
|
+
verbatimSymlinks: true
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (!standardGit) {
|
|
567
|
+
await fs$1.cp(commonDir, resolve(backup, "repository"), {
|
|
568
|
+
recursive: true,
|
|
569
|
+
verbatimSymlinks: true
|
|
570
|
+
});
|
|
571
|
+
await fs$1.cp(resolve(gitDir, "HEAD"), resolve(backup, "repository/HEAD"));
|
|
572
|
+
}
|
|
573
|
+
await fs$1.rename(resolve(root, ".git"), resolve(backup, ".git"));
|
|
574
|
+
for (const path of plan.removeFiles) await fs$1.rm(resolve(root, path), {
|
|
575
|
+
force: true,
|
|
576
|
+
recursive: true
|
|
577
|
+
});
|
|
578
|
+
if (plan.parent) {
|
|
579
|
+
await fs$1.writeFile(resolve(root, ".hitchroot"), "");
|
|
580
|
+
for (const target of plan.targets) await fs$1.rename(resolve(staging, target.code), target.root);
|
|
581
|
+
} else {
|
|
582
|
+
const temporary = resolve(staging, plan.targets[0].code);
|
|
583
|
+
for (const { name: entry } of await fs$1.readdir(temporary, { withFileTypes: true })) {
|
|
584
|
+
if (entry === ".hitch-backup") throw new MigrationError("The rewritten history contains .hitch-backup. The existing backup stays in place.");
|
|
585
|
+
await fs$1.rm(resolve(root, entry), {
|
|
586
|
+
force: true,
|
|
587
|
+
recursive: true
|
|
588
|
+
});
|
|
589
|
+
await fs$1.rename(resolve(temporary, entry), resolve(root, entry));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
await fs$1.rm(staging, {
|
|
593
|
+
recursive: true,
|
|
594
|
+
force: true
|
|
595
|
+
});
|
|
596
|
+
const invokedApplet = roots.find((path) => startingDir === path || startingDir.startsWith(`${path}${sep}`));
|
|
597
|
+
if (invokedApplet !== void 0) process.chdir(plan.targets.find((target) => target.code === basename(invokedApplet)).root);
|
|
598
|
+
if (plan.parent) await writeGeneratedAgents(root);
|
|
599
|
+
for (const target of plan.targets) await writeGeneratedAgents(target.root);
|
|
600
|
+
if (plan.parent) console.log(`Work in parent ${root}`);
|
|
601
|
+
plan.targets.forEach((target) => console.log(`Work in ${target.root}`));
|
|
602
|
+
console.log("Other copies of the old repo must use applet clone from now on");
|
|
603
|
+
console.log("Remove .github/workflows/hitch.yml from the old GitHub repo.");
|
|
604
|
+
return plan.targets.map((target) => target.root);
|
|
605
|
+
} catch (cause) {
|
|
606
|
+
await fs$1.rm(staging, {
|
|
607
|
+
recursive: true,
|
|
608
|
+
force: true
|
|
609
|
+
});
|
|
610
|
+
const restore = fs.existsSync(resolve(backup, ".git")) ? `Remove the new repos and .hitchroot, then restore the backup files and .git into ${root}.` : `The original .git stays in ${root}. The workspace stays in place.`;
|
|
611
|
+
throw new MigrationError(`Migration stopped: ${cause instanceof Error ? cause.message : String(cause)}. Backup: ${backup}. ${restore} Keep .hitch-backup untouched.`, { cause });
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
async function migrateIfEnabled(cwd, message) {
|
|
615
|
+
const root = findWorkspaceRoot(cwd);
|
|
616
|
+
if (root === void 0 || isRootLayout(root)) return void 0;
|
|
617
|
+
const config = readWorkspaceConfig(root);
|
|
618
|
+
if (!await canCheckHitchGit() || !await orgUsesHitchGit(config.org)) return void 0;
|
|
619
|
+
if (process.stdin.isTTY !== true) throw new MigrationError("Migration needs a terminal. Run applet bootstrap in an interactive terminal, then run this command again.");
|
|
620
|
+
const selected = findAppletRoot(cwd);
|
|
621
|
+
const code = selected === void 0 ? void 0 : basename(selected);
|
|
622
|
+
const roots = await migrateWorkspace(root, message);
|
|
623
|
+
return {
|
|
624
|
+
root,
|
|
625
|
+
roots,
|
|
626
|
+
selected: code === void 0 ? void 0 : roots.find((path) => roots.length === 1 || basename(path) === code)
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
export { migrateWorkspace as n, migrateIfEnabled as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/git-safety.ts
|
|
2
|
+
function stagedSecretPaths(paths) {
|
|
3
|
+
return paths.filter((path) => {
|
|
4
|
+
const name = path.split("/").at(-1);
|
|
5
|
+
return name !== ".env.example" && (name === ".env" || name.startsWith(".env.") || name === ".dev.vars" || name.startsWith(".dev.vars."));
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
var StagedSecretsError = class extends Error {
|
|
9
|
+
constructor(paths) {
|
|
10
|
+
super(`Remove these secret files from the index before deployment:\n${paths.join("\n")}`);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export { stagedSecretPaths as n, StagedSecretsError as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/headers.ts
|
|
2
2
|
const HITCH_USER_HEADER = "x-hitch-user";
|
|
3
3
|
const HITCH_SESSION_HEADER = "x-hitch-session";
|
|
4
4
|
const HITCH_APPLET_HEADER = "x-hitch-applet";
|
|
@@ -14,5 +14,4 @@ const HITCH_REQUEST_HOST_HEADER = "x-hitch-request-host";
|
|
|
14
14
|
const HITCH_WORKFLOW_RUN_HEADER = "x-hitch-workflow-run";
|
|
15
15
|
const HITCH_WORKFLOW_HEADER = "x-hitch-workflow";
|
|
16
16
|
const HITCH_WORKFLOW_INVOCATION_HEADER = "x-hitch-workflow-invocation";
|
|
17
|
-
//#endregion
|
|
18
17
|
export { HITCH_ORG_CODE_HEADER as a, HITCH_REQUEST_HOST_HEADER as c, HITCH_SESSION_HEADER as d, HITCH_USER_HEADER as f, HITCH_WORKFLOW_RUN_HEADER as h, HITCH_ORGANIZATION_HEADER as i, HITCH_SCHEDULE_HEADER as l, HITCH_WORKFLOW_INVOCATION_HEADER as m, HITCH_APPLET_HEADER as n, HITCH_PUBLIC_HEADER as o, HITCH_WORKFLOW_HEADER as p, HITCH_APPLET_TOKEN_HEADER as r, HITCH_RELEASE_HEADER as s, HITCH_APPLET_CODE_HEADER as t, HITCH_SCHEDULE_RUN_HEADER as u };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { n as withFilesUpload, r as getRegisteredHitchContract } from "./upload-
|
|
2
|
-
import { t as withBatchRecorder } from "./batch-
|
|
3
|
-
import { t as createLazyClientProxy } from "./lazy-client
|
|
1
|
+
import { n as withFilesUpload, r as getRegisteredHitchContract } from "./upload-D1mzpsSk.js";
|
|
2
|
+
import { t as withBatchRecorder } from "./batch-DwyWmiaE.js";
|
|
3
|
+
import { t as createLazyClientProxy } from "./lazy-client--QCL0wiu.js";
|
|
4
4
|
import { createORPCClient } from "@orpc/client";
|
|
5
5
|
import { OpenAPILink } from "@orpc/openapi-client/fetch";
|
|
6
6
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
7
|
-
|
|
7
|
+
// src/hitch/browser.ts
|
|
8
8
|
function createHitchClient(contract) {
|
|
9
9
|
return createLazyClientProxy(() => createORPCClient(new OpenAPILink(contract, {
|
|
10
10
|
url: `${location.origin}/api`,
|
|
11
11
|
fetch: (request, init) => globalThis.fetch(request, init)
|
|
12
12
|
})));
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
//#region src/author/hitch-client.ts
|
|
14
|
+
// src/author/hitch-client.ts
|
|
16
15
|
function buildClientHitch() {
|
|
17
16
|
const contract = getRegisteredHitchContract();
|
|
18
17
|
if (contract === void 0) throw new Error("`hitch` is unavailable: run `applet generate` first. The framework imports your .hitch automatically at build; in plain node import your .hitch once before calling hitch.");
|
|
@@ -20,5 +19,4 @@ function buildClientHitch() {
|
|
|
20
19
|
}
|
|
21
20
|
const hitchClient = createLazyClientProxy(buildClientHitch);
|
|
22
21
|
const hitch = withFilesUpload(createTanstackQueryUtils(hitchClient), () => hitchClient.files);
|
|
23
|
-
//#endregion
|
|
24
22
|
export { hitch as t };
|