Skip to content

Commit

Permalink
Refactoring build to utilize typescript project references (#262)
Browse files Browse the repository at this point in the history
* chore(build): Refactoring build to utilize typescript project references
  • Loading branch information
scalvert authored Apr 16, 2020
1 parent 2395367 commit 6b2c768
Show file tree
Hide file tree
Showing 24 changed files with 109 additions and 287 deletions.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"packages/*"
],
"scripts": {
"build": "yarn wsrun --stages build",
"build:watch": "yarn wsrun watch",
"clean": "yarn wsrun clean",
"build": "tsc --build",
"build:watch": "tsc --watch",
"clean": "tsc --build --clean",
"lint": "eslint . --cache --ext .ts",
"test": "yarn wsrun test"
"test": "yarn workspaces run test"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -59,8 +59,7 @@
"typescript": "^3.8",
"release-it": "^13.5.1",
"release-it-lerna-changelog": "^2.1.2",
"release-it-yarn-workspaces": "^1.2.0",
"wsrun": "^5.2.0"
"release-it-yarn-workspaces": "^1.2.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/__tests__/__utils__/render-partial.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ReportResultData, ReportComponentType } from '@checkup/core';
import { readFileSync } from 'fs-extra';
import * as Handlebars from 'handlebars';
import * as path from 'path';

import { ReportComponentType, ReportResultData } from '@checkup/core';

import { readFileSync } from 'fs-extra';

export type CompiledPartials = {
[key in ReportComponentType]: HandlebarsTemplateDelegate;
};
Expand All @@ -15,7 +17,7 @@ const COMPILED_PARTIALS: CompiledPartials = {
};

function getPartialDelegate(partialPath: string): HandlebarsTemplateDelegate {
let fullPartialPath = path.join(__dirname, `../../src/static/components/${partialPath}`);
let fullPartialPath = path.join(__dirname, `../../static/components/${partialPath}`);
let partialRaw = readFileSync(fullPartialPath, 'utf8');
return Handlebars.compile(partialRaw);
}
Expand Down
11 changes: 5 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
},
"files": [
"/bin",
"/lib"
"/lib",
"/templates",
"/static"
],
"homepage": "https://github.com/checkupjs/checkup",
"keywords": [
Expand All @@ -63,13 +65,10 @@
},
"repository": "https://github.com/checkupjs/checkup",
"scripts": {
"build": "yarn clean && tsc && yarn copystatic",
"build:watch": "yarn build -w",
"clean": "rm -rf lib",
"build": "tsc --build",
"prepack": "yarn build && oclif-dev readme",
"test": "jest --runInBand --no-cache",
"version": "oclif-dev readme && git add README.md",
"copystatic": "cp -a ./src/static ./lib/static"
"version": "oclif-dev readme && git add README.md"
},
"types": "lib/index.d.ts"
}
6 changes: 3 additions & 3 deletions packages/cli/src/helpers/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as Handlebars from 'handlebars';
import * as fs from 'fs';
import * as path from 'path';

import { ReportComponentType } from '@checkup/core';
import { pathToFileURL } from 'url';
import { printToPDF } from './print-to-pdf';
import { readFileSync } from 'fs-extra';
import { ReportComponentType } from '@checkup/core';

import tmp = require('tmp');

Expand Down Expand Up @@ -42,7 +42,7 @@ export async function generateReport(
}

