Skip to content

Commit

Permalink
ver. 3.1.6-beta.5
Browse files Browse the repository at this point in the history
  • Loading branch information
光弘 committed Oct 19, 2017
1 parent 2be3f15 commit 4f3e2e3
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 30 deletions.
6 changes: 5 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ _site
sea-modules
spm_modules
.cache
dist
dist
demo
dev
dist
template
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SaltUI 即将于 8月 正式开源,敬请期待。
SaltUI will be open-source in August this year.
SaltUI 开源版本,beta 中。

SaltUI open-resource version, now beta.
2 changes: 1 addition & 1 deletion build/salt-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -21622,7 +21622,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
/* eslint-disable */

var __SALT_VERSION__ = void 0;
__SALT_VERSION__ = "3.1.6";
__SALT_VERSION__ = "3.1.6-beta.5";

var __SALT_BUNDLE__ = {
version: __SALT_VERSION__,
Expand Down
2 changes: 1 addition & 1 deletion build/salt-ui.min.js

Large diffs are not rendered by default.

81 changes: 59 additions & 22 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const fs = require('fs');
const path = require('path');
const { spawn } = require('child_process');
const { spawn, spawnSync } = require('child_process');
const getGitlabApi = require('@ali/gitlab-apis');
const co = require('co');
const rm = require('rimraf');
const to = require('to-case');
const assign = require('object-assign');
const colors = require('colors/safe');
const inquirer = require('inquirer');
const gulpRun = require('run-sequence');
const semver = require('semver');
const git = require('git-rev');
const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
Expand All @@ -29,6 +34,10 @@ const cleancssOption = {
debug: true,
};

colors.setTheme({
info: ['bold', 'green'],
});

const runCmd = (cmd, args = [], fn, stdoutFn) => {
console.log(`Run CMD: ${cmd} ${args.join(' ')}`);
const runner = spawn(cmd, args, {
Expand All @@ -47,9 +56,41 @@ const runCmd = (cmd, args = [], fn, stdoutFn) => {
});
};


const upperInitWord = str => str.split('-').map(key => (key[0].toUpperCase() + key.slice(1))).join('');
const removePrefix = str => str.split('-').slice(1).join('-');

const getQuestions = () => (
new Promise((resolve) => {
git.branch((branch) => {
const defaultBranch = branch;
const questions = [
{
type: 'input',
name: 'version',
message: 'please enter the package version to publish (should be xx.xx.xx)',
default: pkg.version,
validate(input) {
if (semver.valid(input)) {
if (semver.gt(input, pkg.version)) {
return true;
}
return 'the version you entered should be larger than now';
}
return 'the version you entered is not valid';
},
},
{
type: 'input',
name: 'branch',
message: 'which branch you want to push',
default: defaultBranch,
},
];
resolve(questions);
});
})
);

// 将 tingle-ui 组下的转移至 saltui 下
gulp.task('copy', () => {
Expand Down Expand Up @@ -156,16 +197,15 @@ gulp.task('gitlab', () => {

// demo 中替换一些变量
gulp.task('demo_replace', () => {
/* eslint-disable max-len */
const dirs = fs.readdirSync('./demo');
dirs.forEach((dir) => {
const files = fs.readdirSync(`./demo/${dir}`);
files.forEach((file) => {
if (/\.js(x)?$/.test(file)) {
let fileData = fs.readFileSync(`./demo/${dir}/${file}`).toString();
// replace @ali/tingle-context with salt-context
fileData = fileData.replace(/@ali\/tingle-(.+?)(['/])/g, (match, s1, s2) => {
return `salt-${s1}${s2}`;
});
fileData = fileData.replace(/@ali\/tingle-(.+?)(['/])/g, (match, s1, s2) => `salt-${s1}${s2}`);
// replace ../../src with salt-current-comp
fileData = fileData.replace('../../src', `salt-${to.slug(dir)}`);
// replace icon-source
Expand All @@ -179,9 +219,8 @@ gulp.task('demo_replace', () => {
// replace ReactDOM.render(<Demo/>, document.getElementById('TingleDemo'));
// with export default Demo
const regExpDemoIndex = /ReactDOM\.render\(<(.+)\/>, document\.getElementById\('TingleDemo'\)\)/g;
fileData = fileData.replace(regExpDemoIndex, (match, s1) => {
return `export default ${s1}`;
});
fileData = fileData.replace(regExpDemoIndex,
(match, s1) => `export default ${s1}`);
if (/^index/.test(file)) {
fileData = fileData.replace("import React from 'react';", '');
fileData = fileData.replace("import ReactDOM from 'react-dom';", '');
Expand Down Expand Up @@ -209,6 +248,7 @@ gulp.task('demo_replace', () => {
}
});
});
/* eslint-enable max-len */
});

// demo 中插入对于样式的引入
Expand Down Expand Up @@ -338,22 +378,22 @@ gulp.task('uglify_js', ['build_js'], (done) => {

gulp.task('build', ['uglify_js', 'build_style']);

gulp.task('pub', function () {
getQuestions().then(function (questions) {
inquirer.prompt(questions).then(function (answers) {
gulp.task('pub', () => {
getQuestions().then((questions) => {
inquirer.prompt(questions).then((answers) => {
pkg.version = answers.version;
// file.writeFileFromString(JSON.stringify(pkg, null, ' '), 'package.json');
fs.writeFileSync('package.json', JSON.stringify(pkg, null, ' '));
gulpRun('build', function() {
gulpRun('build', () => {
console.log(colors.info('#### Git Info ####'));
spawn.sync('git', ['add', '.'], { stdio: 'inherit' });
spawn.sync('git', ['commit', '-m', 'ver. ' + pkg.version], { stdio: 'inherit' });
spawn.sync('git', ['push', 'origin', answers.branch], { stdio: 'inherit' });
spawnSync('git', ['add', '.'], { stdio: 'inherit' });
spawnSync('git', ['commit', '-m', `ver. ${pkg.version}`], { stdio: 'inherit' });
spawnSync('git', ['tag', `${pkg.version}`], { stdio: 'inherit' });
spawnSync('git', ['push', 'origin', answers.branch], { stdio: 'inherit' });
console.log(colors.info('#### Npm Info ####'));
spawn.sync(answers.npm, ['publish'], { stdio: 'inherit' });
spawnSync('npm', ['publish'], { stdio: 'inherit' });
});
}).catch(function (err) { console.log(err); });
}).catch(function (err) { console.log(err); });
}).catch((err) => { console.log(err); });
}).catch((err) => { console.log(err); });
});

gulp.task('server', () => {
Expand Down Expand Up @@ -391,9 +431,7 @@ gulp.task('server', () => {
(resource) => {
/* eslint-disable no-param-reassign */
if (resource.request.indexOf('salt-icon') === -1 && resource.request.indexOf('salt-ui') === -1) {
resource.request = resource.request.replace(/salt-(.+)/, (match, s1) => {
return require.resolve(`./src/${upperInitWord(s1)}`);
});
resource.request = resource.request.replace(/salt-(.+)/, (match, s1) => require.resolve(`./src/${upperInitWord(s1)}`));
}
/* eslint-enable no-param-reassign */
}
Expand All @@ -420,4 +458,3 @@ gulp.task('server', () => {
/* eslint-enable camelcase */
});


12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "saltui",
"version": "3.1.6",
"version": "3.1.6-beta.5",
"description": "React components for mobile",
"main": "build/salt-ui.js",
"scripts": {
"start": "gulp server",
"build": "gulp build"
"build": "gulp build",
"pub": "gulp pub"
},
"repository": {
"type": "git",
Expand All @@ -31,8 +32,10 @@
"browser-sync-webpack-plugin": "^1.2.0",
"bundle-loader": "^0.5.5",
"co": "^4.6.0",
"colors": "^1.1.2",
"css-loader": "^0.28.7",
"fastclick": "^1.0.6",
"git-rev": "^0.2.1",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^4.0.0",
"gulp-babel": "^7.0.0",
Expand All @@ -42,11 +45,14 @@
"gulp-stylus": "^2.6.0",
"gulp-uglify": "^3.0.0",
"happypack": "^4.0.0-beta.2",
"inquirer": "^3.3.0",
"progress-bar-webpack-plugin": "^1.10.0",
"react": "^0.14.9",
"react-dom": "^0.14.9",
"react-router-dom": "^4.2.2",
"rimraf": "^2.6.1",
"run-sequence": "^2.2.0",
"semver": "^5.4.1",
"style-loader": "^0.18.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
Expand All @@ -69,4 +75,4 @@
"uploadcore": "^2.3.1",
"uxcore-formatter": "^0.1.6"
}
}
}

0 comments on commit 4f3e2e3

Please sign in to comment.