Skip to content

Commit

Permalink
chore(tools): added build TS scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
PositiveJS committed Sep 21, 2017
1 parent 254db54 commit d36ec17
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist

### Node ###
# Logs
Expand Down
Empty file added CHANGELOG.md
Empty file.
122 changes: 122 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"scripts": {
"commitmsg": "validate-commit-msg",
"test:rules": "tslint -r ./dist/@ptsecurity/tslint-config/rules --test ./test/rules/*/*"
"test:rules": "tslint -r ./dist/@ptsecurity/tslint-config/rules --test ./test/rules/*/*",
"build:tslint": "ts-node ./tools/index.ts"
},
"dependencies": {
"tslint": "5.7.0",
Expand All @@ -62,9 +63,13 @@
},
"devDependencies": {
"@types/node": "8.0.28",
"@types/rimraf": "2.0.2",
"@types/fs-extra": "4.0.2",
"conventional-changelog": "1.1.5",
"validate-commit-msg": "2.14.0",
"husky": "0.14.3",
"ora": "1.3.0",
"fs-extra": "4.0.2",
"npm-run-all": "4.1.1",
"rimraf": "2.6.1",
"ts-node": "3.3.0",
Expand Down
10 changes: 10 additions & 0 deletions tools/builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createBuilder } from './utils';
import * as tasks from './tasks';

export const build = createBuilder([
['Removing "./dist/@ptsecurity/tslint-config" folder', tasks.removeDistFolder],
['Lint source code', tasks.lint],
['Compiling TypeScript', tasks.compileTS],
['Copy meta files', tasks.copyMetaFiles],
['Testing custom rules', tasks.testRules]
]);
11 changes: 11 additions & 0 deletions tools/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { build } from './builder';

build({
packages: [{ name: 'tslint-config' }]
}).catch(err => {
console.log(err.stdout);
process.exit(1);
}).then(() => {
console.info('Build Complete');
process.exit(0);
});
39 changes: 39 additions & 0 deletions tools/tasks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as util from './utils';
import { helperRoot } from './utils';

const dist = helperRoot('dist');

const root = helperRoot('');
const packageSrc = helperRoot('src');
const packageDist = `${dist}/@ptsecurity/tslint-config`;

console.log(packageSrc);

export function removeDistFolder() {
return util.exec('rimraf', [packageDist]);
}

export async function lint() {
await util.exec('tslint', [`${packageSrc}/src/**/*.ts --project ${root}/tsconfig.json`]);
}

export async function compileTS() {
await util.exec('tsc', []);
}

export async function copyMetaFiles() {
const files = [
{from: `${root}/package.json`, to: `${packageDist}/package.json`},
{from: `${root}/package-lock.json`, to: `${packageDist}/package-lock.json`},
{from: `${root}/CHANGELOG.md`, to: `${packageDist}/CHANGELOG.md`},
{from: `${root}/README.md`, to: `${packageDist}/README.md`}
];

await util.mapAsync(files, async file => {
await util.copy(file.from, file.to);
});
}

export async function testRules() {
await util.exec('tslint', [`-r ${packageDist}/rules --test ${root}/test/rules/**/*`]);
}
Loading

0 comments on commit d36ec17

Please sign in to comment.