@napi-rs/cli 3.0.0-alpha.3 → 3.0.0-alpha.5

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 (71) hide show
  1. package/dist/api/build.js +34 -14
  2. package/dist/api/templates/ci-template.js +10 -11
  3. package/dist/api/templates/ci.yml.js +8 -2
  4. package/dist/api/templates/js-binding.d.ts +1 -1
  5. package/dist/api/templates/js-binding.js +243 -109
  6. package/dist/api/templates/package.json.js +29 -27
  7. package/dist/cli.js +0 -0
  8. package/dist/commands/new.js +1 -4
  9. package/dist/def/build.d.ts +12 -0
  10. package/dist/def/build.js +8 -0
  11. package/dist/index.cjs +2734 -7836
  12. package/dist/utils/__tests__/typegen.spec.js +1 -1
  13. package/dist/utils/ci.js +9 -0
  14. package/dist/utils/config.d.ts +9 -1
  15. package/dist/utils/target.d.ts +2 -2
  16. package/dist/utils/target.js +4 -0
  17. package/dist/utils/typegen.d.ts +4 -1
  18. package/dist/utils/typegen.js +20 -1
  19. package/dist/utils/version.js +2 -2
  20. package/package.json +13 -13
  21. package/src/api/artifacts.ts +2 -2
  22. package/src/api/build.ts +45 -18
  23. package/src/api/pre-publish.ts +8 -5
  24. package/src/api/templates/ci-template.ts +10 -11
  25. package/src/api/templates/ci.yml.ts +8 -2
  26. package/src/api/templates/js-binding.ts +236 -104
  27. package/src/api/templates/package.json.ts +31 -26
  28. package/src/commands/new.ts +1 -5
  29. package/src/def/build.ts +19 -0
  30. package/src/utils/__tests__/__snapshots__/target.spec.ts.md +7 -0
  31. package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
  32. package/src/utils/__tests__/__snapshots__/version.spec.ts.md +7 -7
  33. package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
  34. package/src/utils/__tests__/typegen.spec.ts +1 -1
  35. package/src/utils/ci.ts +9 -0
  36. package/src/utils/config.ts +12 -1
  37. package/src/utils/target.ts +5 -0
  38. package/src/utils/typegen.ts +20 -1
  39. package/src/utils/version.ts +1 -1
  40. package/dist/def/commands/artifacts.d.ts +0 -15
  41. package/dist/def/commands/artifacts.js +0 -29
  42. package/dist/def/commands/build.d.ts +0 -53
  43. package/dist/def/commands/build.js +0 -105
  44. package/dist/def/commands/create-npm-dirs.d.ts +0 -15
  45. package/dist/def/commands/create-npm-dirs.js +0 -29
  46. package/dist/def/commands/new.d.ts +0 -27
  47. package/dist/def/commands/new.js +0 -53
  48. package/dist/def/commands/pre-publish.d.ts +0 -23
  49. package/dist/def/commands/pre-publish.js +0 -45
  50. package/dist/def/commands/rename.d.ts +0 -25
  51. package/dist/def/commands/rename.js +0 -49
  52. package/dist/def/commands/universalize.d.ts +0 -13
  53. package/dist/def/commands/universalize.js +0 -25
  54. package/dist/def/commands/version.d.ts +0 -13
  55. package/dist/def/commands/version.js +0 -25
  56. package/dist/def/options/artifacts.d.ts +0 -35
  57. package/dist/def/options/artifacts.js +0 -11
  58. package/dist/def/options/build.d.ts +0 -97
  59. package/dist/def/options/build.js +0 -3
  60. package/dist/def/options/create-npm-dirs.d.ts +0 -35
  61. package/dist/def/options/create-npm-dirs.js +0 -11
  62. package/dist/def/options/new.d.ts +0 -79
  63. package/dist/def/options/new.js +0 -15
  64. package/dist/def/options/pre-publish.d.ts +0 -65
  65. package/dist/def/options/pre-publish.js +0 -13
  66. package/dist/def/options/rename.d.ts +0 -75
  67. package/dist/def/options/rename.js +0 -11
  68. package/dist/def/options/universalize.d.ts +0 -28
  69. package/dist/def/options/universalize.js +0 -10
  70. package/dist/def/options/version.d.ts +0 -28
  71. package/dist/def/options/version.js +0 -10
