-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
274 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# Using the official mirror source | ||
registry "https://registry.yarnpkg.com" | ||
node-sass:registry "https://registry.npm.taobao.org/" | ||
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/" |
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
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.
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,59 @@ | ||
import path from 'path'; | ||
import chalk from 'chalk'; | ||
import fs from 'fs'; | ||
import title from './utils/printTitle'; | ||
|
||
const Minio = require('minio'); | ||
|
||
export default async (cwd: string) => { | ||
const minioClient = new Minio.Client({ | ||
endPoint: '172.16.6.51', | ||
port: 9000, | ||
useSSL: false, | ||
accessKey: 'www.winning.com.cn', | ||
secretKey: 'www.winning.com.cn', | ||
}); | ||
const pkg = require(`${cwd}/package.json`); | ||
|
||
const metaData = { | ||
'Content-Type': 'application/octet-stream', | ||
'X-Amz-Meta-Testing': 1234, | ||
example: 5678, | ||
}; | ||
|
||
// 递归上传dist下对应当前版本的所有打包产物到minio | ||
const domainName = pkg.name.split('/')[1].split('-')[0]; | ||
const filepath = `materials-umd-lib/${domainName}/${pkg.name}/${pkg.version}/`; | ||
const fileDir = `${cwd}/dist/${pkg.version}/`; | ||
|
||
const classifyFiles = (filepath: string, dir: string) => { | ||
fs.readdir(dir, (err, files) => { | ||
files.forEach(filename => { | ||
let filedir = path.join(dir, filename); | ||
fs.stat(filedir, (err, stats) => { | ||
if (!err) { | ||
let isFile = stats.isFile(); //是文件 | ||
if (isFile) { | ||
upload(`${filepath}${filename}`, `${dir}${filename}`); | ||
} else { | ||
classifyFiles(`${filepath}${filename}/`, `${dir}${filename}/`); | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
// 上传方法 | ||
const upload = (filepath: string, files: string) => { | ||
minioClient.fPutObject('winex', filepath, files, metaData, function( | ||
err: any, | ||
) { | ||
if (err) { | ||
console.log(chalk.red('upload fail', err)); | ||
} | ||
}); | ||
}; | ||
|
||
classifyFiles(filepath, fileDir); | ||
title('success', 'UPLOAD', 'Uploaded successfully '); | ||
}; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import chalk from 'chalk'; | ||
|
||
function capitalizeFirstLetter(string: string) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
|
||
function textColor(severity: string) { | ||
switch (severity.toLowerCase()) { | ||
case 'success': | ||
return 'green'; | ||
case 'info': | ||
return 'blue'; | ||
case 'note': | ||
return 'white'; | ||
case 'warning': | ||
return 'yellow'; | ||
case 'error': | ||
return 'red'; | ||
default: | ||
return 'red'; | ||
} | ||
} | ||
|
||
function bgColor(severity: string) { | ||
const color = textColor(severity); | ||
return 'bg' + capitalizeFirstLetter(color); | ||
} | ||
|
||
function formatTitle(severity: string, message: string) { | ||
return chalk[bgColor(severity)].black('', message, ''); | ||
} | ||
|
||
function formatText(severity: string, message: string) { | ||
return chalk[textColor(severity)](message); | ||
} | ||
|
||
export default function title( | ||
severity: string, | ||
title: string, | ||
subtitle: string, | ||
) { | ||
const date = new Date(); | ||
const dateString = chalk.grey(date.toLocaleTimeString()); | ||
const titleFormatted = formatTitle(severity, title); | ||
const subTitleFormatted = formatText(severity, subtitle); | ||
const message = `${titleFormatted} ${subTitleFormatted}`; | ||
|
||
// In test environment we don't include timestamp | ||
if (process.env.NODE_ENV === 'test') { | ||
console.log(message); | ||
console.log(); | ||
return; | ||
} | ||
|
||
// // Make timestamp appear at the end of the line | ||
// let logSpace = | ||
// // process.stdout.columns - stringWidth(message) - stringWidth(dateString); | ||
// if (logSpace <= 0) { | ||
// logSpace = 10; | ||
// } | ||
|
||
console.log(`${message}${dateString}`); | ||
console.log(); | ||
} |
Oops, something went wrong.