Log SpacetimeDB database names in Jenkins deploy
Some checks failed
CI / verify (push) Has been cancelled
Some checks failed
CI / verify (push) Has been cancelled
This commit is contained in:
@@ -85,6 +85,7 @@ export function buildSpacetimeCallArgs(options, procedureName, input) {
|
||||
if (!options.database) {
|
||||
throw new Error('必须传入 --database。');
|
||||
}
|
||||
validateSpacetimeDatabaseName(options.database);
|
||||
|
||||
const args = [];
|
||||
if (options.rootDir) {
|
||||
@@ -108,6 +109,7 @@ export async function callSpacetimeProcedure(options, procedureName, input) {
|
||||
if (!options.database) {
|
||||
throw new Error('必须传入 --database,或设置 GENARRATIVE_SPACETIME_DATABASE。');
|
||||
}
|
||||
validateSpacetimeDatabaseName(options.database);
|
||||
|
||||
const serverUrl = resolveServerUrl(options).replace(/\/+$/u, '');
|
||||
const url = `${serverUrl}/v1/database/${encodeURIComponent(options.database)}/call/${encodeURIComponent(procedureName)}`;
|
||||
@@ -195,6 +197,14 @@ export async function callSpacetimeProcedureViaCli(options, procedureName, input
|
||||
return parseProcedureResult(output);
|
||||
}
|
||||
|
||||
export function validateSpacetimeDatabaseName(database) {
|
||||
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/u.test(database)) {
|
||||
throw new Error(
|
||||
`SpacetimeDB 数据库名必须匹配 ^[a-z0-9]+(-[a-z0-9]+)*$,只能使用小写字母、数字,并用单个短横线分隔: ${database}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function parseProcedureResult(output) {
|
||||
const candidates = [];
|
||||
const trimmed = output.trim();
|
||||
|
||||
Reference in New Issue
Block a user