Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit 2c1561f

Browse files
committed
feat(cli): add package.json binaries
1 parent c8c0c01 commit 2c1561f

9 files changed

Lines changed: 1979 additions & 1680 deletions

File tree

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
"devDependencies": {
2525
"@biomejs/biome": "^1.7.0",
2626
"@types/node": "18.19.0",
27-
"@vitest/coverage-v8": "^1.3.1",
28-
"@vitest/ui": "^1.3.1",
27+
"@vitest/coverage-v8": "^1.5.0",
28+
"@vitest/ui": "^1.5.0",
2929
"husky": "^9.0.11",
3030
"tsup": "^8.0.2",
31-
"typescript": "^5.4.2",
32-
"vite-tsconfig-paths": "^4.3.1",
33-
"vitest": "^1.3.1"
31+
"typescript": "^5.4.5",
32+
"vite-tsconfig-paths": "^4.3.2",
33+
"vitest": "^1.5.0"
3434
},
3535
"workspaces": [
3636
"./packages/*"

packages/application/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
"publishConfig": {
1414
"types": "./dist/index.d.ts"
1515
},
16-
"os": ["darwin", "linux"],
16+
"os": [
17+
"darwin",
18+
"linux"
19+
],
1720
"engines": {
1821
"node": ">=18.19.0 <19 || >=20.6.0 <21"
1922
},
2023
"dependencies": {
21-
"pino": "^8.19.0",
24+
"pino": "^8.20.0",
2225
"pino-pretty": "^10.3.1"
2326
},
2427
"devDependencies": {
2528
"@neematajs/common": "workspace:*",
26-
"@sinclair/typebox": "^0.32.15",
27-
"zod": "^3.22.4"
29+
"@sinclair/typebox": "^0.32.21",
30+
"zod": "^3.22.5"
2831
},
2932
"peerDependencies": {
3033
"@neematajs/common": "workspace:*",

packages/cli/cli-watch.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node --enable-source-maps --watch
2+
3+
// just a helper to pass --watch to node (primarily for pnpm)
4+
5+
import './cli.mjs'

packages/cli/cli.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,28 @@ const { values, positionals } = parseArgs({
2121
options: {
2222
entry: {
2323
type: 'string',
24-
short: 'a',
2524
multiple: false,
2625
},
2726
swc: {
2827
type: 'boolean',
2928
multiple: false,
3029
},
30+
timeout: {
31+
type: 'string',
32+
multiple: false,
33+
},
3134
},
3235
})
3336

3437
const [command, ...args] = positionals
35-
const { env, entry, swc, ...kwargs } = values
38+
const { env, entry, swc, timeout, ...kwargs } = values
39+
40+
const shutdownTimeout =
41+
(typeof timeout === 'string' ? Number.parseInt(timeout) : undefined) || 1000
3642

3743
const entryPath = resolve(
38-
process.env.NEEMATA_ENTRY || (typeof entry === 'string' ? entry : 'index.ts'),
44+
process.env.NEEMATA_ENTRY ||
45+
(typeof entry === 'string' ? entry : swc ? 'index.ts' : 'index.js'),
3946
)
4047

4148
if (swc) {
@@ -53,7 +60,7 @@ const exitProcess = () => {
5360

5461
const tryExit = async (cb) => {
5562
if (exitTimeout) return
56-
exitTimeout = setTimeout(exitProcess, 10000)
63+
exitTimeout = setTimeout(exitProcess, shutdownTimeout)
5764
try {
5865
await cb()
5966
} catch (error) {

packages/cli/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
"author": "ilchishin.denis@gmail.com",
44
"license": "MIT",
55
"description": "Nodejs application server",
6-
"os": ["darwin", "linux"],
6+
"os": [
7+
"darwin",
8+
"linux"
9+
],
10+
"bin": {
11+
"neemata": "./cli.mjs",
12+
"neemata-watch": "./cli-watch.mjs"
13+
},
714
"exports": {
815
"./swc": {
916
"import": "./swc.mjs"
@@ -13,7 +20,7 @@
1320
"node": ">=18.19.0 <19 || >=20.6.0 <21"
1421
},
1522
"dependencies": {
16-
"@swc/core": "^1.4.6",
23+
"@swc/core": "^1.4.16",
1724
"tsconfig-paths": "^4.2.0"
1825
},
1926
"peerDependencies": {

packages/parser-typebox/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"publishConfig": {
1414
"types": "./dist/index.d.ts"
1515
},
16-
"os": ["darwin", "linux"],
16+
"os": [
17+
"darwin",
18+
"linux"
19+
],
1720
"engines": {
1821
"node": ">=18.19.0 <19 || >=20.6.0 <21"
1922
},
@@ -22,6 +25,6 @@
2225
"@sinclair/typebox": "^0.31.23"
2326
},
2427
"devDependencies": {
25-
"@sinclair/typebox": "^0.32.15"
28+
"@sinclair/typebox": "^0.32.21"
2629
}
2730
}

packages/parser-zod/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@
1313
"publishConfig": {
1414
"types": "./dist/index.d.ts"
1515
},
16-
"os": ["darwin", "linux"],
16+
"os": [
17+
"darwin",
18+
"linux"
19+
],
1720
"engines": {
1821
"node": ">=18.19.0 <19 || >=20.6.0 <21"
1922
},
2023
"dependencies": {
21-
"zod-to-json-schema": "^3.22.4"
24+
"zod-to-json-schema": "^3.22.5"
2225
},
2326
"peerDependencies": {
2427
"@neematajs/application": "workspace:*",
2528
"zod": "^3.22.4"
2629
},
2730
"devDependencies": {
2831
"@neematajs/application": "workspace:*",
29-
"zod": "^3.22.4"
32+
"zod": "^3.22.5"
3033
}
3134
}

packages/server/lib/worker.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ import {
1818
} from './common'
1919
import { WorkerThreadsTaskRunner } from './task-runner'
2020

21-
export const importDefault = (specifier: any) =>
22-
import(`${specifier}`).then((m) => m.default)
23-
2421
export type ApplicationWorkerOptions = {
2522
isServer: boolean
2623
workerType: WorkerType
@@ -62,7 +59,7 @@ export async function start(
6259
isServer: true,
6360
})
6461

65-
const app: Application = await importDefault(applicationPath)
62+
const app: Application = await import(applicationPath).then((m) => m.default)
6663

6764
process.on('uncaughtException', (err) => app.logger.error(err))
6865
process.on('unhandledRejection', (err) => app.logger.error(err))

0 commit comments

Comments
 (0)