Init
This commit is contained in:
commit
9b29b6853f
|
@ -0,0 +1,12 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[{package.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1,2 @@
|
|||
* text=auto
|
||||
*.js text eol=lf
|
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,5 @@
|
|||
os: osx
|
||||
language: node_js
|
||||
node_js:
|
||||
- '6'
|
||||
- '4'
|
Binary file not shown.
After Width: | Height: | Size: 914 B |
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
|
@ -0,0 +1,99 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const meow = require('meow');
|
||||
const appdmg = require('appdmg');
|
||||
const plist = require('plist');
|
||||
const Ora = require('ora');
|
||||
const execa = require('execa');
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
$ create-dmg <app>
|
||||
|
||||
Example
|
||||
$ create-dmg 'Lungo.app'
|
||||
`);
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
console.error('macOS only');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (cli.input.length === 0) {
|
||||
console.error('Specify an app');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const appPath = path.resolve(cli.input[0]);
|
||||
const appInfo = plist.parse(fs.readFileSync(path.join(appPath, 'Contents/Info.plist'), 'utf8'));
|
||||
const appName = appInfo.CFBundleName;
|
||||
const appIconName = appInfo.CFBundleIconFile.replace(/\.icns/, '');
|
||||
const dmgPath = `${appName} ${appInfo.CFBundleShortVersionString}.dmg`;
|
||||
|
||||
const ora = new Ora('Creating DMG');
|
||||
ora.start();
|
||||
|
||||
const ee = appdmg({
|
||||
target: dmgPath,
|
||||
basepath: __dirname,
|
||||
specification: {
|
||||
title: appName,
|
||||
icon: path.join(appPath, 'Contents/Resources', `${appIconName}.icns`),
|
||||
// Use transparent background and `background-color` option when this is fixed:
|
||||
// https://github.com/LinusU/node-appdmg/issues/135
|
||||
background: path.join(__dirname, 'assets/dmg-background.png'),
|
||||
'icon-size': 160,
|
||||
format: 'ULFO',
|
||||
window: {
|
||||
size: {
|
||||
width: 660,
|
||||
height: 400
|
||||
}
|
||||
},
|
||||
contents: [
|
||||
{
|
||||
x: 180,
|
||||
y: 170,
|
||||
type: 'file',
|
||||
path: appPath
|
||||
},
|
||||
{
|
||||
x: 480,
|
||||
y: 170,
|
||||
type: 'link',
|
||||
path: '/Applications'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
ee.on('progress', info => {
|
||||
if (info.type === 'step-begin') {
|
||||
ora.text = info.title;
|
||||
}
|
||||
});
|
||||
|
||||
ee.on('finish', () => {
|
||||
ora.text = 'Code signing DMG';
|
||||
|
||||
execa('codesign', ['--sign', 'Developer ID Application', dmgPath]).then(() => {
|
||||
return execa.stderr('codesign', [dmgPath, '--display', '--verbose=2']);
|
||||
}).then(stderr => {
|
||||
const match = /^Authority=(.*)$/m.exec(stderr);
|
||||
|
||||
if (!match) {
|
||||
ora.fail('Not code signed');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
ora.info(`Code signing identity: ${match[1]}`).start();
|
||||
ora.succeed('DMG created');
|
||||
}).catch(ora.fail.bind(ora));
|
||||
});
|
||||
|
||||
ee.on('error', err => {
|
||||
ora.fail(err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>15G1217</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>fixture</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>app.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.sindresorhus.create-dmg.fixture</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>fixture</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.0.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.0.1</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>8C38</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>16C58</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.12</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0820</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>8C38</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.11</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>EventViewerApplication</string>
|
||||
<key>NSSupportsSuddenTermination</key>
|
||||
<string>YES</string>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
APPL????
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "create-dmg",
|
||||
"version": "0.0.0",
|
||||
"description": "Create a DMG from an app (macOS)",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/create-dmg",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bin": {
|
||||
"create-dmg": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"cli.js",
|
||||
"assets"
|
||||
],
|
||||
"keywords": [
|
||||
"cli-app",
|
||||
"cli",
|
||||
"create",
|
||||
"dmg",
|
||||
"disk",
|
||||
"image",
|
||||
"macos",
|
||||
"mac",
|
||||
"app",
|
||||
"application",
|
||||
"apple"
|
||||
],
|
||||
"dependencies": {
|
||||
"appdmg": "^0.4.5",
|
||||
"execa": "^0.6.3",
|
||||
"meow": "^3.4.2",
|
||||
"ora": "^1.2.0",
|
||||
"plist": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"tempfile": "^1.1.1",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
# create-dmg [![Build Status](https://travis-ci.org/sindresorhus/create-dmg.svg?branch=master)](https://travis-ci.org/sindresorhus/create-dmg)
|
||||
|
||||
> Create a [DMG](https://en.m.wikipedia.org/wiki/Apple_Disk_Image) from an app *(macOS)*
|
||||
|
||||
<img src="screenshot-cli.gif" width="529">
|
||||
|
||||
*This tool is intentionally opinionated and simple. I'm not interested in adding lots of options.*
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --global create-dmg
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ create-dmg --help
|
||||
|
||||
Usage
|
||||
$ create-dmg <app>
|
||||
|
||||
Example
|
||||
$ create-dmg 'Lungo.app'
|
||||
```
|
||||
|
||||
|
||||
## DMG
|
||||
|
||||
The created DMG is code signed, requires macOS 10.11 or later, and has the filename `${appName} ${appVersion}.dmg`, for example `Lungo 1.0.0.dmg`.
|
||||
|
||||
<img src="screenshot-dmg.png" width="772">
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
Binary file not shown.
After Width: | Height: | Size: 274 KiB |
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import test from 'ava';
|
||||
import execa from 'execa';
|
||||
import tempfile from 'tempfile';
|
||||
|
||||
test(async t => {
|
||||
const cwd = tempfile();
|
||||
fs.mkdirSync(cwd);
|
||||
await execa(path.join(__dirname, 'cli.js'), [path.join(__dirname, 'fixture.app')], {cwd});
|
||||
t.true(fs.existsSync(path.join(cwd, 'fixture 0.0.1.dmg')));
|
||||
});
|
Loading…
Reference in New Issue