mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
switch npm scripts with Grunt task
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ node_modules/*
|
|||||||
!node_modules/boost
|
!node_modules/boost
|
||||||
dist/
|
dist/
|
||||||
compiled
|
compiled
|
||||||
|
/secret
|
||||||
|
|||||||
2
LICENSE
Normal file
2
LICENSE
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
本製品をインストール、または使用することによって、お客様は利用規約(
|
||||||
|
https://b00st.io/regulations.html)より拘束されることに承諾されたものとします。利用規約に同意されない場合、Boostnoteは、お客様に本製品のインストール、使用のいずれも許諾できません。
|
||||||
141
gruntfile.js
Normal file
141
gruntfile.js
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const ChildProcess = require('child_process')
|
||||||
|
const packager = require('electron-packager')
|
||||||
|
const archiver = require('archiver')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
|
module.exports = function (grunt) {
|
||||||
|
|
||||||
|
// Project configuration.
|
||||||
|
grunt.initConfig({
|
||||||
|
pkg: grunt.file.readJSON('package.json'),
|
||||||
|
auth_code: grunt.file.readJSON('secret/auth_code.json'),
|
||||||
|
'create-windows-installer': {
|
||||||
|
x64: {
|
||||||
|
appDirectory: path.join(__dirname, 'dist', 'Boostnote-win32-x64'),
|
||||||
|
outputDirectory: path.join(__dirname, 'dist'),
|
||||||
|
authors: 'MAISIN&CO., Inc.',
|
||||||
|
exe: 'Boostnote.exe',
|
||||||
|
loadingGif: path.join(__dirname, 'resources/install.gif'),
|
||||||
|
iconUrl: path.join(__dirname, 'resources/app.ico'),
|
||||||
|
setupIcon: path.join(__dirname, 'resources/dmg.ico'),
|
||||||
|
certificateFile: grunt.config.get('auth_code.win_cert_path'),
|
||||||
|
certificatePassword: grunt.config.get('auth_code.win_cert_pw'),
|
||||||
|
noMsi: true,
|
||||||
|
remoteReleases: 'https://github.com/BoostIO/boost-releases/releases/download/v0.4.10/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
grunt.loadNpmTasks('grunt-electron-installer')
|
||||||
|
|
||||||
|
grunt.registerTask('compile', function () {
|
||||||
|
var done = this.async()
|
||||||
|
var execPath = path.join('node_modules', '.bin', 'webpack') + ' --config webpack.config.production.js'
|
||||||
|
grunt.log.writeln(execPath)
|
||||||
|
var compileProcess = ChildProcess.exec(execPath,
|
||||||
|
{
|
||||||
|
env: Object.assign({}, process.env, {
|
||||||
|
BABEL_ENV: 'production'
|
||||||
|
})
|
||||||
|
}, function (err, stdout, stderr) {
|
||||||
|
grunt.log.writeln(stdout)
|
||||||
|
if (err) {
|
||||||
|
grunt.log.writeln(err)
|
||||||
|
grunt.log.writeln(stderr)
|
||||||
|
done(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
grunt.registerTask('zip', function (platform) {
|
||||||
|
var done = this.async()
|
||||||
|
var archive = archiver.create('zip', {})
|
||||||
|
switch (platform) {
|
||||||
|
case 'win':
|
||||||
|
archive.file(path.join('dist/Setup.exe'), { name:'Boostnote-installer-win32-x64.exe' })
|
||||||
|
default:
|
||||||
|
done()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
archive.finalize()
|
||||||
|
var writeStream = fs.createWriteStream(path.join('dist/Boostnote-installer-win32-x64.zip'))
|
||||||
|
archive.pipe(writeStream)
|
||||||
|
writeStream.on('close', function () {
|
||||||
|
grunt.log.writeln('Zipped!')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
grunt.registerTask('pack', function (platform) {
|
||||||
|
grunt.log.writeln(path.join(__dirname, 'dist'))
|
||||||
|
var done = this.async()
|
||||||
|
var opts = {
|
||||||
|
name: 'Boostnote',
|
||||||
|
arch: 'x64',
|
||||||
|
dir: __dirname,
|
||||||
|
version: '0.35.4',
|
||||||
|
'app-version': grunt.config.get('pkg.version'),
|
||||||
|
'app-bundle-id': 'com.maisin.boost',
|
||||||
|
asar: true,
|
||||||
|
prune: true,
|
||||||
|
overwrite: true,
|
||||||
|
out: path.join(__dirname, 'dist'),
|
||||||
|
ignore: /submodules\/ace\/(?!src-min)|submodules\/ace\/(?=src-min-noconflict)|node_modules\/devicon\/icons|dist|.env/
|
||||||
|
}
|
||||||
|
switch (platform) {
|
||||||
|
case 'win':
|
||||||
|
Object.assign(opts, {
|
||||||
|
platform: 'win32',
|
||||||
|
icon: path.join(__dirname, 'resources/app.ico'),
|
||||||
|
'version-string': {
|
||||||
|
CompanyName: 'MAISIN&CO., Inc.',
|
||||||
|
LegalCopyright: '© 2015 MAISIN&CO., Inc. All rights reserved.',
|
||||||
|
FileDescription: 'Boostnote',
|
||||||
|
OriginalFilename: 'Boostnote',
|
||||||
|
FileVersion: grunt.config.get('pkg.version'),
|
||||||
|
ProductVersion: grunt.config.get('pkg.version'),
|
||||||
|
ProductName: 'Boostnote',
|
||||||
|
InternalName: 'Boostnote'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
packager(opts, function (err, appPath) {
|
||||||
|
if (err) {
|
||||||
|
grunt.log.writeln(err)
|
||||||
|
done(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'osx':
|
||||||
|
Object.assign(opts, {
|
||||||
|
platform: 'darwin',
|
||||||
|
icon: path.join(__dirname, 'resources/app.icns'),
|
||||||
|
'app-category-type': 'public.app-category.developer-tools'
|
||||||
|
})
|
||||||
|
packager(opts, function (err, appPath) {
|
||||||
|
if (err) {
|
||||||
|
grunt.log.writeln(err)
|
||||||
|
done(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
grunt.registerTask('build', function (platform) {
|
||||||
|
if (!platform) {
|
||||||
|
platform = process.platform === 'darwin' ? 'osx' : process.platform === 'win32' ? 'win' : null
|
||||||
|
}
|
||||||
|
switch (platform) {
|
||||||
|
case 'win':
|
||||||
|
grunt.task.run(['pack:win', 'create-windows-installer', 'zip:win'])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// Default task(s).
|
||||||
|
grunt.registerTask('default', ['build'])
|
||||||
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "boost",
|
"name": "boost",
|
||||||
"version": "0.4.6",
|
"version": "0.4.6",
|
||||||
"description": "Boost App",
|
"description": "Boostnote",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron ./index.js",
|
"start": "electron ./index.js",
|
||||||
"hot": "electron ./index.js --hot",
|
"hot": "electron ./index.js --hot",
|
||||||
"webpack": "webpack-dev-server --hot --inline --config webpack.config.js",
|
"webpack": "webpack-dev-server --hot --inline --config webpack.config.js",
|
||||||
"compile": "webpack --config webpack.config.production.js",
|
|
||||||
"pack:osx": "electron-packager ./ Boost --app-version=$npm_package_version $npm_package_config_platform $npm_package_config_version $npm_package_config_ignore --overwrite --out=\"dist\"",
|
|
||||||
"codesign": "codesign --verbose --deep --force --sign \"MAISIN solutions Inc.\" dist/Boost-darwin-x64/Boost.app",
|
"codesign": "codesign --verbose --deep --force --sign \"MAISIN solutions Inc.\" dist/Boost-darwin-x64/Boost.app",
|
||||||
"build:osx": "electron-builder \"dist/Boost-darwin-x64/Boost.app\" --platform=osx --out=\"dist\" --config=\"./builder-config.json\"",
|
"build:osx": "electron-builder \"dist/Boost-darwin-x64/Boost.app\" --platform=osx --out=\"dist\" --config=\"./builder-config.json\"",
|
||||||
"release": "electron-release --app=\"dist/Boost-darwin-x64/Boost.app\" --token=$(cat .env/.github-token) --repo=\"BoostIO/boost-releases\""
|
"release": "electron-release --app=\"dist/Boost-darwin-x64/Boost.app\" --token=$(cat .env/.github-token) --repo=\"BoostIO/boost-releases\""
|
||||||
@@ -55,12 +53,15 @@
|
|||||||
"superagent-promise": "^1.0.3"
|
"superagent-promise": "^1.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"archiver": "^0.20.0",
|
||||||
"babel-loader": "^5.3.2",
|
"babel-loader": "^5.3.2",
|
||||||
"babel-plugin-react-transform": "^1.1.1",
|
"babel-plugin-react-transform": "^1.1.1",
|
||||||
"css-loader": "^0.19.0",
|
"css-loader": "^0.19.0",
|
||||||
"electron-packager": "^5.1.0",
|
"electron-packager": "^5.1.0",
|
||||||
"electron-prebuilt": "^0.35.1",
|
"electron-prebuilt": "^0.35.1",
|
||||||
"electron-release": "^2.2.0",
|
"electron-release": "^2.2.0",
|
||||||
|
"grunt": "^0.4.5",
|
||||||
|
"grunt-electron-installer": "^1.2.0",
|
||||||
"nib": "^1.1.0",
|
"nib": "^1.1.0",
|
||||||
"react": "^0.14.0",
|
"react": "^0.14.0",
|
||||||
"react-dom": "^0.14.0",
|
"react-dom": "^0.14.0",
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
var webpack = require('webpack')
|
var webpack = require('webpack')
|
||||||
module.exports = {
|
var path = require('path')
|
||||||
entry: {
|
var JsonpTemplatePlugin = webpack.JsonpTemplatePlugin
|
||||||
main: './browser/main/index.js',
|
var FunctionModulePlugin = require('webpack/lib/FunctionModulePlugin')
|
||||||
finder: './browser/finder/index.js'
|
var NodeTargetPlugin = require('webpack/lib/node/NodeTargetPlugin')
|
||||||
},
|
|
||||||
output: {
|
var opt = {
|
||||||
path: 'compiled',
|
path: path.join(__dirname, 'compiled'),
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
// sourceMapFilename: '[name].map',
|
sourceMapFilename: '[name].map',
|
||||||
libraryTarget: 'commonjs2'
|
libraryTarget: 'commonjs2',
|
||||||
},
|
publicPath: 'http://localhost:8080/assets/'
|
||||||
|
}
|
||||||
|
|
||||||
|
config = {
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{
|
{
|
||||||
@@ -24,11 +27,26 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
entry: {
|
||||||
|
main: './browser/main/index.js',
|
||||||
|
finder: './browser/finder/index.js'
|
||||||
|
},
|
||||||
|
output: opt,
|
||||||
|
resolve: {
|
||||||
|
extensions: ['', '.js', '.jsx'],
|
||||||
|
packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'],
|
||||||
|
alias: {
|
||||||
|
'boost': path.resolve(__dirname, 'lib')
|
||||||
|
}
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new webpack.NoErrorsPlugin(),
|
||||||
|
new NodeTargetPlugin(),
|
||||||
new webpack.optimize.OccurenceOrderPlugin(),
|
new webpack.optimize.OccurenceOrderPlugin(),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
'NODE_ENV': JSON.stringify('production')
|
'NODE_ENV': JSON.stringify('production'),
|
||||||
|
'BABEL_ENV': JSON.stringify('production')
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
@@ -49,8 +67,14 @@ module.exports = {
|
|||||||
'highlight.js',
|
'highlight.js',
|
||||||
'markdown-it-emoji',
|
'markdown-it-emoji',
|
||||||
'fs-jetpack'
|
'fs-jetpack'
|
||||||
],
|
]
|
||||||
resolve: {
|
|
||||||
extensions: ['', '.js', '.jsx', 'styl']
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.target = function renderer (compiler) {
|
||||||
|
compiler.apply(
|
||||||
|
new JsonpTemplatePlugin(opt),
|
||||||
|
new FunctionModulePlugin(opt)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = config
|
||||||
|
|||||||
Reference in New Issue
Block a user