export function generateHTML(resultsForPdf: any) {
const reportPath = path.join(__dirname, '../static/report-template.hbs');
const reportPath = path.join(__dirname, '../../static/report-template.hbs');
const reportTemplateRaw = readFileSync(reportPath, 'utf8');

const template = Handlebars.compile(reportTemplateRaw);
Expand All @@ -59,7 +59,7 @@ function registerPartials() {
];

partials.forEach((partial) => {
const fullPartialPath = path.join(__dirname, `../static/components/${partial.path}`);
const fullPartialPath = path.join(__dirname, `../../static/components/${partial.path}`);
const partialTemplateRaw = readFileSync(fullPartialPath, 'utf8');
Handlebars.registerPartial(partial.type, partialTemplateRaw);
});
Expand Down
File renamed without changes.
File renamed without changes.
23 changes: 16 additions & 7 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"types": ["chai", "fs-extra", "jest", "node"],
"baseUrl": ".",
"paths": {
"@checkup/core": ["../core/lib/index.d.ts"],
"*": ["../../types/*"]
}
"types": ["chai", "fs-extra", "jest", "node"]
},
"references": [
{
"path": "../core"
},
{
"path": "../plugin-ember"
},
{
"path": "../plugin-ember-octane"
},
{
"path": "../test-helpers"
}
],
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/core/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig",
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true
},
Expand Down
4 changes: 1 addition & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
},
"repository": "https://github.com/checkupjs/checkup",
"scripts": {
"build": "yarn clean && tsc",
"build:watch": "yarn build -w",
"clean": "rm -rf lib",
"build": "tsc --build",
"test": "jest --passWithNoTests --no-cache"
},
"types": "lib/index.d.ts"
Expand Down
10 changes: 3 additions & 7 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"types": ["chai", "jest", "node"],
"baseUrl": ".",
"paths": {
"*": ["../../types/*"]
}
"types": ["chai", "jest", "node"]
},
"include": ["src/**/*"]
"include": ["./src"]
}
6 changes: 2 additions & 4 deletions packages/plugin-ember-octane/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@
},
"repository": "https://github.com/checkupjs/checkup",
"scripts": {
"build": "yarn clean && tsc",
"build:watch": "yarn build -w",
"clean": "rm -rf lib",
"build": "tsc --build",
"postpack": "rm -f oclif.manifest.json",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"prepack": "tsc --build && oclif-dev manifest && oclif-dev readme",
"test": "jest --no-cache",
"test:debug": "yarn clean && yarn build && node --inspect-brk=1337 node_modules/.bin/jest",
"version": "oclif-dev readme && git add README.md"
Expand Down
14 changes: 7 additions & 7 deletions packages/plugin-ember-octane/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"types": ["jest", "node"],
"baseUrl": ".",
"paths": {
"@checkup/core": ["../core/lib/index.d.ts"],
"*": ["../../types/*"]
}
"types": ["jest", "node"]
},
"references": [
{
"path": "../core"
}
],
"include": ["src/**/*"]
}
6 changes: 2 additions & 4 deletions packages/plugin-ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
},
"repository": "https://github.com/checkupjs/checkup",
"scripts": {
"build": "yarn clean && tsc",
"build:watch": "yarn build -w",
"clean": "rm -rf lib",
"build": "tsc --build",
"postpack": "rm -f oclif.manifest.json",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"prepack": "tsc --build && oclif-dev manifest && oclif-dev readme",
"test": "jest",
"version": "oclif-dev readme && git add README.md"
},
Expand Down
17 changes: 10 additions & 7 deletions packages/plugin-ember/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"types": ["jest", "node"],
"baseUrl": ".",
"paths": {
"@checkup/core": ["../core/lib/index.d.ts"],
"*": ["../../types/*"]
}
"types": ["jest", "node"]
},
"references": [
{
"path": "../core"
},
{
"path": "../test-helpers"
}
],
"include": ["src/**/*"]
}
10 changes: 4 additions & 6 deletions packages/test-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"node": "10.* || >= 12.*"
},
"files": [
"/lib"
"/lib",
"/static"
],
"homepage": "https://github.com/checkupjs/checkup",
"license": "MIT",
Expand All @@ -25,11 +26,8 @@
},
"repository": "https://github.com/checkupjs/checkup",
"scripts": {
"build": "yarn clean && tsc && yarn copystatic",
"build:watch": "yarn build -w",
"clean": "rm -rf lib",
"test": "jest --passWithNoTests --no-cache",
"copystatic": "cp -a ./src/static ./lib/static"
"build": "tsc --build",
"test": "jest --passWithNoTests --no-cache"
},
"types": "lib/index.d.ts"
}
2 changes: 1 addition & 1 deletion packages/test-helpers/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Task } from '@checkup/core';
import Project = require('fixturify-project');

const REGISTER_TASKS_TEMPLATE = fs.readFileSync(
path.resolve(__dirname, 'static/templates/register-tasks.hbs'),
path.resolve(__dirname, '../static/templates/register-tasks.hbs'),
'utf-8'
);
const template = Handlebars.compile(REGISTER_TASKS_TEMPLATE);
Expand Down
14 changes: 7 additions & 7 deletions packages/test-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"types": ["chai", "jest", "node"],
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@checkup/core": ["../core/lib/index.d.ts"],
"*": ["../../types/*"]
}
"esModuleInterop": true
},
"references": [
{
"path": "../core"
}
],
"include": ["src/**/*"]
}
23 changes: 23 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"importHelpers": true,
"module": "commonjs",
"strict": true,
"target": "es2017",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@checkup/core": ["./packages/core/lib/index.d.ts"],
"@checkup/cli": ["./packages/cli/lib/index.d.ts"],
"@checkup/plugin-ember": ["./packages/plugin-ember/lib/index.d.ts"],
"@checkup/plugin-ember-octane": ["./packages/plugin-ember-octane/lib/index.d.ts"],
"@checkup/test-helpers": ["./packages/test-helpers/lib/index.d.ts"],
"*": ["./types/*"]
}
},
"exclude": ["**/node_modules/**"]
}
17 changes: 8 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"compilerOptions": {
"declaration": true,
"importHelpers": true,
"module": "commonjs",
"strict": true,
"target": "es2017",
"allowSyntheticDefaultImports": true,
"sourceMap": true
}
"files": [],
"references": [
{ "path": "./packages/cli" },
{ "path": "./packages/core" },
{ "path": "./packages/plugin-ember" },
{ "path": "./packages/plugin-ember-octane" },
{ "path": "./packages/test-helpers" }
]
}
Loading

0 comments on commit 6b2c768

Please sign in to comment.