Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
sompylasar committed Dec 30, 2018
0 parents commit fc5622b
Show file tree
Hide file tree
Showing 32 changed files with 6,075 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:jest/recommended",
"prettier"
],
"rules": {
"no-console": "off",
"no-unused-vars": "warn",
"no-constant-condition": "warn",
"no-use-before-define": "error"
},
"overrides": [
{
"files": ["*.test.js"],
"plugins": [
"jest"
],
"rules": {
"no-unused-expressions": "off",
"node/no-unpublished-require": "off"
}
}
]
}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## OS-specific
.DS_Store

## Git
!.keep

## IDE-specific
/.vscode/

## Node-specific
/node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

## Testing
/coverage
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package.json
.eslintrc.json
.prettierrc
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"arrowParens": "always",
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"semi": true,
"useTabs": false,
"jsxBracketSameLine": false,
"printWidth": 120
}
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# `ts-build-tools`

A command-line toolkit to manage a Node.js package written in TypeScript.

Includes build, clean, lint, test, dev, and prepublish scripts out-of-the box.

Intended to work with [`zmey-gorynych`](https://www.npmjs.com/package/zmey-gorynych), a Node.js package versioning and publishing tool.

## Usage

Initialize a new Node.js package and install the toolkit with [`npm`](https://docs.npmjs.com/cli/init):

```
cd your-package
npm init -y
npm i -D @sompylasar/ts-build-tools
```

or with [`yarn`](https://yarnpkg.com/lang/en/docs/cli/init/):

```
cd your-package
yarn init -y
yarn add --dev @sompylasar/ts-build-tools
```

## Commands

### `init`

Scaffold the package file structure and update the `package.json` to include the necessary file references, dependencies, and scripts.

### `build`

Produce JavaScript in the `lib` directory via `tsc`.

### `clean`

Removes the `lib` and `coverage` directories.

### `lint`

Runs `tslint`.

### `test`

Run the tests via `nyc`, `mocha`, and `ts-node`.

### `dev`

Run the application in the source code watch and hot reload mode via `tsc --watch`.

## Known limitations

- The toolkit in some aspects relies on the `node_modules` structure, so it may not work with `node_modules`-less setups like Yarn PnP and NPM Tink.
6 changes: 6 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

const script = process.argv[2];
const args = process.argv.slice(3);

require('../src/index').cli(script, args);
63 changes: 63 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "@sompylasar/ts-build-tools",
"version": "1.0.0",
"description": "A command-line toolkit to manage a Node.js package written in TypeScript.",
"keywords": ["packages", "typescript"],
"author": "Ivan Babak <babak.john@gmail.com>",
"license": "MIT",
"repository": "github:sompylasar/ts-build-tools",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"files": [
"bin",
"scaffolding",
"src"
],
"bin": {
"ts-build-tools": "./bin/cli.js"
},
"engines": {
"node": "^8.15.0"
},
"dependencies": {
"@types/chai": "4.0.4",
"@types/debug": "0.0.30",
"@types/mocha": "2.2.43",
"@types/node": "8.0.46",
"@types/sinon": "2.3.6",
"chai": "4.1.2",
"chalk": "2.3.0",
"cross-env": "5.1.0",
"custom-tslint-formatters": "2.1.1",
"debug": "3.1.0",
"fs-extra": "4.0.2",
"mocha": "4.0.1",
"npm-run-all": "4.1.1",
"npm-which": "3.0.1",
"nyc": "11.2.1",
"rimraf": "2.6.2",
"sinon": "4.0.1",
"ts-node": "3.3.0",
"tslint": "5.8.0",
"typescript": "2.5.3"
},
"devDependencies": {
"eslint": "^5.10.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-jest": "^22.1.2",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"jest": "^23.6.0",
"jest-date-mock": "^1.0.6",
"prettier": "^1.15.3"
},
"jest": {
"setupFiles": [
"jest-date-mock"
]
},
"scripts": {
"lint": "eslint ./src",
"test": "jest"
}
}
23 changes: 23 additions & 0 deletions scaffolding/scaffolding-gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## OS-specific
.DS_Store

## Git
!.keep

## IDE-specific
/.vscode/

## Node-specific
/node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

## Build
/build/

## Testing
/coverage/
/.nyc_output/

# ----------------
4 changes: 4 additions & 0 deletions scaffolding/scaffolding-index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function main(): number {
// Congrats with a new package! Now let's make it work.
return 0;
}
3 changes: 3 additions & 0 deletions scaffolding/scaffolding-prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package.json
.eslintrc.json
.prettierrc
10 changes: 10 additions & 0 deletions scaffolding/scaffolding-prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"arrowParens": "always",
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"semi": true,
"useTabs": false,
"jsxBracketSameLine": false,
"printWidth": 120
}
9 changes: 9 additions & 0 deletions scaffolding/scaffolding-test-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { assert } from '@sompylasar/ts-build-tools';

import { main } from '../src/index';

describe(require('../package.json').name, () => {
it('works', () => {
assert.strictEqual(0, main(), 'main returns 0');
});
});
14 changes: 14 additions & 0 deletions scaffolding/scaffolding-test-tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../lib/test"
},
"include": [
"../test/**/*.ts",
"../typings/**/*.d.ts",
"../node_modules/@sompylasar/ts-build-tools/scaffolding/typings/**/*.d.ts"
],
"exclude": [
"../node_modules"
]
}
31 changes: 31 additions & 0 deletions scaffolding/scaffolding-tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es5",
"lib": [ "es5", "es6" ],
"module": "commonjs",
"outDir": "./lib",
"sourceMap": true,
"listFiles": false,
"listEmittedFiles": false,
"pretty": true,
"traceResolution": false,
"declaration": true,
"alwaysStrict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"strictNullChecks": true,
"typeRoots": [
"./node_modules/@sompylasar/ts-build-tools/node_modules/@types",
"./node_modules/@types"
]
},
"include": [
"./src/**/*.ts",
"./typings/**/*.d.ts",
"./node_modules/@sompylasar/ts-build-tools/scaffolding/typings/**/*.d.ts"
],
"exclude": [
"./node_modules"
]
}
Loading

0 comments on commit fc5622b

Please # to comment.