mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-03 06:10:20 +00:00
dont download atom-shell -- use local version instead
This commit is contained in:
parent
95c236dd25
commit
330e376372
3
.travis.yml
Normal file
3
.travis.yml
Normal file
@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.12'
|
56
index.js
56
index.js
@ -3,55 +3,41 @@ var path = require('path')
|
||||
var fs = require('fs')
|
||||
var child = require('child_process')
|
||||
|
||||
var nugget = require('nugget')
|
||||
var plist = require('plist')
|
||||
var unzip = require('extract-zip')
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var ncp = require('ncp').ncp
|
||||
|
||||
var latest = '0.22.1'
|
||||
|
||||
module.exports = function packager (opts, cb) {
|
||||
if (!opts.version) opts.version = latest
|
||||
|
||||
var names = {
|
||||
mac: 'atom-shell-v' + opts.version + '-darwin-x64'
|
||||
try {
|
||||
var atomShellPath = require.resolve('atom-shell')
|
||||
atomShellPath = path.join(atomShellPath, '..')
|
||||
} catch (e) {
|
||||
cb(new Error('Cannot find atom-shell from here, please install it from npm'))
|
||||
}
|
||||
|
||||
var macUrl = 'https://github.com/atom/atom-shell/releases/download/v' + opts.version + '/' + names.mac + '.zip'
|
||||
var localFile = path.join(__dirname, 'downloaded', names.mac + '.zip')
|
||||
var tmpDir = path.join(os.tmpdir(), names.mac)
|
||||
var atomPkg = require(path.join(atomShellPath, 'package.json'))
|
||||
console.error('Using atom-shell version', atomPkg.version, 'from', atomShellPath)
|
||||
|
||||
var atomShellApp = path.join(atomShellPath, 'dist', 'Atom.app')
|
||||
var tmpDir = path.join(os.tmpdir(), 'atom-shell-packager-mac')
|
||||
|
||||
var newApp = path.join(tmpDir, opts.name + '.app')
|
||||
|
||||
// reset build folders + copy template app
|
||||
rimraf(tmpDir, function rmrfd () {
|
||||
// ignore errors
|
||||
mkdirp(tmpDir, function mkdirpd () {
|
||||
mkdirp(newApp, function mkdirpd () {
|
||||
// ignore errors
|
||||
if (opts.zip) extractZip(opts.zip)
|
||||
else downloadZip()
|
||||
// copy .app folder and use as template (this is exactly what Atom editor does)
|
||||
ncp(atomShellApp, newApp, function copied (err) {
|
||||
if (err) return cb(err)
|
||||
buildMacApp()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function downloadZip () {
|
||||
nugget(macUrl, {target: localFile, dir: path.join(__dirname, 'downloaded'), resume: true, verbose: true}, function downloaded (err) {
|
||||
if (err) return cb(err)
|
||||
extractZip(localFile)
|
||||
})
|
||||
}
|
||||
|
||||
function extractZip (filename) {
|
||||
unzip(filename, {dir: tmpDir}, function extracted (err) {
|
||||
if (err) return cb(err)
|
||||
buildApp()
|
||||
})
|
||||
}
|
||||
|
||||
function buildApp () {
|
||||
var newApp = path.join(tmpDir, opts.name + '.app')
|
||||
|
||||
// rename .app folder (this is exactly what Atom editor does)
|
||||
fs.renameSync(path.join(tmpDir, 'Atom.app'), newApp)
|
||||
|
||||
function buildMacApp () {
|
||||
var paths = {
|
||||
info1: path.join(newApp, 'Contents', 'Info.plist'),
|
||||
info2: path.join(newApp, 'Contents', 'Frameworks', 'Atom Helper.app', 'Contents', 'Info.plist'),
|
||||
@ -74,7 +60,7 @@ module.exports = function packager (opts, cb) {
|
||||
fs.writeFileSync(paths.info1, plist.build(pl1))
|
||||
fs.writeFileSync(paths.info2, plist.build(pl2))
|
||||
|
||||
function filter(file) {
|
||||
function filter (file) {
|
||||
var ignore = opts.ignore || []
|
||||
if (!Array.isArray(ignore)) ignore = [ignore]
|
||||
for (var i = 0; i < ignore.length; i++) {
|
||||
|
@ -17,16 +17,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/maxogden/atom-shell-packager",
|
||||
"dependencies": {
|
||||
"extract-zip": "^1.0.3",
|
||||
"minimist": "^1.1.1",
|
||||
"mkdirp": "^0.5.0",
|
||||
"ncp": "^2.0.0",
|
||||
"nugget": "^1.4.1",
|
||||
"plist": "^1.1.0",
|
||||
"rimraf": "^2.3.2"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "standard"
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ Build a distributable app from an atom-shell app source code directory. **Curren
|
||||
|
||||
[![NPM](https://nodei.co/npm/atom-shell-packager.png)](https://nodei.co/npm/atom-shell-packager/)
|
||||
|
||||
[![Build Status](https://travis-ci.org/maxogden/atom-shell-packager.svg?branch=master)](https://travis-ci.org/maxogden/atom-shell-packager)
|
||||
|
||||
For an example project using this, check out [Monu](https://github.com/maxogden/monu)
|
||||
|
||||
### installation
|
||||
|
Loading…
Reference in New Issue
Block a user