- Create a new empty git repo
mkdir my-project cd my-project git init .
- Install the template (Copy this into git bash).
git remote add template https://github.com/StatelessStudio/typescript-template-library/ && git pull template master --allow-unrelated-histories && git remote remove template
- Replace "typescript-template-library" with the name of your library project-wide (No Spaces or special characters except dash!)
npm i
- Update the documentation, changelog, etc
- Run the install command in the installation instructions
- Resolve merge conflicts
- Test!
Run a dev test with npm start
.
Here's a rundown of where to put your code, see each file for more information:
- script/example.ts: Create an example application that uses your library
- src/environment.ts: Setup environment variables here
- src/index.ts: You don't typically need to edit this file, it just initializes and starts your app.
To run unit tests, npm run test
You can write custom scripts in the script/
directory. See script/example.ts
as an example. You should also register your scripts in package.json
:
{
...
"scripts": {
...
"admin:example": "ts-node script/example"
}
}
Run your script with npm run admin:example
To compile a debug build, run npm run build:dev
. The build output will appear in the ./dist
folder.
To compile a production build, run npm run build:prod
. The build output will appear in the ./dist
folder.
To generate a clean build (removes old artifacts and reruns pre&post process scripts), append :clean
to a build script:
- Debug:
npm run build:dev:clean
- Release:
npm run build:prod:clean
npm run doc
and browse docs/index.html!
See src/environment.ts
to see how to use this project's environment variables. Configure an environment in .env
or with process.env
(https://nodejs.org/dist/latest-v16.x/docs/api/process.html#processenv).