electron-osx-sign
Advanced tools
Comparing version 0.1.6 to 0.2.0
81
index.js
@@ -36,2 +36,25 @@ var fs = require('fs') | ||
function flatApplication (opts, callback) { | ||
var operations = [] | ||
// Call productbuild | ||
operations.push(function (cb) { | ||
child.exec([ | ||
'productbuild', | ||
'--component', '"' + opts.app.replace(/"/g, '\\"') + '"', '"' + opts.install.replace(/"/g, '\\"') + '"', | ||
'--sign', '"' + opts.identity + '"', | ||
'"' + opts.pkg.replace(/"/g, '\\"') + '"' | ||
].join(' '), function (err, stdout, stderr) { | ||
if (err) return cb(err) | ||
cb() | ||
}) | ||
if (opts.verbose) console.log('Flattening with productbuild...') | ||
}) | ||
series(operations, function (err) { | ||
if (err) return callback(err) | ||
callback() | ||
}) | ||
} | ||
function generateAppBasename (opts) { | ||
@@ -297,1 +320,59 @@ return path.basename(opts.app, '.app') | ||
} | ||
module.exports.flat = function flat (opts, cb) { | ||
// Default callback function if none provided | ||
if (!cb) { | ||
cb = function (err) { | ||
if (err) { | ||
if (opts.verbose) { | ||
console.error('Flat failed.') | ||
if (err.message) console.error(err.message) | ||
else console.error(err, err.stack) | ||
} | ||
return | ||
} | ||
if (opts.verbose) console.log('Application flattened:', opts.pkg) | ||
} | ||
} | ||
if (!opts.app) return cb(new Error('Path to aplication must be specified.')) | ||
if (path.extname(opts.app) !== '.app') return cb(new Error('Extension of application must be `.app`.')) | ||
if (!fs.existsSync(opts.app)) return cb(new Error('Application not found.')) | ||
// Match platform if none is provided | ||
if (!opts.pkg) { | ||
if (opts.verbose) console.warn('No `--pkg` passed in arguments, will fallback to default, inferred from the given application.') | ||
opts.pkg = path.join(path.dirname(opts.app), path.basename(opts.app, '.app') + '.pkg') | ||
} else if (path.extname(opts.pkg) !== '.pkg') return cb(new Error('Extension of output package must be `.pkg`.')) | ||
if (!opts.install) { | ||
if (opts.verbose) console.warn('No `--install` passed in arguments, will fallback to default `/Applications`.') | ||
opts.install = '/Applications' | ||
} | ||
series([ | ||
function (cb) { | ||
// Checking identity with series for async execution of child process | ||
if (!opts.identity) { | ||
if (opts.verbose) console.warn('No `--identity` passed in arguments, matching identities...') | ||
if (!opts.platform) { | ||
if (opts.verbose) console.warn('No `--platform` passed in arguments, cheking Electron platform...') | ||
detectElectronPlatform(opts) | ||
} else if (opts.platform !== 'mas' && opts.platform !== 'darwin') { | ||
return cb(new Error('Only platform `darwin` and `mas` are supported.')) | ||
} | ||
if (opts.platform === 'mas') { | ||
findIdentity(opts, '3rd Party Mac Developer Installer', cb) | ||
} else if (opts.platform === 'darwin') { | ||
findIdentity(opts, 'Developer ID Installer', cb) | ||
} | ||
} else cb() | ||
} | ||
], function (err) { | ||
if (err) return cb(err) | ||
if (opts.verbose) { | ||
console.log('Flattening application...') | ||
console.log('> application ', opts.app) | ||
console.log('> package-output ', opts.pkg) | ||
console.log('> install-path ', opts.install) | ||
console.log('> identity ', opts.identity) | ||
} | ||
return flatApplication(opts, cb) | ||
}) | ||
} |
{ | ||
"name": "electron-osx-sign", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Code-signing for Electron-packed OS X apps.", | ||
"main": "index.js", | ||
"bin": { | ||
"electron-osx-flat": "bin/electron-osx-flat.js", | ||
"electron-osx-sign": "bin/electron-osx-sign.js" | ||
@@ -34,2 +35,3 @@ }, | ||
"scripts": { | ||
"pretest": "rimraf test/work", | ||
"test": "standard && tape test" | ||
@@ -36,0 +38,0 @@ }, |
152
README.md
@@ -21,4 +21,6 @@ # electron-osx-sign [![npm][npm_img]][npm_url] | ||
### From the Command Line | ||
### electron-osx-sign | ||
#### From the Command Line | ||
```sh | ||
@@ -36,3 +38,3 @@ electron-osx-sign <app> [additional-binaries...] [--options...] | ||
### From the API | ||
#### From the API | ||
@@ -46,2 +48,4 @@ ```javascript | ||
##### sign(opts, callback) | ||
```javascript | ||
@@ -60,6 +64,4 @@ var sign = require('electron-osx-sign') | ||
#### sign(opts, callback) | ||
###### opts | ||
##### opts | ||
**Required** | ||
@@ -70,2 +72,3 @@ | ||
Path to the application package. | ||
Needs file extension `.app`. | ||
@@ -119,3 +122,3 @@ **Optional** | ||
*Note: `helper-path`, `helper-eh-path`, `helper-np-path` needn't provided unless error thrown for not able to find any of them automatically.* | ||
*Note: `helper-path`, `helper-executable-path`, `helper-eh-path`, `helper-eh-executable-path`, `helper-np-path`, `helper-np-executable-path` needn't provided unless error thrown for not able to find any of them automatically.* | ||
@@ -133,3 +136,3 @@ `identity` - *String* | ||
Allowed values: `darwin`, `mas`. | ||
Default to auto detect from presence of `Mantle.framework`, `ReactiveCocoa.framework`, and `Squirrel.framework` within the application package. | ||
Default to auto detect from presence of `Squirrel.framework` within the application package. | ||
@@ -141,6 +144,85 @@ `verbose` - *Boolean* | ||
##### callback | ||
###### callback | ||
`err` - *Error* | ||
### electron-osx-flat | ||
#### From the Command Line | ||
```sh | ||
electron-osx-flat <app> [--options...] | ||
``` | ||
Example: | ||
```sh | ||
electron-osx-flat path/to/my.app | ||
``` | ||
For details on the optional flags, run `electron-osx-flat --help` or see [electron-osx-flat-usage.txt](https://github.com/sethlu/electron-sign/blob/master/bin/electron-osx-flat-usage.txt). | ||
#### From the API | ||
##### flat(opts, callback) | ||
```javascript | ||
var flat = require('electron-osx-sign').flat | ||
flat(opts[, function done (err) {}]) | ||
``` | ||
Example: | ||
```javascript | ||
var flat = require('electron-osx-sign').flat | ||
flat({ | ||
app: 'path/to/my.app' | ||
}, function done (err) { | ||
if (err) { | ||
// Handle the error | ||
return; | ||
} | ||
// Regular callback | ||
}) | ||
``` | ||
###### opts | ||
**Required** | ||
`app` - *String* | ||
Path to the application package. | ||
Needs file extension `.app`. | ||
**Optional** | ||
`identity` - *String* | ||
Name of certificate to use when flattening. | ||
Default to retrieve from `login.keychain`. | ||
`install` - *String* | ||
Path to install for the bundle. | ||
Default to `/Applications`. | ||
`platform` - *String* | ||
Build platform of Electron. Allowed values: `darwin`, `mas`. | ||
Default to auto detect from application. | ||
`pkg` - *String* | ||
Path to the output flattened package. | ||
Needs file extension `.app`. | ||
`verbose` - *String* | ||
Verbose flag, to display every action. | ||
###### callback | ||
`err` - *Error* | ||
## Frequently Raised Issues | ||
@@ -185,3 +267,3 @@ | ||
> electron-sign@0.1.6 test electron-osx-sign | ||
> electron-osx-sign@0.2.0 test electron-osx-sign | ||
> standard && tape test | ||
@@ -195,37 +277,53 @@ | ||
ok 1 app signed | ||
ok 2 app flattened | ||
# defaults-test:v0.25.0-darwin-x64 | ||
ok 2 app signed | ||
ok 3 app signed | ||
ok 4 app flattened | ||
# defaults-test:v0.26.0-darwin-x64 | ||
ok 3 app signed | ||
ok 5 app signed | ||
ok 6 app flattened | ||
# defaults-test:v0.27.0-darwin-x64 | ||
ok 4 app signed | ||
ok 7 app signed | ||
ok 8 app flattened | ||
# defaults-test:v0.28.0-darwin-x64 | ||
ok 5 app signed | ||
ok 9 app signed | ||
ok 10 app flattened | ||
# defaults-test:v0.29.0-darwin-x64 | ||
ok 6 app signed | ||
ok 11 app signed | ||
ok 12 app flattened | ||
# defaults-test:v0.30.0-darwin-x64 | ||
ok 7 app signed | ||
ok 13 app signed | ||
ok 14 app flattened | ||
# defaults-test:v0.31.0-darwin-x64 | ||
ok 8 app signed | ||
ok 15 app signed | ||
ok 16 app flattened | ||
# defaults-test:v0.32.0-darwin-x64 | ||
ok 9 app signed | ||
ok 17 app signed | ||
ok 18 app flattened | ||
# defaults-test:v0.33.0-darwin-x64 | ||
ok 10 app signed | ||
ok 19 app signed | ||
ok 20 app flattened | ||
# defaults-test:v0.34.0-darwin-x64 | ||
ok 11 app signed | ||
ok 21 app signed | ||
ok 22 app flattened | ||
# defaults-test:v0.34.0-mas-x64 | ||
ok 12 app signed | ||
ok 23 app signed | ||
ok 24 app flattened | ||
# defaults-test:v0.35.0-darwin-x64 | ||
ok 13 app signed | ||
ok 25 app signed | ||
ok 26 app flattened | ||
# defaults-test:v0.35.0-mas-x64 | ||
ok 14 app signed | ||
ok 27 app signed | ||
ok 28 app flattened | ||
# defaults-test:v0.36.0-darwin-x64 | ||
ok 15 app signed | ||
ok 29 app signed | ||
ok 30 app flattened | ||
# defaults-test:v0.36.0-mas-x64 | ||
ok 16 app signed | ||
ok 31 app signed | ||
ok 32 app flattened | ||
# teardown | ||
1..16 | ||
# tests 16 | ||
# pass 16 | ||
1..32 | ||
# tests 32 | ||
# pass 32 | ||
@@ -232,0 +330,0 @@ # ok |
var sign = require('..') | ||
var flat = require('..').flat | ||
@@ -19,5 +20,8 @@ var waterfall = require('run-waterfall') | ||
function (cb) { | ||
sign(opts, cb) | ||
sign(Object.create(opts), cb) | ||
}, function (cb) { | ||
t.pass('app signed') | ||
flat(Object.create(opts), cb) | ||
}, function (cb) { | ||
t.pass('app flattened') | ||
cb() | ||
@@ -24,0 +28,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34140
16
539
333
3