Giter Club home page Giter Club logo

create-bjerk-typescript's Introduction

Bjerk's Typescript boilerplate

This repository contains a basic Typescript boilerplate, based on Bjerk's typical setup.

yarn create bjerk-typescript my-app

Check the package.json for more details.

See our video about it here: https://www.youtube.com/watch?v=0x82COtqsag

Features

  • GitHub Workflow that build, test, lint and format
  • Uses Yarn v2
  • Pure ESM
  • Standardized (and optimized) Dockerfile
  • Standardized on Node LTS
  • Kept (very) maintained

Motivation

There are thousands of boilerplates on GitHub, and being a company that both contributes and loves Open Source it makes sense to use them. However, we haven't found a boilerplate that follows the guidelines below.

1. Keep it barebone, but enough to provide value

The required tools should come with the boilerplate. An example is Fastify, even though we use Fastify for most of our projects, we don't use Fastify for all the applications. This boilerplate should be barebone for 95% of our projects.

Another example is Jest; Node 18 includes a test runner – do we need it anymore? We should keep asking ourselves that question to make the best boilerplate.

2. Continuous attention to technical excellence

Having a great starting point is paramount. Our boilerplate should strive to always improve technical excellence/quality.

3. Keep it up-to-date

Things change in the software industry very quickly. Our boilerplate should always be kept maintained. We want to start from the most up-to-date point, it feels weird to start updating packages when you start from a boilerplate.

A boilerplate to be inspired by

We strive to make this boilerplate a single source of truth for code that is up-to-date and of upmost technical excellence.

Contribute

We love contributions! If you have some questions about how things work, a feature or just wanna share feedback, feel free to open an issue! If you're thinking about adding a Pull Request and afraid it wouldn't be landed? Feel free to talk about it first :)

create-bjerk-typescript's People

Contributors

bjerk-bot avatar dependabot[bot] avatar github-actions[bot] avatar renovate[bot] avatar simenandre avatar xillians avatar

Watchers

 avatar  avatar

Forkers

mirabtellegen

create-bjerk-typescript's Issues

Refactor to ESM

Our CLI script is currently written in CommonJS, but the rest of our repository is ESM.

Yarn create not working πŸ˜’

Seems like the command line utility is trying to copy a file that does not exist. Not sure if this is caused by files not being included in the NPM package or what.

Steps to reproduce

  1. yarn create bjerk-typescript hello-world

This will output the following:

➜  /tmp yarn create bjerk-typescript hello-world
yarn create v1.22.19
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ”¨  Building fresh packages...

success Installed "[email protected]" with binaries:
      - create-bjerk-typescript
