Skip to content
Permalink
Browse files

style: set-up tslint

  • Loading branch information
MarshallOfSound committed May 3, 2018
1 parent e06aa0b commit 40484e1605995853edbdf38dfd6093ac45a41f4f
Showing with 300 additions and 580 deletions.
  1. +2 −1 .appveyor.yml
  2. +2 −0 .gitignore
  3. +3 −6 package.json
  4. +3 −3 packages/api/cli/src/electron-forge-install.ts
  5. +3 −3 packages/api/cli/src/electron-forge-start.ts
  6. +1 −1 packages/api/cli/src/util/check-system.ts
  7. +2 −1 packages/api/core/package.json
  8. +1 −1 packages/api/core/src/api/import.ts
  9. +6 −3 packages/api/core/src/api/install.ts
  10. +1 −0 packages/api/core/src/api/lint.ts
  11. +5 −5 packages/api/core/src/api/make.ts
  12. +4 −5 packages/api/core/src/api/package.ts
  13. +4 −2 packages/api/core/src/api/publish.ts
  14. +2 −3 packages/api/core/src/api/start.ts
  15. +3 −2 packages/api/core/src/util/forge-config.ts
  16. +1 −1 packages/api/core/src/util/install-dependencies.ts
  17. +1 −1 packages/api/core/src/util/parse-archs.ts
  18. +3 −1 packages/api/core/src/util/plugin-interface.ts
  19. +1 −1 packages/api/core/src/util/rebuild.ts
  20. +3 −3 packages/api/core/test/fast/forge-config_spec.ts
  21. +2 −2 packages/api/core/test/fast/publish_spec.ts
  22. +5 −5 packages/api/core/test/fast/start_spec.ts
  23. +3 −3 packages/api/core/test/slow/api_spec_slow.ts
  24. +13 −13 packages/api/core/test/slow/install_spec_slow.ts
  25. +2 −0 packages/installer/base/src/Installer.ts
  26. +1 −1 packages/installer/linux/src/InstallerLinux.ts
  27. +1 −1 packages/maker/appx/test/MakerAppX_spec.ts
  28. +5 −3 packages/maker/base/src/Maker.ts
  29. +2 −2 packages/maker/deb/src/Config.ts
  30. +1 −1 packages/maker/deb/src/MakerDeb.ts
  31. +1 −1 packages/maker/deb/test/MakerDeb_spec.ts
  32. +1 −1 packages/maker/dmg/src/Config.ts
  33. +1 −1 packages/maker/dmg/test/MakerDMG_spec.ts
  34. +2 −2 packages/maker/flatpak/src/Config.ts
  35. +1 −1 packages/maker/flatpak/test/MakerFlatpak_spec.ts
  36. +1 −1 packages/maker/pkg/src/Config.ts
  37. +4 −4 packages/maker/pkg/test/MakerPKG_spec.ts
  38. +1 −1 packages/maker/rpm/test/MakerRpm_spec.ts
  39. +1 −1 packages/maker/snap/src/Config.ts
  40. +1 −1 packages/maker/snap/test/MakerSnap_spec.ts
  41. +1 −1 packages/maker/squirrel/src/Config.ts
  42. +1 −1 packages/maker/wix/src/Config.ts
  43. +2 −0 packages/plugin/base/src/Plugin.ts
  44. +1 −1 packages/plugin/local-electron/src/Config.ts
  45. +2 −2 packages/plugin/local-electron/src/LocalElectronPlugin.ts
  46. +3 −3 packages/plugin/local-electron/test/LocalElectronPlugin_spec.ts
  47. +5 −3 packages/publisher/base/src/Publisher.ts
  48. +1 −1 packages/publisher/electron-release-server/src/Config.ts
  49. +9 −4 packages/publisher/electron-release-server/src/PublisherERS.ts
  50. +1 −1 packages/publisher/github/src/Config.ts
  51. +9 −9 packages/publisher/github/src/PublisherGithub.ts
  52. +1 −1 packages/publisher/github/src/util/github.ts
  53. +1 −1 packages/publisher/s3/src/Config.ts
  54. +4 −3 packages/publisher/s3/src/PublisherS3.ts
  55. +1 −1 packages/publisher/snapcraft/src/Config.ts
  56. +7 −3 packages/utils/async-ora/src/ora-handler.ts
  57. +4 −4 packages/utils/async-ora/src/ora.ts
  58. +3 −3 packages/utils/async-ora/test/ora-handler_spec.ts
  59. +6 −4 packages/utils/types/src/index.ts
  60. +1 −0 tools/link-ts.ts
  61. +12 −0 tslint.json
  62. +125 −446 yarn.lock
