@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
@@ -75,9 +75,6 @@ export class NewCommand extends BaseNewCommand {
75
75
  .then(({ minNodeApiVersion }) => minNodeApiVersion);
76
76
  }
77
77
  async fetchTargets() {
78
- if (this.enableDefaultTargets) {
79
- return DEFAULT_TARGETS.concat();
80
- }
81
78
  if (this.enableAllTargets) {
82
79
  return AVAILABLE_TARGETS.concat();
83
80
  }
@@ -86,7 +83,7 @@ export class NewCommand extends BaseNewCommand {
86
83
  type: 'checkbox',
87
84
  loop: false,
88
85
  message: 'Choose target(s) your crate will be compiled to',
89
- default: DEFAULT_TARGETS,
86
+ default: this.enableDefaultTargets ? DEFAULT_TARGETS : [],
90
87
  choices: AVAILABLE_TARGETS,
91
88
  });
92
89
  return targets;
@@ -20,7 +20,9 @@ export declare abstract class BaseBuildCommand extends Command {
20
20
  verbose?: boolean;
21
21
  bin?: string;
22
22
  package?: string;
23
+ profile?: string;
23
24
  crossCompile?: boolean;
25
+ useCross?: boolean;
24
26
  watch?: boolean;
25
27
  features?: string[];
26
28
  allFeatures?: boolean;
@@ -44,7 +46,9 @@ export declare abstract class BaseBuildCommand extends Command {
44
46
  verbose: boolean | undefined;
45
47
  bin: string | undefined;
46
48
  package: string | undefined;
49
+ profile: string | undefined;
47
50
  crossCompile: boolean | undefined;
51
+ useCross: boolean | undefined;
48
52
  watch: boolean | undefined;
49
53
  features: string[] | undefined;
50
54
  allFeatures: boolean | undefined;
@@ -127,10 +131,18 @@ export interface BuildOptions {
127
131
  * Build the specified library or the one at cwd
128
132
  */
129
133
  package?: string;
134
+ /**
135
+ * Build artifacts with the specified profile
136
+ */
137
+ profile?: string;
130
138
  /**
131
139
  * [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
132
140
  */
133
141
  crossCompile?: boolean;
142
+ /**
143
+ * [experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`
144
+ */
145
+ useCross?: boolean;
134
146
  /**
135
147
  * watch the crate changes and build continiously with `cargo-watch` crates
136
148
  */
package/dist/def/build.js CHANGED
@@ -60,9 +60,15 @@ export class BaseBuildCommand extends Command {
60
60
  package = Option.String('--package,-p', {
61
61
  description: 'Build the specified library or the one at cwd',
62
62
  });
63
+ profile = Option.String('--profile', {
64
+ description: 'Build artifacts with the specified profile',
65
+ });
63
66
  crossCompile = Option.Boolean('--cross-compile,-x', {
64
67
  description: '[experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform',
65
68
  });
69
+ useCross = Option.Boolean('--use-cross', {
70
+ description: '[experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`',
71
+ });
66
72
  watch = Option.Boolean('--watch,-w', {
67
73
  description: 'watch the crate changes and build continiously with `cargo-watch` crates',
68
74
  });
@@ -95,7 +101,9 @@ export class BaseBuildCommand extends Command {
95
101
  verbose: this.verbose,
96
102
  bin: this.bin,
97
103
  package: this.package,
104
+ profile: this.profile,
98
105
  crossCompile: this.crossCompile,
106
+ useCross: this.useCross,
99
107
  watch: this.watch,
100
108
  features: this.features,
101
109
  allFeatures: this.allFeatures,