Skip to content
Permalink
Browse files

chore: make type checking faster, type check entire repo at once

  • Loading branch information
MarshallOfSound committed Oct 24, 2018
1 parent 22549d9 commit 00c5769f21212f2ca140fef5a3abbcd57fc454f4
@@ -17,3 +17,4 @@ packages/publisher/**/README.md
packages/plugin/**/README.md
!packages/**/base/README.md
!/README.md
packages/*/*/index.ts
@@ -5,3 +5,4 @@ README.md
test
ci
docs
/index.ts
@@ -22,8 +22,8 @@
}
},
"scripts": {
"clean": "bolt ws exec -- rimraf dist",
"prebuild": "bolt clean && ts-node tools/link-ts.ts && ts-node tools/copy-shared-types.ts && bolt ws exec -- node_modules/.bin/tsc --emitDeclarationOnly",
"clean": "rimraf dist && bolt ws exec -- rimraf dist",
"prebuild": "bolt clean && ts-node tools/link-ts.ts && ts-node tools/copy-shared-types.ts && tsc --project ./tsconfig.packages.json --emitDeclarationOnly && ts-node tools/copy-types.ts",
"build": "yarn build:quick",
"build:quick": "bolt ws exec -- node_modules/.bin/babel src -d dist --quiet --extensions \".ts\" --config-file ../../../.babelrc",
"postbuild": "ts-node tools/test-dist",
@@ -5,7 +5,7 @@ import os from 'os';
import path from 'path';
import semver from 'semver';

import { hasYarn, yarnOrNpmSpawn } from '@electron-forge/core/dist/util/yarn-or-npm';
import { utils as forgeUtils } from '@electron-forge/core';
import { OraImpl } from '@electron-forge/async-ora';

const d = debug('electron-forge:check-system');
@@ -55,10 +55,10 @@ The known versions that work with Electron Forge are: ${versions}`);
}

async function checkPackageManagerVersion(ora: OraImpl) {
return yarnOrNpmSpawn(['--version'])
return forgeUtils.yarnOrNpmSpawn(['--version'])
.then((version) => {
const versionString = version.toString();
if (hasYarn()) {
if (forgeUtils.hasYarn()) {
warnIfPackageManagerIsntAKnownGoodVersion('Yarn', versionString, YARN_WHITELISTED_VERSIONS, ora);
} else {
warnIfPackageManagerIsntAKnownGoodVersion('NPM', versionString, NPM_WHITELISTED_VERSIONS, ora);
@@ -12,6 +12,7 @@ import publish, { PublishOptions } from './publish';
import start, { StartOptions } from './start';

import { fromBuildIdentifier } from '../util/forge-config';
import { hasYarn, yarnOrNpmSpawn } from '../util/yarn-or-npm';

export class ForgeAPI {
/**
@@ -85,6 +86,9 @@ export class ForgeUtils {
fromBuildIdentifier<T>(map: { [key: string]: T | undefined }) {
return fromBuildIdentifier(map);
}

hasYarn = hasYarn;
yarnOrNpmSpawn = yarnOrNpmSpawn;
}

const api = new ForgeAPI();
@@ -1,8 +1,7 @@
import { asyncOra } from '@electron-forge/async-ora';
import PluginBase from '@electron-forge/plugin-base';
import { ForgeConfig } from '@electron-forge/shared-types';
import Logger from '@electron-forge/web-multi-logger';
import Tab from '@electron-forge/web-multi-logger/dist/Tab';
import Logger, { Tab } from '@electron-forge/web-multi-logger';
import { ChildProcess } from 'child_process';
import debug from 'debug';
import fs from 'fs-extra';
@@ -5,6 +5,8 @@ import http from 'http';

import Tab from './Tab';

export { Tab };

export default class Logger {
private app = express();
private ws!: ews.Instance;
@@ -0,0 +1,22 @@
import * as fs from 'fs-extra';
import * as path from 'path';

const BASE_DIR = path.resolve(__dirname, '..');
const DIST_DIR = path.resolve(BASE_DIR, 'dist');
const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');

(async () => {
const dirsToLink = [];

for (const subDir of await fs.readdir(PACKAGES_DIR)) {
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
dirsToLink.push(path.join(subDir, packageDir));
}
}

for (const dir of dirsToLink) {
const targetDir = path.resolve(BASE_DIR, 'packages', dir, 'dist');
await fs.mkdirp(targetDir);
await fs.copy(path.resolve(DIST_DIR, dir, 'src'), targetDir);
}
})();
@@ -17,5 +17,17 @@ const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');
await fs.copy(path.resolve(BASE_DIR, 'tsconfig.json'), path.resolve(dir, 'tsconfig.json'));
await fs.copy(path.resolve(BASE_DIR, 'tslint.json'), path.resolve(dir, 'tslint.json'));
await fs.copy(path.resolve(BASE_DIR, '.npmignore'), path.resolve(dir, '.npmignore'));
const pj = await fs.readJson(path.resolve(dir, 'package.json'));
if (pj.main) {
const mainFile = pj.main.replace('dist', 'src').replace('.js', '.ts');
const importableFile = mainFile.replace('.ts', '');
const hasDefault = (await fs.readFile(path.resolve(dir, mainFile), 'utf8')).includes('export default');

if (hasDefault) {
await fs.writeFile(path.resolve(dir, 'index.ts'), `import d from './${importableFile}';\nexport default d;\nexport * from './${importableFile}';\n`);
} else {
await fs.writeFile(path.resolve(dir, 'index.ts'), `export * from './${importableFile}';\n`);
}
}
}
})();
@@ -18,6 +18,7 @@
"exclude": [
"node_modules",
"dist",
"test"
"test",
"index.ts"
]
}
@@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "packages"
},
"exclude": [
"dist",
"node_modules",
"ci",
"tools",
"**/dist",
"**/node_modules",
"**/test",
"packages/installer/**/typings/ambient.d.ts",
"packages/maker/wix/typings/ambient.d.ts",
]
}

0 comments on commit 00c5769

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