Skip to content

Commit fe6aef0

Browse files
committed
Support for node.js and build system
1 parent 4114e56 commit fe6aef0

18 files changed

Lines changed: 3714 additions & 375 deletions

File tree

README.md

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
Convert C# DTO source files into TypeScript interfaces and enums.
44

5-
TypeSharp is a Deno-powered TypeScript CLI. It reads `.cs` files directly, parses simple DTO models, and writes one `.ts` file per DTO or enum.
5+
TypeSharp is a Node-powered TypeScript CLI. It reads `.cs` files directly, parses simple DTO models, and writes one `.ts` file per DTO or enum.
66

77
![Example Image](src/Onbox.TypeSharp/Example.png)
88

99
## Requirements
1010

11+
- [Node.js](https://nodejs.org/)
12+
or
1113
- [Deno](https://deno.com/)
1214

1315
## Usage
1416

1517
Run TypeSharp with Deno:
1618

1719
```bash
18-
deno run --allow-read --allow-write src/typesharp-ts/main.ts \
20+
deno run -A src/main.ts \
1921
--source "./samples/SampleModels" \
2022
--file-filter "*.cs" \
2123
--destination "./samples/SampleModels/Typescript" \
@@ -25,7 +27,19 @@ deno run --allow-read --allow-write src/typesharp-ts/main.ts \
2527
Or use a config file:
2628

2729
```bash
28-
deno run --allow-read --allow-write src/typesharp-ts/main.ts --config "./typesharp.json"
30+
deno run -A src/main.ts --config "./typesharp.json"
31+
```
32+
33+
With node (tsx):
34+
35+
```bash
36+
npx tsx src/main.ts
37+
```
38+
39+
With node (build the project then run with node)
40+
41+
```bash
42+
npm run build && node ./dist/main.js
2943
```
3044

3145
When `--config` is not provided, TypeSharp reads `typesharp.json` from the current folder if it exists. Command-line options override config file values.
@@ -84,22 +98,11 @@ Create `typesharp.json`:
8498
}
8599
```
86100

87-
Run with the default config path:
88-
89-
```bash
90-
deno run --allow-read --allow-write src/typesharp-ts/main.ts
91-
```
92-
93-
Run with a custom config path:
94-
95-
```bash
96-
deno run --allow-read --allow-write src/typesharp-ts/main.ts --config "./config/tssharp.json"
97-
```
98101

99102
Override config values from the command line:
100103

101104
```bash
102-
deno run --allow-read --allow-write src/typesharp-ts/main.ts \
105+
deno run -A src/main.ts \
103106
--config "./config/tssharp.json" \
104107
--dictionary-style record \
105108
--readonly-properties \
@@ -184,20 +187,8 @@ export * from "./Person";
184187

185188
## Development
186189

187-
Format:
188-
189-
```bash
190-
deno fmt src/typesharp-ts
191-
```
192-
193-
Lint:
194-
195-
```bash
196-
deno lint src/typesharp-ts
197-
```
198-
199190
Test:
200191

201192
```bash
202-
deno test --allow-read --allow-write src/typesharp-ts
193+
npm rum test
203194
```
File renamed without changes.

src/typesharp-ts/deno.json

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

src/typesharp-ts/dist/main.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/typesharp-ts/esbuild.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as esbuild from 'esbuild';
2+
3+
await esbuild.build({
4+
bundle: true,
5+
minify: true,
6+
minifyIdentifiers: true,
7+
minifySyntax: true,
8+
minifyWhitespace: true,
9+
platform: 'node',
10+
format: 'esm',
11+
entryPoints: [ './src/main.ts' ],
12+
outdir: './dist'
13+
});

0 commit comments

Comments
 (0)