Skip to content

Commit

Permalink
Make publishers work and add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Feb 20, 2018
1 parent f7a9839 commit 422241a
Show file tree
Hide file tree
Showing 39 changed files with 605 additions and 73 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"bolt": {
"workspaces": [
"packages/api/*",
"packages/installer/*",
"packages/maker/*",
"packages/publisher/*",
"packages/installer/*"
"packages/utils/*"
]
},
"config": {
Expand Down
1 change: 1 addition & 0 deletions packages/api/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"mocha": "^5.0.0"
},
"dependencies": {
"@electron-forge/async-ora": "^6.0.0-beta.0",
"@electron-forge/core": "^6.0.0-beta.0",
"colors": "^1.1.2",
"commander": "^2.9.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/api/cli/src/electron-forge.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env node
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import program from 'commander';
import tabtab from 'tabtab';
// FIXME: Deep imports like this are a bad idea
import asyncOra from '@electron-forge/core/dist/util/ora-handler';

import './util/terminate';

Expand Down
3 changes: 1 addition & 2 deletions packages/api/cli/test/check-system_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fakeOra } from '@electron-forge/async-ora';
import { expect } from 'chai';
// FIXME: Deep imports like this are a bad idea
import { fakeOra } from '@electron-forge/core/dist/util/ora';

