Skip to content

Commit

Permalink
refactor(all): rewrote in typescript
Browse files Browse the repository at this point in the history
* well here we go

* refactor(all-makers): rewrote in typescript

* now some publishers

* more publishers

* pretty much everything

* Finish typescript conversion with core tests

* Conflict resolution

* Ensure ts output is generated (forgot the tsconfig)

* Fix ES5 inclusion of fetch-mock

* Remove .vscode
  • Loading branch information
MarshallOfSound authored Apr 28, 2018
1 parent 129e4ab commit a3faa61
Show file tree
Hide file tree
Showing 173 changed files with 3,385 additions and 1,822 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"node": "6"
}
}
]
],
"@babel/typescript"
]
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules
dist
yarn-error.log
packages/.old
packages/.old
**/tsconfig.json
!/tsconfig.json
.vscode
1 change: 1 addition & 0 deletions mocha.opts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--require @babel/register
--require ../../../tools/test-setup.js
--timeout 800000
49 changes: 40 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
}
},
"scripts": {
"build": "bolt ws exec -- node_modules/.bin/babel src -d dist --quiet",
"clean": "bolt ws exec -- rimraf dist",
"prebuild": "bolt clean && ts-node tools/link-ts.ts && bolt ws exec -- node_modules/.bin/tsc --emitDeclarationOnly",
"build": "bolt ws exec -- node_modules/.bin/babel src -d dist --quiet --extensions \".ts\"",
"postbuild": "ts-node tools/test-dist",
"commit": "git-cz",
"docs:build": "cd docs && gitbook build",
"docs:install": "cd docs && gitbook install",
Expand All @@ -32,7 +35,7 @@
"dependencies": {
"@octokit/rest": "^15.2.6",
"aws-sdk": "^2.9.0",
"colors": "^1.1.2",
"colors": "^1.2.0",
"commander": "^2.9.0",
"cross-spawn": "^6.0.4",
"cross-spawn-promise": "^0.10.1",
Expand Down Expand Up @@ -68,12 +71,37 @@
"zip-folder": "^1.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0-beta.40",
"@babel/core": "^7.0.0-beta.40",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.40",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.40",
"@babel/preset-env": "^7.0.0-beta.40",
"@babel/register": "^7.0.0-beta.40",
"@babel/cli": "^7.0.0-beta.44",
"@babel/core": "^7.0.0-beta.44",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.44",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.44",
"@babel/preset-env": "^7.0.0-beta.44",
"@babel/preset-typescript": "^7.0.0-beta.44",
"@babel/register": "^7.0.0-beta.44",
"@types/chai": "^4.1.2",
"@types/chai-as-promised": "^7.1.0",
"@types/cross-spawn": "^6.0.0",
"@types/debug": "^0.0.30",
"@types/electron-packager": "^10.1.0",
"@types/electron-winstaller": "^2.6.1",
"@types/fetch-mock": "^6.0.1",
"@types/form-data": "^2.2.1",
"@types/fs-extra": "^5.0.2",
"@types/glob": "^5.0.35",
"@types/inquirer": "^0.0.41",
"@types/lodash.merge": "^4.6.3",
"@types/lodash.template": "^4.4.3",
"@types/log-symbols": "^2.0.0",
"@types/mime-types": "^2.1.0",
"@types/mocha": "^5.1.0",
"@types/node": "^9.6.5",
"@types/node-fetch": "^1.6.8",
"@types/opn": "^5.1.0",
"@types/ora": "^1.3.4",
"@types/pify": "^3.0.1",
"@types/proxyquire": "^1.3.28",
"@types/semver": "^5.5.0",
"@types/sinon": "^4.3.1",
"asar": "^0.14.0",
"babel-eslint": "^7.0.0",
"chai": "^4.0.0",
Expand All @@ -95,7 +123,10 @@
"nodemon": "^1.11.0",
"nyc": "^11.0.0",
"proxyquire": "^2.0.1",
"sinon": "^4.1.2"
"rimraf": "^2.6.2",
"sinon": "^4.1.2",
"ts-node": "^6.0.0",
"typescript": "^2.8.1"
},
"optionalDependencies": {
"electron-installer-debian": "^0.8.0",
Expand Down
7 changes: 4 additions & 3 deletions packages/api/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"electron-forge-vscode-win": "script/vscode.cmd"
},
"scripts": {
"test": "mocha test/**/*_spec.js test/**/**/*_spec.js --opts ../../../mocha.opts"
"test": "mocha --require ts-node/register test/**/*_spec.ts test/**/**/*_spec.ts --opts ../../../mocha.opts"
},
"devDependencies": {
"chai": "^4.0.0",
Expand All @@ -21,13 +21,14 @@
"dependencies": {
"@electron-forge/async-ora": "6.0.0-beta.3",
"@electron-forge/core": "6.0.0-beta.3",
"colors": "^1.1.2",
"colors": "^1.2.0",
"commander": "^2.9.0",
"debug": "^3.0.0",
"fs-extra": "^5.0.0",
"inquirer": "^5.0.0",
"semver": "^5.3.0"
},
"engines": {
"node": ">= 6.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { import as importAPI } from '@electron-forge/core';
import { api } from '@electron-forge/core';

import path from 'path';
import program from 'commander';
Expand All @@ -20,7 +20,7 @@ import './util/terminate';
})
.parse(process.argv);

await importAPI({
await api.import({
dir,
interactive: true,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { init } from '@electron-forge/core';
import { api, InitOptions } from '@electron-forge/core';

import path from 'path';
import program from 'commander';
Expand All @@ -22,12 +22,12 @@ import './util/terminate';
})
.parse(process.argv);

const initOpts = {
const initOpts: InitOptions = {
dir,
interactive: true,
copyCIFiles: !!program.copyCiFiles,
};
if (program.template) initOpts.template = program.template;

await init(initOpts);
await api.init(initOpts);
})();
24 changes: 0 additions & 24 deletions packages/api/cli/src/electron-forge-install.js

This file was deleted.

41 changes: 41 additions & 0 deletions packages/api/cli/src/electron-forge-install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { api, InstallAsset } from '@electron-forge/core';
import inquirer from 'inquirer';

import program from 'commander';

import './util/terminate';

(async () => {
let repo!: string;

program
.version(require('../package.json').version)
.arguments('[repository]')
.option('--prerelease', 'Fetch prerelease versions')
.action((repository) => {
repo = repository;
})
.parse(process.argv);

const chooseAsset = async (assets: InstallAsset[]) => {
const choices: { name: string, value: string }[] = [];
assets.forEach((asset) => {
choices.push({ name: asset.name, value: asset.id });
});
const { assetID } = await inquirer.createPromptModule()<{ assetID: string }>({
type: 'list',
name: 'assetID',
message: 'Multiple potential assets found, please choose one from the list below:'.cyan,
choices,
});

return assets.find(asset => asset.id === assetID)!;
}

await api.install({
repo,
interactive: true,
chooseAsset,
prerelease: program.prerelease,
});
})();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lint } from '@electron-forge/core';
import { api } from '@electron-forge/core';

import fs from 'fs';
import path from 'path';
Expand All @@ -21,7 +21,7 @@ import './util/terminate';
})
.parse(process.argv);

