()
| 83 | |
| 84 | // 创建KV namespace |
| 85 | function 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文件 |
| 108 | function updateWranglerConfig(kvNamespaceId) { |
no test coverage detected