From ce216d218bc1ef7934d5de033f8a6f9e556e16d6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Feb 2017 10:49:11 +0900 Subject: [PATCH] Clean up :sparkles: --- docs/license.pug | 7 ------- gulpfile.ts | 32 ++++++++------------------------ package.json | 8 ++------ src/const.json | 3 +++ webpack.config.ts | 6 ++++-- 5 files changed, 17 insertions(+), 39 deletions(-) create mode 100644 src/const.json diff --git a/docs/license.pug b/docs/license.pug index 229a47385a..323b9b9528 100644 --- a/docs/license.pug +++ b/docs/license.pug @@ -5,11 +5,4 @@ block title block content h1 ライセンス - div!= license - - hr - - details - summary サードパーティ - div!= thirdpartyLicenses diff --git a/gulpfile.ts b/gulpfile.ts index 00772925ef..f7503912ce 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -14,16 +14,13 @@ import * as es from 'event-stream'; import * as webpack from 'webpack-stream'; import cssnano = require('gulp-cssnano'); import * as uglify from 'gulp-uglify'; -import riotify = require('riotify'); import pug = require('gulp-pug'); import git = require('git-last-commit'); import * as rimraf from 'rimraf'; -import * as escapeHtml from 'escape-html'; import prominence = require('prominence'); import * as chalk from 'chalk'; import imagemin = require('gulp-imagemin'); import * as rename from 'gulp-rename'; -import named = require('vinyl-named'); const env = process.env.NODE_ENV; const isProduction = env === 'production'; @@ -33,6 +30,8 @@ if (isDebug) { console.log(chalk.yellow.bold('!!!注意!!! 開発モードが有効です。(成果物の圧縮などはスキップされます)')); } +const constants = require('./src/const.json'); + const tsProject = ts.createProject('tsconfig.json'); gulp.task('build', [ @@ -65,37 +64,22 @@ gulp.task('build:ts', () => gulp.task('build:about:docs', () => { function getLicenseHtml(path: string) { - return escapeHtml(fs.readFileSync(path, 'utf-8')) + return fs.readFileSync(path, 'utf-8') .replace(/\r\n/g, '\n') .replace(/(.)\n(.)/g, '$1 $2') .replace(/(^|\n)(.*?)($|\n)/g, '

$2

'); } - function getLicenseSectionHtml(path: string) { - try { - const pkg = JSON.parse(fs.readFileSync(Path.parse(path).dir + '/package.json', 'utf-8')); - const licenseHtml = getLicenseHtml(path); - return `
${pkg.name} v${pkg.version}${licenseHtml}
`; - } catch (e) { - return null; - } - } - - const licenses = glob.sync('./node_modules/**/LICENSE*'); const licenseHtml = getLicenseHtml('./LICENSE'); - const thirdpartyLicensesHtml = licenses.map(license => getLicenseSectionHtml(license)).join(''); - const pugs = glob.sync('./docs/**/*.pug'); - const streams = pugs.map(file => { + const streams = glob.sync('./docs/**/*.pug').map(file => { const page = file.replace('./docs/', '').replace('.pug', ''); return gulp.src(file) .pipe(pug({ - locals: Object.assign({ + locals: { path: page, license: licenseHtml, - thirdpartyLicenses: thirdpartyLicensesHtml - }, { - themeColor: '#f76d6c' - }) + themeColor: constants.themeColor + } })) .pipe(gulp.dest('./built/web/about/pages/' + Path.parse(page).dir)); }); @@ -209,7 +193,7 @@ gulp.task('build:client:pug', [ gulp.src('./src/web/app/*/view.pug') .pipe(pug({ locals: { - themeColor: '#f76d6c' + themeColor: constants.themeColor } })) .pipe(gulp.dest('./built/web/app/')) diff --git a/package.json b/package.json index bf01f30b51..d8861bd7f0 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,6 @@ "@types/rimraf": "0.0.28", "@types/riot": "2.6.1", "@types/serve-favicon": "2.2.28", - "@types/twitter": "0.0.28", "@types/uuid": "2.0.29", "@types/webpack": "2.2.6", "@types/webpack-stream": "3.2.6", @@ -98,7 +97,6 @@ "gulp-imagemin": "3.1.1", "gulp-pug": "3.2.0", "gulp-rename": "1.2.2", - "gulp-replace": "0.5.4", "gulp-tslint": "7.1.0", "gulp-typescript": "3.1.5", "gulp-uglify": "2.0.1", @@ -126,14 +124,13 @@ "request": "2.79.0", "rimraf": "2.6.0", "riot": "3.3.1", - "riot-compiler": "3.2.1", "riot-tag-loader": "1.0.0", - "riotify": "2.0.0", "rndstr": "1.0.0", "s-age": "1.1.0", "serve-favicon": "2.4.0", "string-replace-webpack-plugin": "0.0.5", - "stylus-loader": "^2.5.0", + "stylus": "0.54.5", + "stylus-loader": "2.5.0", "subdomain": "1.2.0", "summaly": "2.0.0", "swagger-jsdoc": "1.9.1", @@ -145,7 +142,6 @@ "uuid": "3.0.1", "velocity-animate": "1.4.3", "vhost": "3.0.2", - "vinyl-named": "1.1.0", "webpack": "2.2.1", "webpack-stream": "3.2.0", "websocket": "1.0.24", diff --git a/src/const.json b/src/const.json new file mode 100644 index 0000000000..4c8d05cb53 --- /dev/null +++ b/src/const.json @@ -0,0 +1,3 @@ +{ + "themeColor": "#f76d6c" +} diff --git a/webpack.config.ts b/webpack.config.ts index 00fd3f00a3..19e095a91c 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -1,6 +1,8 @@ import * as webpack from 'webpack'; const StringReplacePlugin = require('string-replace-webpack-plugin'); +const constants = require('./src/const.json'); + module.exports = (commit, env) => { const isProduction = env === 'production'; const isDebug = !isProduction; @@ -21,7 +23,7 @@ module.exports = (commit, env) => { loader: StringReplacePlugin.replace({ replacements: [ { pattern: /\$theme\-color\-foreground/g, replacement: () => '#fff' }, - { pattern: /\$theme\-color/g, replacement: () => '#f76d6c' }, + { pattern: /\$theme\-color/g, replacement: () => constants.themeColor }, ] }) }, @@ -62,7 +64,7 @@ module.exports = (commit, env) => { new webpack.DefinePlugin({ VERSION: JSON.stringify(commit ? commit.hash : null), CONFIG: { - themeColor: JSON.stringify('#f76d6c') + themeColor: JSON.stringify(constants.themeColor) } }), new StringReplacePlugin(),