-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from Serverless-Devs/develop
pre 0.1.42
- Loading branch information
Showing
16 changed files
with
1,665 additions
and
1,478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ALIYUN_CLI } from './constant'; | ||
import { getCredential, getCredentialFromEnv } from './credential'; | ||
import path from 'path'; | ||
import { getRootHome, getYamlContent } from '../libs'; | ||
import { get } from 'lodash'; | ||
|
||
const getAccountByAccess = async (access: string) => { | ||
if (!access) return; | ||
if (access === ALIYUN_CLI) { | ||
return await getCredential(access); | ||
} | ||
const accessPath = path.join(getRootHome(), 'access.yaml'); | ||
const data = await getYamlContent(accessPath); | ||
|
||
let credentials; | ||
// 密钥存在 才去获取密钥信息 | ||
if (get(data, access)) { | ||
credentials = await getCredential(access); | ||
} | ||
const accessFromEnv = await getCredentialFromEnv(access); | ||
if (accessFromEnv) { | ||
credentials = accessFromEnv; | ||
} | ||
return credentials; | ||
}; | ||
|
||
export default getAccountByAccess; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
DEFAULT_CORE_VERSION: '0.1.41', | ||
DEFAULT_CORE_VERSION: '0.1.42', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const { | ||
got, | ||
isDocker, | ||
getCicdEnv, | ||
getRootHome, | ||
getCommand, | ||
lodash: _, | ||
getAccountByAccess, | ||
getYamlContent, | ||
} = require('../index'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
async function init() { | ||
const { CLI_VERSION, syaml } = process.env; | ||
const core_version = await getCoreVersion(); | ||
const os = getCicdEnv() || process.platform; | ||
const node_version = process.version; | ||
const baseURL = 'http://cn-tracker.cn-heyuan.log.aliyuncs.com/logstores/serverless-devs/track'; | ||
let url = `${baseURL}?APIVersion=0.6.0&cli_version=${CLI_VERSION}&core_version=${core_version}&node_version=${node_version}&os=${os}&isDocker=${isDocker()}&trackerType=command`; | ||
if (getCommand()) { | ||
url = `${url}&trackerName=${getCommand()}`; | ||
} | ||
const mainUid = await getMainUid(syaml); | ||
if (mainUid) { | ||
url = `${url}&mainUid=${mainUid}`; | ||
} | ||
await got(url, { timeout: 3000 }); | ||
} | ||
|
||
function getCoreVersion() { | ||
const corePath = path.join(getRootHome(), 'cache', 'core', 'package.json'); | ||
return fs.existsSync(corePath) ? require(corePath).version : 'unknown'; | ||
} | ||
|
||
async function getMainUid(syaml) { | ||
try { | ||
const data = await getYamlContent(syaml); | ||
if (_.get(data, 'access')) { | ||
const credentials = await getAccountByAccess(data.access); | ||
return credentials.AccountID; | ||
} | ||
} catch (error) {} | ||
} | ||
|
||
(async () => { | ||
await init(); | ||
process.exit(); | ||
})().catch(() => { | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.