@@ -1,97 +0,0 @@
1
- /**
2
- * Build the napi-rs project
3
- */
4
- export interface BuildOptions {
5
- /**
6
- * Build for the target triple, bypassed to `cargo build --target`
7
- */
8
- target?: string;
9
- /**
10
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
11
- */
12
- cwd?: string;
13
- /**
14
- * Path to `Cargo.toml`
15
- */
16
- manifestPath?: string;
17
- /**
18
- * Path to `package.json`
19
- */
20
- packageJsonPath?: string;
21
- /**
22
- * Directory for all crate generated artifacts, see `cargo build --target-dir`
23
- */
24
- targetDir?: string;
25
- /**
26
- * Path to where all the built files would be put. Default to the crate folder
27
- */
28
- outputDir?: string;
29
- /**
30
- * Add platform triple to the generated nodejs binding file, eg: `[name].linux-x64-gnu.node`
31
- */
32
- platform?: boolean;
33
- /**
34
- * Package name in generated js binding file. Only works with `--platform` flag
35
- */
36
- jsPackageName?: string;
37
- /**
38
- * Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output_dir`.
39
- */
40
- jsBinding?: string;
41
- /**
42
- * Whether to disable the generation JS binding file. Only works with `--platform` flag.
43
- */
44
- noJsBinding?: boolean;
45
- /**
46
- * Path and filename of generated type def file. Relative to `--output_dir`
47
- */
48
- dts?: string;
49
- /**
50
- * Custom file header for generated type def file. Only works when `typedef` feature enabled.
51
- */
52
- dtsHeader?: string;
53
- /**
54
- * Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled.
55
- */
56
- noDtsHeader?: boolean;
57
- /**
58
- * Whether strip the library to achieve the minimum file size
59
- */
60
- strip?: boolean;
61
- /**
62
- * Build in release mode
63
- */
64
- release?: boolean;
65
- /**
66
- * Verbosely log build command trace
67
- */
68
- verbose?: boolean;
69
- /**
70
- * Build only the specified binary
71
- */
72
- bin?: string;
73
- /**
74
- * Build the specified library or the one at cwd
75
- */
76
- package?: string;
77
- /**
78
- * [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
79
- */
80
- crossCompile?: boolean;
81
- /**
82
- * watch the crate changes and build continiously with `cargo-watch` crates
83
- */
84
- watch?: boolean;
85
- /**
86
- * Space-separated list of features to activate
87
- */
88
- features?: string[];
89
- /**
90
- * Activate all available features
91
- */
92
- allFeatures?: boolean;
93
- /**
94
- * Do not activate the `default` feature
95
- */
96
- noDefaultFeatures?: boolean;
97
- }
@@ -1,3 +0,0 @@
1
- // This file is generated by codegen/index.ts
2
- // Do not edit this file manually
3
- export {};
@@ -1,35 +0,0 @@
1
- /**
2
- * Create npm package dirs for different platforms
3
- */
4
- export interface CreateNpmDirsOptions {
5
- /**
6
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
7
- *
8
- * @default process.cwd()
9
- */
10
- cwd?: string;
11
- /**
12
- * Path to `package.json`
13
- *
14
- * @default 'package.json'
15
- */
16
- packageJsonPath?: string;
17
- /**
18
- * Path to the folder where the npm packages put
19
- *
20
- * @default 'npm'
21
- */
22
- npmDir?: string;
23
- /**
24
- * Dry run without touching file system
25
- *
26
- * @default false
27
- */
28
- dryRun?: boolean;
29
- }
30
- export declare function applyDefaultCreateNpmDirsOptions(options: CreateNpmDirsOptions): {
31
- cwd: string;
32
- packageJsonPath: string;
33
- npmDir: string;
34
- dryRun: boolean;
35
- };
@@ -1,11 +0,0 @@
1
- // This file is generated by codegen/index.ts
2
- // Do not edit this file manually
3
- export function applyDefaultCreateNpmDirsOptions(options) {
4
- return {
5
- cwd: process.cwd(),
6
- packageJsonPath: 'package.json',
7
- npmDir: 'npm',
8
- dryRun: false,
9
- ...options,
10
- };
11
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * Create a new project with pre-configured boilerplate
3
- */
4
- export interface NewOptions {
5
- /**
6
- * The path where the napi-rs project will be created.
7
- */
8
- path: string;
9
- /**
10
- * The name of the project, default to the name of the directory if not provided
11
- */
12
- name?: string;
13
- /**
14
- * The minimum Node-API version to support
15
- *
16
- * @default 4
17
- */
18
- minNodeApiVersion?: number;
19
- /**
20
- * License for open-sourced project
21
- *
22
- * @default 'MIT'
23
- */
24
- license?: string;
25
- /**
26
- * All targets the crate will be compiled for.
27
- *
28
- * @default []
29
- */
30
- targets?: string[];
31
- /**
32
- * Whether enable default targets
33
- *
34
- * @default true
35
- */
36
- enableDefaultTargets?: boolean;
37
- /**
38
- * Whether enable all targets
39
- *
40
- * @default false
41
- */
42
- enableAllTargets?: boolean;
43
- /**
44
- * Whether enable the `type-def` feature for typescript definitions auto-generation
45
- *
46
- * @default true
47
- */
48
- enableTypeDef?: boolean;
49
- /**
50
- * Whether generate preconfigured GitHub Actions workflow
51
- *
52
- * @default true
53
- */
54
- enableGithubActions?: boolean;
55
- /**
56
- * Whether to run the command in dry-run mode
57
- *
58
- * @default false
59
- */
60
- dryRun?: boolean;
61
- }
62
- export declare function applyDefaultNewOptions(options: NewOptions): {
63
- /**
64
- * The path where the napi-rs project will be created.
65
- */
66
- path: string;
67
- /**
68
- * The name of the project, default to the name of the directory if not provided
69
- */
70
- name?: string | undefined;
71
- minNodeApiVersion: number;
72
- license: string;
73
- targets: string[];
74
- enableDefaultTargets: boolean;
75
- enableAllTargets: boolean;
76
- enableTypeDef: boolean;
77
- enableGithubActions: boolean;
78
- dryRun: boolean;
79
- };
@@ -1,15 +0,0 @@
1
- // This file is generated by codegen/index.ts
2
- // Do not edit this file manually
3
- export function applyDefaultNewOptions(options) {
4
- return {
5
- minNodeApiVersion: 4,
6
- license: 'MIT',
7
- targets: [],
8
- enableDefaultTargets: true,
9
- enableAllTargets: false,
10
- enableTypeDef: true,
11
- enableGithubActions: true,
12
- dryRun: false,
13
- ...options,
14
- };
15
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * Update package.json and copy addons into per platform packages
3
- */
4
- export interface PrePublishOptions {
5
- /**
6
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
7
- *
8
- * @default process.cwd()
9
- */
10
- cwd?: string;
11
- /**
12
- * Path to `package.json`
13
- *
14
- * @default 'package.json'
15
- */
16
- packageJsonPath?: string;
17
- /**
18
- * Path to the folder where the npm packages put
19
- *
20
- * @default 'npm'
21
- */
22
- npmDir?: string;
23
- /**
24
- * git tag style, `npm` or `lerna`
25
- *
26
- * @default 'lerna'
27
- */
28
- tagStyle?: 'npm' | 'lerna';
29
- /**
30
- * Whether create GitHub release
31
- *
32
- * @default true
33
- */
34
- ghRelease?: boolean;
35
- /**
36
- * GitHub release name
37
- */
38
- ghReleaseName?: string;
39
- /**
40
- * Existing GitHub release id
41
- */
42
- ghReleaseId?: string;
43
- /**
44
- * Dry run without touching file system
45
- *
46
- * @default false
47
- */
48
- dryRun?: boolean;
49
- }
50
- export declare function applyDefaultPrePublishOptions(options: PrePublishOptions): {
51
- cwd: string;
52
- packageJsonPath: string;
53
- npmDir: string;
54
- tagStyle: string;
55
- ghRelease: boolean;
56
- /**
57
- * GitHub release name
58
- */
59
- ghReleaseName?: string | undefined;
60
- /**
61
- * Existing GitHub release id
62
- */
63
- ghReleaseId?: string | undefined;
64
- dryRun: boolean;
65
- };
@@ -1,13 +0,0 @@
1
- // This file is generated by codegen/index.ts
2
- // Do not edit this file manually
3
- export function applyDefaultPrePublishOptions(options) {
4
- return {
5
- cwd: process.cwd(),
6
- packageJsonPath: 'package.json',
7
- npmDir: 'npm',
8
- tagStyle: 'lerna',
9
- ghRelease: true,
10
- dryRun: false,
11
- ...options,
12
- };
13
- }
@@ -1,75 +0,0 @@
1
- /**
2
- * Rename the napi-rs project
3
- */
4
- export interface RenameOptions {
5
- /**
6
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
7
- *
8
- * @default process.cwd()
9
- */
10
- cwd?: string;
11
- /**
12
- * Path to `package.json`
13
- *
14
- * @default 'package.json'
15
- */
16
- packageJsonPath?: string;
17
- /**
18
- * Path to the folder where the npm packages put
19
- *
20
- * @default 'npm'
21
- */
22
- npmDir?: string;
23
- /**
24
- * The new name of the project
25
- */
26
- name?: string;
27
- /**
28
- * The new binary name *.node files
29
- */
30
- binaryName?: string;
31
- /**
32
- * The new package name of the project
33
- */
34
- packageName?: string;
35
- /**
36
- * Path to `Cargo.toml`
37
- *
38
- * @default 'Cargo.toml'
39
- */
40
- manifestPath?: string;
41
- /**
42
- * The new repository of the project
43
- */
44
- repository?: string;
45
- /**
46
- * The new description of the project
47
- */
48
- description?: string;
49
- }
50
- export declare function applyDefaultRenameOptions(options: RenameOptions): {
51
- cwd: string;
52
- packageJsonPath: string;
53
- npmDir: string;
54
- /**
55
- * The new name of the project
56
- */
57
- name?: string | undefined;
58
- /**
59
- * The new binary name *.node files
60
- */
61
- binaryName?: string | undefined;
62
- /**
63
- * The new package name of the project
64
- */
65
- packageName?: string | undefined;
66
- manifestPath: string;
67
- /**
68
- * The new repository of the project
69
- */
70
- repository?: string | undefined;
71
- /**
72
- * The new description of the project
73
- */
74
- description?: string | undefined;
75
- };
@@ -1,11 +0,0 @@
1
- // This file is generated by codegen/index.ts
2
- // Do not edit this file manually
3
- export function applyDefaultRenameOptions(options) {
4
- return {
5
- cwd: process.cwd(),
6
- packageJsonPath: 'package.json',
7
- npmDir: 'npm',
8
- manifestPath: 'Cargo.toml',
9
- ...options,
10
- };
11
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Combile built binaries into one universal binary
3
- */
4
- export interface UniversalizeOptions {
5
- /**
6
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
7
- *
8
- * @default process.cwd()
9
- */
10
- cwd?: string;
11
- /**
12
- * Path to `package.json`
13
- *
14
- * @default 'package.json'
15
- */
16
- packageJsonPath?: string;
17
- /**
18
- * Path to the folder where all built `.node` files put, same as `--output-dir` of build command
19
- *
20
- * @default './'
21
- */
22
- outputDir?: string;
23
- }
24
- export declare function applyDefaultUniversalizeOptions(options: UniversalizeOptions): {
25
- cwd: string;
26
- packageJsonPath: string;
27
- outputDir: string;
28
- };
@@ -1,10 +0,0 @@
1
- // This file is generated by codegen/index.ts
2
- // Do not edit this file manually
3
- export function applyDefaultUniversalizeOptions(options) {
4
- return {
5
- cwd: process.cwd(),
6
- packageJsonPath: 'package.json',
7
- outputDir: './',
8
- ...options,
9
- };
10
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Update version in created npm packages
3
- */
4
- export interface VersionOptions {
5
- /**
6
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
7
- *
8
- * @default process.cwd()
9
- */
10
- cwd?: string;
11
- /**
12
- * Path to `package.json`
13
- *
14
- * @default 'package.json'
15
- */
16
- packageJsonPath?: string;
17
- /**
18
- * Path to the folder where the npm packages put
19
- *
20
- * @default 'npm'
21
- */
22
- npmDir?: string;
23
- }
24
- export declare function applyDefaultVersionOptions(options: VersionOptions): {
25
- cwd: string;
26
- packageJsonPath: string;
27
- npmDir: string;
28
- };
@@ -1,10 +0,0 @@
1
- // This file is generated by codegen/index.ts
2
- // Do not edit this file manually
3
- export function applyDefaultVersionOptions(options) {
4
- return {
5
- cwd: process.cwd(),
6
- packageJsonPath: 'package.json',
7
- npmDir: 'npm',
8
- ...options,
9
- };
10
- }