build-plugin-teamix
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -13,25 +13,35 @@ const fs = require('fs'); | ||
compiler.hooks.afterEmit.tap('AssetsInfoPlugin', async () => { | ||
const { assetsPath = '' } = this.options; | ||
const gitDir = path.join(process.cwd(), '.git'); | ||
if (!fs.existsSync(gitDir)) { | ||
return; | ||
} | ||
const url = await gitRemoteOriginUrl() || ''; | ||
let repo = ''; | ||
if (url) { | ||
const repoInfo = url.split(':'); | ||
if (repoInfo && repoInfo[1]) { | ||
repo = repoInfo[1].replace('.git', ''); | ||
const { BUILD_GIT_GROUP, BUILD_GIT_PROJECT, BUILD_GIT_COMMITID, BUILD_GIT_BRANCH, BUILD_ENV } = process.env; | ||
let repoInfo; | ||
let repo; | ||
if (BUILD_ENV === 'cloud') { | ||
repoInfo = { | ||
branch: BUILD_GIT_BRANCH, | ||
commitId: BUILD_GIT_COMMITID, | ||
}; | ||
repo = `${BUILD_GIT_GROUP}/${BUILD_GIT_PROJECT}`; | ||
} else { | ||
const { assetsPath = '' } = this.options; | ||
const gitDir = path.join(process.cwd(), '.git'); | ||
if (!fs.existsSync(gitDir)) { | ||
return; | ||
} | ||
const url = await gitRemoteOriginUrl() || ''; | ||
if (url) { | ||
const repoInfo = url.split(':'); | ||
if (repoInfo && repoInfo[1]) { | ||
repo = repoInfo[1].replace('.git', ''); | ||
} | ||
} | ||
if (!repo) { | ||
return; | ||
} | ||
const HEAD = fs.readFileSync(path.join(gitDir, 'HEAD'), { encoding: 'utf-8' }); | ||
const currentBranch = HEAD.replace('ref: refs/heads/', '').replace(os.EOL, ''); | ||
const commitId = fs.readFileSync(path.join(gitDir, HEAD.replace('ref: ', '').replace(os.EOL, '')), { encoding: 'utf-8' }).replace(os.EOL, ''); | ||
repoInfo = { | ||
branch: currentBranch, | ||
commitId, | ||
}; | ||
} | ||
if (!repo) { | ||
return; | ||
} | ||
const HEAD = fs.readFileSync(path.join(gitDir, 'HEAD'), { encoding: 'utf-8' }); | ||
const currentBranch = HEAD.replace('ref: refs/heads/', '').replace(os.EOL, ''); | ||
const commitId = fs.readFileSync(path.join(gitDir, HEAD.replace('ref: ', '').replace(os.EOL, '')), { encoding: 'utf-8' }).replace(os.EOL, ''); | ||
const repoInfo = { | ||
branch: currentBranch, | ||
commitId, | ||
}; | ||
const snippet = `;if(!window.__assets_info__){window.__assets_info__={};}window.__assets_info__['${repo}']=${JSON.stringify(repoInfo)};`; | ||
@@ -50,3 +60,7 @@ const appendConent = dir => { | ||
} | ||
appendConent(assetsPath); | ||
if (process.env.BUILD_ENV === 'cloud') { | ||
appendConent(process.evn.BUILD_DEST_ABSOLUTE); | ||
} else { | ||
appendConent(assetsPath); | ||
} | ||
}); | ||
@@ -53,0 +67,0 @@ } |
{ | ||
"name": "build-plugin-teamix", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "build-scripts 插件, 适配teamix基础工程", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
6776
174
5