siteplane 0.1.37 → 0.1.39
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/bin/siteplane.js +113 -75
- package/dist/index.js +81 -75
- package/dist/next.js +26 -24
- package/package.json +1 -1
package/dist/bin/siteplane.js
CHANGED
|
@@ -2921,57 +2921,48 @@ async function bookingTestCommand(input) {
|
|
|
2921
2921
|
}
|
|
2922
2922
|
|
|
2923
2923
|
// ../cli/dist/commands/connect.js
|
|
2924
|
+
import { spawn } from "child_process";
|
|
2924
2925
|
import { randomBytes } from "crypto";
|
|
2925
2926
|
import { z as z27 } from "zod";
|
|
2926
2927
|
|
|
2927
|
-
// ../cli/dist/config/
|
|
2928
|
-
import {
|
|
2928
|
+
// ../cli/dist/config/credentials.js
|
|
2929
|
+
import { execFile } from "child_process";
|
|
2929
2930
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
2930
|
-
import {
|
|
2931
|
+
import { chmod, mkdir as mkdir5, open, readFile as readFile5, rename, rm } from "fs/promises";
|
|
2932
|
+
import { dirname as dirname5, join as join3, relative } from "path";
|
|
2933
|
+
import { promisify } from "util";
|
|
2931
2934
|
import { z as z24 } from "zod";
|
|
2932
|
-
var
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
siteId: z24.string().uuid(),
|
|
2936
|
-
publicSiteKeyId: z24.string().uuid(),
|
|
2937
|
-
publicSiteKey: z24.string().trim().min(1),
|
|
2938
|
-
fieldContractHash: z24.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
|
|
2935
|
+
var siteplaneCredentialsSchema = z24.object({
|
|
2936
|
+
accessToken: z24.string().trim().min(1),
|
|
2937
|
+
siteRevalidationSecret: z24.string().trim().min(1)
|
|
2939
2938
|
}).strict();
|
|
2940
|
-
async function
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
return true;
|
|
2939
|
+
async function assertLocalCredentialsPathSafe(projectDir, options = {}) {
|
|
2940
|
+
const path = join3(projectDir, ".siteplane/credentials.json");
|
|
2941
|
+
const isTrackedFile = options.isTrackedFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "ls-files"));
|
|
2942
|
+
const isIgnoredFile = options.isIgnoredFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "check-ignore"));
|
|
2943
|
+
if (await isTrackedFile(path)) {
|
|
2944
|
+
throw new Error("Refusing to write Siteplane credentials into a tracked file.");
|
|
2947
2945
|
}
|
|
2948
|
-
|
|
2949
|
-
"
|
|
2950
|
-
"next.config.mjs",
|
|
2951
|
-
"next.config.ts"
|
|
2952
|
-
]) {
|
|
2953
|
-
try {
|
|
2954
|
-
await access(join3(projectDir, fileName));
|
|
2955
|
-
return true;
|
|
2956
|
-
} catch {
|
|
2957
|
-
}
|
|
2946
|
+
if (!await isIgnoredFile(path)) {
|
|
2947
|
+
throw new Error("Add .siteplane/credentials.json to .gitignore before running Siteplane connect.");
|
|
2958
2948
|
}
|
|
2959
|
-
return
|
|
2949
|
+
return path;
|
|
2960
2950
|
}
|
|
2961
|
-
async function
|
|
2962
|
-
const path =
|
|
2963
|
-
const parsed =
|
|
2964
|
-
await
|
|
2951
|
+
async function writeLocalCredentials(projectDir, credentials, options = {}) {
|
|
2952
|
+
const path = await assertLocalCredentialsPathSafe(projectDir, options);
|
|
2953
|
+
const parsed = siteplaneCredentialsSchema.parse(credentials);
|
|
2954
|
+
await mkdir5(dirname5(path), { recursive: true, mode: 448 });
|
|
2955
|
+
await writeCredentialsAtomically(path, parsed);
|
|
2965
2956
|
return path;
|
|
2966
2957
|
}
|
|
2967
|
-
async function
|
|
2968
|
-
return
|
|
2958
|
+
async function readLocalCredentials(projectDir) {
|
|
2959
|
+
return siteplaneCredentialsSchema.parse(JSON.parse(await readFile5(join3(projectDir, ".siteplane/credentials.json"), "utf8")));
|
|
2969
2960
|
}
|
|
2970
|
-
async function
|
|
2961
|
+
async function writeCredentialsAtomically(path, credentials) {
|
|
2971
2962
|
const temporaryPath = `${path}.${randomUUID2()}.tmp`;
|
|
2972
|
-
const file = await open(temporaryPath, "wx",
|
|
2963
|
+
const file = await open(temporaryPath, "wx", 384);
|
|
2973
2964
|
try {
|
|
2974
|
-
await file.writeFile(`${JSON.stringify(
|
|
2965
|
+
await file.writeFile(`${JSON.stringify(credentials, null, 2)}
|
|
2975
2966
|
`, "utf8");
|
|
2976
2967
|
await file.sync();
|
|
2977
2968
|
} catch (error) {
|
|
@@ -2982,47 +2973,71 @@ async function writeJsonAtomically(path, value, mode) {
|
|
|
2982
2973
|
await file.close();
|
|
2983
2974
|
try {
|
|
2984
2975
|
await rename(temporaryPath, path);
|
|
2985
|
-
await chmod(path,
|
|
2976
|
+
await chmod(path, 384);
|
|
2986
2977
|
} catch (error) {
|
|
2987
2978
|
await rm(temporaryPath, { force: true });
|
|
2988
2979
|
throw error;
|
|
2989
2980
|
}
|
|
2990
2981
|
}
|
|
2982
|
+
var execFileAsync = promisify(execFile);
|
|
2983
|
+
async function gitPathMatches(projectDir, path, command) {
|
|
2984
|
+
const args = command === "check-ignore" ? ["check-ignore", "--quiet", relative(projectDir, path)] : ["ls-files", "--error-unmatch", relative(projectDir, path)];
|
|
2985
|
+
try {
|
|
2986
|
+
await execFileAsync("git", args, { cwd: projectDir });
|
|
2987
|
+
return true;
|
|
2988
|
+
} catch {
|
|
2989
|
+
return false;
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2991
2992
|
|
|
2992
|
-
// ../cli/dist/config/
|
|
2993
|
-
import {
|
|
2993
|
+
// ../cli/dist/config/project-config.js
|
|
2994
|
+
import { access, chmod as chmod2, open as open2, readFile as readFile6, rename as rename2, rm as rm2 } from "fs/promises";
|
|
2994
2995
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
2995
|
-
import {
|
|
2996
|
-
import { dirname as dirname5, join as join4, relative } from "path";
|
|
2997
|
-
import { promisify } from "util";
|
|
2996
|
+
import { join as join4 } from "path";
|
|
2998
2997
|
import { z as z25 } from "zod";
|
|
2999
|
-
var
|
|
3000
|
-
|
|
3001
|
-
|
|
2998
|
+
var siteplaneProjectConfigSchema = z25.object({
|
|
2999
|
+
version: z25.literal(1),
|
|
3000
|
+
apiBaseUrl: z25.string().url(),
|
|
3001
|
+
siteId: z25.string().uuid(),
|
|
3002
|
+
publicSiteKeyId: z25.string().uuid(),
|
|
3003
|
+
publicSiteKey: z25.string().trim().min(1),
|
|
3004
|
+
fieldContractHash: z25.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
|
|
3002
3005
|
}).strict();
|
|
3003
|
-
async function
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3006
|
+
async function readProjectPackageJson(projectDir) {
|
|
3007
|
+
return JSON.parse(await readFile6(join4(projectDir, "package.json"), "utf8"));
|
|
3008
|
+
}
|
|
3009
|
+
async function detectNextProject(projectDir) {
|
|
3010
|
+
const packageJson = await readProjectPackageJson(projectDir).catch(() => null);
|
|
3011
|
+
if (packageJson?.dependencies?.next || packageJson?.devDependencies?.next) {
|
|
3012
|
+
return true;
|
|
3009
3013
|
}
|
|
3010
|
-
|
|
3011
|
-
|
|
3014
|
+
for (const fileName of [
|
|
3015
|
+
"next.config.js",
|
|
3016
|
+
"next.config.mjs",
|
|
3017
|
+
"next.config.ts"
|
|
3018
|
+
]) {
|
|
3019
|
+
try {
|
|
3020
|
+
await access(join4(projectDir, fileName));
|
|
3021
|
+
return true;
|
|
3022
|
+
} catch {
|
|
3023
|
+
}
|
|
3012
3024
|
}
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3025
|
+
return false;
|
|
3026
|
+
}
|
|
3027
|
+
async function writeProjectConfig(projectDir, config) {
|
|
3028
|
+
const path = join4(projectDir, "siteplane.config.json");
|
|
3029
|
+
const parsed = siteplaneProjectConfigSchema.parse(config);
|
|
3030
|
+
await writeJsonAtomically(path, parsed, 420);
|
|
3016
3031
|
return path;
|
|
3017
3032
|
}
|
|
3018
|
-
async function
|
|
3019
|
-
return
|
|
3033
|
+
async function readProjectConfig(projectDir) {
|
|
3034
|
+
return siteplaneProjectConfigSchema.parse(JSON.parse(await readFile6(join4(projectDir, "siteplane.config.json"), "utf8")));
|
|
3020
3035
|
}
|
|
3021
|
-
async function
|
|
3036
|
+
async function writeJsonAtomically(path, value, mode) {
|
|
3022
3037
|
const temporaryPath = `${path}.${randomUUID3()}.tmp`;
|
|
3023
|
-
const file = await open2(temporaryPath, "wx",
|
|
3038
|
+
const file = await open2(temporaryPath, "wx", mode);
|
|
3024
3039
|
try {
|
|
3025
|
-
await file.writeFile(`${JSON.stringify(
|
|
3040
|
+
await file.writeFile(`${JSON.stringify(value, null, 2)}
|
|
3026
3041
|
`, "utf8");
|
|
3027
3042
|
await file.sync();
|
|
3028
3043
|
} catch (error) {
|
|
@@ -3033,22 +3048,12 @@ async function writeCredentialsAtomically(path, credentials) {
|
|
|
3033
3048
|
await file.close();
|
|
3034
3049
|
try {
|
|
3035
3050
|
await rename2(temporaryPath, path);
|
|
3036
|
-
await chmod2(path,
|
|
3051
|
+
await chmod2(path, mode);
|
|
3037
3052
|
} catch (error) {
|
|
3038
3053
|
await rm2(temporaryPath, { force: true });
|
|
3039
3054
|
throw error;
|
|
3040
3055
|
}
|
|
3041
3056
|
}
|
|
3042
|
-
var execFileAsync = promisify(execFile);
|
|
3043
|
-
async function gitPathMatches(projectDir, path, command) {
|
|
3044
|
-
const args = command === "check-ignore" ? ["check-ignore", "--quiet", relative(projectDir, path)] : ["ls-files", "--error-unmatch", relative(projectDir, path)];
|
|
3045
|
-
try {
|
|
3046
|
-
await execFileAsync("git", args, { cwd: projectDir });
|
|
3047
|
-
return true;
|
|
3048
|
-
} catch {
|
|
3049
|
-
return false;
|
|
3050
|
-
}
|
|
3051
|
-
}
|
|
3052
3057
|
|
|
3053
3058
|
// ../cli/dist/commands/init.js
|
|
3054
3059
|
import { join as join5 } from "path";
|
|
@@ -3192,7 +3197,8 @@ var claimResponseSchema = z27.object({
|
|
|
3192
3197
|
ok: z27.literal(true),
|
|
3193
3198
|
data: z27.object({
|
|
3194
3199
|
pairingId: z27.string().uuid(),
|
|
3195
|
-
status: z27.literal("approval_required")
|
|
3200
|
+
status: z27.literal("approval_required"),
|
|
3201
|
+
approvalUrl: z27.string().url()
|
|
3196
3202
|
}).passthrough()
|
|
3197
3203
|
}).strict();
|
|
3198
3204
|
var waitingResponseSchema = z27.object({
|
|
@@ -3207,6 +3213,10 @@ async function connectCommand(input) {
|
|
|
3207
3213
|
if (!await detectNextProject(input.projectDir)) {
|
|
3208
3214
|
throw new Error("Siteplane connect currently supports Next.js projects.");
|
|
3209
3215
|
}
|
|
3216
|
+
await assertLocalCredentialsPathSafe(input.projectDir, {
|
|
3217
|
+
...input.isIgnoredFile ? { isIgnoredFile: input.isIgnoredFile } : {},
|
|
3218
|
+
...input.isTrackedFile ? { isTrackedFile: input.isTrackedFile } : {}
|
|
3219
|
+
});
|
|
3210
3220
|
const fetcher = input.fetcher ?? fetch;
|
|
3211
3221
|
const pollSecret = randomBytes(32).toString("base64url");
|
|
3212
3222
|
const envelopeKey = randomBytes(32).toString("base64url");
|
|
@@ -3228,6 +3238,16 @@ async function connectCommand(input) {
|
|
|
3228
3238
|
if (!claimResponse.ok || !claim.success) {
|
|
3229
3239
|
throw new Error(readErrorMessage2(claimPayload) ?? "Siteplane pairing failed.");
|
|
3230
3240
|
}
|
|
3241
|
+
let browserOpened = false;
|
|
3242
|
+
try {
|
|
3243
|
+
await (input.openBrowser ?? openInDefaultBrowser)(claim.data.data.approvalUrl);
|
|
3244
|
+
browserOpened = true;
|
|
3245
|
+
} catch {
|
|
3246
|
+
}
|
|
3247
|
+
input.onApprovalRequired?.({
|
|
3248
|
+
approvalUrl: claim.data.data.approvalUrl,
|
|
3249
|
+
browserOpened
|
|
3250
|
+
});
|
|
3231
3251
|
const wait = input.wait ?? ((milliseconds) => new Promise((resolve2) => setTimeout(resolve2, milliseconds)));
|
|
3232
3252
|
let bootstrap = null;
|
|
3233
3253
|
for (; ; ) {
|
|
@@ -3281,6 +3301,18 @@ async function connectCommand(input) {
|
|
|
3281
3301
|
]
|
|
3282
3302
|
};
|
|
3283
3303
|
}
|
|
3304
|
+
async function openInDefaultBrowser(url) {
|
|
3305
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32.exe" : "xdg-open";
|
|
3306
|
+
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
3307
|
+
await new Promise((resolve2, reject) => {
|
|
3308
|
+
const child = spawn(command, args, { detached: true, stdio: "ignore" });
|
|
3309
|
+
child.once("error", reject);
|
|
3310
|
+
child.once("spawn", () => {
|
|
3311
|
+
child.unref();
|
|
3312
|
+
resolve2();
|
|
3313
|
+
});
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3284
3316
|
function createHeaders(input) {
|
|
3285
3317
|
return new Headers({
|
|
3286
3318
|
"content-type": "application/json",
|
|
@@ -4021,7 +4053,7 @@ var safeErrorSchema = z28.object({
|
|
|
4021
4053
|
}).passthrough();
|
|
4022
4054
|
var errorResponseSchema2 = z28.object({ ok: z28.literal(false), error: safeErrorSchema }).passthrough();
|
|
4023
4055
|
var contextDataSchema = z28.object({
|
|
4024
|
-
site: z28.object({ siteId: z28.string().uuid(),
|
|
4056
|
+
site: z28.object({ siteId: z28.string().uuid(), portalPath: z28.string() }),
|
|
4025
4057
|
run: z28.object({
|
|
4026
4058
|
runId: z28.string().uuid(),
|
|
4027
4059
|
mode: z28.enum(["initial", "update"]),
|
|
@@ -4184,6 +4216,12 @@ async function runSiteplaneCli(args, dependencies = createDefaultDependencies())
|
|
|
4184
4216
|
projectDir: dependencies.cwd(),
|
|
4185
4217
|
pairingCode,
|
|
4186
4218
|
apiBaseUrl,
|
|
4219
|
+
onApprovalRequired: ({ approvalUrl, browserOpened }) => {
|
|
4220
|
+
dependencies.stdout(
|
|
4221
|
+
browserOpened ? "Opened Siteplane in your browser. Approve the connection there:" : "Could not open a browser automatically. Approve the connection here:"
|
|
4222
|
+
);
|
|
4223
|
+
dependencies.stdout(approvalUrl);
|
|
4224
|
+
},
|
|
4187
4225
|
...readOptionalVercelAutomationBypassSecret(dependencies.env)
|
|
4188
4226
|
});
|
|
4189
4227
|
dependencies.stdout(`Wrote ${result.configPath}`);
|
package/dist/index.js
CHANGED
|
@@ -1990,57 +1990,48 @@ async function bookingTestCommand(input) {
|
|
|
1990
1990
|
}
|
|
1991
1991
|
|
|
1992
1992
|
// ../cli/dist/commands/connect.js
|
|
1993
|
+
import { spawn } from "child_process";
|
|
1993
1994
|
import { randomBytes } from "crypto";
|
|
1994
1995
|
import { z as z27 } from "zod";
|
|
1995
1996
|
|
|
1996
|
-
// ../cli/dist/config/
|
|
1997
|
-
import {
|
|
1997
|
+
// ../cli/dist/config/credentials.js
|
|
1998
|
+
import { execFile } from "child_process";
|
|
1998
1999
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1999
|
-
import {
|
|
2000
|
+
import { chmod, mkdir as mkdir5, open, readFile as readFile5, rename, rm } from "fs/promises";
|
|
2001
|
+
import { dirname as dirname5, join as join3, relative } from "path";
|
|
2002
|
+
import { promisify } from "util";
|
|
2000
2003
|
import { z as z24 } from "zod";
|
|
2001
|
-
var
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
siteId: z24.string().uuid(),
|
|
2005
|
-
publicSiteKeyId: z24.string().uuid(),
|
|
2006
|
-
publicSiteKey: z24.string().trim().min(1),
|
|
2007
|
-
fieldContractHash: z24.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
|
|
2004
|
+
var siteplaneCredentialsSchema = z24.object({
|
|
2005
|
+
accessToken: z24.string().trim().min(1),
|
|
2006
|
+
siteRevalidationSecret: z24.string().trim().min(1)
|
|
2008
2007
|
}).strict();
|
|
2009
|
-
async function
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
return true;
|
|
2008
|
+
async function assertLocalCredentialsPathSafe(projectDir, options = {}) {
|
|
2009
|
+
const path = join3(projectDir, ".siteplane/credentials.json");
|
|
2010
|
+
const isTrackedFile = options.isTrackedFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "ls-files"));
|
|
2011
|
+
const isIgnoredFile = options.isIgnoredFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "check-ignore"));
|
|
2012
|
+
if (await isTrackedFile(path)) {
|
|
2013
|
+
throw new Error("Refusing to write Siteplane credentials into a tracked file.");
|
|
2016
2014
|
}
|
|
2017
|
-
|
|
2018
|
-
"
|
|
2019
|
-
"next.config.mjs",
|
|
2020
|
-
"next.config.ts"
|
|
2021
|
-
]) {
|
|
2022
|
-
try {
|
|
2023
|
-
await access(join3(projectDir, fileName));
|
|
2024
|
-
return true;
|
|
2025
|
-
} catch {
|
|
2026
|
-
}
|
|
2015
|
+
if (!await isIgnoredFile(path)) {
|
|
2016
|
+
throw new Error("Add .siteplane/credentials.json to .gitignore before running Siteplane connect.");
|
|
2027
2017
|
}
|
|
2028
|
-
return
|
|
2018
|
+
return path;
|
|
2029
2019
|
}
|
|
2030
|
-
async function
|
|
2031
|
-
const path =
|
|
2032
|
-
const parsed =
|
|
2033
|
-
await
|
|
2020
|
+
async function writeLocalCredentials(projectDir, credentials, options = {}) {
|
|
2021
|
+
const path = await assertLocalCredentialsPathSafe(projectDir, options);
|
|
2022
|
+
const parsed = siteplaneCredentialsSchema.parse(credentials);
|
|
2023
|
+
await mkdir5(dirname5(path), { recursive: true, mode: 448 });
|
|
2024
|
+
await writeCredentialsAtomically(path, parsed);
|
|
2034
2025
|
return path;
|
|
2035
2026
|
}
|
|
2036
|
-
async function
|
|
2037
|
-
return
|
|
2027
|
+
async function readLocalCredentials(projectDir) {
|
|
2028
|
+
return siteplaneCredentialsSchema.parse(JSON.parse(await readFile5(join3(projectDir, ".siteplane/credentials.json"), "utf8")));
|
|
2038
2029
|
}
|
|
2039
|
-
async function
|
|
2030
|
+
async function writeCredentialsAtomically(path, credentials) {
|
|
2040
2031
|
const temporaryPath = `${path}.${randomUUID2()}.tmp`;
|
|
2041
|
-
const file = await open(temporaryPath, "wx",
|
|
2032
|
+
const file = await open(temporaryPath, "wx", 384);
|
|
2042
2033
|
try {
|
|
2043
|
-
await file.writeFile(`${JSON.stringify(
|
|
2034
|
+
await file.writeFile(`${JSON.stringify(credentials, null, 2)}
|
|
2044
2035
|
`, "utf8");
|
|
2045
2036
|
await file.sync();
|
|
2046
2037
|
} catch (error) {
|
|
@@ -2051,47 +2042,71 @@ async function writeJsonAtomically(path, value, mode) {
|
|
|
2051
2042
|
await file.close();
|
|
2052
2043
|
try {
|
|
2053
2044
|
await rename(temporaryPath, path);
|
|
2054
|
-
await chmod(path,
|
|
2045
|
+
await chmod(path, 384);
|
|
2055
2046
|
} catch (error) {
|
|
2056
2047
|
await rm(temporaryPath, { force: true });
|
|
2057
2048
|
throw error;
|
|
2058
2049
|
}
|
|
2059
2050
|
}
|
|
2051
|
+
var execFileAsync = promisify(execFile);
|
|
2052
|
+
async function gitPathMatches(projectDir, path, command) {
|
|
2053
|
+
const args = command === "check-ignore" ? ["check-ignore", "--quiet", relative(projectDir, path)] : ["ls-files", "--error-unmatch", relative(projectDir, path)];
|
|
2054
|
+
try {
|
|
2055
|
+
await execFileAsync("git", args, { cwd: projectDir });
|
|
2056
|
+
return true;
|
|
2057
|
+
} catch {
|
|
2058
|
+
return false;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2060
2061
|
|
|
2061
|
-
// ../cli/dist/config/
|
|
2062
|
-
import {
|
|
2062
|
+
// ../cli/dist/config/project-config.js
|
|
2063
|
+
import { access, chmod as chmod2, open as open2, readFile as readFile6, rename as rename2, rm as rm2 } from "fs/promises";
|
|
2063
2064
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
2064
|
-
import {
|
|
2065
|
-
import { dirname as dirname5, join as join4, relative } from "path";
|
|
2066
|
-
import { promisify } from "util";
|
|
2065
|
+
import { join as join4 } from "path";
|
|
2067
2066
|
import { z as z25 } from "zod";
|
|
2068
|
-
var
|
|
2069
|
-
|
|
2070
|
-
|
|
2067
|
+
var siteplaneProjectConfigSchema = z25.object({
|
|
2068
|
+
version: z25.literal(1),
|
|
2069
|
+
apiBaseUrl: z25.string().url(),
|
|
2070
|
+
siteId: z25.string().uuid(),
|
|
2071
|
+
publicSiteKeyId: z25.string().uuid(),
|
|
2072
|
+
publicSiteKey: z25.string().trim().min(1),
|
|
2073
|
+
fieldContractHash: z25.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
|
|
2071
2074
|
}).strict();
|
|
2072
|
-
async function
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2075
|
+
async function readProjectPackageJson(projectDir) {
|
|
2076
|
+
return JSON.parse(await readFile6(join4(projectDir, "package.json"), "utf8"));
|
|
2077
|
+
}
|
|
2078
|
+
async function detectNextProject(projectDir) {
|
|
2079
|
+
const packageJson = await readProjectPackageJson(projectDir).catch(() => null);
|
|
2080
|
+
if (packageJson?.dependencies?.next || packageJson?.devDependencies?.next) {
|
|
2081
|
+
return true;
|
|
2078
2082
|
}
|
|
2079
|
-
|
|
2080
|
-
|
|
2083
|
+
for (const fileName of [
|
|
2084
|
+
"next.config.js",
|
|
2085
|
+
"next.config.mjs",
|
|
2086
|
+
"next.config.ts"
|
|
2087
|
+
]) {
|
|
2088
|
+
try {
|
|
2089
|
+
await access(join4(projectDir, fileName));
|
|
2090
|
+
return true;
|
|
2091
|
+
} catch {
|
|
2092
|
+
}
|
|
2081
2093
|
}
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2094
|
+
return false;
|
|
2095
|
+
}
|
|
2096
|
+
async function writeProjectConfig(projectDir, config) {
|
|
2097
|
+
const path = join4(projectDir, "siteplane.config.json");
|
|
2098
|
+
const parsed = siteplaneProjectConfigSchema.parse(config);
|
|
2099
|
+
await writeJsonAtomically(path, parsed, 420);
|
|
2085
2100
|
return path;
|
|
2086
2101
|
}
|
|
2087
|
-
async function
|
|
2088
|
-
return
|
|
2102
|
+
async function readProjectConfig(projectDir) {
|
|
2103
|
+
return siteplaneProjectConfigSchema.parse(JSON.parse(await readFile6(join4(projectDir, "siteplane.config.json"), "utf8")));
|
|
2089
2104
|
}
|
|
2090
|
-
async function
|
|
2105
|
+
async function writeJsonAtomically(path, value, mode) {
|
|
2091
2106
|
const temporaryPath = `${path}.${randomUUID3()}.tmp`;
|
|
2092
|
-
const file = await open2(temporaryPath, "wx",
|
|
2107
|
+
const file = await open2(temporaryPath, "wx", mode);
|
|
2093
2108
|
try {
|
|
2094
|
-
await file.writeFile(`${JSON.stringify(
|
|
2109
|
+
await file.writeFile(`${JSON.stringify(value, null, 2)}
|
|
2095
2110
|
`, "utf8");
|
|
2096
2111
|
await file.sync();
|
|
2097
2112
|
} catch (error) {
|
|
@@ -2102,22 +2117,12 @@ async function writeCredentialsAtomically(path, credentials) {
|
|
|
2102
2117
|
await file.close();
|
|
2103
2118
|
try {
|
|
2104
2119
|
await rename2(temporaryPath, path);
|
|
2105
|
-
await chmod2(path,
|
|
2120
|
+
await chmod2(path, mode);
|
|
2106
2121
|
} catch (error) {
|
|
2107
2122
|
await rm2(temporaryPath, { force: true });
|
|
2108
2123
|
throw error;
|
|
2109
2124
|
}
|
|
2110
2125
|
}
|
|
2111
|
-
var execFileAsync = promisify(execFile);
|
|
2112
|
-
async function gitPathMatches(projectDir, path, command) {
|
|
2113
|
-
const args = command === "check-ignore" ? ["check-ignore", "--quiet", relative(projectDir, path)] : ["ls-files", "--error-unmatch", relative(projectDir, path)];
|
|
2114
|
-
try {
|
|
2115
|
-
await execFileAsync("git", args, { cwd: projectDir });
|
|
2116
|
-
return true;
|
|
2117
|
-
} catch {
|
|
2118
|
-
return false;
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
2126
|
|
|
2122
2127
|
// ../cli/dist/commands/init.js
|
|
2123
2128
|
import { join as join5 } from "path";
|
|
@@ -2261,7 +2266,8 @@ var claimResponseSchema = z27.object({
|
|
|
2261
2266
|
ok: z27.literal(true),
|
|
2262
2267
|
data: z27.object({
|
|
2263
2268
|
pairingId: z27.string().uuid(),
|
|
2264
|
-
status: z27.literal("approval_required")
|
|
2269
|
+
status: z27.literal("approval_required"),
|
|
2270
|
+
approvalUrl: z27.string().url()
|
|
2265
2271
|
}).passthrough()
|
|
2266
2272
|
}).strict();
|
|
2267
2273
|
var waitingResponseSchema = z27.object({
|
|
@@ -2318,7 +2324,7 @@ var safeErrorSchema = z28.object({
|
|
|
2318
2324
|
}).passthrough();
|
|
2319
2325
|
var errorResponseSchema2 = z28.object({ ok: z28.literal(false), error: safeErrorSchema }).passthrough();
|
|
2320
2326
|
var contextDataSchema = z28.object({
|
|
2321
|
-
site: z28.object({ siteId: z28.string().uuid(),
|
|
2327
|
+
site: z28.object({ siteId: z28.string().uuid(), portalPath: z28.string() }),
|
|
2322
2328
|
run: z28.object({
|
|
2323
2329
|
runId: z28.string().uuid(),
|
|
2324
2330
|
mode: z28.enum(["initial", "update"]),
|
package/dist/next.js
CHANGED
|
@@ -1898,38 +1898,39 @@ alwaysApply: true
|
|
|
1898
1898
|
${bookingRulesTemplate}`;
|
|
1899
1899
|
|
|
1900
1900
|
// ../cli/dist/commands/connect.js
|
|
1901
|
+
import { spawn } from "child_process";
|
|
1901
1902
|
import { randomBytes } from "crypto";
|
|
1902
1903
|
import { z as z27 } from "zod";
|
|
1903
1904
|
|
|
1904
|
-
// ../cli/dist/config/
|
|
1905
|
-
import {
|
|
1905
|
+
// ../cli/dist/config/credentials.js
|
|
1906
|
+
import { execFile } from "child_process";
|
|
1906
1907
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1907
|
-
import {
|
|
1908
|
+
import { chmod, mkdir as mkdir5, open, readFile as readFile5, rename, rm } from "fs/promises";
|
|
1909
|
+
import { dirname as dirname5, join as join3, relative } from "path";
|
|
1910
|
+
import { promisify } from "util";
|
|
1908
1911
|
import { z as z24 } from "zod";
|
|
1909
|
-
var
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
siteId: z24.string().uuid(),
|
|
1913
|
-
publicSiteKeyId: z24.string().uuid(),
|
|
1914
|
-
publicSiteKey: z24.string().trim().min(1),
|
|
1915
|
-
fieldContractHash: z24.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
|
|
1912
|
+
var siteplaneCredentialsSchema = z24.object({
|
|
1913
|
+
accessToken: z24.string().trim().min(1),
|
|
1914
|
+
siteRevalidationSecret: z24.string().trim().min(1)
|
|
1916
1915
|
}).strict();
|
|
1917
|
-
|
|
1918
|
-
return siteplaneProjectConfigSchema.parse(JSON.parse(await readFile5(join3(projectDir, "siteplane.config.json"), "utf8")));
|
|
1919
|
-
}
|
|
1916
|
+
var execFileAsync = promisify(execFile);
|
|
1920
1917
|
|
|
1921
|
-
// ../cli/dist/config/
|
|
1922
|
-
import {
|
|
1918
|
+
// ../cli/dist/config/project-config.js
|
|
1919
|
+
import { access, chmod as chmod2, open as open2, readFile as readFile6, rename as rename2, rm as rm2 } from "fs/promises";
|
|
1923
1920
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
1924
|
-
import {
|
|
1925
|
-
import { dirname as dirname5, join as join4, relative } from "path";
|
|
1926
|
-
import { promisify } from "util";
|
|
1921
|
+
import { join as join4 } from "path";
|
|
1927
1922
|
import { z as z25 } from "zod";
|
|
1928
|
-
var
|
|
1929
|
-
|
|
1930
|
-
|
|
1923
|
+
var siteplaneProjectConfigSchema = z25.object({
|
|
1924
|
+
version: z25.literal(1),
|
|
1925
|
+
apiBaseUrl: z25.string().url(),
|
|
1926
|
+
siteId: z25.string().uuid(),
|
|
1927
|
+
publicSiteKeyId: z25.string().uuid(),
|
|
1928
|
+
publicSiteKey: z25.string().trim().min(1),
|
|
1929
|
+
fieldContractHash: z25.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
|
|
1931
1930
|
}).strict();
|
|
1932
|
-
|
|
1931
|
+
async function readProjectConfig(projectDir) {
|
|
1932
|
+
return siteplaneProjectConfigSchema.parse(JSON.parse(await readFile6(join4(projectDir, "siteplane.config.json"), "utf8")));
|
|
1933
|
+
}
|
|
1933
1934
|
|
|
1934
1935
|
// ../cli/dist/commands/init.js
|
|
1935
1936
|
import { join as join5 } from "path";
|
|
@@ -1962,7 +1963,8 @@ var claimResponseSchema = z27.object({
|
|
|
1962
1963
|
ok: z27.literal(true),
|
|
1963
1964
|
data: z27.object({
|
|
1964
1965
|
pairingId: z27.string().uuid(),
|
|
1965
|
-
status: z27.literal("approval_required")
|
|
1966
|
+
status: z27.literal("approval_required"),
|
|
1967
|
+
approvalUrl: z27.string().url()
|
|
1966
1968
|
}).passthrough()
|
|
1967
1969
|
}).strict();
|
|
1968
1970
|
var waitingResponseSchema = z27.object({
|
|
@@ -2692,7 +2694,7 @@ var safeErrorSchema = z28.object({
|
|
|
2692
2694
|
}).passthrough();
|
|
2693
2695
|
var errorResponseSchema2 = z28.object({ ok: z28.literal(false), error: safeErrorSchema }).passthrough();
|
|
2694
2696
|
var contextDataSchema = z28.object({
|
|
2695
|
-
site: z28.object({ siteId: z28.string().uuid(),
|
|
2697
|
+
site: z28.object({ siteId: z28.string().uuid(), portalPath: z28.string() }),
|
|
2696
2698
|
run: z28.object({
|
|
2697
2699
|
runId: z28.string().uuid(),
|
|
2698
2700
|
mode: z28.enum(["initial", "update"]),
|