@napi-rs/cli 3.2.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/cli.mjs +3 -3
  2. package/dist/cli.js +793 -864
  3. package/dist/index.cjs +920 -754
  4. package/dist/index.d.cts +31 -2
  5. package/dist/index.d.ts +30 -3
  6. package/dist/index.js +891 -751
  7. package/package.json +7 -7
  8. package/src/api/artifacts.ts +1 -1
  9. package/src/api/build.ts +175 -108
  10. package/src/api/create-npm-dirs.ts +2 -2
  11. package/src/api/new.ts +4 -3
  12. package/src/api/pre-publish.ts +1 -1
  13. package/src/api/rename.ts +3 -4
  14. package/src/api/templates/js-binding.ts +5 -1
  15. package/src/api/universalize.ts +1 -1
  16. package/src/api/version.ts +4 -1
  17. package/src/cli.ts +1 -27
  18. package/src/commands/new.ts +1 -1
  19. package/src/index.ts +33 -0
  20. package/src/utils/config.ts +1 -1
  21. package/src/utils/target.ts +1 -0
  22. package/src/api/__tests__/create-npm-dirs.spec.ts +0 -210
  23. package/src/api/__tests__/new.spec.ts +0 -429
  24. package/src/utils/__tests__/__fixtures__/napi_type_def +0 -201
  25. package/src/utils/__tests__/__snapshots__/config.spec.ts.md +0 -97
  26. package/src/utils/__tests__/__snapshots__/config.spec.ts.snap +0 -0
  27. package/src/utils/__tests__/__snapshots__/target.spec.ts.md +0 -173
  28. package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
  29. package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +0 -1157
  30. package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
  31. package/src/utils/__tests__/__snapshots__/version.spec.ts.md +0 -21
  32. package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
  33. package/src/utils/__tests__/config.spec.ts +0 -81
  34. package/src/utils/__tests__/target.spec.ts +0 -19
  35. package/src/utils/__tests__/typegen.spec.ts +0 -64
  36. package/src/utils/__tests__/version.spec.ts +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/cli",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "Cli tools for napi-rs",
5
5
  "author": "LongYinan <lynweklm@gmail.com>",
6
6
  "homepage": "https://github.com/napi-rs/napi-rs",
@@ -25,7 +25,8 @@
25
25
  },
26
26
  "files": [
27
27
  "dist",
28
- "src"
28
+ "src",
29
+ "!__tests__"
29
30
  ],
30
31
  "keywords": [
31
32
  "cli",
@@ -68,13 +69,11 @@
68
69
  "debug": "^4.4.1",
69
70
  "emnapi": "^1.5.0",
70
71
  "es-toolkit": "^1.39.10",
71
- "find-up": "^7.0.0",
72
72
  "js-yaml": "^4.1.0",
73
73
  "semver": "^7.7.2",
74
74
  "typanion": "^3.14.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@emnapi/core": "^1.5.0",
78
77
  "@emnapi/runtime": "^1.5.0",
79
78
  "@oxc-node/core": "^0.0.32",
80
79
  "@std/toml": "npm:@jsr/std__toml@^1.0.10",
@@ -84,6 +83,7 @@
84
83
  "@types/node": "^24.3.1",
85
84
  "@types/semver": "^7.7.1",
86
85
  "ava": "^6.4.1",
86
+ "empathic": "^2.0.0",
87
87
  "env-paths": "^3.0.0",
88
88
  "prettier": "^3.6.2",
89
89
  "tsdown": "^0.15.0",
@@ -91,8 +91,7 @@
91
91
  "typescript": "^5.9.2"
92
92
  },
93
93
  "peerDependencies": {
94
- "@emnapi/runtime": "^1.1.0",
95
- "emnapi": "^1.1.0"
94
+ "@emnapi/runtime": "^1.5.0"
96
95
  },