@@ -32,6 +32,7 @@ install:
test_script:
- node --version
- yarn --version
- bolt ws test
- bolt lint
- bolt test

build: off
@@ -4,6 +4,8 @@ yarn-error.log
packages/.old
**/tsconfig.json
!/tsconfig.json
**/tslint.json
!/tslint.json
docs
doc
.vscode
@@ -31,7 +31,7 @@
"docs:generate": "bolt ws exec -- node_modules/.bin/typedoc --out doc --excludeExternals --ignoreCompilerErrors --mode file --excludePrivate --excludeProtected --hideGenerator",
"docs:position": "ts-node tools/position-docs.ts",
"docs:deploy": "bolt docs && ts-node tools/copy-now.ts && cd docs && now && now alias",
"lint": "bolt ws exec -- node_modules/.bin/eslint src test",
"lint": "ts-node tools/link-ts.ts && bolt ws exec -- node_modules/.bin/tslint src/**/*.ts test/**/*.ts",
"test": "bolt ws run test"
},
"dependencies": {
@@ -106,7 +106,6 @@
"@types/semver": "^5.5.0",
"@types/sinon": "^4.3.1",
"asar": "^0.14.0",
"babel-eslint": "^7.0.0",
"babel-plugin-source-map-support": "^2.0.1",
"chai": "^4.0.0",
"chai-as-promised": "^7.0.0",
@@ -117,10 +116,6 @@
"esdoc": "^1.0.1",
"esdoc-importpath-plugin": "^1.0.0",
"esdoc-standard-plugin": "^1.0.0",
"eslint": "^3.7.1",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-mocha": "^4.8.0",
"fetch-mock": "^6.0.0",
"generate-changelog": "^1.0.2",
"mocha": "^5.0.0",
@@ -130,6 +125,8 @@
"rimraf": "^2.6.2",
"sinon": "^4.1.2",
"ts-node": "^6.0.0",
"tslint": "^5.9.1",
"tslint-config-airbnb": "^5.8.0",
"typedoc": "^0.11.1",
"typescript": "^2.8.1"
},
@@ -23,19 +23,19 @@ import './util/terminate';
choices.push({ name: asset.name, value: asset.id });
});
const { assetID } = await inquirer.createPromptModule()<{ assetID: string }>({
choices,
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({
chooseAsset,
repo,
interactive: true,
chooseAsset,
prerelease: program.prerelease,
});
})();
@@ -20,7 +20,7 @@ import './util/terminate';
program
.version(require('../package.json').version)
.arguments('[cwd]')
.option('-p, --app-path <path>', "Override the path to the Electron app to launch (defaults to '.')")
.option('-p, --app-path <path>', 'Override the path to the Electron app to launch (defaults to \'.\')')
.option('-l, --enable-logging', 'Enable advanced logging. This will log internal Electron things')
.option('-n, --run-as-node', 'Run the Electron app as a Node.JS script')
.option('--vscode', 'Used to enable arg transformation for debugging Electron through VSCode. Do not use yourself.')
@@ -36,11 +36,11 @@ import './util/terminate';
.parse(commandArgs);

program.on('--help', () => {
console.log(" Any arguments found after '--' will be passed to the Electron app, e.g.");
console.log(' Any arguments found after "--" will be passed to the Electron app, e.g.');
console.log('');
console.log(' $ electron-forge /path/to/project -l -- -d -f foo.txt');
console.log('');
console.log(" will pass the arguments '-d -f foo.txt' to the Electron app");
console.log(' will pass the arguments "-d -f foo.txt" to the Electron app');
});

