Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 06c33a8

Browse files
committed
fix init error
1 parent 93fa742 commit 06c33a8

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

lib/commands/init.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ commander_1.default
6363
}
6464
loading.stop();
6565
const envs = envData
66-
.map(item => `${item.Alias} - [${item.EnvId}:${item.PackageName}]`)
66+
.map(item => ({
67+
name: `${item.Alias} - [${item.EnvId}:${item.PackageName}]`,
68+
value: item.EnvId
69+
}))
6770
.sort();
6871
if (!envs.length) {
6972
throw new error_1.CloudBaseError('没有可以使用的环境,请先开通云开发服务并创建环境(https://console.cloud.tencent.com/tcb)');
@@ -129,7 +132,7 @@ commander_1.default
129132
return;
130133
}
131134
const configContent = fs_1.default.readFileSync(configFilePath).toString();
132-
fs_1.default.writeFileSync(configFilePath, configContent.replace('{{envId}}', env.split(':')[0]));
135+
fs_1.default.writeFileSync(configFilePath, configContent.replace('{{envId}}', env));
133136
logger_1.successLog(`创建项目 ${projectName} 成功!\n`);
134137
console.log('🎉 欢迎贡献你的模板 👉 https://github.com/TencentCloudBase/cloudbase-examples');
135138
});

src/commands/init.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ program
5858
throw e
5959
}
6060
loading.stop()
61-
const envs: string[] = envData
62-
.map(item => `${item.Alias} - [${item.EnvId}:${item.PackageName}]`)
61+
const envs: { name: string; value: string }[] = envData
62+
.map(item => ({
63+
name: `${item.Alias} - [${item.EnvId}:${item.PackageName}]`,
64+
value: item.EnvId
65+
}))
6366
.sort()
6467

6568
if (!envs.length) {
@@ -159,7 +162,7 @@ program
159162

160163
fs.writeFileSync(
161164
configFilePath,
162-
configContent.replace('{{envId}}', env.split(':')[0])
165+
configContent.replace('{{envId}}', env)
163166
)
164167

165168
successLog(`创建项目 ${projectName} 成功!\n`)

0 commit comments

Comments
 (0)