Commit 6a2f8aed authored by likely's avatar likely

step2

parent d56c563f
...@@ -4,6 +4,9 @@ const gulpClean = require('gulp-clean') ...@@ -4,6 +4,9 @@ const gulpClean = require('gulp-clean')
const gulpLess = require('gulp-less') const gulpLess = require('gulp-less')
const gulpRev = require('gulp-rev') const gulpRev = require('gulp-rev')
const gulpRevreplace = require('gulp-rev-replace') const gulpRevreplace = require('gulp-rev-replace')
const gulpUglify = require('gulp-uglify')
const gulpCsso = require('gulp-csso')
const pump = require('pump')
const browserSync = require('browser-sync').create() const browserSync = require('browser-sync').create()
const runSequence = require('run-sequence') const runSequence = require('run-sequence')
const rollup = require('rollup') const rollup = require('rollup')
...@@ -14,6 +17,7 @@ const TuiaAutoUpload = require('tuia-auto-upload') ...@@ -14,6 +17,7 @@ const TuiaAutoUpload = require('tuia-auto-upload')
const pluginDir = './src/' // 插件库目录 const pluginDir = './src/' // 插件库目录
const outputPath = './dist/' const outputPath = './dist/'
const tmpPath = './.tmp/' const tmpPath = './.tmp/'
const uploadPath = '/jimu-web/plugin/'
let pluginName let pluginName
let pluginPath let pluginPath
...@@ -87,36 +91,43 @@ gulp.task('bundle', ['bundle:init'], cb => { ...@@ -87,36 +91,43 @@ gulp.task('bundle', ['bundle:init'], cb => {
// bundle rev // bundle rev
gulp.task('bundle:rev', cb => { gulp.task('bundle:rev', cb => {
return gulp.src([`${outputPath}**/*`, `!${outputPath}index.html`, `!${outputPath}/**/*.js.map`]) return gulp.src([`${outputPath}**/*`, `!${outputPath}/**/*.js.map`, `!${outputPath}index.html`])
.pipe(gulpRev()) .pipe(gulpRev())
.pipe(gulp.dest(tmpPath)) .pipe(gulp.dest(tmpPath))
.pipe(gulpRev.manifest('manifest.json')) .pipe(gulpRev.manifest())
.pipe(gulp.dest(outputPath)) .pipe(gulp.dest(outputPath))
}) })
// bundle replace // bundle replace
gulp.task('bundle:replace', cb => { gulp.task('bundle:replace', cb => {
const manifest = gulp.src(`${outputPath}manifest.json`) let manifest = gulp.src(outputPath + 'rev-manifest.json')
const replace = gulpRevreplace({ return gulp.src([`${tmpPath}**/*.js`, `${tmpPath}**/*.css`])
manifest: manifest, .pipe(gulpRevreplace({
prefix: '//yun.tuisnake.com' manifest,
}) prefix: `//yun.tuisnake.com${uploadPath}`
}))
.pipe(gulp.dest(tmpPath))
})
gulp.src([`${outputPath}index.html`])
.pipe(replace) // bundle beautiful
.pipe(gulp.dest(outputPath)) gulp.task('bundle:beautify', cb => {
gulp.src([`${tmpPath}**/*.js`])
.pipe(gulpUglify())
.pipe(gulp.dest(tmpPath))
gulp.src([`${tmpPath}**/*.css`]) gulp.src([`${tmpPath}**/*.css`])
.pipe(replace) .pipe(gulpCsso())
.pipe(gulp.dest(tmpPath)) .pipe(gulp.dest(tmpPath))
cb() cb()
}) })
// bundle upload
gulp.task('build:upload', cb => { gulp.task('build:upload', cb => {
const uploader = new TuiaAutoUpload({ const uploader = new TuiaAutoUpload({
dir: path.join(__dirname, `${tmpPath}`), dir: path.join(__dirname, `${tmpPath}`),
originDir: '/jimu-web/plugin/' originDir: uploadPath
}) })
uploader.start() uploader.start()
...@@ -140,5 +151,5 @@ gulp.task('preview', ['bundle'], cb => { ...@@ -140,5 +151,5 @@ gulp.task('preview', ['bundle'], cb => {
// build plugin // build plugin
gulp.task('build', ['bundle'], cb => { gulp.task('build', ['bundle'], cb => {
runSequence(['bundle:rev'], ['bundle:replace'], ['build:upload'], cb) runSequence(['bundle:rev'], ['bundle:replace'], ['bundle:beautify'], ['build:upload'], cb)
}) })
\ No newline at end of file
<html> <html>
<head> <head>
<title>插件预览页</title> <title>插件预览页</title>
<link rel="stylesheet" type="text/css" href="/vendor.css"> <link rel="stylesheet" type="text/css" href="vendor.css">
<link rel="stylesheet" type="text/css" href="/plugin.css"> <link rel="stylesheet" type="text/css" href="plugin.css">
</head> </head>
<body> <body>
<div class="app"></div> <div class="app"></div>
<script src="/vendor.js"></script> <script src="vendor.js"></script>
<script src="/plugin.js"></script> <script src="plugin.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
import $ from 'jquery' import $ from 'jquery'
window.$ = $ window.$ = $
console.log(1) console.log(2)
\ No newline at end of file \ No newline at end of file
const OSS = require('ali-oss')
const path = require('path')
const fs = require('fs')
const stream = require('stream')
const chalk = require('chalk')
const store = new OSS({
region: 'oss-cn-hangzhou',
accessKeyId: 'LTAIdGi1IOap7fkF',
accessKeySecret: 'SKrOOp6EVtDGEV47yn0t2h97gyNioQ',
bucket: 'duiba'
})
const instance = async(opts) => {
if (!opts.fileDir || !opts.uploadDir) {
return;
}
let res = [];
let getFiles = function(dir) {
if (!dir) {
return;
}
if (!!path.extname(dir)) {
res.push(dir)
return
}
var files = fs.readdirSync(dir)
files.forEach(function(i) {
var filePath = path.resolve(dir, i)
var stat = fs.statSync(filePath);
if (stat.isFile()) {
res.push(filePath)
} else if (stat.isDirectory()) {
getFiles(filePath);
}
})
}
getFiles(opts.fileDir)
let totalNum = res.length
res.forEach(filePath => {
let fileStream = fs.createReadStream(filePath)
let uploadPath = path.join(opts.uploadDir, path.relative(opts.fileDir, filePath))
uploadPath = uploadPath.replace(/\\/g, '/')
store.putStream(uploadPath, fileStream).then(result => {
if (result.url) {
console.log(chalk.green(result.url))
} else {
console.log(chalk.red(result))
}
}).catch(err=>{
console.log(chalk.red(err))
})
})
}
module.exports = instance
\ No newline at end of file
...@@ -296,6 +296,13 @@ axios@0.17.1: ...@@ -296,6 +296,13 @@ axios@0.17.1:
follow-redirects "^1.2.5" follow-redirects "^1.2.5"
is-buffer "^1.1.5" is-buffer "^1.1.5"
axios@^0.18.0:
version "0.18.0"
resolved "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz#32d53e4851efdc0a11993b6cd000789d70c05102"
dependencies:
follow-redirects "^1.3.0"
is-buffer "^1.1.5"
babel-code-frame@^6.26.0: babel-code-frame@^6.26.0:
version "6.26.0" version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
...@@ -1118,6 +1125,10 @@ commander@^2.2.0: ...@@ -1118,6 +1125,10 @@ commander@^2.2.0:
version "2.18.0" version "2.18.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970"
commander@~2.17.1:
version "2.17.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
component-bind@1.0.0: component-bind@1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1"
...@@ -1181,6 +1192,19 @@ core-util-is@1.0.2, core-util-is@^1.0.2, core-util-is@~1.0.0: ...@@ -1181,6 +1192,19 @@ core-util-is@1.0.2, core-util-is@^1.0.2, core-util-is@~1.0.0:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
css-tree@1.0.0-alpha.29:
version "1.0.0-alpha.29"
resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.0.0-alpha.29.tgz#3fa9d4ef3142cbd1c301e7664c1f352bd82f5a39"
dependencies:
mdn-data "~1.1.0"
source-map "^0.5.3"
csso@^3.0.0:
version "3.5.1"
resolved "https://registry.yarnpkg.com/csso/-/csso-3.5.1.tgz#7b9eb8be61628973c1b261e169d2f024008e758b"
dependencies:
css-tree "1.0.0-alpha.29"
dashdash@^1.12.0: dashdash@^1.12.0:
version "1.14.1" version "1.14.1"
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
...@@ -1207,7 +1231,7 @@ debug@2.6.8: ...@@ -1207,7 +1231,7 @@ debug@2.6.8:
dependencies: dependencies:
ms "2.0.0" ms "2.0.0"
debug@3.1.0, debug@~3.1.0: debug@3.1.0, debug@=3.1.0, debug@~3.1.0:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies: dependencies:
...@@ -1682,6 +1706,12 @@ follow-redirects@^1.2.5: ...@@ -1682,6 +1706,12 @@ follow-redirects@^1.2.5:
dependencies: dependencies:
debug "^3.1.0" debug "^3.1.0"
follow-redirects@^1.3.0:
version "1.5.8"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.8.tgz#1dbfe13e45ad969f813e86c00e5296f525c885a1"
dependencies:
debug "=3.1.0"
for-in@^1.0.1, for-in@^1.0.2: for-in@^1.0.1, for-in@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
...@@ -1924,6 +1954,14 @@ gulp-clean@^0.4.0: ...@@ -1924,6 +1954,14 @@ gulp-clean@^0.4.0:
through2 "^2.0.3" through2 "^2.0.3"
vinyl "^2.1.0" vinyl "^2.1.0"
gulp-csso@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/gulp-csso/-/gulp-csso-3.0.1.tgz#3c160364491e32f2ecefd5d531cf7724f1afb7f0"
dependencies:
csso "^3.0.0"
plugin-error "^0.1.2"
vinyl-sourcemaps-apply "^0.2.1"
gulp-less@^4.0.1: gulp-less@^4.0.1:
version "4.0.1" version "4.0.1"
resolved "https://registry.yarnpkg.com/gulp-less/-/gulp-less-4.0.1.tgz#348c33a5dde7a207c5771b1d8261d1ac1021ceed" resolved "https://registry.yarnpkg.com/gulp-less/-/gulp-less-4.0.1.tgz#348c33a5dde7a207c5771b1d8261d1ac1021ceed"
...@@ -1956,6 +1994,19 @@ gulp-rev@^8.1.1: ...@@ -1956,6 +1994,19 @@ gulp-rev@^8.1.1:
vinyl "^2.1.0" vinyl "^2.1.0"
vinyl-file "^3.0.0" vinyl-file "^3.0.0"
gulp-uglify@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/gulp-uglify/-/gulp-uglify-3.0.1.tgz#8d3eee466521bea6b10fd75dff72adf8b7ea2d97"
dependencies:
gulplog "^1.0.0"
has-gulplog "^0.1.0"
lodash "^4.13.1"
make-error-cause "^1.1.1"
safe-buffer "^5.1.2"
through2 "^2.0.0"
uglify-js "^3.0.5"
vinyl-sourcemaps-apply "^0.2.0"
gulp-util@^3.0.0: gulp-util@^3.0.0:
version "3.0.8" version "3.0.8"
resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f"
...@@ -2706,7 +2757,7 @@ lodash.uniq@^4.3.0: ...@@ -2706,7 +2757,7 @@ lodash.uniq@^4.3.0:
version "4.5.0" version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
lodash@^4.17.10, lodash@^4.17.4: lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4:
version "4.17.10" version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
...@@ -2741,6 +2792,16 @@ magic-string@^0.22.4: ...@@ -2741,6 +2792,16 @@ magic-string@^0.22.4:
dependencies: dependencies:
vlq "^0.2.2" vlq "^0.2.2"
make-error-cause@^1.1.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/make-error-cause/-/make-error-cause-1.2.2.tgz#df0388fcd0b37816dff0a5fb8108939777dcbc9d"
dependencies:
make-error "^1.2.0"
make-error@^1.2.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
make-iterator@^1.0.0: make-iterator@^1.0.0:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/make-iterator/-/make-iterator-1.0.1.tgz#29b33f312aa8f547c4a5e490f56afcec99133ad6" resolved "https://registry.yarnpkg.com/make-iterator/-/make-iterator-1.0.1.tgz#29b33f312aa8f547c4a5e490f56afcec99133ad6"
...@@ -2761,6 +2822,10 @@ math-random@^1.0.1: ...@@ -2761,6 +2822,10 @@ math-random@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.1.tgz#8b3aac588b8a66e4975e3cdea67f7bb329601fac" resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.1.tgz#8b3aac588b8a66e4975e3cdea67f7bb329601fac"
mdn-data@~1.1.0:
version "1.1.4"
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-1.1.4.tgz#50b5d4ffc4575276573c4eedb8780812a8419f01"
merge-descriptors@^1.0.1: merge-descriptors@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
...@@ -3937,7 +4002,7 @@ source-map-url@^0.4.0: ...@@ -3937,7 +4002,7 @@ source-map-url@^0.4.0:
version "0.4.0" version "0.4.0"
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
source-map@^0.5.1, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1: source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1:
version "0.5.7" version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
...@@ -4217,11 +4282,12 @@ trim-right@^1.0.1: ...@@ -4217,11 +4282,12 @@ trim-right@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
"tuia-auto-upload@git+ssh://git@gitlab2.dui88.com:frontend/tuia-auto-upload.git#1.1.5": "tuia-auto-upload@git+ssh://git@gitlab2.dui88.com:frontend/tuia-auto-upload.git#1.1.7":
version "1.1.1" version "1.1.5"
resolved "git+ssh://git@gitlab2.dui88.com:frontend/tuia-auto-upload.git#ffa33dc61b3240e265e1fa3f56c2a4d0df27b3ff" resolved "git+ssh://git@gitlab2.dui88.com:frontend/tuia-auto-upload.git#480bcc3bc7c1d92ca8bd931bb95112e759110d25"
dependencies: dependencies:
ali-oss "^4.11.4" ali-oss "^4.11.4"
axios "^0.18.0"
chalk "^2.3.0" chalk "^2.3.0"
co "^4.6.0" co "^4.6.0"
progress "^2.0.0" progress "^2.0.0"
...@@ -4255,6 +4321,13 @@ uglify-js@^2.8.22: ...@@ -4255,6 +4321,13 @@ uglify-js@^2.8.22:
optionalDependencies: optionalDependencies:
uglify-to-browserify "~1.0.0" uglify-to-browserify "~1.0.0"
uglify-js@^3.0.5:
version "3.4.9"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"
dependencies:
commander "~2.17.1"
source-map "~0.6.1"
uglify-to-browserify@~1.0.0: uglify-to-browserify@~1.0.0:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
...@@ -4397,7 +4470,7 @@ vinyl-fs@^0.3.0: ...@@ -4397,7 +4470,7 @@ vinyl-fs@^0.3.0:
through2 "^0.6.1" through2 "^0.6.1"
vinyl "^0.4.0" vinyl "^0.4.0"
vinyl-sourcemaps-apply@^0.2.0: vinyl-sourcemaps-apply@^0.2.0, vinyl-sourcemaps-apply@^0.2.1:
version "0.2.1" version "0.2.1"
resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705"
dependencies: dependencies:
......
Markdown is supported
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