[#####################################################################] 153/153Bootstrapping

Summary:
Destination: /private/tmp/hello-world
App: hello-world

Copying Project Files ...
Copying Templates ...
node:internal/fs/utils:345
    throw err;
    ^

Error: ENOENT: no such file or directory, lstat '/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/templates/.github/workflows/workflow.yml'
    at Object.lstatSync (node:fs:1529:3)
    at Object.lstatSync (/Users/cobraz/.config/yarn/global/node_modules/graceful-fs/polyfills.js:311:34)
    at statFunc (/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/node_modules/fs-extra/lib/util/stat.js:24:20)
    at getStatsSync (/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/node_modules/fs-extra/lib/util/stat.js:25:19)
    at Object.checkPathsSync (/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/node_modules/fs-extra/lib/util/stat.js:67:33)
    at Object.copySync (/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/node_modules/fs-extra/lib/copy/copy-sync.js:24:38)
    at /Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/cmd/create-bjerk-typescript/index.cjs:100:11
    at Array.forEach (<anonymous>)
    at main (/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/cmd/create-bjerk-typescript/index.cjs:99:13)
    at Object.<anonymous> (/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/cmd/create-bjerk-typescript/index.cjs:139:1) {
  errno: -2,
  syscall: 'lstat',
  code: 'ENOENT',
  path: '/Users/cobraz/.config/yarn/global/node_modules/create-bjerk-typescript/templates/.github/workflows/workflow.yml'
}
error Command failed.
Exit code: 1
Command: /Users/cobraz/.yarn/bin/create-bjerk-typescript
Arguments: hello-world
Directory: /private/tmp
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

Move from ts-node to tsx

πŸ‘‹

I'm wondering if we should drop ts-node and replace it with tsx (the esbuild runtime). Not only are we blocked from upgrading to Typescript v5, but we are also having to add a separate package to provide a watch script.

Not to mention that tsx is more performant. I think for our use, it makes more sense.

One thing would change, there wouldn't be support for type checking on development mode. Which, I don't think really is necessary. We have IDEs that does just that, and we will be running ordinary tsc when building anyway.

Cannot find module '/Users/brage/Kode/flexisoft/portal-api/.yarn/releases/yarn-3.4.1.cjs'

I ran yarn create bjerk-typescript my-app and tried to install with yarn install

node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module '/Users/brage/Kode/flexisoft/portal-api/.yarn/releases/yarn-3.4.1.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.12.0

Add workflow improvements

I recently added a workflow to test the latest version. We probably want to test if it works before releasing as well?

[RFC] Update existing files

As create-bjerk-typescript is being updated, I want to be able to update it.

Currently, I am running the command again and resetting the files I don't want to be updated.
Most of the time, I have to reset package.json; the diff isn't very useful.

Maybe it's worth looking into updating the files typically updated by the users if they exist when running create-bjerk-typescript? I.e. package.json could be read and updated, maybe ignoring dependencies?

I would love to have a programmatic way to update workspaces, so they are kept updated with what is happening in this repository.

Yarn installs should be `--immutable`

Abort with an error exit code if the lockfile was to be modified

The statement above is taken from Yarn's manuals. It makes sense to expect that our yarn.lock is not modified by yarn installs either run in GitHub Action or Dockerfile.

Move copying workflows to template to on push

In our current workflow, we're copying workflows from .github/workflows to `templates/githubΒ΄.

copy-workflows:
name: Copy workflows to templates
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cp .github/workflows/pull-request.yml templates/github/workflows/
- run: cp .github/workflows/workflow.yml templates/github/workflows/
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: 'chore(deps): update github actions workflows'
author: Bjerk Bot <[email protected]>
token: ${{ secrets.BJERKBOT_GITHUB_TOKEN }}
branch: update-workflows
team-reviewers: thebranches
delete-branch: true
title: 'chore(deps): update github actions workflows'
body: |
This pull request updates workflows from main .github directory.
Reason for this update is probably because Dependabot has updated
either pull-request.yml or workflow.yml. We synchronize these files
from the main .github directory to template directory to keep them
up-to-date.

I realize that v2.11.0 didn't get the GitHub Workflow updates that are in the changelog because we only updated .github/workflows. Would it make sense to always look for these changes on every push?

[RFC] Change yarn to pnpm

Main driver for me is:

  • pnpm config set auto-install-peers true (Automatically install peer dependencies, no need to keep maintaining it in our own package.json)
  • Less boilerplate in each repository (no .yarn folder)

As we're moving towards using tools like corepack, I no longer feel we need to pack the binary for our package manager with our code.

Personally not sure about this yet, but I want to request some comments.

Better support for mono-repos

I am working on a mono-repo, which uses most of the files from create-bjerk-typescript.

If it makes sense, I would love to generate new packages in the mono-repo based on this, but without all the unrelated boilerplate (i.e. editor config is always in root, not in a package).

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm @tsconfig/esm Unavailable

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-plugin-jest to v28
  • chore(deps): update docker/build-push-action action to v6
  • chore(deps): update google-github-actions/release-please-action action to v4
  • chore(deps): update peter-evans/create-pull-request action to v6
  • chore(deps): update simenandre/publish-with-yarn action to v2
  • chore(deps): lock file maintenance
  • πŸ” Create all rate-limited PRs at once πŸ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

dockerfile
Dockerfile
  • node 18-alpine3.16
  • node 18-alpine3.16
  • node 18-alpine3.16
github-actions
.github/workflows/maintenance.yml
  • actions/checkout v4
  • peter-evans/create-pull-request v5
  • actions/checkout v4
  • peter-evans/create-pull-request v5
.github/workflows/new-project-test.yml
  • actions/setup-node v3
  • actions/checkout v4
  • actions/setup-node v3
.github/workflows/pull-request.yml
  • actions/checkout v4
  • actions/setup-node v3
  • actions/checkout v4
  • docker/metadata-action v4
  • docker/setup-buildx-action v2
  • docker/build-push-action v4
.github/workflows/release-please.yml
  • actions/checkout v4
  • google-github-actions/release-please-action v3
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v3
  • simenandre/publish-with-yarn v1
.github/workflows/workflow.yml
  • actions/checkout v4
  • actions/setup-node v3
  • actions/checkout v4
  • docker/metadata-action v4
  • docker/setup-buildx-action v2
  • docker/build-push-action v4
npm
package.json
  • fs-extra ^11.1.0
  • @bjerk/eslint-config ^5.3.1
  • @simenandre/prettier 5.0.0
  • @tsconfig/esm ^1.0.3
  • @tsconfig/node-lts ^18.12.1
  • @tsconfig/strictest ^2.0.1
  • @types/jest ^29.1.2
  • @types/node ^18
  • eslint ^8.25.0
  • eslint-plugin-jest ^27.1.5
  • jest ^29.1.2
  • prettier ^3.0.0
  • ts-jest ^29.0.3
  • tsx ^3.12.7
  • typescript ^5.1
  • node >=18
  • node 18.17.1
  • yarn 1.22.19
  • yarn 3.6.2

  • Check this box to trigger a request for Renovate to run again on this repository

Cannot find module yarn-3.3.0.cjs

Something seems off with the configuration of yarn.

On a brand new project, this error occurs:

Error: Cannot find module '/Users/moripen/Documents/GitHub/abax-vwfs/.yarn/releases/yarn-3.3.0.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.