import checkSystem, { validPackageManagerVersion } from '../src/util/check-system';

Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"sinon": "^4.1.2"
},
"dependencies": {
"@electron-forge/async-ora": "^6.0.0-beta.0",
"@electron-forge/installer-deb": "^6.0.0-beta.0",
"@electron-forge/installer-dmg": "^6.0.0-beta.0",
"@electron-forge/installer-exe": "^6.0.0-beta.0",
"@electron-forge/installer-rpm": "^6.0.0-beta.0",
"@electron-forge/installer-zip": "^6.0.0-beta.0",
"@octokit/rest": "^14.0.4",
"colors": "^1.1.2",
"cross-spawn-promise": "^0.10.1",
"debug": "^3.0.0",
Expand All @@ -50,7 +50,6 @@
"log-symbols": "^2.0.0",
"node-fetch": "^2.0.0",
"nugget": "^2.0.1",
"ora": "^1.1.0",
"pify": "^3.0.0",
"resolve-package": "^1.0.1",
"semver": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/import.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';
Expand All @@ -6,7 +7,6 @@ import initGit from './init-scripts/init-git';
import { deps, devDeps, exactDevDeps } from './init-scripts/init-npm';

import { setInitialForgeConfig } from '../util/forge-config';
import asyncOra from '../util/ora-handler';
import { info, warn } from '../util/messages';
import installDepList from '../util/install-dependencies';
import readPackageJSON from '../util/read-package-json';
Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/src/api/init-scripts/init-custom.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { asyncOra, ora } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import glob from 'glob';
import resolvePackage from 'resolve-package';
import path from 'path';

import { copy } from './init-starter-files';
import asyncOra from '../../util/ora-handler';
import installDepList from '../../util/install-dependencies';
import ora from '../../util/ora';

const d = debug('electron-forge:init:custom');

Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/src/api/init-scripts/init-directory.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import logSymbols from 'log-symbols';

import asyncOra from '../../util/ora-handler';

const d = debug('electron-forge:init:directory');

export default async (dir) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/src/api/init-scripts/init-git.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { asyncOra } from '@electron-forge/async-ora';
import { exec } from 'child_process';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';

import asyncOra from '../../util/ora-handler';

const d = debug('electron-forge:init:git');

export default async (dir) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/init-scripts/init-npm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';
Expand All @@ -6,7 +7,6 @@ import username from 'username';
import { setInitialForgeConfig } from '../../util/forge-config';
import installDepList from '../../util/install-dependencies';
import readPackageJSON from '../../util/read-package-json';
import asyncOra from '../../util/ora-handler';

const d = debug('electron-forge:init:npm');

Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/src/api/init-scripts/init-starter-files.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';

import asyncOra from '../../util/ora-handler';

const d = debug('electron-forge:init:starter-files');

export const copy = async (source, target) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/src/api/init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';

import initCustom from './init-scripts/init-custom';
Expand All @@ -6,8 +7,6 @@ import initGit from './init-scripts/init-git';
import initNPM from './init-scripts/init-npm';
import initStarter from './init-scripts/init-starter-files';

import asyncOra from '../util/ora-handler';

const d = debug('electron-forge:init');

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/install.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fetch from 'node-fetch';
import fs from 'fs-extra';
Expand All @@ -14,7 +15,6 @@ import DebInstaller from '@electron-forge/installer-deb';
import RPMInstaller from '@electron-forge/installer-rpm';
import ExeInstaller from '@electron-forge/installer-exe';

import asyncOra from '../util/ora-handler';
import { info } from '../util/messages';

const d = debug('electron-forge:install');
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/lint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import { yarnOrNpmSpawn } from '../util/yarn-or-npm';

import asyncOra from '../util/ora-handler';
import resolveDir from '../util/resolve-dir';

const d = debug('electron-forge:lint');
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/make.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import fs from 'fs-extra';
import path from 'path';
import { hostArch } from 'electron-packager/targets';

import asyncOra from '../util/ora-handler';
import getForgeConfig from '../util/forge-config';
import runHook from '../util/hook';
import { info, warn } from '../util/messages';
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/package.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'colors';
import { ora as realOra, fakeOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import glob from 'glob';
Expand All @@ -10,7 +11,6 @@ import { hostArch } from 'electron-packager/targets';
import getForgeConfig from '../util/forge-config';
import runHook from '../util/hook';
import { warn } from '../util/messages';
import realOra, { fakeOra } from '../util/ora';
import readPackageJSON from '../util/read-package-json';
import rebuildHook from '../util/rebuild';
import requireSearch from '../util/require-search';
Expand Down
46 changes: 28 additions & 18 deletions packages/api/core/src/api/publish.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';

import asyncOra from '../util/ora-handler';
import getForgeConfig from '../util/forge-config';
import readPackageJSON from '../util/read-package-json';
import requireSearch from '../util/require-search';
import resolveDir from '../util/resolve-dir';
import PublishState from '../util/publish-state';
import getCurrentOutDir from '../util/out-dir';
Expand All @@ -15,13 +14,19 @@ import make from './make';

const d = debug('electron-forge:publish');

/**
* @typedef {Object} PublishTarget
* @property {string} [name]
* @property {Array<string>} [platforms=[process.platform]]
* @property {Object} [config={}]
*/

/**
* @typedef {Object} PublishOptions
* @property {string} [dir=process.cwd()] The path to the app to be published
* @property {boolean} [interactive=false] Whether to use sensible defaults or prompt the user visually
* @property {string} [authToken] An authentication token to use when publishing
* @property {string} [tag=packageJSON.version] The string to tag this release with
* @property {Array<string>} [publishTargets=[github]] The publish targets
* @property {Array<PublishTarget>} [publishTargets=[]] The publish targets
* @property {MakeOptions} [makeOptions] Options object to passed through to make()
* @property {string} [outDir=`${dir}/out`] The path to the directory containing generated distributables
* @property {boolean} [dryRun=false] Whether to generate dry run meta data but not actually publish
Expand Down Expand Up @@ -120,31 +125,36 @@ const publish = async (providedOptions = {}) => {
return accum;
}, []);

const testPlatform = makeOptions.platform || process.platform;
if (publishTargets === null) {
publishTargets = forgeConfig.publish_targets[makeOptions.platform || process.platform];
publishTargets = (forgeConfig.publishers || [])
.filter(publisher => publisher.platforms ? publisher.platforms.indexOf(testPlatform !== -1) : true);
}
publishTargets = publishTargets.map((target) => {
if (typeof target === 'string') return { name: target };
return target;
});

for (const publishTarget of publishTargets) {
let publisher;
await asyncOra(`Resolving publish target: ${`${publishTarget}`.cyan}`, async () => { // eslint-disable-line no-loop-func
publisher = requireSearch(__dirname, [
`../publishers/${publishTarget}.js`,
`electron-forge-publisher-${publishTarget}`,
publishTarget,
path.resolve(dir, publishTarget),
path.resolve(dir, 'node_modules', publishTarget),
]);
if (!publisher) {
throw `Could not find a publish target with the name: ${publishTarget}`;
let publisherModule;
await asyncOra(`Resolving publish target: ${`${publishTarget.name}`.cyan}`, async () => { // eslint-disable-line no-loop-func
try {
publisherModule = require(publishTarget.name);
} catch (err) {
console.error(err);
throw `Could not find a publish target with the name: ${publishTarget.name}`;
}
});

await publisher({
const PublisherClass = publisherModule.default || publisherModule;
const publisher = new PublisherClass();

await publisher.publish({
dir,
artifacts,
packageJSON,
config: publishTarget.config || {},
forgeConfig,
authToken,
tag,
platform: makeOptions.platform || process.platform,
arch: makeOptions.arch || process.arch,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/start.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import { spawn } from 'child_process';
import path from 'path';

import asyncOra from '../util/ora-handler';
import readPackageJSON from '../util/read-package-json';
import rebuild from '../util/rebuild';
import resolveDir from '../util/resolve-dir';
Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/src/util/plugin-interface.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';

import asyncOra from './ora-handler';

const d = debug('electron-forge:plugins');

export default class PluginInterface {
Expand Down
3 changes: 1 addition & 2 deletions packages/api/core/src/util/rebuild.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { asyncOra } from '@electron-forge/async-ora';
import rebuild from 'electron-rebuild';

import asyncOra from '../util/ora-handler';

export default async (buildPath, electronVersion, platform, arch, config = {}) => {
await asyncOra('Preparing native dependencies', async (rebuildSpinner) => {
const rebuilder = rebuild(Object.assign({}, config, {
Expand Down
Loading

0 comments on commit 422241a

Please sign in to comment.