tthr 0.0.36 → 0.0.38
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/index.js +41 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -93,24 +93,38 @@ async function deploySchemaToServer(projectId, token, schemaPath, environment, d
|
|
|
93
93
|
}
|
|
94
94
|
spinner.text = "Deploying schema...";
|
|
95
95
|
const envPath = environment !== "production" ? `/env/${environment}` : "";
|
|
96
|
-
const
|
|
96
|
+
const schemaUrl = `${API_URL}/projects/${projectId}${envPath}/deploy/schema`;
|
|
97
|
+
console.log(chalk.dim(`
|
|
98
|
+
URL: ${schemaUrl}`));
|
|
99
|
+
const requestBody = {
|
|
100
|
+
sql,
|
|
101
|
+
tables: tables.map((t) => ({
|
|
102
|
+
name: t.name,
|
|
103
|
+
source: t.source,
|
|
104
|
+
columns: t.columns
|
|
105
|
+
}))
|
|
106
|
+
};
|
|
107
|
+
const response = await fetch(schemaUrl, {
|
|
97
108
|
method: "POST",
|
|
98
109
|
headers: {
|
|
99
110
|
"Content-Type": "application/json",
|
|
100
111
|
"Authorization": `Bearer ${token}`
|
|
101
112
|
},
|
|
102
|
-
body: JSON.stringify(
|
|
103
|
-
sql,
|
|
104
|
-
tables: tables.map((t) => ({
|
|
105
|
-
name: t.name,
|
|
106
|
-
source: t.source,
|
|
107
|
-
columns: t.columns
|
|
108
|
-
}))
|
|
109
|
-
})
|
|
113
|
+
body: JSON.stringify(requestBody)
|
|
110
114
|
});
|
|
115
|
+
console.log(chalk.dim(` Response: ${response.status} ${response.statusText}`));
|
|
116
|
+
console.log(chalk.dim(` Content-Type: ${response.headers.get("content-type")}`));
|
|
111
117
|
if (!response.ok) {
|
|
112
|
-
const
|
|
113
|
-
|
|
118
|
+
const text = await response.text();
|
|
119
|
+
console.log(chalk.dim(` Body: ${text.slice(0, 500)}`));
|
|
120
|
+
let errorMessage;
|
|
121
|
+
try {
|
|
122
|
+
const error = JSON.parse(text);
|
|
123
|
+
errorMessage = error.error || `HTTP ${response.status}`;
|
|
124
|
+
} catch {
|
|
125
|
+
errorMessage = text || `HTTP ${response.status}: ${response.statusText}`;
|
|
126
|
+
}
|
|
127
|
+
throw new Error(errorMessage);
|
|
114
128
|
}
|
|
115
129
|
spinner.succeed(`Schema deployed (${tables.length} table(s))`);
|
|
116
130
|
} catch (error) {
|
|
@@ -153,7 +167,10 @@ async function deployFunctionsToServer(projectId, token, functionsDir, environme
|
|
|
153
167
|
}
|
|
154
168
|
spinner.text = "Deploying functions...";
|
|
155
169
|
const envPath = environment !== "production" ? `/env/${environment}` : "";
|
|
156
|
-
const
|
|
170
|
+
const functionsUrl = `${API_URL}/projects/${projectId}${envPath}/deploy/functions`;
|
|
171
|
+
console.log(chalk.dim(`
|
|
172
|
+
URL: ${functionsUrl}`));
|
|
173
|
+
const response = await fetch(functionsUrl, {
|
|
157
174
|
method: "POST",
|
|
158
175
|
headers: {
|
|
159
176
|
"Content-Type": "application/json",
|
|
@@ -167,9 +184,19 @@ async function deployFunctionsToServer(projectId, token, functionsDir, environme
|
|
|
167
184
|
}))
|
|
168
185
|
})
|
|
169
186
|
});
|
|
187
|
+
console.log(chalk.dim(` Response: ${response.status} ${response.statusText}`));
|
|
188
|
+
console.log(chalk.dim(` Content-Type: ${response.headers.get("content-type")}`));
|
|
170
189
|
if (!response.ok) {
|
|
171
|
-
const
|
|
172
|
-
|
|
190
|
+
const text = await response.text();
|
|
191
|
+
console.log(chalk.dim(` Body: ${text.slice(0, 500)}`));
|
|
192
|
+
let errorMessage;
|
|
193
|
+
try {
|
|
194
|
+
const error = JSON.parse(text);
|
|
195
|
+
errorMessage = error.error || `HTTP ${response.status}`;
|
|
196
|
+
} catch {
|
|
197
|
+
errorMessage = text || `HTTP ${response.status}: ${response.statusText}`;
|
|
198
|
+
}
|
|
199
|
+
throw new Error(errorMessage);
|
|
173
200
|
}
|
|
174
201
|
spinner.succeed(`Functions deployed (${functions.length} function(s))`);
|
|
175
202
|
const queries = functions.filter((f) => f.type === "query");
|