Skip to content

Commit

Permalink
feat: tsn2 - experimental esbuild-based tsn alternative
Browse files Browse the repository at this point in the history
It actually uses the correct `scripts/tsconfig.json`, while normal `tsn` actually
doesn't (due to a bug).
  • Loading branch information
kirillgroshkov committed Nov 14, 2021
1 parent d8f7ab4 commit 9439f5d
Show file tree
Hide file tree
Showing 9 changed files with 1,695 additions and 1,820 deletions.
35 changes: 0 additions & 35 deletions .circleci/config.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: release

on:
push:
branches: [master, next, act]

jobs:
release-job:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
env: { NODE_OPTIONS: '--max-old-space-size=3200' }
steps:
- { uses: actions/checkout@v2, with: { persist-credentials: true } }
- { uses: actions/setup-node@v2, with: { node-version: 16, cache: 'yarn' } }

# Cache for npm/npx in ~/.npm
- uses: actions/cache@v2
with:
path: ~/.npm
key: npm-v1-${{ runner.os }}

- name: yarn
run: yarn --frozen-lockfile

- name: build
run: yarn build-prod

- name: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx @naturalcycles/semantic-release
167 changes: 1 addition & 166 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,166 +1 @@
## [1.2.5](https://github.com/NaturalCycles/cli/compare/v1.2.4...v1.2.5) (2021-09-10)


### Bug Fixes

* allow `.script.ts` outside of `scripts` ([14112cc](https://github.com/NaturalCycles/cli/commit/14112cc3b8ab1d4096ee68ed3d0fa582a1bd1f67))

## [1.2.4](https://github.com/NaturalCycles/cli/compare/v1.2.3...v1.2.4) (2021-05-24)


### Bug Fixes

* deps ([565cedc](https://github.com/NaturalCycles/cli/commit/565cedc8e4e052e14b8b19967a183174c5db49ee))

## [1.2.3](https://github.com/NaturalCycles/cli/compare/v1.2.2...v1.2.3) (2021-05-05)


### Bug Fixes

* deps ([fc73e2a](https://github.com/NaturalCycles/cli/commit/fc73e2acdf25b9c8ec4a3c9048d7d5e9535ae7a8))

## [1.2.2](https://github.com/NaturalCycles/cli/compare/v1.2.1...v1.2.2) (2021-04-06)


### Bug Fixes

* deps ([014dbce](https://github.com/NaturalCycles/cli/commit/014dbce738365a4c635c9aafb28735c14423d98b))

## [1.2.1](https://github.com/NaturalCycles/cli/compare/v1.2.0...v1.2.1) (2020-11-03)


### Bug Fixes

* build ([90b2b92](https://github.com/NaturalCycles/cli/commit/90b2b9202cd855be0dd79a067967270375fefb55))
* depend on nodejs-lib instead of deprecated fs-lib ([872b43a](https://github.com/NaturalCycles/cli/commit/872b43ae0e230ef2e1dbb5900159bd43375a5e42))

# [1.2.0](https://github.com/NaturalCycles/cli/compare/v1.1.10...v1.2.0) (2020-11-01)


### Features

* print Node version together with NODE_OPTIONS ([5bf263e](https://github.com/NaturalCycles/cli/commit/5bf263eaf7b305bc36aa1e2efd26fb88f51028de))

## [1.1.10](https://github.com/NaturalCycles/cli/compare/v1.1.9...v1.1.10) (2020-08-21)


### Bug Fixes

* deps (ts-node@9) ([710fad2](https://github.com/NaturalCycles/cli/commit/710fad26c98a86fe90c1cfa9824a330296a18337))

## [1.1.9](https://github.com/NaturalCycles/cli/compare/v1.1.8...v1.1.9) (2020-08-20)


### Bug Fixes

* deps ([email protected]) ([fbb65ff](https://github.com/NaturalCycles/cli/commit/fbb65ff5dbe072db0513c4dae5e9f7a36ce4e2cf))

## [1.1.8](https://github.com/NaturalCycles/cli/compare/v1.1.7...v1.1.8) (2020-06-26)


### Bug Fixes

* release ([6db6f72](https://github.com/NaturalCycles/cli/commit/6db6f721ec23b87ea476cbba38d8c9df4e3204b4))


### Reverts

* original tsconfig-paths behavior ([2dbb2b3](https://github.com/NaturalCycles/cli/commit/2dbb2b3926c15e580dbdba5000ea53a875d06545))

## [1.1.7](https://github.com/NaturalCycles/cli/compare/v1.1.6...v1.1.7) (2020-06-25)


### Bug Fixes

* read tsconfig.json as json5 ([99315c1](https://github.com/NaturalCycles/cli/commit/99315c1f6679f2e7cdb1436e224e20c4e2b612db))

## [1.1.6](https://github.com/NaturalCycles/cli/compare/v1.1.5...v1.1.6) (2020-06-25)


### Bug Fixes

* pass correct tsconfig path to tsconfig-paths ([b37f7df](https://github.com/NaturalCycles/cli/commit/b37f7dfe75b00af73df7a16369748a16cbd7debb))

## [1.1.5](https://github.com/NaturalCycles/cli/compare/v1.1.4...v1.1.5) (2020-06-25)


### Bug Fixes

* support ${scriptName}.script.ts ([7eb1f4a](https://github.com/NaturalCycles/cli/commit/7eb1f4a86dd5a3b16aca32479a0805e582e0bcd5))

## [1.1.4](https://github.com/NaturalCycles/cli/compare/v1.1.3...v1.1.4) (2020-04-08)


### Bug Fixes

* remove logging (hide behind env.CLI_DEBUG) ([ff49938](https://github.com/NaturalCycles/cli/commit/ff4993811f7991413a07555f50534c37d795c3b4))

## [1.1.3](https://github.com/NaturalCycles/cli/compare/v1.1.2...v1.1.3) (2020-04-08)


### Bug Fixes

* argv, try2 ([694b6d8](https://github.com/NaturalCycles/cli/commit/694b6d84c9e272da6097ba4f71ec05b225c8ac88))

## [1.1.2](https://github.com/NaturalCycles/cli/compare/v1.1.1...v1.1.2) (2020-04-08)


### Bug Fixes

* remove argv[1] ([1292a35](https://github.com/NaturalCycles/cli/commit/1292a3536683748f53254c2b608ad5a1e5840d44))

## [1.1.1](https://github.com/NaturalCycles/cli/compare/v1.1.0...v1.1.1) (2020-04-08)


### Bug Fixes

* script/tsconfig.json auto-copying path ([9726498](https://github.com/NaturalCycles/cli/commit/9726498419d1b88b1bfd67be93252d12ff3f3ea2))

# [1.1.0](https://github.com/NaturalCycles/cli/compare/v1.0.5...v1.1.0) (2020-04-04)


### Features

* auto-complete .ts extension ([ddc0cc7](https://github.com/NaturalCycles/cli/commit/ddc0cc71b8313328d326c80313f0d263dbdfd015))

## [1.0.5](https://github.com/NaturalCycles/cli/compare/v1.0.4...v1.0.5) (2020-04-04)


### Bug Fixes

* tsconfig-paths ([2bd49d3](https://github.com/NaturalCycles/cli/commit/2bd49d3d405b9d38ee51eba4160d4eec2a83ee33))

## [1.0.4](https://github.com/NaturalCycles/cli/compare/v1.0.3...v1.0.4) (2020-04-04)


### Bug Fixes

* tsconfig-paths ([a2d7b57](https://github.com/NaturalCycles/cli/commit/a2d7b57dc196da34841b1d7a9ea743c857454e74))

## [1.0.3](https://github.com/NaturalCycles/cli/compare/v1.0.2...v1.0.3) (2020-04-04)


### Bug Fixes

* path ([670f9a2](https://github.com/NaturalCycles/cli/commit/670f9a26900a13c8a4b72ea0a44720389567d3e0))

## [1.0.2](https://github.com/NaturalCycles/cli/compare/v1.0.1...v1.0.2) (2020-04-04)


### Bug Fixes

* use ts-node programmatically ([a82b3ba](https://github.com/NaturalCycles/cli/commit/a82b3baa1028c2c559c03c78b1d84a836c08893b))

## [1.0.1](https://github.com/NaturalCycles/cli/compare/v1.0.0...v1.0.1) (2020-04-04)


### Bug Fixes

* deps ([710e9a9](https://github.com/NaturalCycles/cli/commit/710e9a97ea4ea3917d3ff9699fb9e471d2700edb))

# 1.0.0 (2020-04-04)


### Features

* first version ([77b2da4](https://github.com/NaturalCycles/cli/commit/77b2da408f223bcee961f85a829021dba8aff9d8))
See [Github Releases](https://github.com/NaturalCycles/cli/releases)
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"scripts": {
"prepare": "husky install",
"debug": "tsn ./src/bin/tsn.ts",
"tsn-debug": "tsn ./src/bin/tsn.ts testscript.ts",
"tsn-debug2": "ts-node -T ./src/bin/tsn.ts testscript.ts"
"tsn-debug": "tsc && CLI_DEBUG=1 node ./dist/bin/tsn.js testscript.ts",
"tsn2-debug": "tsc && CLI_DEBUG=1 node ./dist/bin/tsn2.js testscript.ts"
},
"dependencies": {
"@naturalcycles/nodejs-lib": "^12.8.0",
"chalk": "^4.0.0",
"dotenv": "^10.0.0",
"esbuild": "^0.13.13",
"esbuild-register": "^3.1.2",
"loud-rejection": "^2.2.0",
"ts-node": "^10.0.0",
"typescript": "^4.0.2"
Expand All @@ -30,6 +32,7 @@
],
"main": "dist/index.js",
"bin": {
"tsn2": "dist/bin/tsn2.js",
"tsn": "dist/bin/tsn.js"
},
"publishConfig": {
Expand All @@ -40,7 +43,7 @@
"url": "https://github.com/NaturalCycles/cli"
},
"engines": {
"node": ">=12.13.1"
"node": ">=14.15.0"
},
"version": "1.2.5",
"description": "CLI utils to be installed globally via 'npm i -g'",
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
`-T -r tsconfig-paths/register -r dotenv/config`. Will use `./scripts/tsconfig.json` (file will be
auto-generated in not present).

- ...
- `tsn2` is an experimental version of `tsn` that uses `esbuild` and `esbuild-register` instead of
`typescript` and `ts-node`.

# Packaging

- `engines.node`: Latest Node.js LTS
- `main: dist/index.js`: commonjs, es2019
- `main: dist/index.js`: commonjs, es2020
3 changes: 2 additions & 1 deletion scripts/testscript.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
yarn tsn testscript.ts
yarn tsn-debug
yarn tsn2-debug
*/

Expand Down
4 changes: 2 additions & 2 deletions src/bin/tsn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
This CLI command is optimized for speed, so, it includes minimum dependencies
*/

import type * as nodejsLib from '@naturalcycles/nodejs-lib/dist/fs'
import * as c from 'chalk'
import * as fs from 'fs'
import * as path from 'path'
import type * as nodejsLib from '@naturalcycles/nodejs-lib/dist/fs'
import * as c from 'chalk'
import * as tsnode from 'ts-node'

const projectDir = path.join(__dirname, '../..')
Expand Down
Loading

0 comments on commit 9439f5d

Please sign in to comment.