Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
refactor: Simplify the starter project and improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sramam committed Oct 1, 2017
1 parent dbd81e8 commit 75618ff
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 128 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ node ./.reinit
```

At this point, explore ./src for the bare bones example.
Typically, you'd want to delete it's contents, start over and profit!

Typically, you'd want to modify `./src/index.ts` to get started.

## Development Tooling

Expand Down
4 changes: 0 additions & 4 deletions dist/calculator/index.d.ts

This file was deleted.

11 changes: 0 additions & 11 deletions dist/calculator/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions dist/greeter/index.d.ts

This file was deleted.

11 changes: 0 additions & 11 deletions dist/greeter/index.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function main(): void;
5 changes: 2 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
Object.defineProperty(exports, "__esModule", { value: true });
const engchk = require("runtime-engine-check");
engchk();
const greeter_1 = require("./greeter");
let greeter = new greeter_1.default('Hello, world');
console.log(greeter.greet());
function main() { }
exports.main = main;
67 changes: 34 additions & 33 deletions docs/DevTools.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,57 +28,59 @@ expensive mishaps or re-work later in the project life-cycle.

## run-scripts
Since "lean"-ness is a primary goal, npm is used as a build tool.
We use [npm-run-batch](https://github.com/sramam/npm-run-batch) to create
a simple pipeline of tasks to perform for each build step.

The run-scripts used:
*aside:* To help with these, we recommend [npm-completion](https://docs.npmjs.com/cli/completion)?
### The run-scripts used:

clean : removes all generated directories
prebuild : cleans build and runs tslint (for large projects, remove the automatic clean)
*aside:* To help with these, we recommend [npm-completion](https://docs.npmjs.com/cli/completion)

commit : uses `commitizen` to help format commit messages
clean : `rimraf ./build ./coverage`
build : builds the project
postbuild : runs tests
test : runs tests with coverage on generated JavaScript
posttest : remaps coverage report to source TypeScript
build:dist : build a distribution - skips compiling test files
build:watch : watch project files and rebuild when anything changes
build:dist : build a distribution (no tests)
npm-sh : spawn a new shell with local npm installs in path
test : runs tests with coverage on generated JavaScript
secure : checks all installed dependencies for vulnerabilities
check : checks all installed dependencies for updates
lcheck : list dependencies not in compliance with project license requirements
lcheck : compliance check of project dependency license
coverage : prints coverage report over typescript source

## Structure
## Project Structure
The directory structure of a typical project:

├── LICENSE
├── README.md
├── package.json
├── scripts
│   └── remapped-coverage.js
├── src
│   ├── calculator
│   │   ├── index.ts
│   │   └── test.ts
│   ├── greeter
│   │   ├── index.ts
│   │   └── test.ts
├── scripts/ - post install scripts
├── src/ - module source (TypeScript)
│   ├── test/
│   │   └── specs/
│   │   └── index.ts
│   └── index.ts
├── test
│   └── mocha.opts
├── tsconfig.dist.json
├── tsconfig.json
└── tslint.json
├── docs/ - module documentation
── mocha.opts - mocha config
├── tsconfig.dist.json - production tsconfig
├── tsconfig.json - development tsconfig
└── tslint.json - tslint

In addition, these directories are auto-created by the various scripts.
The coverage & build directories are .gitignored. By design, dist
directories are - for pure-Type/JavaScript packages, this is an advantage.
If your package included native/compiled artifacts, it might need to be
The coverage & build directories are .gitignored.
By design, dist directories are commited to the repo. For components
with non-native dependencies, which is a vast majority of the cases,
this is an advantage, since it minimizes the module size for download
and makes the build setup a lot simpler.

If your module includes native/compiled artifacts, this might need to be
reconsidered.

├── coverage
├── dist
└── build
├── coverage/
| └── typescript/
| └── index.html - html report of typescript
├── dist/ - Commmitted to repo. Minimizes package size
└── build/ - scratch dir - for build & test

### Why are there two tsconfig*.json files?

TypeScript compiler configuration, tsconfig.json does not support multiple
build targets. To create separate builds then, one has to use multiple config
files and invoke atleast one of them explicitly like we do.
Expand All @@ -87,4 +89,3 @@ Further, our opinioned preferences is to keep source and associated tests
together in the source tree. This requires to compile time configurations -
a regular build that includes


3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-starter-node",
"version": "1.0.0",
"version": "1.0.2",
"description": "A starter package for typescript projects",
"keywords": [
"TypeScript",
Expand All @@ -19,6 +19,7 @@
"types": "dist/index.d.ts",
"files": [
"dist",
"docs",
"scripts"
],
"scripts": {
Expand Down
9 changes: 0 additions & 9 deletions src/calculator/index.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/calculator/test.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/greeter/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/greeter/test.ts

This file was deleted.

5 changes: 1 addition & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
import * as engchk from 'runtime-engine-check';
engchk(); // checks node version matches spec in package.json

import Greeter from './greeter';

let greeter = new Greeter<string>('Hello, world');
console.log(greeter.greet());
export function main() {}
9 changes: 9 additions & 0 deletions src/test/specs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import { expect } from 'chai';
import { main } from '../..';

describe('main', () => {
it('main', () => {
main();
});
});

0 comments on commit 75618ff

Please sign in to comment.