Welcome to TS-Starter, a dead-simple TypeScript starter template for Visual Studio Code, crafted to provide a seamless development experience for TypeScript projects.
- Build Tools: Integrated with
tsup
(ESBuild) for fast build processes, supporting ONLYESM
format - Some packages need to be downgraded to work withcjs
(eg chalk v5 --> v4). - Linter and Formatter:
ESLint
andPrettier
are configured to ensure code quality and consistency. - Environment Variables: Support for
.env
and.env.development
files to manage environment-specific configurations usingdotenv
. - Concurrent Tasks: Use of
concurrently
for running multiple scripts simultaneously. - Package Management: Managed with
pnpm
for efficient and fast dependency resolution.
-
Clone the Repository:
git clone https://github.com/christos97/ts-starter.git cd ts-starter chmod +x .husky/pre-commit .husky/pre-push
-
Install Dependencies
pnpm install
-
Start dev server
pnpm start
- Copy
.env.example
to.env
and.env.development
:cp .env.example .env cp .env.example .env.development rm .env.example
- Fill in the actual values in
.env
and.env.development
as per your development and production environments. - Sensitive data like api-keys should be stored in github secrets instead
build
: Builds the project in both CJS and ESM formats.build:esm
: Builds the project in ECMAScript Module format.clean
: Cleans the project by removing the dist directory and node modules.format
: Formats the codebase using Prettier and syncs package configurations.lint
: Lints the codebase using ESLint.start
: Runs the application in ESM format.start:esm
: Runs the application in ESM format.
build:cjs
: Builds the project in CommonJS format.start:cjs
: Runs the application in CJS format.
-
GitHub Secrets for Production/CI
: For environment variables that are sensitive or specific to production and CI environments (like API keys or service credentials), we use GitHub Secrets. This approach ensures that these variables are securely stored and are not exposed in the codebase or in the CI logs -
Setting Up GitHub Secrets
:-
Add Secrets to your repository
- Navigate to your GitHub repository.
- Click on the Settings tab.
- Go to Secrets and choose Actions.
- Use New repository secret to add each environment variable as a secret.
-
Name your Secrets
- Name your secrets in a clear and consistent manner. For example, PROD_API_BASE_URL for the production API base URL
-
-
Using Secrets in GitHub Actions Workflow
: In the GitHub Actions workflow, these secrets are accessed and set as environment variables. Here's an example from our workflow configuration:.
jobs:
build:
runs-on: ubuntu-latest
# ... other configurations ...
steps:
# ... previous steps ...
env:
CI: true
# API_BASE_URL: ${{ secrets.API_BASE_URL }}
# API_KEY: ${{ secrets.API_KEY }}s