await lint({
await api.lint({
dir,
interactive: true,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { make } from '@electron-forge/core';
import { api, MakeOptions } from '@electron-forge/core';

import fs from 'fs-extra';
import path from 'path';
Expand Down Expand Up @@ -27,7 +27,7 @@ export const getMakeOptions = () => {
})
.parse(process.argv);

const makeOpts = {
const makeOpts: MakeOptions = {
dir,
interactive: true,
skipPackage: program.skipPackage,
Expand All @@ -39,10 +39,10 @@ export const getMakeOptions = () => {
return makeOpts;
};

if (process.mainModule === module || global.__LINKED_FORGE__) {
if (process.mainModule === module || (global as any).__LINKED_FORGE__) {
(async () => {
const makeOpts = getMakeOptions();

await make(makeOpts);
await api.make(makeOpts);
})();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { package as packageAPI } from '@electron-forge/core';
import { api, PackageOptions } from '@electron-forge/core';

import fs from 'fs-extra';
import path from 'path';
Expand All @@ -24,12 +24,12 @@ import './util/terminate';
})
.parse(process.argv);

const packageOpts = {
const packageOpts: PackageOptions = {
dir,
interactive: true,
};
if (program.arch) packageOpts.arch = program.arch;
if (program.platform) packageOpts.platform = program.platform;

await packageAPI(packageOpts);
await api.package(packageOpts);
})();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { publish } from '@electron-forge/core';
import { api, PublishOptions } from '@electron-forge/core';

import fs from 'fs-extra';
import path from 'path';
Expand All @@ -12,7 +12,6 @@ import { getMakeOptions } from './electron-forge-make';
program
.version(require('../package.json').version)
.arguments('[cwd]')
.option('--tag', 'The tag to publish to on GitHub')
.option('--target [target[,target...]]', 'The comma-separated deployment targets, defaults to "github"')
.option('--dry-run', 'Triggers a publish dry run which saves state and doesn\'t upload anything')
.option('--from-dry-run', 'Attempts to publish artifacts from the last saved dry run')
Expand All @@ -27,17 +26,15 @@ import { getMakeOptions } from './electron-forge-make';
})
.parse(process.argv);

const publishOpts = {
const publishOpts: PublishOptions = {
dir,
interactive: true,
authToken: program.authToken,
tag: program.tag,
dryRun: program.dryRun,
dryRunResume: program.fromDryRun,
};
if (program.target) publishOpts.publishTargets = program.target.split(',');

publishOpts.makeOptions = getMakeOptions();

await publish(publishOpts);
await api.publish(publishOpts);
})();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { start } from '@electron-forge/core';
import { api, StartOptions } from '@electron-forge/core';

import fs from 'fs-extra';
import path from 'path';
Expand Down Expand Up @@ -43,7 +43,7 @@ import './util/terminate';
console.log(" will pass the arguments '-d -f foo.txt' to the Electron app");
});

const opts = {
const opts: StartOptions = {
dir,
interactive: true,
enableLogging: !!program.enableLogging,
Expand All @@ -61,10 +61,10 @@ import './util/terminate';
if (program.appPath) opts.appPath = program.appPath;
if (appArgs) opts.args = appArgs;

const spawned = await start(opts);
const spawned = await api.start(opts);

await new Promise((resolve) => {
spawned.on('exit', (code) => {
spawned.on('exit', (code: number) => {
if (code !== 0) {
process.exit(code);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import './util/terminate';
import checkSystem from './util/check-system';

const originalSC = program.executeSubCommand.bind(program);
program.executeSubCommand = (argv, args, unknown) => {
program.executeSubCommand = (argv: string[], args: string[], unknown: string[]) => {
let indexOfDoubleDash = process.argv.indexOf('--');
indexOfDoubleDash = indexOfDoubleDash < 0 ? process.argv.length + 1 : indexOfDoubleDash;

Expand Down
Loading

0 comments on commit a3faa61

Please sign in to comment.