@napi-rs/cli 3.1.1 → 3.1.3

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 (57) hide show
  1. package/dist/cli.js +519 -321
  2. package/dist/index.cjs +615 -6991
  3. package/dist/index.d.cts +537 -0
  4. package/dist/index.d.ts +527 -19
  5. package/dist/index.js +474 -287
  6. package/package.json +9 -19
  7. package/src/api/build.ts +36 -55
  8. package/src/api/rename.ts +9 -3
  9. package/src/api/templates/js-binding.ts +1 -1
  10. package/src/utils/config.ts +2 -2
  11. package/src/utils/typegen.ts +14 -2
  12. package/dist/api/__tests__/create-npm-dirs.spec.d.ts +0 -1
  13. package/dist/api/__tests__/new.spec.d.ts +0 -1
  14. package/dist/api/artifacts.d.ts +0 -2
  15. package/dist/api/build.d.ts +0 -14
  16. package/dist/api/create-npm-dirs.d.ts +0 -7
  17. package/dist/api/new.d.ts +0 -4
  18. package/dist/api/pre-publish.d.ts +0 -2
  19. package/dist/api/rename.d.ts +0 -2
  20. package/dist/api/templates/index.d.ts +0 -1
  21. package/dist/api/templates/js-binding.d.ts +0 -2
  22. package/dist/api/templates/load-wasi-template.d.ts +0 -2
  23. package/dist/api/templates/wasi-worker-template.d.ts +0 -2
  24. package/dist/api/universalize.d.ts +0 -2
  25. package/dist/api/version.d.ts +0 -2
  26. package/dist/cli.d.ts +0 -2
  27. package/dist/commands/artifacts.d.ts +0 -6
  28. package/dist/commands/build.d.ts +0 -6
  29. package/dist/commands/create-npm-dirs.d.ts +0 -4
  30. package/dist/commands/help.d.ts +0 -10
  31. package/dist/commands/new.d.ts +0 -12
  32. package/dist/commands/pre-publish.d.ts +0 -4
  33. package/dist/commands/rename.d.ts +0 -4
  34. package/dist/commands/universalize.d.ts +0 -4
  35. package/dist/commands/version.d.ts +0 -4
  36. package/dist/def/artifacts.d.ts +0 -70
  37. package/dist/def/build.d.ts +0 -313
  38. package/dist/def/create-npm-dirs.d.ts +0 -60
  39. package/dist/def/new.d.ts +0 -124
  40. package/dist/def/pre-publish.d.ts +0 -107
  41. package/dist/def/rename.d.ts +0 -110
  42. package/dist/def/universalize.d.ts +0 -51
  43. package/dist/def/version.d.ts +0 -51
  44. package/dist/utils/__tests__/config.spec.d.ts +0 -1
  45. package/dist/utils/__tests__/target.spec.d.ts +0 -1
  46. package/dist/utils/__tests__/typegen.spec.d.ts +0 -1
  47. package/dist/utils/__tests__/version.spec.d.ts +0 -1
  48. package/dist/utils/cargo.d.ts +0 -1
  49. package/dist/utils/config.d.ts +0 -129
  50. package/dist/utils/index.d.ts +0 -9
  51. package/dist/utils/log.d.ts +0 -10
  52. package/dist/utils/metadata.d.ts +0 -36
  53. package/dist/utils/misc.d.ts +0 -13
  54. package/dist/utils/read-config.d.ts +0 -7
  55. package/dist/utils/target.d.ts +0 -33
  56. package/dist/utils/typegen.d.ts +0 -6
  57. package/dist/utils/version.d.ts +0 -12
