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

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 (61) hide show
  1. package/cli.mjs +0 -0
  2. package/dist/api/build.js +8 -2
  3. package/dist/api/templates/ci-template.js +9 -8
  4. package/dist/api/templates/js-binding.js +242 -109
  5. package/dist/cli.js +0 -0
  6. package/dist/commands/artifacts.js +2 -1
  7. package/dist/commands/help.js +2 -1
  8. package/dist/def/artifacts.js +2 -1
  9. package/dist/def/build.d.ts +12 -0
  10. package/dist/def/build.js +10 -1
  11. package/dist/def/create-npm-dirs.js +2 -1
  12. package/dist/def/new.js +2 -1
  13. package/dist/def/pre-publish.js +2 -1
  14. package/dist/def/rename.js +2 -1
  15. package/dist/def/universalize.js +2 -1
  16. package/dist/def/version.js +2 -1
  17. package/dist/index.cjs +274 -116
  18. package/dist/utils/ci.js +9 -0
  19. package/dist/utils/target.d.ts +2 -2
  20. package/dist/utils/target.js +4 -0
  21. package/package.json +5 -5
  22. package/src/api/build.ts +11 -7
  23. package/src/api/templates/ci-template.ts +9 -8
  24. package/src/api/templates/js-binding.ts +231 -104
  25. package/src/def/build.ts +19 -0
  26. package/src/utils/__tests__/__snapshots__/target.spec.ts.md +7 -0
  27. package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
  28. package/src/utils/ci.ts +9 -0
  29. package/src/utils/target.ts +5 -0
  30. package/dist/def/commands/artifacts.d.ts +0 -15
  31. package/dist/def/commands/artifacts.js +0 -29
  32. package/dist/def/commands/build.d.ts +0 -53
  33. package/dist/def/commands/build.js +0 -105
  34. package/dist/def/commands/create-npm-dirs.d.ts +0 -15
  35. package/dist/def/commands/create-npm-dirs.js +0 -29
  36. package/dist/def/commands/new.d.ts +0 -27
  37. package/dist/def/commands/new.js +0 -53
  38. package/dist/def/commands/pre-publish.d.ts +0 -23
  39. package/dist/def/commands/pre-publish.js +0 -45
  40. package/dist/def/commands/rename.d.ts +0 -25
  41. package/dist/def/commands/rename.js +0 -49
  42. package/dist/def/commands/universalize.d.ts +0 -13
  43. package/dist/def/commands/universalize.js +0 -25
  44. package/dist/def/commands/version.d.ts +0 -13
  45. package/dist/def/commands/version.js +0 -25
  46. package/dist/def/options/artifacts.d.ts +0 -35
  47. package/dist/def/options/artifacts.js +0 -11
  48. package/dist/def/options/build.d.ts +0 -97
  49. package/dist/def/options/build.js +0 -3
  50. package/dist/def/options/create-npm-dirs.d.ts +0 -35
  51. package/dist/def/options/create-npm-dirs.js +0 -11
  52. package/dist/def/options/new.d.ts +0 -79
  53. package/dist/def/options/new.js +0 -15
  54. package/dist/def/options/pre-publish.d.ts +0 -65
  55. package/dist/def/options/pre-publish.js +0 -13
  56. package/dist/def/options/rename.d.ts +0 -75
  57. package/dist/def/options/rename.js +0 -11
  58. package/dist/def/options/universalize.d.ts +0 -28
  59. package/dist/def/options/universalize.js +0 -10
  60. package/dist/def/options/version.d.ts +0 -28
  61. package/dist/def/options/version.js +0 -10
@@ -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
- }