-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit d686fa8
Showing
36 changed files
with
1,331 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
releases/ |
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,28 @@ | ||
env: | ||
browser: true | ||
es6: true | ||
node: true | ||
|
||
ecmaFeatures: | ||
jsx: true | ||
|
||
globals: | ||
log: true | ||
|
||
plugins: | ||
- react | ||
|
||
rules: | ||
comma-dangle: always | ||
no-unused-expressions: false | ||
no-unused-vars: | ||
- 2 | ||
- vars: all | ||
args: none | ||
quotes: | ||
- 2 | ||
- single | ||
- avoid-escape | ||
strict: false | ||
|
||
# vim:ft=yaml: |
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,14 @@ | ||
# node.js | ||
npm-debug.log | ||
node_modules/ | ||
|
||
# main process | ||
main/*.js | ||
|
||
# renderer process | ||
renderer/*.css | ||
renderer/*.html | ||
renderer/*.js | ||
|
||
# release files | ||
releases/ |
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,24 @@ | ||
language: node_js | ||
node_js: | ||
- "iojs" | ||
sudo: false | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false | ||
before_deploy: | ||
- npm run release-travis | ||
deploy: | ||
provider: releases | ||
all_braches: true | ||
skip_cleanup: true | ||
api_key: | ||
secure: OfUZkFsmeZzgIV+L3/B787TnhW+Wqxf8Sk/hsZ1oU4MGfE1M/RZWHLWJuRRJESwshivCaMbCJ7iqtE6MQEBZmjHX95HWm3TLeEqf5TL1uOEkH6tonlFhvblYPthfCJIOJ/E19dCjX8ePfpuL7AqtzVzY4pgtbT8yOe7BM+SpW7OMKuESFsHjJcIR21kbBADvR/prwqqMjCwhldlyKDyqxV1I2/3fURt61tL9RPJH83T6BkkETMa72SLvDTwLoM12EaUWUEnmUA8c9a8O6yOLSRNjbyVZfD9E/p9EZMpIwDq14hsS9fbn5KdsmOBS7mjBQzNcDdKUwc7GGhmLfwSgOiz/4BRFYNMwPZPGuWLRUjc+8O75Ell52n5HHHcyF4Q1qHvgPFPhgCXKKbK9/ocgOjeSgtW/Um3kJGbjD79NkS+yOSq95U5BBNd5B53SWtfp7zBpMJVVETBg1c/8nfwGwqxcD3lSlCwdI7leDeNMfEskJhj1JnwiUpIiWqW+47uAjKJjrtQp9D1omBStiu/DQnrd51X5p/Zw91xQRZVSWwEnHfY7kJKi64zQpUYhJSrFexHy5zPRhqwyqLYv2hXASbN+UOEcg0u0/Y8KeNmYrLwplqK4MNwlsSVAnaaOqjO/hZKfEEaIBJB/BQ8GTA8Q4qyJ6ldlNLS1cgiCD93Brd0= | ||
file: | ||
- releases/minify-image-win-x86_64.zip | ||
- releases/minify-image-osx-x86_64.zip | ||
- releases/minify-image-linux-x86_64.zip | ||
on: | ||
repo: tsukurite/minify-image | ||
tags: 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,3 @@ | ||
# 0.0.0 / 2015-06-24 | ||
|
||
- initial release |
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,21 @@ | ||
(The MIT license) | ||
|
||
Copyright (c) 2015 tsukurite | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to | ||
deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
sell copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. |
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,7 @@ | ||
# minify-image | ||
|
||
application for minifying image, based on [Electron](http://electron.atom.io/) | ||
|
||
## License | ||
|
||
The MIT license. |
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,205 @@ | ||
#!/usr/bin/env node --harmony_arrow_functions | ||
|
||
'use strict'; | ||
|
||
var fs = require('fs'), | ||
path = require('path'), | ||
co = require('co'), | ||
electronPackager = require('electron-packager'), | ||
glob = require('glob'), | ||
objectAssign = require('object-assign'), | ||
rimraf = require('rimraf'), | ||
thunkify = require('thunkify'), | ||
packageData = require('./package'); | ||
|
||
/** | ||
* wrpping with Electron | ||
* | ||
* @param {Object} baseOptions | ||
* @param {Object} overwriteOptions | ||
* @return {Promise} | ||
*/ | ||
function packaging(baseOptions, overwriteOptions) { | ||
var options = objectAssign({}, baseOptions, overwriteOptions); | ||
|
||
return co(function*() { | ||
return yield thunkify(electronPackager).call(electronPackager, options); | ||
}); | ||
} | ||
|
||
/** | ||
* download for imagemin moudule | ||
* | ||
* @param {String} vendorDirPath | ||
* @return {Promise} | ||
*/ | ||
function download(vendorDirPath) { | ||
var pluginModule = require(`${vendorDirPath}/../lib`), | ||
fetch = thunkify(pluginModule.download.bind(pluginModule)); | ||
|
||
return co(function*() { | ||
return yield fetch(); | ||
}); | ||
} | ||
|
||
/** | ||
* parallel download for imagemin modules | ||
* | ||
* @param {String[]} vendorDirPaths | ||
* @return {Function[]} | ||
*/ | ||
function parallelDownload(vendorDirPaths) { | ||
return vendorDirPaths.map( | ||
(vendorDirPath) => download(vendorDirPath) | ||
); | ||
} | ||
|
||
/** | ||
* remove downloaded binaries and download binaries for target platform | ||
* | ||
* @param {String} platform | ||
* @param {String} releasesDir | ||
* @param {Promise} | ||
*/ | ||
function setupBinaries(platform, releasesDir) { | ||
return co(function*() { | ||
var vendorDirGlob = `${releasesDir}/${platform}/**/vendor`, | ||
vendorDirs = yield thunkify(glob).call(glob, vendorDirGlob); | ||
|
||
// remove installed module's binaries | ||
yield vendorDirs.map( | ||
(vendorDir) => thunkify(rimraf).call(rimraf, vendorDir) | ||
); | ||
|
||
// download to binaries for target platform | ||
return yield parallelDownload(vendorDirs); | ||
}); | ||
} | ||
|
||
/** | ||
* process faker | ||
* | ||
* @class | ||
*/ | ||
function ProcessFaker() { | ||
this._originalProcess = process; | ||
this._originalDescripters = {}; | ||
} | ||
|
||
/** | ||
* fake property | ||
* | ||
* @param {String} propertyName | ||
* @param {*} fakeValue | ||
*/ | ||
ProcessFaker.prototype.fake = function fake(propertyName, fakeValue) { | ||
var originalDescripter = | ||
Object.getOwnPropertyDescriptor(this._originalProcess, propertyName); | ||
|
||
this._originalDescripters[propertyName] = originalDescripter; | ||
Object.defineProperty(process, propertyName, fakeValue); | ||
}; | ||
|
||
/** | ||
* revert faked property. | ||
* | ||
* @param {String} propertyName | ||
*/ | ||
ProcessFaker.prototype.unfake = function unfake(propertyName) { | ||
var originalDescripter = | ||
this._originalDescripters[propertyName]; | ||
|
||
Object.defineProperty(process, propertyName, originalDescripter); | ||
this._originalDescripters[propertyName] = null; | ||
}; | ||
|
||
co(function*() { | ||
const RELEASES_DIR = path.join(__dirname, '/releases'); | ||
|
||
var options = { | ||
dir: __dirname, | ||
name: 'minify-image', | ||
arch: 'x64', | ||
version: '0.28.1', | ||
prune: true, | ||
ignore: [ | ||
// common | ||
'\.(?:coffee|jade|jsx|scss)$', | ||
|
||
// development files | ||
'webpack.config.js$', | ||
|
||
// MEMO: fail when prune option is true | ||
// 'package.json$', | ||
|
||
// empty dirs | ||
'renderer/actions', | ||
'renderer/components', | ||
'renderer/constants', | ||
'renderer/dispatcher', | ||
'renderer/stores', | ||
|
||
// this file | ||
path.basename(__filename), | ||
|
||
// releases dir | ||
RELEASES_DIR, | ||
], | ||
'app-version': packageData.version, | ||
}; | ||
|
||
// packaging | ||
// TODO: parallel execution | ||
console.log('packaged to', yield packaging(options, { | ||
platform: 'win32', | ||
out: RELEASES_DIR, | ||
})); | ||
console.log('packaged to', yield packaging(options, { | ||
platform: 'linux', | ||
out: path.normalize(`${RELEASES_DIR}/minify-image-linux-x86_64`), | ||
})); | ||
console.log('packaged to', yield packaging(options, { | ||
platform: 'darwin', | ||
out: path.normalize(`${RELEASES_DIR}/minify-image-osx-x86_64`), | ||
})); | ||
|
||
// rename directory | ||
yield thunkify(fs.rename).call( | ||
fs, | ||
path.normalize(`${RELEASES_DIR}/minify-image-win32`), | ||
path.normalize(`${RELEASES_DIR}/minify-image-win-x86_64`) | ||
); | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
var processFaker = new ProcessFaker(); | ||
|
||
try { | ||
let platforms = ['win32', 'linux', 'darwin']; | ||
|
||
// fake process.arch | ||
processFaker.fake('arch', { value: options.arch }); | ||
|
||
for (let i = 0, len = platforms.length; i < len; ++i) { | ||
// fake process.platform | ||
processFaker.fake('platform', { value: platforms[i] }); | ||
|
||
console.log(`downloading ${platforms[i]} imagemin binaries`); | ||
|
||
// remove downloaded binaries, | ||
// and download to binaries for target platform | ||
yield setupBinaries(platforms[i], RELEASES_DIR); | ||
|
||
console.log(`downloaded ${platforms[i]} imagemin binaries`); | ||
} | ||
} finally { | ||
// revert faked properties | ||
processFaker.unfake('arch'); | ||
processFaker.unfake('platform'); | ||
} | ||
}).then(function() { | ||
console.log('done'); | ||
}).catch(function(err) { | ||
console.error('error:'); | ||
console.error(err.stack); | ||
}); |
Oops, something went wrong.