Skip to content

Commit 6b2cb3e

Browse files
committed
build: refactor build option parser
1 parent 50ee02d commit 6b2cb3e

15 files changed

+78
-65
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"script/*.js",
2020
"script/*.d.ts",
2121
"docs/",
22-
"docs-raw/",
22+
"doc-unminified/",
2323
"test/unit/compat/",
2424
"test/bench/"
2525
]

.gitignore

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@ build-tmp-napi-v*
1313
test.js
1414
.cache/
1515
test/typings-compatibility/
16-
/script/*.js
17-
/script/*.mjs
16+
/script/*js
1817
/script/*.d.ts
19-
/script/*.d.mts
20-
/script/*.js.map
21-
/script/*.mjs.map
22-
/script/*/*.js
23-
/script/*/*.mjs
24-
/script/*/*.d.ts
25-
/script/*/*.js.map
18+
/script/*.d.*ts
19+
/script/*js.map
2620
tsconfig.tsbuildinfo
27-
tsconfig.esm.tsbuildinfo
28-
/docs-raw
21+
tsconfig.*.tsbuildinfo
22+
/doc-unminified
2923
.DS_Store
3024
.idea

.idea/.gitignore

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

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/docs/
2-
/docs-raw
2+
/doc-unminified
33
/lib
44
/prebuilds
55
/node_modules

.vscode/settings.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,18 @@
44
"mochaExplorer.nodeArgv": [
55
"--expose-gc"
66
],
7-
"mochaExplorer.debuggerConfig": "JS-Attach"
7+
"mochaExplorer.debuggerConfig": "JS-Attach",
8+
"files.exclude": {
9+
"**/.git": true,
10+
"**/.DS_Store": true,
11+
"**/Thumbs.db": true,
12+
"**/.cache": true,
13+
"**/script/*.js": true,
14+
"**/script/*.mjs": true,
15+
"**/script/*.js.map": true,
16+
"**/script/*.mjs.map": true,
17+
"**/script/*.d.ts": true,
18+
"**/script/*.d.mts": true,
19+
"**/script/*.tsbuildinfo": true,
20+
}
821
}

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,30 @@ build_from_source=true
9090
When building from source, you can also specify additional build options in a
9191
`.npmrc` file in your project:
9292

93+
### Available Build Options
94+
9395
<details>
94-
<summary>Available Build Options</summary>
96+
<summary>👉🏻 Options</summary>
9597

9698
#### Draft support
9799

98100
By default `libzmq` is built with support for `Draft` patterns (e.g.
99101
`server-client`, `radio-dish`, `scatter-gather`). If you want to build `libzmq`
100102
without support for `Draft`, you can specify the following in `.npmrc`:
101103

102-
```
104+
```ini
103105
zmq_draft=false
104106
```
105107

108+
#### Not Synchronous Resolve
109+
110+
If you want to send/receive on the socket immediately, you can specify the
111+
following in `.npmrc`:
112+
113+
```ini
114+
zmq_no_sync_resolve="true"
115+
```
116+
106117
#### Shared library support
107118

108119
If you want to link against a shared ZeroMQ library installed on your system,

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@
8383
],
8484
"scripts": {
8585
"install": "(npm run build.js || echo ok) && aminya-node-gyp-build --build-from-source",
86-
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo",
86+
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.mjs ./script/*.js.map ./script/*.mjs.map ./script/*.d.ts ./script/*.d.mts ./script/*.cjs ./scripts/*.cjs.map ./scripts/*.d.cts ./script/*.tsbuildinfo",
8787
"clean.release": "shx rm -rf ./build/Release",
8888
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp",
8989
"build.library": "tsc -p ./src/tsconfig.json",
90-
"build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json",
90+
"build.script": "tsc -p ./script/tsconfig.esm.json && tsc -p ./script/tsconfig.json",
9191
"build.js": "run-p build.script build.library",
92-
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
92+
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-unminified -d docs --jsCompressor terser && shx rm -rf docs-unminified",
9393
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
9494
"build.prebuild": "run-s build.js && node ./script/prebuild.mjs",
9595
"build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release",

script/build.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {dirname} from "path"
22
import {existsSync, writeFileSync} from "fs"
33
import {mkdir, cd, exec, find, mv} from "shelljs"
4+
import {toBool, toString} from "./utils.js"
45

56
const root = dirname(__dirname)
67

@@ -13,29 +14,6 @@ type Options = {
1314
macosx_deployment_target?: string
1415
}
1516

16-
function toBool(value: string | undefined): boolean | undefined {
17-
switch (value) {
18-
case "true":
19-
case "1":
20-
return true
21-
case "false":
22-
case "0":
23-
return false
24-
default:
25-
return undefined
26-
}
27-
}
28-
29-
function toString(value: string | undefined): string | undefined {
30-
switch (value) {
31-
case undefined:
32-
case "":
33-
return undefined
34-
default:
35-
return value
36-
}
37-
}
38-
3917
function parseOptions(): Options {
4018
return {
4119
zmq_shared: toBool(process.env.npm_config_zmq_shared) ?? false,

script/prebuild.mts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import {execaCommandSync} from "execa"
2+
import * as buildUtils from "./utils.js"
3+
const {toString} = buildUtils
24

35
type Options = {
46
arch: string
57
}
68

7-
function toString(value: string | undefined): string | undefined {
8-
switch (value) {
9-
case undefined:
10-
case "":
11-
return undefined
12-
default:
13-
return value
14-
}
15-
}
16-
179
function parserOptions(): Options {
1810
return {
1911
arch: toString(process.env.npm_config_arch) ?? process.arch,

script/tsconfig.esm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"moduleResolution": "node"
66
},
77
"include": ["./**/*.mts"],
8-
"exclude": []
8+
"exclude": ["./**/*.d.mts"]
99
}

script/tsconfig.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "./"
4+
"outDir": "./",
55
},
6-
"include": ["./**/*.ts"],
7-
"exclude": []
6+
"include": [
7+
"./**/*.ts",
8+
"./**/*.cts"
9+
],
10+
"exclude": [
11+
"./**/*.d.ts",
12+
"./**/*.d.cts"
13+
]
814
}

script/utils.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export function toBool(value: string | undefined): boolean | undefined {
2+
switch (value) {
3+
case "true":
4+
case "1":
5+
return true
6+
case "false":
7+
case "0":
8+
return false
9+
case undefined:
10+
case "":
11+
return undefined
12+
default:
13+
throw new Error(`Invalid boolean value: ${value}`)
14+
}
15+
}
16+
17+
export function toString(value: string | undefined): string | undefined {
18+
switch (value) {
19+
case undefined:
20+
case "":
21+
return undefined
22+
default:
23+
return value
24+
}
25+
}

tsconfig.docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"exclude": [
1010
"script/**/*",
1111
"test/**/*",
12+
"build/**/*",
1213
"examples/**/*",
1314
"src/errors.ts",
1415
"src/util.ts"

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"target": "es2020",
66
"declaration": true,
77
"module": "commonjs",
8+
"moduleResolution": "node",
89
"types": [
910
"node",
1011
"mocha"

typedoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "zeromq.js",
44
"entryPoints": ["./src/index.ts"],
55
"tsconfig": "./tsconfig.docs.json",
6-
"out": "docs-raw",
6+
"out": "docs-unminified",
77
"excludePrivate": true,
88
"excludeExternals": false,
99
"exclude": [

0 commit comments

Comments
 (0)