const opts: StartOptions = {
@@ -48,7 +48,7 @@ function warnIfPackageManagerIsntAKnownGoodVersion(packageManager: string, versi
if (!validPackageManagerVersion(packageManager, versionString, versions, ora)) {
ora.warn!(
`You are using ${packageManager}, but not a known good version.\n` +
`The known versions that work with Electron Forge are: ${versions}`
`The known versions that work with Electron Forge are: ${versions}`,
);
}
}
@@ -35,6 +35,7 @@
},
"dependencies": {
"@electron-forge/async-ora": "6.0.0-beta.5",
"@electron-forge/installer-base": "^6.0.0-beta.5",
"@electron-forge/installer-deb": "6.0.0-beta.5",
"@electron-forge/installer-dmg": "6.0.0-beta.5",
"@electron-forge/installer-exe": "6.0.0-beta.5",
@@ -65,4 +66,4 @@
"engines": {
"node": ">= 6.0"
}
}
}
@@ -164,7 +164,7 @@ export default async ({
packageJSON = await readPackageJSON(dir);

if (!packageJSON.version) {
warn(interactive, "Please set the 'version' in your application's package.json".yellow);
warn(interactive, 'Please set the "version" in your application\'s package.json'.yellow);
}

packageJSON.config = packageJSON.config || {};
@@ -1,5 +1,6 @@
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import InstallerBase from '@electron-forge/installer-base';
import debug from 'debug';
import fetch from 'node-fetch';
import fs from 'fs-extra';
@@ -22,6 +23,8 @@ const d = debug('electron-forge:install');

const GITHUB_API = 'https://api.github.com';

class InstallerImpl extends InstallerBase { name = 'impl'; }

interface Release {
tag_name: string;
prerelease: boolean;
@@ -58,7 +61,7 @@ export default async ({
interactive = false,
prerelease = false,
repo,
chooseAsset
chooseAsset,
}: InstallOptions) => {
asyncOra.interactive = interactive;

@@ -156,7 +159,7 @@ export default async ({
await asyncOra('Installing Application', async (installSpinner) => {
const installActions: {
[key: string]: {
[key: string]: any;
[key: string]: typeof InstallerImpl;
};
} = {
win32: {
@@ -178,6 +181,6 @@ export default async ({
}
const InstallerClass = installActions[process.platform][suffixFnIdent];
const installer = new InstallerClass();
await installer.install({ filePath: fullFilePath, installSpinner });
await installer.install({ installSpinner, filePath: fullFilePath });
});
};
@@ -26,6 +26,7 @@ export default async ({
if (!resolvedDir) {
throw 'Failed to locate lintable Electron application';
}

dir = resolvedDir;

d('executing "run lint" in dir:', dir);
@@ -86,7 +86,7 @@ export default async ({
const targets = (overrideTargets || forgeConfig.makers.filter(
maker => maker.platforms
? maker.platforms.indexOf(actualTargetPlatform) !== -1
: true
: true,
)).map((target) => {
if (typeof target === 'string') {
return { name: target };
@@ -168,13 +168,13 @@ export default async ({
await asyncOra(`Making for target: ${maker.name.green} - On platform: ${actualTargetPlatform.cyan} - For arch: ${targetArch.cyan}`, async () => {
try {
const artifacts = await maker.make({
dir: packageDir,
makeDir: path.resolve(actualOutDir, 'make'),
appName,
targetPlatform: actualTargetPlatform,
targetArch,
forgeConfig,
packageJSON,
targetArch,
dir: packageDir,
makeDir: path.resolve(actualOutDir, 'make'),
targetPlatform: actualTargetPlatform,
});

outputs.push({
@@ -17,7 +17,6 @@ import requireSearch from '../util/require-search';
import resolveDir from '../util/resolve-dir';
import getCurrentOutDir from '../util/out-dir';
import getElectronVersion from '../util/electron-version';
import electronVersion from '../util/electron-version';

const { hostArch }: { hostArch: () => ForgeArch | 'all'} = require('electron-packager/targets');

@@ -165,20 +164,20 @@ export default async ({
asar: false,
overwrite: true,
}, forgeConfig.packagerConfig, {
afterCopy: sequentialHooks(afterCopyHooks),
afterExtract: sequentialHooks(afterExtractHooks),
afterPrune: sequentialHooks(afterPruneHooks),
dir,
arch,
platform,
afterCopy: sequentialHooks(afterCopyHooks),
afterExtract: sequentialHooks(afterExtractHooks),
afterPrune: sequentialHooks(afterPruneHooks),
out: calculatedOutDir,
electronVersion: getElectronVersion(packageJSON),
});
packageOpts.quiet = true;

if (!packageJSON.version && !packageOpts.appVersion) {
// eslint-disable-next-line max-len
warn(interactive, "Please set 'version' or 'config.forge.packagerConfig.appVersion' in your application's package.json so auto-updates work properly".yellow);
warn(interactive, 'Please set "version" or "config.forge.packagerConfig.appVersion" in your application\'s package.json so auto-updates work properly'.yellow);
}

await runHook(forgeConfig, 'generateAssets');
@@ -95,7 +95,9 @@ const publish = async ({
});
}
return;
} else if (!makeResults) {
}

if (!makeResults) {
d('triggering make');
makeResults = await make(Object.assign({
dir,
@@ -133,7 +135,7 @@ const publish = async ({

const testPlatform = makeOptions.platform || process.platform as ForgePlatform;
if (!publishTargets) {
publishTargets = (forgeConfig.publishers || [])
publishTargets = (forgeConfig.publishers || []);
// .filter(publisher => (typeof publisher !== 'string' && publisher.platforms) ? publisher.platforms.indexOf(testPlatform) !== -1 : true);
}
publishTargets = publishTargets.map((target) => {
@@ -1,6 +1,6 @@
import 'colors';
import { asyncOra } from '@electron-forge/async-ora';
import { StartOptions } from '@electron-forge/shared-types';
import { StartOptions, ForgePlatform, ForgeArch } from '@electron-forge/shared-types';
import { spawn, ChildProcess } from 'child_process';
import path from 'path';

@@ -10,7 +10,6 @@ import resolveDir from '../util/resolve-dir';
import getForgeConfig from '../util/forge-config';
import runHook from '../util/hook';
import getElectronVersion from '../util/electron-version';
import { ForgePlatform, ForgeArch } from '@electron-forge/shared-types';

export { StartOptions };

@@ -46,7 +45,7 @@ export default async ({
getElectronVersion(packageJSON),
process.platform as ForgePlatform,
process.arch as ForgeArch,
forgeConfig.electronRebuildConfig
forgeConfig.electronRebuildConfig,
);

await runHook(forgeConfig, 'generateAssets');
@@ -42,7 +42,8 @@ const proxify = <T extends object>(buildIdentifier: string | (() => string), obj
// eslint-disable-next-line no-prototype-builtins
if (target.hasOwnProperty(name)) {
return Reflect.getOwnPropertyDescriptor(target, name);
} else if (envValue) {
}
if (envValue) {
return { writable: true, enumerable: true, configurable: true, value: envValue };
}
},
@@ -62,8 +63,8 @@ export function setInitialForgeConfig(packageJSON: any) {

export function fromBuildIdentifier<T>(map: { [key: string]: T | undefined }) {
return {
__isMagicBuildIdentifierMap: true,
map,
__isMagicBuildIdentifierMap: true,
};
}

@@ -7,7 +7,7 @@ export default async (
dir: string,
deps: string[],
areDev = false,
exact = false
exact = false,
) => {
d('installing', JSON.stringify(deps), 'in:', dir, `dev=${areDev},exact=${exact},withYarn=${hasYarn()}`);
if (deps.length === 0) {
@@ -5,7 +5,7 @@ const { allOfficialArchsForPlatformAndVersion } = require('electron-packager/tar
export default function parseArchs(
platform: ForgePlatform | string,
declaredArch: ForgeArch | 'all' | string,
electronVersion: string
electronVersion: string,
): ForgeArch[] {
if (declaredArch === 'all') {
return allOfficialArchsForPlatformAndVersion(platform, electronVersion) || ['x64'];
@@ -14,7 +14,9 @@ export default class PluginInterface implements IForgePluginInterface {
this.plugins = forgeConfig.plugins.map((plugin) => {
if ((plugin as IForgePlugin).__isElectronForgePlugin) {
return plugin;
} else if (Array.isArray(plugin)) {
}

if (Array.isArray(plugin)) {
if (typeof plugin[0] !== 'string') {
throw `Expected plugin[0] to be a string but found ${plugin[0]}`;
}
@@ -9,7 +9,7 @@ export default async (
electronVersion: string,
platform: ForgePlatform,
arch: ForgeArch,
config: Partial<RebuildOptions> = {}
config: Partial<RebuildOptions> = {},
) => {
await asyncOra('Preparing native dependencies', async (rebuildSpinner) => {
const rebuilder = rebuild(Object.assign({}, config, {
@@ -89,13 +89,13 @@ describe.only('forge-config', () => {
expect(conf.sub).to.deep.equal({
prop: {
deep: {
prop: 'bar'
prop: 'bar',
},
inArray: [
'arr',
'natural',
'array'
]
'array',
],
},
});
});
@@ -244,15 +244,15 @@ describe('publish', () => {
darwinArtifacts.push(...result.artifacts);
}
expect(darwinArtifacts.sort()).to.deep.equal(
fakeMake('darwin').reduce((accum, val) => accum.concat(val.artifacts), [] as string[]).sort()
fakeMake('darwin').reduce((accum, val) => accum.concat(val.artifacts), [] as string[]).sort(),
);
const win32Args = publisherSpy.getCall(win32Index).args[0];
const win32Artifacts = [];
for (const result of win32Args.makeResults) {
win32Artifacts.push(...result.artifacts);
}
expect(win32Artifacts.sort()).to.deep.equal(
fakeMake('win32').reduce((accum, val) => accum.concat(val.artifacts), [] as string[]).sort()
fakeMake('win32').reduce((accum, val) => accum.concat(val.artifacts), [] as string[]).sort(),
);
});
});

0 comments on commit 40484e1

Please sign in to comment.
You can’t perform that action at this time.