Skip to content

Commit

Permalink
Merge pull request #85 from Serverless-Devs/develop
Browse files Browse the repository at this point in the history
pre 0.1.43
  • Loading branch information
xsahxl authored Jul 4, 2022
2 parents bb14bca + 773356a commit a90ab73
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/core",
"version": "0.1.42",
"version": "0.1.43",
"description": "Serverless Devs Tool Core Component",
"keywords": [
"Serverless",
Expand Down
2 changes: 1 addition & 1 deletion publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Type: Component
Name: core
Provider:
- 阿里云
Version: 0.1.42
Version: 0.1.43
Description: Serverless Devs 核心组件
HomePage: https://github.com/Serverless-Devs/core
Tags: #标签详情
Expand Down
4 changes: 2 additions & 2 deletions src/common/execCommand/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ExecCommand {
makeLogFile();
}
async init() {
const { syaml, serverName } = this.configs;
const { syaml, serverName, globalArgs = {} } = this.configs;
const originSpath = await getTemplatePath(syaml);
const spath = await transforYamlPath(originSpath);
this.parse = new Parse(spath);
Expand All @@ -45,7 +45,7 @@ class ExecCommand {
const executeOrderList = analysis.getProjectOrder();
// 私有化部署不在进行上报数据
if (!useLocal()) {
execDaemon('reportTracker.js', { syaml: spath });
execDaemon('reportTracker.js', { syaml: spath, access: globalArgs.access });
}
// 只有一个服务,或者指定服务操作
if (executeOrderList.length === 1 || serverName) {
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/constant.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
DEFAULT_CORE_VERSION: '0.1.42',
DEFAULT_CORE_VERSION: '0.1.43',
};
16 changes: 10 additions & 6 deletions src/daemon/reportTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');
const fs = require('fs');

async function init() {
const { CLI_VERSION, syaml } = process.env;
const { CLI_VERSION, access, syaml } = process.env;
const core_version = await getCoreVersion();
const os = getCicdEnv() || process.platform;
const node_version = process.version;
Expand All @@ -21,7 +21,7 @@ async function init() {
if (getCommand()) {
url = `${url}&trackerName=${getCommand()}`;
}
const mainUid = await getMainUid(syaml);
const mainUid = await getMainUid(access, syaml);
if (mainUid) {
url = `${url}&mainUid=${mainUid}`;
}
Expand All @@ -33,11 +33,15 @@ function getCoreVersion() {
return fs.existsSync(corePath) ? require(corePath).version : 'unknown';
}

async function getMainUid(syaml) {
async function getMainUid(access, syaml) {
try {
const data = await getYamlContent(syaml);
if (_.get(data, 'access')) {
const credentials = await getAccountByAccess(data.access);
let newAccess = access;
if (_.isEmpty(newAccess)) {
const data = await getYamlContent(syaml);
newAccess = _.get(data, 'access');
}
if (newAccess) {
const credentials = await getAccountByAccess(newAccess);
return credentials.AccountID;
}
} catch (error) {}
Expand Down
9 changes: 8 additions & 1 deletion src/libs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { includes } from 'lodash';
import getYamlContent from './getYamlContent';
import getMAC from 'getmac';
import yaml from 'js-yaml';
import _ from 'lodash';

const semver = require('semver');

Expand All @@ -23,6 +24,9 @@ export const isDebugMode = () => {

// s工具的家目录
export function getCicdEnv() {
if (process.env.HOME === '/kaniko' && process.env.BUILD_IMAGE_ENV === 'fc-backend') {
return 'app_center';
}
for (const key in process.env) {
if (key.startsWith('CLOUDSHELL')) return 'cloud_shell';
if (key.startsWith('PIPELINE')) return 'yunxiao';
Expand All @@ -33,7 +37,10 @@ export function getCicdEnv() {
}

export function isCiCdEnv() {
return includes(['cloud_shell', 'yunxiao', 'github', 'gitlab', 'jenkins'], getCicdEnv());
return includes(
['app_center', 'cloud_shell', 'yunxiao', 'github', 'gitlab', 'jenkins'],
getCicdEnv(),
);
}

export function useLocal() {
Expand Down

0 comments on commit a90ab73

Please sign in to comment.