-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
8 changed files
with
207 additions
and
6 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,3 +1,4 @@ | ||
hide-*.js | ||
node_modules | ||
.idea/ | ||
.idea/ | ||
lib/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
'build': { | ||
action: 'custom', | ||
script: '/tools/build/builder.js' | ||
}, | ||
'release': { | ||
action: 'custom', | ||
script: '/tools/release/process.js' | ||
}, | ||
'watch': { | ||
files: 'components/**', | ||
config: '#[build]' | ||
}, | ||
'default': [ 'build' ] | ||
}; |
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,87 @@ | ||
module.exports = { | ||
process: function(config, done){ | ||
|
||
build_Prism(); | ||
build_Components(); | ||
build_Plugins(); | ||
|
||
done(); | ||
} | ||
}; | ||
|
||
|
||
var OUTPUT = '/lib/', | ||
DIR = __dirname + '/'; | ||
|
||
function build_Prism () { | ||
io.settings({ | ||
extensions: { | ||
js: [ 'importer:read' ] | ||
} | ||
}); | ||
|
||
saveJavascript( | ||
io.File.read(DIR + 'prism-lib.js'), '', 'prism.js' | ||
); | ||
} | ||
function build_Components () { | ||
var umd = io.File.read(DIR + 'extension-umd.js'), | ||
SKIP = [ | ||
'.min.', | ||
'-core.', | ||
'-markup.', | ||
'-css.', | ||
'-clike.', | ||
'-javascript.' | ||
]; | ||
|
||
io.glob.readFiles('components/*.js').forEach(function(file){ | ||
if (!shouldSkip(file, SKIP)) | ||
wrapJavascript(file, umd, 'components/'); | ||
}); | ||
} | ||
function build_Plugins () { | ||
var umd = io.File.read(DIR + 'extension-umd.js'), | ||
SKIP = [ | ||
'.min.', | ||
'index.html' | ||
]; | ||
io.glob.read('plugins/*').forEach(function(dir){ | ||
if (dir instanceof io.Directory === false) return; | ||
|
||
var pluginName = dir.getName(); | ||
|
||
dir.readFiles('*').files.forEach(function(file) { | ||
if (shouldSkip(file, SKIP)) return; | ||
if (file.uri.getName() !== 'prism-' + pluginName + '.js') { | ||
file.copyTo(OUTPUT + 'plugins/' + pluginName + '/'); | ||
return; | ||
} | ||
|
||
wrapJavascript(file, umd, 'plugins/' + pluginName + '/'); | ||
}); | ||
}) | ||
} | ||
|
||
|
||
function minify (source) { | ||
return require('uglify-js').minify(source, {fromString: true}).code; | ||
} | ||
function shouldSkip (file, patterns) { | ||
return patterns.some(function(pattern){ | ||
return file.uri.file.indexOf(pattern) !== -1; | ||
}); | ||
} | ||
function wrapJavascript(file, umdSource, outputDir) { | ||
logger.log('wrap', file.uri.file.bold); | ||
|
||
var source = umdSource.replace('//%SOURCE%', function() { | ||
return file.read() | ||
}); | ||
|
||
saveJavascript(source, outputDir, file.uri.file); | ||
} | ||
function saveJavascript(source, outputDir, filename) { | ||
io.File.write(OUTPUT + outputDir + filename, source); | ||
io.File.write(OUTPUT + outputDir + filename.replace('.js', '.min.js'), minify(source), { skipHooks: true }); | ||
} |
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,30 @@ | ||
(function(factory){ | ||
|
||
var prism_ = (typeof Prism !== 'undefined' && Prism ) || null, | ||
global_ = (typeof global !== 'undefined' && global) | ||
|| (typeof window !== 'undefined' && window) | ||
|| (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self) | ||
|| null; | ||
|
||
if (prism_ == null && typeof require === 'function') { | ||
prism_ = require('prismjs'); | ||
} | ||
if (prism_ == null && typeof define === 'function' && define.amd) { | ||
define(['prismjs'], function (Prism) { | ||
return factory(Prism, global_, { Prism: Prism }); | ||
}); | ||
return; | ||
} | ||
|
||
if (prism_ == null) { | ||
throw Error('Prism is not loaded'); | ||
} | ||
|
||
// some plugins depend on `self` | ||
factory(prism_, global_, { Prism: Prism }); | ||
|
||
}(function(Prism, window, self) { | ||
|
||
//%SOURCE% | ||
|
||
})); |
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,15 @@ | ||
(function(root, factory){ | ||
|
||
factory(root); | ||
|
||
}(this, function(self) { | ||
|
||
// import /components/prism-core.js | ||
|
||
// import /components/prism-markup.js | ||
// import /components/prism-css.js | ||
// import /components/prism-clike.js | ||
// import /components/prism-javascript.js | ||
// import /plugins/file-highlight/prism-file-highlight.js | ||
|
||
})); |
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,48 @@ | ||
var Builder = require('../build/builder'); | ||
var BRANCH = 'builder'; | ||
|
||
module.exports = { | ||
process: function(config, done){ | ||
|
||
app | ||
.findAction('release') | ||
.done(function(Release){ | ||
|
||
// bump package.json and bower.json versions | ||
Release.bump(function(err, version){ | ||
|
||
Release.runCommands([ | ||
'git add -A', | ||
'git commit -a -m "v' + version + '"', | ||
'git push origin ' + BRANCH, | ||
'git checkout -B release', | ||
function (done) { | ||
Builder.process({}, done); | ||
}, | ||
function () { | ||
Release.includeFiles.create([ | ||
'lib/**', | ||
'themes/**', | ||
'README.md', | ||
'LICENSE', | ||
'package.json', | ||
'bower.json' | ||
]); | ||
}, | ||
'git rm -r --cached .', | ||
'git add -A', | ||
'git commit -a -m "v' + version + '"', | ||
'git push origin release -ff', | ||
'git tag v' + version, | ||
'git push --tags', | ||
//'npm publish', | ||
function () { | ||
Release.includeFiles.reset(); | ||
}, | ||
'git checkout ' + BRANCH + ' -ff' | ||
], done); | ||
}); | ||
|
||
}); | ||
} | ||
}; |