Skip to content

Commit

Permalink
Merge pull request #178 from electron-userland/ts-installer-dmg
Browse files Browse the repository at this point in the history
refactor: convert to typescript and upgrade Node.js versions
  • Loading branch information
felixrieseberg committed Jul 2, 2024
2 parents 4fc4910 + 001ed46 commit 7953a8d
Show file tree
Hide file tree
Showing 15 changed files with 943 additions and 533 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"rules": {
"consistent-return": "off"
},
"extends": "airbnb-base"
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser"
}
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
python-version: '3.11' # distutils is required by node-gyp and dropped by python core in 3.12
- name: Install
run: yarn --frozen-lockfile
- name: Build
run: yarn tsc
- name: Lint
run: yarn lint
- name: Test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ coverage/
npm-debug.log
package-lock.json
test/fixture*
dist
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
## Requirements

This module requires using macOS and Node 12 (LTS) or above.
This module requires using macOS and Node 16 or above.

## Installation

Expand Down Expand Up @@ -38,7 +38,6 @@ Options:
--icon-size=<px> How big to make the icon for the app in the DMG. [Default: `80`].
--background=<path> Path to a PNG image to use as the background of the DMG. [Size: 658 x 498]
--title=<string> The title of the produced DMG, which will be shown when mounted.
--debug Enable debug messages.
--overwrite Overwrite any existing DMG.
-h --help Show this screen.
--version Show version.
Expand Down Expand Up @@ -75,18 +74,15 @@ Path to the background for the DMG window. Background image should be of size 65
`icon` - *String*
Path to the icon to use for the app in the DMG window.

`iconSize` - *Number*
How big to make the icon for the app in the DMG. [Default: `80`].

`overwrite` - *Boolean*
Overwrite an existing DMG file if if already exists.

`debug` - *Boolean*
Enable debug message output.

`out` - *String*
The directory to put the DMG into. [Default: `process.cwd()`].

`iconSize` - *Number*
How big to make the icon for the app in the DMG. [Default: `80`].

`contents` - *Array* or *Function* that returns an Array of objects.
The content that will appear in the window when user opens the `.dmg` file.
[Default: Array of two icons, application and application destination folder].
Expand Down
41 changes: 0 additions & 41 deletions bin/electron-installer-dmg.js

This file was deleted.

35 changes: 23 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,58 @@
"name": "electron-installer-dmg",
"description": "Create DMG installers for your electron apps.",
"version": "4.0.0",
"main": "./src/index.js",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"author": "Lucas Hrabovsky <lucas@mongodb.com> (http://imlucas.com)",
"homepage": "http://github.com/electron-userland/electron-installer-dmg",
"repository": {
"type": "git",
"url": "git://github.com/electron-userland/electron-installer-dmg.git"
},
"scripts": {
"build": "tsc",
"coverage": "nyc --reporter=lcov --reporter=text npm run spec",
"lint": "eslint src test bin",
"spec": "mocha",
"test": "npm run lint && npm run spec"
"lint": "eslint src test --ext js,ts",
"spec": "ts-mocha test/*.test.ts",
"test": "tsc && npm run lint && npm run spec",
"prepublishOnly": "tsc"
},
"bin": {
"electron-installer-dmg": "bin/electron-installer-dmg.js"
"electron-installer-dmg": "dist/electron-installer-dmg-bin.js"
},
"engines": {
"node": ">= 12.13.0"
"node": ">= 16"
},
"files": [
"bin",
"dist",
"resources",
"src",
"usage.txt"
],
"dependencies": {
"debug": "^4.3.2",
"minimist": "^1.1.1"
"minimist": "^1.2.7"
},
"optionalDependencies": {
"appdmg": "^0.6.4"
},
"license": "Apache-2.0",
"devDependencies": {
"@electron/get": "^1.1.0",
"eslint": "^7.32.0",
"@electron/get": "^2.0.2",
"@types/appdmg": "^0.5.2",
"@types/debug": "^4.1.7",
"@types/minimist": "^1.2.2",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.7",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"eslint": "^8.26.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.23.4",
"extract-zip": "^2.0.1",
"mocha": "^9.0.3",
"nyc": "^15.1.0"
"nyc": "^15.1.0",
"ts-mocha": "^10.0.0",
"typescript": "5.5.2"
},
"keywords": [
"mongodb.js",
Expand Down
Binary file removed resources/mac/atom.icns
Binary file not shown.
Binary file added resources/mac/electron.icns
Binary file not shown.
53 changes: 53 additions & 0 deletions src/electron-installer-dmg-bin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env node

/* eslint no-console:0 no-sync:0 */
import * as fs from 'fs';
import * as minimist from 'minimist';
import * as path from 'path';

import { createDMG, ElectronInstallerDMGOptions } from '.';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg: { version: string } = require('../package.json');

const usage = fs.readFileSync(path.resolve(__dirname, '../usage.txt')).toString();
const args = minimist<Pick<ElectronInstallerDMGOptions, 'overwrite' | 'icon' | 'background' | 'title' | 'format'> & {
out?: string;
'icon-size'?: string;
}>(process.argv.slice(2), {
boolean: ['overwrite'],
string: ['out', 'icon', 'icon-size', 'background', 'title', 'format'],
});

const [appPath, name] = args._;

const options: ElectronInstallerDMGOptions = {
appPath,
name,
overwrite: args.overwrite,
icon: args.icon,
iconSize: args['icon-size'] ? parseInt(args['icon-size'], 10) : undefined,
background: args.background,
title: args.title,
format: args.format,
out: args.out,
};

if (args.help || args.h || !options.appPath || !options.name) {
console.error(usage);
process.exit(1);
}

if (args.version) {
console.error(pkg.version);
process.exit(1);
}

createDMG(options)
.then(() => {
console.log(`Wrote DMG to:\n${args.dmgPath}`);
})
.catch((err) => {
console.error(err);
process.exit(1);
});
123 changes: 0 additions & 123 deletions src/index.js

This file was deleted.

Loading

0 comments on commit 7953a8d

Please sign in to comment.