97
96
  "peerDependenciesMeta": {
98
97
  "@emnapi/runtime": {
@@ -115,7 +114,8 @@
115
114
  "extensions": {
116
115
  "ts": "module"
117
116
  },
118
- "timeout": "1m",
117
+ "timeout": "2m",
118
+ "workerThreads": false,
119
119
  "files": [
120
120
  "**/__tests__/**/*.spec.ts",
121
121
  "e2e/**/*.spec.ts"
@@ -4,7 +4,7 @@ import * as colors from 'colorette'
4
4
 
5
5
  import {
6
6
  applyDefaultArtifactsOptions,
7
- ArtifactsOptions,
7
+ type ArtifactsOptions,
8
8
  } from '../def/artifacts.js'
9
9
  import {
10
10
  readNapiConfig,
package/src/api/build.ts CHANGED
@@ -7,31 +7,31 @@ import { parse, join, resolve } from 'node:path'
7
7
 
8
8
  import * as colors from 'colorette'
9
9
 
10
- import { BuildOptions as RawBuildOptions } from '../def/build.js'
10
+ import type { BuildOptions as RawBuildOptions } from '../def/build.js'
11
11
  import {
12
12
  CLI_VERSION,
13
13
  copyFileAsync,
14
- Crate,
14
+ type Crate,
15
15
  debugFactory,
16
16
  DEFAULT_TYPE_DEF_HEADER,
17
17
  fileExists,
18
18
  getSystemDefaultTarget,
19
19
  getTargetLinker,
20
20
  mkdirAsync,
21
- NapiConfig,
21
+ type NapiConfig,
22
22
  parseMetadata,
23
23
  parseTriple,
24
24
  processTypeDef,
25
25
  readFileAsync,
26
26
  readNapiConfig,
27
- Target,
27
+ type Target,
28
28
  targetToEnvVar,
29
29
  tryInstallCargoBinary,
30
30
  unlinkAsync,
31
31
  writeFileAsync,
32
32
  dirExistsAsync,
33
33
  readdirAsync,
34
- CargoWorkspaceMetadata,
34
+ type CargoWorkspaceMetadata,
35
35
  } from '../utils/index.js'
36
36
 
37
37
  import { createCjsBinding, createEsmBinding } from './templates/index.js'
@@ -876,121 +876,42 @@ class Builder {
876
876
 
877
877
  private async generateTypeDef() {
878
878
  const typeDefDir = this.envs.NAPI_TYPE_DEF_TMP_FOLDER
879
- if (!this.enableTypeDef || !(await dirExistsAsync(typeDefDir))) {
880
- return []
881
- }
882
-
883
- const dest = join(this.outputDir, this.options.dts ?? 'index.d.ts')
884
-
885
- let header = ''
886
- let dts = ''
887
- let exports: string[] = []
888
-
889
- if (!this.options.noDtsHeader) {
890
- const dtsHeader = this.options.dtsHeader ?? this.config.dtsHeader
891
- // `dtsHeaderFile` in config > `dtsHeader` in cli flag > `dtsHeader` in config
892
- if (this.config.dtsHeaderFile) {
893
- try {
894
- header = await readFileAsync(
895
- join(this.options.cwd, this.config.dtsHeaderFile),
896
- 'utf-8',
897
- )
898
- } catch (e) {
899
- debug.warn(
900
- `Failed to read dts header file ${this.config.dtsHeaderFile}`,
901
- e,
902
- )
903
- }
904
- } else if (dtsHeader) {
905
- header = dtsHeader
906
- } else {
907
- header = DEFAULT_TYPE_DEF_HEADER
908
- }
909
- }
910
-
911
- const files = await readdirAsync(typeDefDir, { withFileTypes: true })
912
-
913
- if (!files.length) {
914
- debug('No type def files found. Skip generating dts file.')
879
+ if (!this.enableTypeDef) {
915
880
  return []
916
881
  }
917
882
 
918
- for (const file of files) {
919
- if (!file.isFile()) {
920
- continue
921
- }
922
-
923
- const { dts: fileDts, exports: fileExports } = await processTypeDef(
924
- join(typeDefDir, file.name),
925
- this.options.constEnum ?? this.config.constEnum ?? true,
926
- )
927
-
928
- dts += fileDts
929
- exports.push(...fileExports)
930
- }
931
-
932
- if (dts.indexOf('ExternalObject<') > -1) {
933
- header += `
934
- export declare class ExternalObject<T> {
935
- readonly '': {
936
- readonly '': unique symbol
937
- [K: symbol]: T
938
- }
939
- }
940
- `
941
- }
942
-
943
- if (dts.indexOf('TypedArray') > -1) {
944
- header += `
945
- export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array
946
- `
947
- }
948
-
949
- dts = header + dts
883
+ const exports = await generateTypeDef({
884
+ typeDefDir,
885
+ outputDir: this.outputDir,
886
+ dts: this.options.dts,
887
+ noDtsHeader: this.options.noDtsHeader,
888
+ dtsHeader: this.options.dtsHeader,
889
+ configDtsHeader: this.config.dtsHeader,
890
+ configDtsHeaderFile: this.config.dtsHeaderFile,
891
+ constEnum: this.options.constEnum ?? this.config.constEnum,
892
+ cwd: this.options.cwd,
893
+ })
950
894
 
951
- try {
952
- debug('Writing type def to:')
953
- debug(' %i', dest)
954
- await writeFileAsync(dest, dts, 'utf-8')
895
+ if (exports.length > 0) {
896
+ const dest = join(this.outputDir, this.options.dts ?? 'index.d.ts')
955
897
  this.outputs.push({ kind: 'dts', path: dest })
956
- } catch (e) {
957
- debug.error('Failed to write type def file')
958
- debug.error(e as Error)
959
898
  }
960
899
 
961
900
  return exports
962
901
  }
963
902
 
964
903
  private async writeJsBinding(idents: string[]) {
965
- if (
966
- !this.options.platform ||
967
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
968
- this.options.noJsBinding ||
969
- idents.length === 0
970
- ) {
971
- return
972
- }
973
-
974
- const name = this.options.jsBinding ?? 'index.js'
975
-
976
- const createBinding = this.options.esm ? createEsmBinding : createCjsBinding
977
- const binding = createBinding(
978
- this.config.binaryName,
979
- this.config.packageName,
904
+ return writeJsBinding({
905
+ platform: this.options.platform,
906
+ noJsBinding: this.options.noJsBinding,
980
907
  idents,
981
- // in npm preversion hook
982
- process.env.npm_new_version ?? this.config.packageJson.version,
983
- )
984
-
985
- try {
986
- const dest = join(this.outputDir, name)
987
- debug('Writing js binding to:')
988
- debug(' %i', dest)
989
- await writeFileAsync(dest, binding, 'utf-8')
990
- return { kind: 'js', path: dest } satisfies Output
991
- } catch (e) {
992
- throw new Error('Failed to write js binding file', { cause: e })
993
- }
908
+ jsBinding: this.options.jsBinding,
909
+ esm: this.options.esm,
910
+ binaryName: this.config.binaryName,
911
+ packageName: this.config.packageName,
912
+ version: process.env.npm_new_version ?? this.config.packageJson.version,
913
+ outputDir: this.outputDir,
914
+ })
994
915
  }
995
916
 
996
917
  private async writeWasiBinding(
@@ -1074,3 +995,149 @@ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array
1074
995
  }
1075
996
  }
1076
997
  }
998
+
999
+ export interface WriteJsBindingOptions {
1000
+ platform?: boolean
1001
+ noJsBinding?: boolean
1002
+ idents: string[]
1003
+ jsBinding?: string
1004
+ esm?: boolean
1005
+ binaryName: string
1006
+ packageName: string
1007
+ version: string
1008
+ outputDir: string
1009
+ }
1010
+
1011
+ export async function writeJsBinding(
1012
+ options: WriteJsBindingOptions,
1013
+ ): Promise<Output | undefined> {
1014
+ if (
1015
+ !options.platform ||
1016
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
1017
+ options.noJsBinding ||
1018
+ options.idents.length === 0
1019
+ ) {
1020
+ return
1021
+ }
1022
+
1023
+ const name = options.jsBinding ?? 'index.js'
1024
+
1025
+ const createBinding = options.esm ? createEsmBinding : createCjsBinding
1026
+ const binding = createBinding(
1027
+ options.binaryName,
1028
+ options.packageName,
1029
+ options.idents,
1030
+ // in npm preversion hook
1031
+ options.version,
1032
+ )
1033
+
1034
+ try {
1035
+ const dest = join(options.outputDir, name)
1036
+ debug('Writing js binding to:')
1037
+ debug(' %i', dest)
1038
+ await writeFileAsync(dest, binding, 'utf-8')
1039
+ return { kind: 'js', path: dest } satisfies Output
1040
+ } catch (e) {
1041
+ throw new Error('Failed to write js binding file', { cause: e })
1042
+ }
1043
+ }
1044
+
1045
+ export interface GenerateTypeDefOptions {
1046
+ typeDefDir: string
1047
+ outputDir: string
1048
+ dts?: string
1049
+ noDtsHeader?: boolean
1050
+ dtsHeader?: string
1051
+ dtsHeaderFile?: string
1052
+ configDtsHeader?: string
1053
+ configDtsHeaderFile?: string
1054
+ constEnum?: boolean
1055
+ cwd: string
1056
+ }
1057
+
1058
+ export async function generateTypeDef(
1059
+ options: GenerateTypeDefOptions,
1060
+ ): Promise<string[]> {
1061
+ if (!(await dirExistsAsync(options.typeDefDir))) {
1062
+ return []
1063
+ }
1064
+
1065
+ const dest = join(options.outputDir, options.dts ?? 'index.d.ts')
1066
+
1067
+ let header = ''
1068
+ let dts = ''
1069
+ let exports: string[] = []
1070
+
1071
+ if (!options.noDtsHeader) {
1072
+ const dtsHeader = options.dtsHeader ?? options.configDtsHeader
1073
+ // `dtsHeaderFile` in config > `dtsHeader` in cli flag > `dtsHeader` in config
1074
+ if (options.configDtsHeaderFile) {
1075
+ try {
1076
+ header = await readFileAsync(
1077
+ join(options.cwd, options.configDtsHeaderFile),
1078
+ 'utf-8',
1079
+ )
1080
+ } catch (e) {
1081
+ debug.warn(
1082
+ `Failed to read dts header file ${options.configDtsHeaderFile}`,
1083
+ e,
1084
+ )
1085
+ }
1086
+ } else if (dtsHeader) {
1087
+ header = dtsHeader
1088
+ } else {
1089
+ header = DEFAULT_TYPE_DEF_HEADER
1090
+ }
1091
+ }
1092
+
1093
+ const files = await readdirAsync(options.typeDefDir, { withFileTypes: true })
1094
+
1095
+ if (!files.length) {
1096
+ debug('No type def files found. Skip generating dts file.')
1097
+ return []
1098
+ }
1099
+
1100
+ for (const file of files) {
1101
+ if (!file.isFile()) {
1102
+ continue
1103
+ }
1104
+
1105
+ const { dts: fileDts, exports: fileExports } = await processTypeDef(
1106
+ join(options.typeDefDir, file.name),
1107
+ options.constEnum ?? true,
1108
+ )
1109
+
1110
+ dts += fileDts
1111
+ exports.push(...fileExports)
1112
+ }
1113
+
1114
+ if (dts.indexOf('ExternalObject<') > -1) {
1115
+ header += `
1116
+ export declare class ExternalObject<T> {
1117
+ readonly '': {
1118
+ readonly '': unique symbol
1119
+ [K: symbol]: T
1120
+ }
1121
+ }
1122
+ `
1123
+ }
1124
+
1125
+ if (dts.indexOf('TypedArray') > -1) {
1126
+ header += `
1127
+ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array
1128
+ `
1129
+ }
1130
+
1131
+ dts = header + dts
1132
+
1133
+ try {
1134
+ debug('Writing type def to:')
1135
+ debug(' %i', dest)
1136
+ await writeFileAsync(dest, dts, 'utf-8')
1137
+ } catch (e) {
1138
+ debug.error('Failed to write type def file')
1139
+ debug.error(e as Error)
1140
+ }
1141
+
1142
+ return exports
1143
+ }
@@ -4,7 +4,7 @@ import { parse } from 'semver'
4
4
 
5
5
  import {
6
6
  applyDefaultCreateNpmDirsOptions,
7
- CreateNpmDirsOptions,
7
+ type CreateNpmDirsOptions,
8
8
  } from '../def/create-npm-dirs.js'
9
9
  import {
10
10
  debugFactory,
@@ -12,7 +12,7 @@ import {
12
12
  mkdirAsync as rawMkdirAsync,
13
13
  pick,
14
14
  writeFileAsync as rawWriteFileAsync,
15
- Target,
15
+ type Target,
16
16
  type CommonPackageJsonFields,
17
17
  } from '../utils/index.js'
18
18
 
package/src/api/new.ts CHANGED
@@ -8,7 +8,7 @@ import { load as yamlLoad, dump as yamlDump } from 'js-yaml'
8
8
 
9
9
  import {
10
10
  applyDefaultNewOptions,
11
- NewOptions as RawNewOptions,
11
+ type NewOptions as RawNewOptions,
12
12
  } from '../def/new.js'
13
13
  import {
14
14
  AVAILABLE_TARGETS,
@@ -17,7 +17,7 @@ import {
17
17
  mkdirAsync,
18
18
  readdirAsync,
19
19
  statAsync,
20
- SupportedPackageManager,
20
+ type SupportedPackageManager,
21
21
  } from '../utils/index.js'
22
22
  import { napiEngineRequirement } from '../utils/version.js'
23
23
  import { renameProject } from './rename.js'
@@ -169,6 +169,7 @@ async function filterTargetsInGithubActions(
169
169
 
170
170
  const macOSAndWindowsTargets = new Set([
171
171
  'x86_64-pc-windows-msvc',
172
+ 'x86_64-pc-windows-gnu',
172
173
  'aarch64-pc-windows-msvc',
173
174
  'x86_64-apple-darwin',
174
175
  ])
@@ -468,4 +469,4 @@ function getBinaryName(name: string): string {
468
469
  return name.split('/').pop()!
469
470
  }
470
471
 
471
- export { NewOptions }
472
+ export type { NewOptions }
@@ -6,7 +6,7 @@ import { Octokit } from '@octokit/rest'
6
6
 
7
7
  import {
8
8
  applyDefaultPrePublishOptions,
9
- PrePublishOptions,
9
+ type PrePublishOptions,
10
10
  } from '../def/pre-publish.js'
11
11
  import {
12
12
  readFileAsync,
package/src/api/rename.ts CHANGED
@@ -5,9 +5,9 @@ import { resolve, join } from 'node:path'
5
5
  import { parse as parseToml, stringify as stringifyToml } from '@std/toml'
6
6
  import { load as yamlParse, dump as yamlStringify } from 'js-yaml'
7
7
  import { isNil, merge, omitBy, pick } from 'es-toolkit'
8
- import { findUp } from 'find-up'
8
+ import * as find from 'empathic/find'
9
9
 
10
- import { applyDefaultRenameOptions, RenameOptions } from '../def/rename.js'
10
+ import { applyDefaultRenameOptions, type RenameOptions } from '../def/rename.js'
11
11
  import { readConfig, readFileAsync, writeFileAsync } from '../utils/index.js'
12
12
 
13
13
  export async function renameProject(userOptions: RenameOptions) {
@@ -74,9 +74,8 @@ export async function renameProject(userOptions: RenameOptions) {
74
74
 
75
75
  await writeFileAsync(cargoTomlPath, updatedTomlContent)
76
76
  if (oldName !== options.binaryName) {
77
- const githubActionsPath = await findUp('.github', {
77
+ const githubActionsPath = find.dir('.github', {
78
78
  cwd: options.cwd,
79
- type: 'directory',
80
79
  })
81
80
  if (githubActionsPath) {
82
81
  const githubActionsCIYmlPath = join(
@@ -146,7 +146,11 @@ function requireNative() {
146
146
  }
147
147
  } else if (process.platform === 'win32') {
148
148
  if (process.arch === 'x64') {
149
- ${requireTuple('win32-x64-msvc')}
149
+ if (process.report?.getReport?.()?.header?.osName?.startsWith?.('MINGW')) {
150
+ ${requireTuple('win32-x64-gnu')}
151
+ } else {
152
+ ${requireTuple('win32-x64-msvc')}
153
+ }
150
154
  } else if (process.arch === 'ia32') {
151
155
  ${requireTuple('win32-ia32-msvc')}
152
156
  } else if (process.arch === 'arm64') {
@@ -3,7 +3,7 @@ import { join, resolve } from 'node:path'
3
3
 
4
4
  import {
5
5
  applyDefaultUniversalizeOptions,
6
- UniversalizeOptions,
6
+ type UniversalizeOptions,
7
7
  } from '../def/universalize.js'
8
8
  import { readNapiConfig } from '../utils/config.js'
9
9
  import { debugFactory } from '../utils/log.js'
@@ -1,6 +1,9 @@
1
1
  import { join, resolve } from 'node:path'
2
2
 
3
- import { applyDefaultVersionOptions, VersionOptions } from '../def/version.js'
3
+ import {
4
+ applyDefaultVersionOptions,
5
+ type VersionOptions,
6
+ } from '../def/version.js'
4
7
  import {
5
8
  readNapiConfig,
6
9
  debugFactory,
package/src/cli.ts CHANGED
@@ -1,31 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { Cli } from 'clipanion'
4
-
5
- import { ArtifactsCommand } from './commands/artifacts.js'
6
- import { BuildCommand } from './commands/build.js'
7
- import { CreateNpmDirsCommand } from './commands/create-npm-dirs.js'
8
- import { HelpCommand } from './commands/help.js'
9
- import { NewCommand } from './commands/new.js'
10
- import { PrePublishCommand } from './commands/pre-publish.js'
11
- import { RenameCommand } from './commands/rename.js'
12
- import { UniversalizeCommand } from './commands/universalize.js'
13
- import { VersionCommand } from './commands/version.js'
14
- import { CLI_VERSION } from './utils/misc.js'
15
-
16
- const cli = new Cli({
17
- binaryName: 'napi',
18
- binaryVersion: CLI_VERSION,
19
- })
20
-
21
- cli.register(NewCommand)
22
- cli.register(BuildCommand)
23
- cli.register(CreateNpmDirsCommand)
24
- cli.register(ArtifactsCommand)
25
- cli.register(UniversalizeCommand)
26
- cli.register(RenameCommand)
27
- cli.register(PrePublishCommand)
28
- cli.register(VersionCommand)
29
- cli.register(HelpCommand)
3
+ import { cli } from './index.js'
30
4
 
31
5
  void cli.runExit(process.argv.slice(2))
@@ -9,7 +9,7 @@ import {
9
9
  AVAILABLE_TARGETS,
10
10
  debugFactory,
11
11
  DEFAULT_TARGETS,
12
- TargetTriple,
12
+ type TargetTriple,
13
13
  } from '../utils/index.js'
14
14
  import { napiEngineRequirement } from '../utils/version.js'
15
15
 
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Cli } from 'clipanion'
2
+
1
3
  import { collectArtifacts } from './api/artifacts.js'
2
4
  import { buildProject } from './api/build.js'
3
5
  import { createNpmDirs } from './api/create-npm-dirs.js'
@@ -6,6 +8,31 @@ import { prePublish } from './api/pre-publish.js'
6
8
  import { renameProject } from './api/rename.js'
7
9
  import { universalizeBinaries } from './api/universalize.js'
8
10
  import { version } from './api/version.js'
11
+ import { ArtifactsCommand } from './commands/artifacts.js'
12
+ import { BuildCommand } from './commands/build.js'
13
+ import { CreateNpmDirsCommand } from './commands/create-npm-dirs.js'
14
+ import { HelpCommand } from './commands/help.js'
15
+ import { NewCommand } from './commands/new.js'
16
+ import { PrePublishCommand } from './commands/pre-publish.js'
17
+ import { RenameCommand } from './commands/rename.js'
18
+ import { UniversalizeCommand } from './commands/universalize.js'
19
+ import { VersionCommand } from './commands/version.js'
20
+ import { CLI_VERSION } from './utils/misc.js'
21
+
22
+ export const cli = new Cli({
23
+ binaryName: 'napi',
24
+ binaryVersion: CLI_VERSION,
25
+ })
26
+
27
+ cli.register(NewCommand)
28
+ cli.register(BuildCommand)
29
+ cli.register(CreateNpmDirsCommand)
30
+ cli.register(ArtifactsCommand)
31
+ cli.register(UniversalizeCommand)
32
+ cli.register(RenameCommand)
33
+ cli.register(PrePublishCommand)
34
+ cli.register(VersionCommand)
35
+ cli.register(HelpCommand)
9
36
 
10
37
  /**
11
38
  *
@@ -31,3 +58,9 @@ export class NapiCli {
31
58
  }
32
59
 
33
60
  export { parseTriple } from './utils/target.js'
61
+ export {
62
+ type GenerateTypeDefOptions,
63
+ type WriteJsBindingOptions,
64
+ writeJsBinding,
65
+ generateTypeDef,
66
+ } from './api/build.js'
@@ -2,7 +2,7 @@ import { underline, yellow } from 'colorette'
2
2
  import { merge, omit } from 'es-toolkit'
3
3
 
4
4
  import { fileExists, readFileAsync } from './misc.js'
5
- import { DEFAULT_TARGETS, parseTriple, Target } from './target.js'
5
+ import { DEFAULT_TARGETS, parseTriple, type Target } from './target.js'
6
6
 
7
7
  export type ValueOfConstArray<T> = T[Exclude<keyof T, keyof Array<any>>]
8
8
 
@@ -17,6 +17,7 @@ export const AVAILABLE_TARGETS = [
17
17
  'aarch64-pc-windows-msvc',
18
18
  'x86_64-apple-darwin',
19
19
  'x86_64-pc-windows-msvc',
20
+ 'x86_64-pc-windows-gnu',
20
21
  'x86_64-unknown-linux-gnu',
21
22
  'x86_64-unknown-linux-musl',
22
23
  'x86_64-unknown-linux-ohos',