2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-06-29 14:11:02 -06:00

gulp.js now auto downloads dependencies

This commit is contained in:
Wes Cossick 2015-09-12 02:01:50 -05:00
parent 2fd52aa629
commit c9db36af67
2 changed files with 94 additions and 57 deletions

View File

@ -1,61 +1,97 @@
var gulp = require('gulp'), var gulp = require("gulp"),
minifycss = require('gulp-minify-css'), minifycss = require("gulp-minify-css"),
uglify = require('gulp-uglify'), uglify = require("gulp-uglify"),
concat = require('gulp-concat'), concat = require("gulp-concat"),
header = require('gulp-header'), header = require("gulp-header"),
pkg = require('./package.json'), pkg = require("./package.json"),
prettify = require('gulp-jsbeautifier'); prettify = require("gulp-jsbeautifier"),
download = require("gulp-download");
var banner = ['/**', var banner = ["/**",
' * <%= pkg.name %> v<%= pkg.version %>', " * <%= pkg.name %> v<%= pkg.version %>",
' * Copyright <%= pkg.company %>', " * Copyright <%= pkg.company %>",
' * @link <%= pkg.homepage %>', " * @link <%= pkg.homepage %>",
' * @license <%= pkg.license %>', " * @license <%= pkg.license %>",
' */', " */",
''].join('\n'); ""].join("\n");
gulp.task('scripts', function() { gulp.task("downloads-codemirror", function() {
var download_urls = [
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/lib/codemirror.js",
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/edit/continuelist.js",
//"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/edit/tablist.js", //waiting for PRs
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/display/fullscreen.js",
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/mode/overlay.js",
//"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/gfm/gfm.js", //waiting for PRs
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/markdown/markdown.js",
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/xml/xml.js"];
return download(download_urls)
.pipe(gulp.dest("src/js/codemirror/"));
});
gulp.task("downloads-js", function() {
var download_urls = [
"https://raw.githubusercontent.com/chjj/marked/master/lib/marked.js",
"https://raw.githubusercontent.com/NextStepWebs/codemirror-spell-checker/master/src/js/spell-checker.js",
"https://raw.githubusercontent.com/NextStepWebs/codemirror-spell-checker/master/src/js/typo.js"];
return download(download_urls)
.pipe(gulp.dest("src/js/"));
});
gulp.task("downloads-css", function() {
var download_urls = [
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/lib/codemirror.css",
"https://raw.githubusercontent.com/NextStepWebs/codemirror-spell-checker/master/src/css/spell-checker.css"];
return download(download_urls)
.pipe(gulp.dest("src/css/"));
});
gulp.task("scripts", ["downloads-codemirror", "downloads-js", "downloads-css"], function() {
var js_files = [ var js_files = [
'./src/js/codemirror/codemirror.js', "./src/js/codemirror/codemirror.js",
'./src/js/codemirror/continuelist.js', "./src/js/codemirror/continuelist.js",
'./src/js/codemirror/fullscreen.js', "./src/js/codemirror/tablist.js",
'./src/js/codemirror/markdown.js', "./src/js/codemirror/fullscreen.js",
'./src/js/codemirror/overlay.js', "./src/js/codemirror/markdown.js",
'./src/js/codemirror/gfm.js', "./src/js/codemirror/overlay.js",
'./src/js/codemirror/xml.js', "./src/js/codemirror/gfm.js",
'./src/js/typo.js', "./src/js/codemirror/xml.js",
'./src/js/spell-checker.js', "./src/js/typo.js",
'./src/js/marked.js', "./src/js/spell-checker.js",
'./src/js/simplemde.js']; "./src/js/marked.js",
"./src/js/simplemde.js"];
return gulp.src(js_files) return gulp.src(js_files)
.pipe(header(banner, {pkg: pkg})) .pipe(header(banner, {pkg: pkg}))
.pipe(concat('simplemde.min.js')) .pipe(concat("simplemde.min.js"))
.pipe(gulp.dest('dist')) .pipe(gulp.dest("dist"))
.pipe(uglify()) .pipe(uglify())
.pipe(header(banner, {pkg: pkg})) .pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('dist')); .pipe(gulp.dest("dist"));
}); });
gulp.task('styles', function() { gulp.task("styles", ["downloads-codemirror", "downloads-js", "downloads-css"], function() {
return gulp.src('./src/css/*.css') return gulp.src("./src/css/*.css")
.pipe(concat('simplemde.min.css')) .pipe(concat("simplemde.min.css"))
.pipe(gulp.dest('dist')) .pipe(gulp.dest("dist"))
.pipe(minifycss()) .pipe(minifycss())
.pipe(header(banner, {pkg: pkg})) .pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('dist')); .pipe(gulp.dest("dist"));
}); });
gulp.task('prettify-js', function() { gulp.task("prettify-js", function() {
gulp.src('./src/js/simplemde.js') gulp.src("./src/js/simplemde.js")
.pipe(prettify({js: {braceStyle: "collapse", indentChar: "\t", indentSize: 1, maxPreserveNewlines: 3, spaceBeforeConditional: false}})) .pipe(prettify({js: {braceStyle: "collapse", indentChar: "\t", indentSize: 1, maxPreserveNewlines: 3, spaceBeforeConditional: false}}))
.pipe(gulp.dest('./src/js')); .pipe(gulp.dest("./src/js"));
}); });
gulp.task('prettify-css', function() { gulp.task("prettify-css", function() {
gulp.src('./src/css/simplemde.css') gulp.src("./src/css/simplemde.css")
.pipe(prettify({css: {indentChar: "\t", indentSize: 1}})) .pipe(prettify({css: {indentChar: "\t", indentSize: 1}}))
.pipe(gulp.dest('./src/css')); .pipe(gulp.dest("./src/css"));
}); });
gulp.task('default', ['scripts', 'styles', 'prettify-js', 'prettify-css']); gulp.task("default", ["downloads-codemirror", "downloads-js", "downloads-css", "scripts", "styles", "prettify-js", "prettify-css"]);

View File

@ -3,33 +3,34 @@
"version": "1.7.1", "version": "1.7.1",
"description": "A simple, beautiful, and embeddable JavaScript markdown editor. Features autosaving and spell checking.", "description": "A simple, beautiful, and embeddable JavaScript markdown editor. Features autosaving and spell checking.",
"keywords": [ "keywords": [
"embeddable", "embeddable",
"markdown", "markdown",
"editor", "editor",
"javascript", "javascript",
"wysiwyg" "wysiwyg"
], ],
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor", "homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
"main": "gulpfile.js", "main": "gulpfile.js",
"license": "MIT", "license": "MIT",
"company": "Next Step Webs, Inc.", "company": "Next Step Webs, Inc.",
"author": { "author": {
"name": "Wes Cossick", "name": "Wes Cossick",
"url": "http://www.WesCossick.com" "url": "http://www.WesCossick.com"
}, },
"bugs": { "bugs": {
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues" "url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues"
}, },
"devDependencies": { "devDependencies": {
"gulp": "*", "gulp": "*",
"gulp-minify-css": "*", "gulp-minify-css": "*",
"gulp-uglify": "*", "gulp-uglify": "*",
"gulp-concat": "*", "gulp-concat": "*",
"gulp-header": "*", "gulp-header": "*",
"gulp-jsbeautifier": "*" "gulp-jsbeautifier": "*",
"gulp-download": "*"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor" "url": "https://github.com/NextStepWebs/simplemde-markdown-editor"
} }
} }