@micropue/drop-cli 0.0.0-stage → 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 +21 -0
- package/README.md +307 -2
- package/package.json +52 -4
- package/src/cli.js +95 -0
- package/src/commands/auth.js +71 -0
- package/src/commands/deploy.js +81 -0
- package/src/commands/init.js +50 -0
- package/src/commands/status.js +38 -0
- package/src/commands/watch.js +380 -0
- package/src/index.js +9 -0
- package/src/lib/api.js +206 -0
- package/src/lib/auth.js +88 -0
- package/src/lib/config.js +159 -0
- package/src/lib/constants.js +22 -0
- package/src/lib/deployer.js +248 -0
- package/src/lib/discovery.js +329 -0
- package/src/lib/errors.js +59 -0
- package/src/lib/ignore.js +48 -0
- package/src/lib/prompt.js +58 -0
- package/src/lib/runtime.js +130 -0
- package/src/lib/snapshot.js +38 -0
- package/src/lib/terminal.js +45 -0
- package/src/lib/utils.js +189 -0
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { DropConfigError } from "./errors.js";
|
|
6
|
+
import { promptHidden } from "./prompt.js";
|
|
7
|
+
|
|
8
|
+
function authFile() {
|
|
9
|
+
if (process.env.DROP_AUTH_FILE) {
|
|
10
|
+
return path.resolve(process.env.DROP_AUTH_FILE);
|
|
11
|
+
}
|
|
12
|
+
const configRoot =
|
|
13
|
+
process.platform === "win32"
|
|
14
|
+
? process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming")
|
|
15
|
+
: process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
|
|
16
|
+
return path.join(configRoot, "micropue-drop", "auth.json");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function readStoredKey() {
|
|
20
|
+
try {
|
|
21
|
+
const raw = await readFile(authFile(), "utf8");
|
|
22
|
+
const parsed = JSON.parse(raw);
|
|
23
|
+
return typeof parsed.apiKey === "string" && parsed.apiKey.trim()
|
|
24
|
+
? parsed.apiKey.trim()
|
|
25
|
+
: null;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (error.code === "ENOENT") {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (error instanceof SyntaxError) {
|
|
31
|
+
throw new DropConfigError(`Invalid auth file: ${authFile()}`, {
|
|
32
|
+
hint: "Run `drop logout` and `drop login` again.",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function saveStoredKey(apiKey) {
|
|
40
|
+
const target = authFile();
|
|
41
|
+
await mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
|
|
42
|
+
await chmod(path.dirname(target), 0o700).catch(() => {});
|
|
43
|
+
await writeFile(
|
|
44
|
+
target,
|
|
45
|
+
`${JSON.stringify({ apiKey, savedAt: new Date().toISOString() }, null, 2)}\n`,
|
|
46
|
+
{ mode: 0o600 },
|
|
47
|
+
);
|
|
48
|
+
await chmod(target, 0o600).catch(() => {});
|
|
49
|
+
return target;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function clearStoredKey() {
|
|
53
|
+
await rm(authFile(), { force: true });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function storedKeyPath() {
|
|
57
|
+
return authFile();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function resolveApiKey({ allowPrompt = true } = {}) {
|
|
61
|
+
const environmentKey = process.env.DROP_API_KEY?.trim();
|
|
62
|
+
if (environmentKey) {
|
|
63
|
+
return environmentKey;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const stored = await readStoredKey();
|
|
67
|
+
if (stored) {
|
|
68
|
+
return stored;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!allowPrompt) {
|
|
72
|
+
throw new DropConfigError("DROP API key is required.", {
|
|
73
|
+
hint: "Set DROP_API_KEY, or run `drop login` once.",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!process.stdin.isTTY) {
|
|
78
|
+
throw new DropConfigError("DROP API key is required in non-interactive mode.", {
|
|
79
|
+
hint: "Set DROP_API_KEY before running the command.",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const key = (await promptHidden("DROP API key")).trim();
|
|
84
|
+
if (!key) {
|
|
85
|
+
throw new DropConfigError("No API key was provided.");
|
|
86
|
+
}
|
|
87
|
+
return key;
|
|
88
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, rename, rm, rmdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
CONFIG_FILE_NAME,
|
|
7
|
+
CONFIG_SCHEMA_VERSION,
|
|
8
|
+
DROP_DIR_NAME,
|
|
9
|
+
} from "./constants.js";
|
|
10
|
+
import { DropConfigError } from "./errors.js";
|
|
11
|
+
import { isInside, resolveInside } from "./utils.js";
|
|
12
|
+
|
|
13
|
+
export function dropPaths(root) {
|
|
14
|
+
const directory = path.join(root, DROP_DIR_NAME);
|
|
15
|
+
return {
|
|
16
|
+
directory,
|
|
17
|
+
config: path.join(directory, CONFIG_FILE_NAME),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function readConfig(root) {
|
|
22
|
+
const { config: configPath } = dropPaths(root);
|
|
23
|
+
let raw;
|
|
24
|
+
try {
|
|
25
|
+
raw = await readFile(configPath, "utf8");
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (error.code === "ENOENT") {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
throw new DropConfigError("Could not read .drop/drop.json", {
|
|
31
|
+
cause: error,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let config;
|
|
36
|
+
try {
|
|
37
|
+
config = JSON.parse(raw);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new DropConfigError(".drop/drop.json is not valid JSON", {
|
|
40
|
+
cause: error,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
!config ||
|
|
46
|
+
typeof config !== "object" ||
|
|
47
|
+
Array.isArray(config) ||
|
|
48
|
+
config.schemaVersion !== CONFIG_SCHEMA_VERSION
|
|
49
|
+
) {
|
|
50
|
+
throw new DropConfigError(
|
|
51
|
+
`Unsupported .drop/drop.json schema. Expected schemaVersion ${CONFIG_SCHEMA_VERSION}.`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function atomicWrite(filePath, content) {
|
|
59
|
+
const temporary = `${filePath}.${randomUUID()}.tmp`;
|
|
60
|
+
await writeFile(temporary, content);
|
|
61
|
+
try {
|
|
62
|
+
await rename(temporary, filePath);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
await rm(temporary, { force: true });
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function writeConfig(root, config) {
|
|
70
|
+
const { directory, config: configPath } = dropPaths(root);
|
|
71
|
+
await mkdir(directory, { recursive: true });
|
|
72
|
+
const serialized = `${JSON.stringify(config, null, 2)}\n`;
|
|
73
|
+
await atomicWrite(configPath, serialized);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function collectBundleFiles(dropRoot, relativeDir = "") {
|
|
77
|
+
const absoluteDir = relativeDir
|
|
78
|
+
? path.join(dropRoot, relativeDir)
|
|
79
|
+
: dropRoot;
|
|
80
|
+
const entries = await readdir(absoluteDir, { withFileTypes: true });
|
|
81
|
+
const files = [];
|
|
82
|
+
const directories = [];
|
|
83
|
+
for (const entry of entries) {
|
|
84
|
+
const relativePath = relativeDir
|
|
85
|
+
? `${relativeDir}/${entry.name}`
|
|
86
|
+
: entry.name;
|
|
87
|
+
if (relativeDir === "" && relativePath === CONFIG_FILE_NAME) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const absolutePath = path.join(dropRoot, relativePath);
|
|
91
|
+
if (entry.isDirectory()) {
|
|
92
|
+
directories.push(relativePath);
|
|
93
|
+
const nested = await collectBundleFiles(dropRoot, relativePath);
|
|
94
|
+
files.push(...nested.files);
|
|
95
|
+
directories.push(...nested.directories);
|
|
96
|
+
} else {
|
|
97
|
+
files.push({ relativePath, absolutePath });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return { files, directories };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function pruneEmptyDirectories(dropRoot, directories, expectedFolders) {
|
|
104
|
+
directories.sort((left, right) => right.length - left.length);
|
|
105
|
+
for (const relativeDir of directories) {
|
|
106
|
+
if (expectedFolders.has(relativeDir)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const absoluteDir = resolveInside(dropRoot, relativeDir);
|
|
110
|
+
if (!isInside(dropRoot, absoluteDir) || absoluteDir === dropRoot) {
|
|
111
|
+
throw new DropConfigError(`Unsafe folder path: ${relativeDir}`);
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
await rmdir(absoluteDir);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (error.code !== "ENOENT" && error.code !== "ENOTEMPTY") {
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export async function syncDropBundle(root, snapshot, config) {
|
|
124
|
+
const { directory: dropRoot } = dropPaths(root);
|
|
125
|
+
await mkdir(dropRoot, { recursive: true });
|
|
126
|
+
|
|
127
|
+
const existing = await collectBundleFiles(dropRoot);
|
|
128
|
+
const expected = new Set(snapshot.files.map((file) => file.path));
|
|
129
|
+
const expectedFolders = new Set(snapshot.folders);
|
|
130
|
+
|
|
131
|
+
for (const file of snapshot.files) {
|
|
132
|
+
const target = resolveInside(dropRoot, file.path);
|
|
133
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
134
|
+
await atomicWrite(target, file.content);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const folder of snapshot.folders) {
|
|
138
|
+
const target = resolveInside(dropRoot, folder);
|
|
139
|
+
if (!isInside(dropRoot, target)) {
|
|
140
|
+
throw new DropConfigError(`Unsafe folder path: ${folder}`);
|
|
141
|
+
}
|
|
142
|
+
await mkdir(target, { recursive: true });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
for (const file of existing.files) {
|
|
146
|
+
if (!expected.has(file.relativePath)) {
|
|
147
|
+
await rm(file.absolutePath, { force: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
await pruneEmptyDirectories(dropRoot, existing.directories, expectedFolders);
|
|
152
|
+
await writeConfig(root, config);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function incrementVersion(previousVersion) {
|
|
156
|
+
return Number.isSafeInteger(previousVersion) && previousVersion >= 0
|
|
157
|
+
? previousVersion + 1
|
|
158
|
+
: 1;
|
|
159
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const PACKAGE_NAME = "@micropue/drop-cli";
|
|
2
|
+
export const DEFAULT_API_BASE = "https://drop.micropue.com.cn/v1";
|
|
3
|
+
export const DROP_DIR_NAME = ".drop";
|
|
4
|
+
export const CONFIG_FILE_NAME = "drop.json";
|
|
5
|
+
export const IGNORE_FILE_NAME = ".drop-ignore";
|
|
6
|
+
export const CONFIG_SCHEMA_VERSION = 1;
|
|
7
|
+
export const NO_SOURCE_FILES_CODE = "no_source_files";
|
|
8
|
+
|
|
9
|
+
export const SUPPORTED_EXTENSIONS = new Set([".html", ".css", ".js"]);
|
|
10
|
+
|
|
11
|
+
export const LIMITS = Object.freeze({
|
|
12
|
+
files: 20,
|
|
13
|
+
fileBytes: 512 * 1024,
|
|
14
|
+
projectBytes: 1024 * 1024,
|
|
15
|
+
folders: 50,
|
|
16
|
+
pathLength: 120,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_INTERVAL_MS = 2_000;
|
|
20
|
+
export const MIN_INTERVAL_MS = 500;
|
|
21
|
+
export const DEFAULT_REQUEST_TIMEOUT_MS = 20_000;
|
|
22
|
+
export const MAX_REQUEST_TIMEOUT_MS = 120_000;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import { incrementVersion, syncDropBundle } from "./config.js";
|
|
4
|
+
import { remoteFiles, stripFileContent } from "./discovery.js";
|
|
5
|
+
import { DropApiError, DropConfigError } from "./errors.js";
|
|
6
|
+
import { metadataChanged } from "./runtime.js";
|
|
7
|
+
|
|
8
|
+
function uniqueMessage(snapshot, version, customMessage) {
|
|
9
|
+
if (customMessage) {
|
|
10
|
+
return customMessage;
|
|
11
|
+
}
|
|
12
|
+
return `DROP CLI · v${version} · ${snapshot.files.length} files`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function requiredPassword(settings, previous) {
|
|
16
|
+
if (settings.visibility !== "password") {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (settings.password) {
|
|
20
|
+
return settings.password;
|
|
21
|
+
}
|
|
22
|
+
if (!previous?.projectId || previous.visibility !== "password") {
|
|
23
|
+
throw new DropConfigError("A password is required for a protected site.", {
|
|
24
|
+
hint: "Pass --password, set DROP_PASSWORD, or use the interactive prompt.",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function resolvePassword(settings, previous) {
|
|
31
|
+
if (settings.visibility !== "password") {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const needsPassword =
|
|
35
|
+
!previous?.projectId ||
|
|
36
|
+
previous.visibility !== "password" ||
|
|
37
|
+
settings.explicitPassword;
|
|
38
|
+
if (!needsPassword) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const password =
|
|
42
|
+
settings.password ??
|
|
43
|
+
(process.env.DROP_PASSWORD?.trim() || undefined);
|
|
44
|
+
if (password === undefined) {
|
|
45
|
+
return requiredPassword(settings, previous);
|
|
46
|
+
}
|
|
47
|
+
if (password.length < 6 || password.length > 128) {
|
|
48
|
+
throw new DropConfigError("Site password must contain 6-128 characters.");
|
|
49
|
+
}
|
|
50
|
+
return password;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function metadataPayload(settings, previous) {
|
|
54
|
+
const payload = {};
|
|
55
|
+
if (previous.name !== settings.name) {
|
|
56
|
+
payload.name = settings.name;
|
|
57
|
+
}
|
|
58
|
+
if (previous.slug !== settings.slug) {
|
|
59
|
+
payload.slug = settings.slug;
|
|
60
|
+
}
|
|
61
|
+
if (previous.visibility !== settings.visibility) {
|
|
62
|
+
payload.visibility = settings.visibility;
|
|
63
|
+
}
|
|
64
|
+
return payload;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function retryOnRevisionConflict(operation, client, projectId, signal) {
|
|
68
|
+
try {
|
|
69
|
+
return await operation();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (!(error instanceof DropApiError) || error.status !== 412) {
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
const fresh = await client.getProject(projectId, { signal });
|
|
75
|
+
return operation(fresh.revision);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function nextConfig({
|
|
80
|
+
previous,
|
|
81
|
+
settings,
|
|
82
|
+
snapshot,
|
|
83
|
+
project,
|
|
84
|
+
deployment,
|
|
85
|
+
version,
|
|
86
|
+
contentChanged,
|
|
87
|
+
}) {
|
|
88
|
+
const now = new Date().toISOString();
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
schemaVersion: 1,
|
|
92
|
+
slug: project.slug,
|
|
93
|
+
name: project.name,
|
|
94
|
+
visibility: project.visibility,
|
|
95
|
+
projectId: project.id,
|
|
96
|
+
url: project.url,
|
|
97
|
+
revision: project.revision,
|
|
98
|
+
version,
|
|
99
|
+
contentHash: snapshot.hash,
|
|
100
|
+
files: stripFileContent(snapshot).files,
|
|
101
|
+
folders: snapshot.folders,
|
|
102
|
+
totalBytes: snapshot.totalBytes,
|
|
103
|
+
hasPassword: project.hasPassword ?? previous?.hasPassword ?? false,
|
|
104
|
+
enabled: project.enabled ?? previous?.enabled ?? true,
|
|
105
|
+
deploymentId: deployment?.id ?? previous?.deploymentId,
|
|
106
|
+
apiBase: settings.apiBase,
|
|
107
|
+
createdAt: previous?.createdAt ?? project.createdAt ?? now,
|
|
108
|
+
updatedAt: project.updatedAt ?? now,
|
|
109
|
+
deployedAt: contentChanged
|
|
110
|
+
? deployment?.createdAt ?? now
|
|
111
|
+
: previous?.deployedAt,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function publishSnapshot({
|
|
116
|
+
root,
|
|
117
|
+
config: previous,
|
|
118
|
+
settings,
|
|
119
|
+
snapshot,
|
|
120
|
+
client,
|
|
121
|
+
onProgress = () => {},
|
|
122
|
+
signal,
|
|
123
|
+
}) {
|
|
124
|
+
const password = resolvePassword(settings, previous);
|
|
125
|
+
const contentChanged =
|
|
126
|
+
settings.force ||
|
|
127
|
+
!previous?.projectId ||
|
|
128
|
+
previous.contentHash !== snapshot.hash;
|
|
129
|
+
const metadataIsChanged = metadataChanged(previous, settings);
|
|
130
|
+
|
|
131
|
+
if (!contentChanged && !metadataIsChanged) {
|
|
132
|
+
return {
|
|
133
|
+
changed: false,
|
|
134
|
+
metadataChanged: false,
|
|
135
|
+
created: false,
|
|
136
|
+
config: previous,
|
|
137
|
+
snapshot,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const version = previous?.projectId
|
|
142
|
+
? incrementVersion(previous.version)
|
|
143
|
+
: 1;
|
|
144
|
+
let project;
|
|
145
|
+
let deployment;
|
|
146
|
+
let created = false;
|
|
147
|
+
|
|
148
|
+
if (!previous?.projectId) {
|
|
149
|
+
onProgress(`Creating project ${settings.slug} · ${snapshot.files.length} files`);
|
|
150
|
+
const payload = {
|
|
151
|
+
name: settings.name,
|
|
152
|
+
slug: settings.slug,
|
|
153
|
+
visibility: settings.visibility,
|
|
154
|
+
enabled: true,
|
|
155
|
+
files: remoteFiles(snapshot),
|
|
156
|
+
folders: snapshot.folders,
|
|
157
|
+
message: uniqueMessage(snapshot, version, settings.message),
|
|
158
|
+
};
|
|
159
|
+
if (password) {
|
|
160
|
+
payload.password = password;
|
|
161
|
+
}
|
|
162
|
+
const response = await client.createProject(payload, {
|
|
163
|
+
idempotencyKey: randomUUID(),
|
|
164
|
+
signal,
|
|
165
|
+
});
|
|
166
|
+
project = response.project;
|
|
167
|
+
deployment = response.deployment;
|
|
168
|
+
created = true;
|
|
169
|
+
} else {
|
|
170
|
+
project = {
|
|
171
|
+
id: previous.projectId,
|
|
172
|
+
slug: previous.slug,
|
|
173
|
+
name: previous.name,
|
|
174
|
+
visibility: previous.visibility,
|
|
175
|
+
url: previous.url,
|
|
176
|
+
revision: previous.revision,
|
|
177
|
+
hasPassword: previous.hasPassword,
|
|
178
|
+
enabled: previous.enabled,
|
|
179
|
+
createdAt: previous.createdAt,
|
|
180
|
+
updatedAt: previous.updatedAt,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
if (contentChanged) {
|
|
184
|
+
onProgress(
|
|
185
|
+
`Publishing v${version} · ${snapshot.files.length} files · ${snapshot.totalBytes} bytes`,
|
|
186
|
+
);
|
|
187
|
+
const payload = {
|
|
188
|
+
files: remoteFiles(snapshot),
|
|
189
|
+
folders: snapshot.folders,
|
|
190
|
+
message: uniqueMessage(snapshot, version, settings.message),
|
|
191
|
+
};
|
|
192
|
+
const response = await retryOnRevisionConflict(
|
|
193
|
+
(revision = project.revision) =>
|
|
194
|
+
client.deployProject(previous.projectId, payload, {
|
|
195
|
+
revision,
|
|
196
|
+
idempotencyKey: randomUUID(),
|
|
197
|
+
signal,
|
|
198
|
+
}),
|
|
199
|
+
client,
|
|
200
|
+
previous.projectId,
|
|
201
|
+
signal,
|
|
202
|
+
);
|
|
203
|
+
project = response.project;
|
|
204
|
+
deployment = response.deployment;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const metadata = metadataPayload(settings, project);
|
|
208
|
+
if (password) {
|
|
209
|
+
metadata.password = password;
|
|
210
|
+
}
|
|
211
|
+
if (Object.keys(metadata).length > 0) {
|
|
212
|
+
onProgress(`Updating project metadata`);
|
|
213
|
+
project = await retryOnRevisionConflict(
|
|
214
|
+
(revision = project.revision) =>
|
|
215
|
+
client.updateProject(previous.projectId, metadata, {
|
|
216
|
+
revision,
|
|
217
|
+
idempotencyKey: randomUUID(),
|
|
218
|
+
signal,
|
|
219
|
+
}),
|
|
220
|
+
client,
|
|
221
|
+
previous.projectId,
|
|
222
|
+
signal,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const config = nextConfig({
|
|
228
|
+
previous,
|
|
229
|
+
settings,
|
|
230
|
+
snapshot,
|
|
231
|
+
project,
|
|
232
|
+
deployment,
|
|
233
|
+
version,
|
|
234
|
+
contentChanged,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
await syncDropBundle(root, snapshot, config);
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
changed: contentChanged,
|
|
241
|
+
metadataChanged: metadataIsChanged,
|
|
242
|
+
created,
|
|
243
|
+
config,
|
|
244
|
+
snapshot,
|
|
245
|
+
project,
|
|
246
|
+
deployment,
|
|
247
|
+
};
|
|
248
|
+
}
|