Unverified Commit f414718a authored by heimanba's avatar heimanba Committed by GitHub
Browse files

Merge pull request #394 from Serverless-Devs/develop

develop
Showing with 22 additions and 42 deletions
+22 -42
{
"name": "@serverless-devs/s",
"version": "2.0.97",
"version": "2.0.98",
"description": "Serverless devs tool, serverless developer tool, supports Alibaba cloud, AWS, azure, baidu cloud, Huawei cloud, Google cloud and Tencent cloud.",
"homepage": "https://www.serverless-devs.com",
"keywords": [
......
......@@ -83,53 +83,34 @@ program
if (AccountID) {
keyInformation['AccountID'] = AccountID;
}
const akRegx = /^[A-Za-z0-9-]+$/;
if (AccessKeyID) {
if (akRegx.test(AccessKeyID)) {
keyInformation['AccessKeyID'] = AccessKeyID;
} else {
new HumanError({
errorMessage: 'Your AccessKeyID id is not correct.',
tips: `Please check if your AccessKeyID is correct. documents: ${colors.underline(
'https://github.com/Serverless-Devs/Serverless-Devs/blob/master/docs/zh/default_provider_config/alibabacloud.md',
)}`,
});
process.exit(1);
}
keyInformation['AccessKeyID'] = AccessKeyID;
}
if (AccessKeySecret) {
if (akRegx.test(AccessKeySecret)) {
keyInformation['AccessKeySecret'] = AccessKeySecret;
} else {
new HumanError({
errorMessage: 'Your AccessKeySecret id is not correct.',
tips: `Please check if your AccessKeySecret is correct. documents: ${colors.underline(
'https://github.com/Serverless-Devs/Serverless-Devs/blob/master/docs/zh/default_provider_config/alibabacloud.md',
)}`,
});
process.exit(1);
}
keyInformation['AccessKeySecret'] = AccessKeySecret;
}
if (SecurityToken) {
keyInformation['SecurityToken'] = SecurityToken;
}
// 同时存在ak/sk 认为是阿里云密钥
if (AccessKeyID && AccessKeySecret && !f) {
if (AccessKeyID && AccessKeySecret) {
try {
const data = await getAccountId({ AccessKeyID, AccessKeySecret });
const data = await getAccountId({ AccessKeyID, AccessKeySecret, SecurityToken });
keyInformation['AccountID'] = data.AccountId;
} catch (error) {
new HumanWarning({
warningMessage: 'You may be configuring an incorrect Alibaba Cloud SecretKey.',
tips: `Please check the accuracy of Alibaba Cloud SecretKey. If your configuration is not an Alibaba Cloud SecretKey, you can force writing by adding the -f parameter. Or execute ${chalk.yellow(
`${getCommand()} -f`,
)}`,
});
process.exit(1);
if (!f) {
new HumanWarning({
warningMessage: 'You may be configuring an incorrect Alibaba Cloud SecretKey.',
tips: `Please check the accuracy of Alibaba Cloud SecretKey. If your configuration is not an Alibaba Cloud SecretKey, you can force writing by adding the -f parameter. Or execute ${chalk.yellow(
`${getCommand()} -f`,
)}`,
});
process.exit(1);
}
}
}
if (SecurityToken) {
keyInformation['SecurityToken'] = SecurityToken;
}
if (SecretAccessKey) {
keyInformation['SecretAccessKey'] = SecretAccessKey;
}
......
......@@ -40,7 +40,7 @@ export const HandleError = async (configs: IConfigs) => {
}
console.log(colors.gray("You can run 's clean --all' to clean Serverless devs."));
if(traceId && catchableError) {
if(traceId && !catchableError) {
await report({
type: 'jsError',
content: `${error.message}||${error.stack}`,
......
......@@ -79,6 +79,7 @@ const descption = {
const helperLength = publishHelp.maxLen(descption.Options);
(async () => {
process.env['CLI_VERSION'] = pkg.version;
registerCommandChecker(program);
const system_command = program
.helpOption('-h, --help', `Display help for command.`)
......@@ -107,8 +108,6 @@ const helperLength = publishHelp.maxLen(descption.Options);
);
});
process.env['CLI_VERSION'] = pkg.version;
// 将参数存储到env
process.env['serverless_devs_temp_argv'] = JSON.stringify(process.argv);
......
......@@ -131,7 +131,7 @@ export class InitManager {
console.log(`${emoji('👉')} You could [cd ${appPath}] and enjoy your serverless journey!`);
console.log(`${emoji('🧭️')} If you need help for this example, you can use [s -h] after you enter folder.`);
console.log(
`${emoji('💞')} Document ❤ Star` +
`${emoji('💞')} Document ❤ Star:` +
colors.cyan.underline('https://github.com/Serverless-Devs/Serverless-Devs' + '\n'),
);
}
......@@ -158,7 +158,7 @@ export class InitManager {
console.log(`${emoji('👉')} You could [cd ${appPath}] and enjoy your serverless journey!`);
console.log(`${emoji('🧭️')} If you need help for this example, you can use [s -h] after you enter folder.`);
console.log(
`${emoji('💞')} Document ❤ Star` +
`${emoji('💞')} Document ❤ Star:` +
colors.cyan.underline('https://github.com/Serverless-Devs/Serverless-Devs' + '\n'),
);
}
......
......@@ -61,7 +61,7 @@ export const getErrorMessage = async (error: Error, prefix) => {
} catch (error) {}
if(jsonMsg && jsonMsg.tips) {
const messageStr = `Message: ${jsonMsg.message}\n` || '';
const messageStr = jsonMsg.message ? `Message: ${jsonMsg.message}\n` : '';
const tipsStr = jsonMsg.tips ? `* ${makeUnderLine(jsonMsg.tips.replace(/\n/, "\n* "))}` : '';
Logger.log(`\n${colors.hex('#000').bgYellow('WARNING:')}\n======================\n${tipsStr}\n`, 'yellow');
console.log(colors.grey(messageStr));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment