Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 9439f5d

Browse files
feat: tsn2 - experimental esbuild-based tsn alternative
It actually uses the correct `scripts/tsconfig.json`, while normal `tsn` actually doesn't (due to a bug).
1 parent d8f7ab4 commit 9439f5d

File tree

9 files changed

+1695
-1820
lines changed

9 files changed

+1695
-1820
lines changed

.circleci/config.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [master, next, act]
6+
7+
jobs:
8+
release-job:
9+
runs-on: ubuntu-latest
10+
if: "!contains(github.event.head_commit.message, 'skip ci')"
11+
env: { NODE_OPTIONS: '--max-old-space-size=3200' }
12+
steps:
13+
- { uses: actions/checkout@v2, with: { persist-credentials: true } }
14+
- { uses: actions/setup-node@v2, with: { node-version: 16, cache: 'yarn' } }
15+
16+
# Cache for npm/npx in ~/.npm
17+
- uses: actions/cache@v2
18+
with:
19+
path: ~/.npm
20+
key: npm-v1-${{ runner.os }}
21+
22+
- name: yarn
23+
run: yarn --frozen-lockfile
24+
25+
- name: build
26+
run: yarn build-prod
27+
28+
- name: release
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
run: npx @naturalcycles/semantic-release

CHANGELOG.md

Lines changed: 1 addition & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1 @@
1-
## [1.2.5](https://github.com/NaturalCycles/cli/compare/v1.2.4...v1.2.5) (2021-09-10)
2-
3-
4-
### Bug Fixes
5-
6-
* allow `.script.ts` outside of `scripts` ([14112cc](https://github.com/NaturalCycles/cli/commit/14112cc3b8ab1d4096ee68ed3d0fa582a1bd1f67))
7-
8-
## [1.2.4](https://github.com/NaturalCycles/cli/compare/v1.2.3...v1.2.4) (2021-05-24)
9-
10-
11-
### Bug Fixes
12-
13-
* deps ([565cedc](https://github.com/NaturalCycles/cli/commit/565cedc8e4e052e14b8b19967a183174c5db49ee))
14-
15-
## [1.2.3](https://github.com/NaturalCycles/cli/compare/v1.2.2...v1.2.3) (2021-05-05)
16-
17-
18-
### Bug Fixes
19-
20-
* deps ([fc73e2a](https://github.com/NaturalCycles/cli/commit/fc73e2acdf25b9c8ec4a3c9048d7d5e9535ae7a8))
21-
22-
## [1.2.2](https://github.com/NaturalCycles/cli/compare/v1.2.1...v1.2.2) (2021-04-06)
23-
24-
25-
### Bug Fixes
26-
27-
* deps ([014dbce](https://github.com/NaturalCycles/cli/commit/014dbce738365a4c635c9aafb28735c14423d98b))
28-
29-
## [1.2.1](https://github.com/NaturalCycles/cli/compare/v1.2.0...v1.2.1) (2020-11-03)
30-
31-
32-
### Bug Fixes
33-
34-
* build ([90b2b92](https://github.com/NaturalCycles/cli/commit/90b2b9202cd855be0dd79a067967270375fefb55))
35-
* depend on nodejs-lib instead of deprecated fs-lib ([872b43a](https://github.com/NaturalCycles/cli/commit/872b43ae0e230ef2e1dbb5900159bd43375a5e42))
36-
37-
# [1.2.0](https://github.com/NaturalCycles/cli/compare/v1.1.10...v1.2.0) (2020-11-01)
38-
39-
40-
### Features
41-
42-
* print Node version together with NODE_OPTIONS ([5bf263e](https://github.com/NaturalCycles/cli/commit/5bf263eaf7b305bc36aa1e2efd26fb88f51028de))
43-
44-
## [1.1.10](https://github.com/NaturalCycles/cli/compare/v1.1.9...v1.1.10) (2020-08-21)
45-
46-
47-
### Bug Fixes
48-
49-
* deps (ts-node@9) ([710fad2](https://github.com/NaturalCycles/cli/commit/710fad26c98a86fe90c1cfa9824a330296a18337))
50-
51-
## [1.1.9](https://github.com/NaturalCycles/cli/compare/v1.1.8...v1.1.9) (2020-08-20)
52-
53-
54-
### Bug Fixes
55-
56-
* deps ([email protected]) ([fbb65ff](https://github.com/NaturalCycles/cli/commit/fbb65ff5dbe072db0513c4dae5e9f7a36ce4e2cf))
57-
58-
## [1.1.8](https://github.com/NaturalCycles/cli/compare/v1.1.7...v1.1.8) (2020-06-26)
59-
60-
61-
### Bug Fixes
62-
63-
* release ([6db6f72](https://github.com/NaturalCycles/cli/commit/6db6f721ec23b87ea476cbba38d8c9df4e3204b4))
64-
65-
66-
### Reverts
67-
68-
* original tsconfig-paths behavior ([2dbb2b3](https://github.com/NaturalCycles/cli/commit/2dbb2b3926c15e580dbdba5000ea53a875d06545))
69-
70-
## [1.1.7](https://github.com/NaturalCycles/cli/compare/v1.1.6...v1.1.7) (2020-06-25)
71-
72-
73-
### Bug Fixes
74-
75-
* read tsconfig.json as json5 ([99315c1](https://github.com/NaturalCycles/cli/commit/99315c1f6679f2e7cdb1436e224e20c4e2b612db))
76-
77-
## [1.1.6](https://github.com/NaturalCycles/cli/compare/v1.1.5...v1.1.6) (2020-06-25)
78-
79-
80-
### Bug Fixes
81-
82-
* pass correct tsconfig path to tsconfig-paths ([b37f7df](https://github.com/NaturalCycles/cli/commit/b37f7dfe75b00af73df7a16369748a16cbd7debb))
83-
84-
## [1.1.5](https://github.com/NaturalCycles/cli/compare/v1.1.4...v1.1.5) (2020-06-25)
85-
86-
87-
### Bug Fixes
88-
89-
* support ${scriptName}.script.ts ([7eb1f4a](https://github.com/NaturalCycles/cli/commit/7eb1f4a86dd5a3b16aca32479a0805e582e0bcd5))
90-
91-
## [1.1.4](https://github.com/NaturalCycles/cli/compare/v1.1.3...v1.1.4) (2020-04-08)
92-
93-
94-
### Bug Fixes
95-
96-
* remove logging (hide behind env.CLI_DEBUG) ([ff49938](https://github.com/NaturalCycles/cli/commit/ff4993811f7991413a07555f50534c37d795c3b4))
97-
98-
## [1.1.3](https://github.com/NaturalCycles/cli/compare/v1.1.2...v1.1.3) (2020-04-08)
99-
100-
101-
### Bug Fixes
102-
103-
* argv, try2 ([694b6d8](https://github.com/NaturalCycles/cli/commit/694b6d84c9e272da6097ba4f71ec05b225c8ac88))
104-
105-
## [1.1.2](https://github.com/NaturalCycles/cli/compare/v1.1.1...v1.1.2) (2020-04-08)
106-
107-
108-
### Bug Fixes
109-
110-
* remove argv[1] ([1292a35](https://github.com/NaturalCycles/cli/commit/1292a3536683748f53254c2b608ad5a1e5840d44))
111-
112-
## [1.1.1](https://github.com/NaturalCycles/cli/compare/v1.1.0...v1.1.1) (2020-04-08)
113-
114-
115-
### Bug Fixes
116-
117-
* script/tsconfig.json auto-copying path ([9726498](https://github.com/NaturalCycles/cli/commit/9726498419d1b88b1bfd67be93252d12ff3f3ea2))
118-
119-
# [1.1.0](https://github.com/NaturalCycles/cli/compare/v1.0.5...v1.1.0) (2020-04-04)
120-
121-
122-
### Features
123-
124-
* auto-complete .ts extension ([ddc0cc7](https://github.com/NaturalCycles/cli/commit/ddc0cc71b8313328d326c80313f0d263dbdfd015))
125-
126-
## [1.0.5](https://github.com/NaturalCycles/cli/compare/v1.0.4...v1.0.5) (2020-04-04)
127-
128-
129-
### Bug Fixes
130-
131-
* tsconfig-paths ([2bd49d3](https://github.com/NaturalCycles/cli/commit/2bd49d3d405b9d38ee51eba4160d4eec2a83ee33))
132-
133-
## [1.0.4](https://github.com/NaturalCycles/cli/compare/v1.0.3...v1.0.4) (2020-04-04)
134-
135-
136-
### Bug Fixes
137-
138-
* tsconfig-paths ([a2d7b57](https://github.com/NaturalCycles/cli/commit/a2d7b57dc196da34841b1d7a9ea743c857454e74))
139-
140-
## [1.0.3](https://github.com/NaturalCycles/cli/compare/v1.0.2...v1.0.3) (2020-04-04)
141-
142-
143-
### Bug Fixes
144-
145-
* path ([670f9a2](https://github.com/NaturalCycles/cli/commit/670f9a26900a13c8a4b72ea0a44720389567d3e0))
146-
147-
## [1.0.2](https://github.com/NaturalCycles/cli/compare/v1.0.1...v1.0.2) (2020-04-04)
148-
149-
150-
### Bug Fixes
151-
152-
* use ts-node programmatically ([a82b3ba](https://github.com/NaturalCycles/cli/commit/a82b3baa1028c2c559c03c78b1d84a836c08893b))
153-
154-
## [1.0.1](https://github.com/NaturalCycles/cli/compare/v1.0.0...v1.0.1) (2020-04-04)
155-
156-
157-
### Bug Fixes
158-
159-
* deps ([710e9a9](https://github.com/NaturalCycles/cli/commit/710e9a97ea4ea3917d3ff9699fb9e471d2700edb))
160-
161-
# 1.0.0 (2020-04-04)
162-
163-
164-
### Features
165-
166-
* first version ([77b2da4](https://github.com/NaturalCycles/cli/commit/77b2da408f223bcee961f85a829021dba8aff9d8))
1+
See [Github Releases](https://github.com/NaturalCycles/cli/releases)

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"scripts": {
44
"prepare": "husky install",
55
"debug": "tsn ./src/bin/tsn.ts",
6-
"tsn-debug": "tsn ./src/bin/tsn.ts testscript.ts",
7-
"tsn-debug2": "ts-node -T ./src/bin/tsn.ts testscript.ts"
6+
"tsn-debug": "tsc && CLI_DEBUG=1 node ./dist/bin/tsn.js testscript.ts",
7+
"tsn2-debug": "tsc && CLI_DEBUG=1 node ./dist/bin/tsn2.js testscript.ts"
88
},
99
"dependencies": {
1010
"@naturalcycles/nodejs-lib": "^12.8.0",
1111
"chalk": "^4.0.0",
1212
"dotenv": "^10.0.0",
13+
"esbuild": "^0.13.13",
14+
"esbuild-register": "^3.1.2",
1315
"loud-rejection": "^2.2.0",
1416
"ts-node": "^10.0.0",
1517
"typescript": "^4.0.2"
@@ -30,6 +32,7 @@
3032
],
3133
"main": "dist/index.js",
3234
"bin": {
35+
"tsn2": "dist/bin/tsn2.js",
3336
"tsn": "dist/bin/tsn.js"
3437
},
3538
"publishConfig": {
@@ -40,7 +43,7 @@
4043
"url": "https://github.com/NaturalCycles/cli"
4144
},
4245
"engines": {
43-
"node": ">=12.13.1"
46+
"node": ">=14.15.0"
4447
},
4548
"version": "1.2.5",
4649
"description": "CLI utils to be installed globally via 'npm i -g'",

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
`-T -r tsconfig-paths/register -r dotenv/config`. Will use `./scripts/tsconfig.json` (file will be
1717
auto-generated in not present).
1818

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

2122
# Packaging
2223

2324
- `engines.node`: Latest Node.js LTS
24-
- `main: dist/index.js`: commonjs, es2019
25+
- `main: dist/index.js`: commonjs, es2020

scripts/testscript.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
3-
yarn tsn testscript.ts
3+
yarn tsn-debug
4+
yarn tsn2-debug
45
56
*/
67

src/bin/tsn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
This CLI command is optimized for speed, so, it includes minimum dependencies
55
*/
66

7-
import type * as nodejsLib from '@naturalcycles/nodejs-lib/dist/fs'
8-
import * as c from 'chalk'
97
import * as fs from 'fs'
108
import * as path from 'path'
9+
import type * as nodejsLib from '@naturalcycles/nodejs-lib/dist/fs'
10+
import * as c from 'chalk'
1111
import * as tsnode from 'ts-node'
1212

1313
const projectDir = path.join(__dirname, '../..')

0 commit comments

Comments
 (0)