@@ -1,51 +0,0 @@
1
- import { Command } from 'clipanion';
2
- export declare abstract class BaseUniversalizeCommand extends Command {
3
- static paths: string[][];
4
- static usage: import("clipanion").Usage;
5
- cwd: string;
6
- configPath?: string;
7
- packageJsonPath: string;
8
- outputDir: string;
9
- getOptions(): {
10
- cwd: string;
11
- configPath: string | undefined;
12
- packageJsonPath: string;
13
- outputDir: string;
14
- };
15
- }
16
- /**
17
- * Combile built binaries into one universal binary
18
- */
19
- export interface UniversalizeOptions {
20
- /**
21
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
22
- *
23
- * @default process.cwd()
24
- */
25
- cwd?: string;
26
- /**
27
- * Path to `napi` config json file
28
- */
29
- configPath?: string;
30
- /**
31
- * Path to `package.json`
32
- *
33
- * @default 'package.json'
34
- */
35
- packageJsonPath?: string;
36
- /**
37
- * Path to the folder where all built `.node` files put, same as `--output-dir` of build command
38
- *
39
- * @default './'
40
- */
41
- outputDir?: string;
42
- }
43
- export declare function applyDefaultUniversalizeOptions(options: UniversalizeOptions): {
44
- cwd: string;
45
- /**
46
- * Path to `napi` config json file
47
- */
48
- configPath?: string;
49
- packageJsonPath: string;
50
- outputDir: string;
51
- };
@@ -1,51 +0,0 @@
1
- import { Command } from 'clipanion';
2
- export declare abstract class BaseVersionCommand extends Command {
3
- static paths: string[][];
4
- static usage: import("clipanion").Usage;
5
- cwd: string;
6
- configPath?: string;
7
- packageJsonPath: string;
8
- npmDir: string;
9
- getOptions(): {
10
- cwd: string;
11
- configPath: string | undefined;
12
- packageJsonPath: string;
13
- npmDir: string;
14
- };
15
- }
16
- /**
17
- * Update version in created npm packages
18
- */
19
- export interface VersionOptions {
20
- /**
21
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
22
- *
23
- * @default process.cwd()
24
- */
25
- cwd?: string;
26
- /**
27
- * Path to `napi` config json file
28
- */
29
- configPath?: string;
30
- /**
31
- * Path to `package.json`
32
- *
33
- * @default 'package.json'
34
- */
35
- packageJsonPath?: string;
36
- /**
37
- * Path to the folder where the npm packages put
38
- *
39
- * @default 'npm'
40
- */
41
- npmDir?: string;
42
- }
43
- export declare function applyDefaultVersionOptions(options: VersionOptions): {
44
- cwd: string;
45
- /**
46
- * Path to `napi` config json file
47
- */
48
- configPath?: string;
49
- packageJsonPath: string;
50
- npmDir: string;
51
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare function tryInstallCargoBinary(name: string, bin: string): void;
@@ -1,129 +0,0 @@
1
- import { Target } from './target.js';
2
- export type ValueOfConstArray<T> = T[Exclude<keyof T, keyof Array<any>>];
3
- export declare const SupportedPackageManagers: readonly ["yarn", "pnpm"];
4
- export declare const SupportedTestFrameworks: readonly ["ava"];
5
- export type SupportedPackageManager = ValueOfConstArray<typeof SupportedPackageManagers>;
6
- export type SupportedTestFramework = ValueOfConstArray<typeof SupportedTestFrameworks>;
7
- export interface UserNapiConfig {
8
- /**
9
- * Name of the binary to be generated, default to `index`
10
- */
11
- binaryName?: string;
12
- /**
13
- * Name of the npm package, default to the name of root package.json name
14
- *
15
- * Always given `@scope/pkg` and arch suffix will be appended like `@scope/pkg-linux-gnu-x64`
16
- */
17
- packageName?: string;
18
- /**
19
- * All targets the crate will be compiled for
20
- */
21
- targets?: string[];
22
- /**
23
- * The npm client project uses.
24
- */
25
- npmClient?: string;
26
- /**
27
- * Whether generate const enum for typescript bindings
28
- */
29
- constEnum?: boolean;
30
- /**
31
- * dts header prepend to the generated dts file
32
- */
33
- dtsHeader?: string;
34
- /**
35
- * dts header file path to be prepended to the generated dts file
36
- * if both dtsHeader and dtsHeaderFile are provided, dtsHeaderFile will be used
37
- */
38
- dtsHeaderFile?: string;
39
- /**
40
- * wasm compilation options
41
- */
42
- wasm?: {
43
- /**
44
- * https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Memory
45
- * @default 4000 pages (256MiB)
46
- */
47
- initialMemory?: number;
48
- /**
49
- * @default 65536 pages (4GiB)
50
- */
51
- maximumMemory?: number;
52
- /**
53
- * Browser wasm binding configuration
54
- */
55
- browser: {
56
- /**
57
- * Whether to use fs module in browser
58
- */
59
- fs?: boolean;
60
- /**
61
- * Whether to initialize wasm asynchronously
62
- */
63
- asyncInit?: boolean;
64
- /**
65
- * Whether to inject `buffer` to emnapi context
66
- */
67
- buffer?: boolean;
68
- };
69
- };
70
- /**
71
- * @deprecated binaryName instead
72
- */
73
- name?: string;
74
- /**
75
- * @deprecated use packageName instead
76
- */
77
- package?: {
78
- name?: string;
79
- };
80
- /**
81
- * @deprecated use targets instead
82
- */
83
- triples?: {
84
- /**
85
- * Whether enable default targets
86
- */
87
- defaults: boolean;
88
- /**
89
- * Additional targets to be compiled for
90
- */
91
- additional?: string[];
92
- };
93
- }
94
- export interface CommonPackageJsonFields {
95
- name: string;
96
- version: string;
97
- description?: string;
98
- keywords?: string[];
99
- author?: string;
100
- authors?: string[];
101
- license?: string;
102
- cpu?: string[];
103
- os?: string[];
104
- libc?: string[];
105
- files?: string[];
106
- repository?: any;
107
- homepage?: any;
108
- engines?: Record<string, string>;
109
- publishConfig?: any;
110
- bugs?: any;
111
- napi?: UserNapiConfig;
112
- type?: 'module' | 'commonjs';
113
- scripts?: Record<string, string>;
114
- main?: string;
115
- module?: string;
116
- types?: string;
117
- browser?: string;
118
- exports?: any;
119
- dependencies?: Record<string, string>;
120
- devDependencies?: Record<string, string>;
121
- ava?: {
122
- timeout?: string;
123
- };
124
- }
125
- export type NapiConfig = Required<Pick<UserNapiConfig, 'binaryName' | 'packageName' | 'npmClient'>> & Pick<UserNapiConfig, 'wasm' | 'dtsHeader' | 'dtsHeaderFile' | 'constEnum'> & {
126
- targets: Target[];
127
- packageJson: CommonPackageJsonFields;
128
- };
129
- export declare function readNapiConfig(path: string, configPath?: string): Promise<NapiConfig>;
@@ -1,9 +0,0 @@
1
- export * from './log.js';
2
- export * from './misc.js';
3
- export * from './target.js';
4
- export * from './version.js';
5
- export * from './metadata.js';
6
- export * from './config.js';
7
- export * from './cargo.js';
8
- export * from './typegen.js';
9
- export * from './read-config.js';
@@ -1,10 +0,0 @@
1
- import rawDebug from 'debug';
2
- declare module 'debug' {
3
- interface Debugger {
4
- info: typeof console.error;
5
- warn: typeof console.error;
6
- error: typeof console.error;
7
- }
8
- }
9
- export declare const debugFactory: (namespace: string) => rawDebug.Debugger;
10
- export declare const debug: rawDebug.Debugger;
@@ -1,36 +0,0 @@
1
- export type CrateTargetKind = 'bin' | 'example' | 'test' | 'bench' | 'lib' | 'rlib' | 'cdylib' | 'custom-build';
2
- export interface CrateTarget {
3
- name: string;
4
- kind: CrateTargetKind[];
5
- crate_types: CrateTargetKind[];
6
- }
7
- export interface Crate {
8
- id: string;
9
- name: string;
10
- src_path: string;
11
- version: string;
12
- edition: string;
13
- targets: CrateTarget[];
14
- features: Record<string, string[]>;
15
- manifest_path: string;
16
- dependencies: Array<{
17
- name: string;
18
- source: string;
19
- req: string;
20
- kind: string | null;
21
- rename: string | null;
22
- optional: boolean;
23
- uses_default_features: boolean;
24
- features: string[];
25
- target: string | null;
26
- registry: string | null;
27
- }>;
28
- }
29
- export interface CargoWorkspaceMetadata {
30
- version: number;
31
- packages: Crate[];
32
- workspace_members: string[];
33
- target_directory: string;
34
- workspace_root: string;
35
- }
36
- export declare function parseMetadata(manifestPath: string): Promise<CargoWorkspaceMetadata>;
@@ -1,13 +0,0 @@
1
- import { readFile, writeFile, copyFile, mkdir, unlink, stat, readdir } from 'node:fs';
2
- export declare const readFileAsync: typeof readFile.__promisify__;
3
- export declare const writeFileAsync: typeof writeFile.__promisify__;
4
- export declare const unlinkAsync: typeof unlink.__promisify__;
5
- export declare const copyFileAsync: typeof copyFile.__promisify__;
6
- export declare const mkdirAsync: typeof mkdir.__promisify__;
7
- export declare const statAsync: typeof stat.__promisify__;
8
- export declare const readdirAsync: typeof readdir.__promisify__;
9
- export declare function fileExists(path: string): Promise<boolean>;
10
- export declare function dirExistsAsync(path: string): Promise<boolean>;
11
- export declare function pick<O, K extends keyof O>(o: O, ...keys: K[]): Pick<O, K>;
12
- export declare function updatePackageJson(path: string, partial: Record<string, any>): Promise<void>;
13
- export declare const CLI_VERSION: string;
@@ -1,7 +0,0 @@
1
- interface MinimalNapiOptions {
2
- cwd: string;
3
- configPath?: string;
4
- packageJsonPath?: string;
5
- }
6
- export declare function readConfig(options: MinimalNapiOptions): Promise<import("./config.js").NapiConfig>;
7
- export {};
@@ -1,33 +0,0 @@
1
- export type Platform = NodeJS.Platform | 'wasm' | 'wasi' | 'openharmony';
2
- export declare const UNIVERSAL_TARGETS: {
3
- readonly 'universal-apple-darwin': readonly ["aarch64-apple-darwin", "x86_64-apple-darwin"];
4
- };
5
- export declare const AVAILABLE_TARGETS: readonly ["aarch64-apple-darwin", "aarch64-linux-android", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "aarch64-unknown-linux-ohos", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-linux-ohos", "x86_64-unknown-freebsd", "i686-pc-windows-msvc", "armv7-unknown-linux-gnueabihf", "armv7-unknown-linux-musleabihf", "armv7-linux-androideabi", "universal-apple-darwin", "riscv64gc-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "s390x-unknown-linux-gnu", "wasm32-wasi-preview1-threads", "wasm32-wasip1-threads"];
6
- export type TargetTriple = (typeof AVAILABLE_TARGETS)[number];
7
- export declare const DEFAULT_TARGETS: readonly ["x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"];
8
- export declare const TARGET_LINKER: Record<string, string>;
9
- type NodeJSArch = 'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x' | 'x32' | 'x64' | 'universal' | 'wasm32';
10
- export declare const NodeArchToCpu: Record<string, string>;
11
- export declare const UniArchsByPlatform: Partial<Record<Platform, NodeJSArch[]>>;
12
- export interface Target {
13
- triple: string;
14
- platformArchABI: string;
15
- platform: Platform;
16
- arch: NodeJSArch;
17
- abi: string | null;
18
- }
19
- /**
20
- * A triple is a specific format for specifying a target architecture.
21
- * Triples may be referred to as a target triple which is the architecture for the artifact produced, and the host triple which is the architecture that the compiler is running on.
22
- * The general format of the triple is `<arch><sub>-<vendor>-<sys>-<abi>` where:
23
- * - `arch` = The base CPU architecture, for example `x86_64`, `i686`, `arm`, `thumb`, `mips`, etc.
24
- * - `sub` = The CPU sub-architecture, for example `arm` has `v7`, `v7s`, `v5te`, etc.
25
- * - `vendor` = The vendor, for example `unknown`, `apple`, `pc`, `nvidia`, etc.
26
- * - `sys` = The system name, for example `linux`, `windows`, `darwin`, etc. none is typically used for bare-metal without an OS.
27
- * - `abi` = The ABI, for example `gnu`, `android`, `eabi`, etc.
28
- */
29
- export declare function parseTriple(rawTriple: string): Target;
30
- export declare function getSystemDefaultTarget(): Target;
31
- export declare function getTargetLinker(target: string): string | undefined;
32
- export declare function targetToEnvVar(target: string): string;
33
- export {};
@@ -1,6 +0,0 @@
1
- export declare const DEFAULT_TYPE_DEF_HEADER = "/* auto-generated by NAPI-RS */\n/* eslint-disable */\n";
2
- export declare function processTypeDef(intermediateTypeFile: string, constEnum: boolean): Promise<{
3
- dts: string;
4
- exports: string[];
5
- }>;
6
- export declare function correctStringIdent(src: string, ident: number): string;
@@ -1,12 +0,0 @@
1
- export declare enum NapiVersion {
2
- Napi1 = 1,
3
- Napi2 = 2,
4
- Napi3 = 3,
5
- Napi4 = 4,
6
- Napi5 = 5,
7
- Napi6 = 6,
8
- Napi7 = 7,
9
- Napi8 = 8,
10
- Napi9 = 9
11
- }
12
- export declare function napiEngineRequirement(napiVersion: NapiVersion): string;