MCPcopy Create free account
hub / github.com/cfwuya1/sublink-worker-admin / createKvNamespace

Function createKvNamespace

scripts/setup-kv.js:85–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83
84// 创建KV namespace
85function createKvNamespace() {
86 console.log(`创建KV namespace "${KV_NAMESPACE_NAME}"...`);
87 const output = runWranglerCommand(`kv namespace create "${KV_NAMESPACE}"`);
88
89 try {
90 // 尝试从输出中提取ID
91 const idMatch = output.match(/id\s*=\s*"([^"]+)"/);
92 if (idMatch) {
93 return {
94 title: KV_NAMESPACE_NAME,
95 id: idMatch[1]
96 };
97 } else {
98 throw new Error('无法从输出中提取KV namespace ID');
99 }
100 } catch (error) {
101 console.error('解析创建KV namespace结果失败:', error.message);
102 console.error('原始输出:', output);
103 process.exit(1);
104 }
105}
106
107// 更新wrangler.toml文件
108function updateWranglerConfig(kvNamespaceId) {

Callers 1

mainFunction · 0.85

Calls 1

runWranglerCommandFunction · 0.85

Tested by

no test coverage detected