hcordova 1.0.0

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 (55) hide show
  1. package/LICENSE +204 -0
  2. package/README.md +346 -0
  3. package/bin/hcordova +27 -0
  4. package/package.json +39 -0
  5. package/src/base-cli.js +1181 -0
  6. package/src/utils/DependencyChecker.js +382 -0
  7. package/src/utils/PlatformProject.js +452 -0
  8. package/src/utils/PluginConfigParser.js +408 -0
  9. package/src/utils/PluginDownloader.js +181 -0
  10. package/src/utils/PluginHandler.js +1097 -0
  11. package/src/utils/VariableValidator.js +369 -0
  12. package/src/utils/args-processor.js +79 -0
  13. package/templates/project/AppScope/app.json5 +10 -0
  14. package/templates/project/AppScope/resources/base/element/string.json +8 -0
  15. package/templates/project/AppScope/resources/base/media/background.png +0 -0
  16. package/templates/project/AppScope/resources/base/media/foreground.png +0 -0
  17. package/templates/project/AppScope/resources/base/media/layered_image.json +7 -0
  18. package/templates/project/build-profile.json5 +46 -0
  19. package/templates/project/code-linter.json5 +32 -0
  20. package/templates/project/entry/build-profile.json5 +28 -0
  21. package/templates/project/entry/hvigorfile.ts +6 -0
  22. package/templates/project/entry/obfuscation-rules.txt +23 -0
  23. package/templates/project/entry/oh-package.json5 +12 -0
  24. package/templates/project/entry/src/main/ets/entryability/EntryAbility.ets +62 -0
  25. package/templates/project/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +32 -0
  26. package/templates/project/entry/src/main/ets/pages/Index.ets +40 -0
  27. package/templates/project/entry/src/main/module.json5 +52 -0
  28. package/templates/project/entry/src/main/resources/base/element/color.json +8 -0
  29. package/templates/project/entry/src/main/resources/base/element/float.json +8 -0
  30. package/templates/project/entry/src/main/resources/base/element/string.json +16 -0
  31. package/templates/project/entry/src/main/resources/base/media/background.png +0 -0
  32. package/templates/project/entry/src/main/resources/base/media/foreground.png +0 -0
  33. package/templates/project/entry/src/main/resources/base/media/layered_image.json +7 -0
  34. package/templates/project/entry/src/main/resources/base/media/startIcon.png +0 -0
  35. package/templates/project/entry/src/main/resources/base/profile/backup_config.json +3 -0
  36. package/templates/project/entry/src/main/resources/base/profile/main_pages.json +5 -0
  37. package/templates/project/entry/src/main/resources/dark/element/color.json +8 -0
  38. package/templates/project/entry/src/main/resources/rawfile/config.xml +26 -0
  39. package/templates/project/entry/src/main/resources/rawfile/www/cordova.js +1925 -0
  40. package/templates/project/entry/src/main/resources/rawfile/www/css/index.css +158 -0
  41. package/templates/project/entry/src/main/resources/rawfile/www/img/cordova.png +0 -0
  42. package/templates/project/entry/src/main/resources/rawfile/www/img/logo.png +0 -0
  43. package/templates/project/entry/src/main/resources/rawfile/www/index.html +110 -0
  44. package/templates/project/entry/src/main/resources/rawfile/www/js/index.js +68 -0
  45. package/templates/project/entry/src/mock/mock-config.json5 +2 -0
  46. package/templates/project/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  47. package/templates/project/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  48. package/templates/project/entry/src/ohosTest/module.json5 +13 -0
  49. package/templates/project/entry/src/test/List.test.ets +5 -0
  50. package/templates/project/entry/src/test/LocalUnit.test.ets +33 -0
  51. package/templates/project/hvigor/hvigor-config.json5 +22 -0
  52. package/templates/project/hvigorfile.ts +6 -0
  53. package/templates/project/local.properties +9 -0
  54. package/templates/project/oh-package-lock.json5 +27 -0
  55. package/templates/project/oh-package.json5 +10 -0
package/LICENSE ADDED
@@ -0,0 +1,204 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+
191
+ Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
204
+
package/README.md ADDED
@@ -0,0 +1,346 @@
1
+ # hcordova HarmonyOS命令化工具
2
+
3
+ ## 1. 项目概述
4
+
5
+ 本项目基于 **cordova-openharmony** 开发,旨在通过 Web 技术(HTML5、CSS3、JavaScript)快速构建支持 Android、iOS、HarmonyOS三平台的原生移动应用。Cordova 框架将 Web 代码封装为原生应用容器,实现 “一次开发,多端部署”,同时支持调用设备原生能力(如相机、定位、存储等),兼顾开发效率与原生体验。
6
+
7
+ 项目核心特性:
8
+
9
+
10
+
11
+ * 跨平台兼容:同步支持 Android 7.0+、iOS 12.0+ 、HarmonyOS 5.0+系统
12
+
13
+ * 原生能力集成:通过 Cordova 插件调用设备硬件功能
14
+
15
+ * 轻量化架构:基于 Web 技术栈,降低跨平台开发门槛
16
+
17
+ * 灵活扩展:支持自定义插件开发与第三方插件集成
18
+
19
+ ## 2. 环境准备
20
+
21
+ ### 2.1 基础依赖(必装)
22
+
23
+
24
+
25
+ * **Node.js**:v16.0.0 及以上(推荐 v18 LTS 版本)
26
+
27
+ 下载地址:[no](https://nodejs.org/)[dejs.](https://nodejs.org/)[org](https://nodejs.org/),安装后验证:
28
+
29
+
30
+
31
+ ```
32
+ node -v # 查看 Node 版本
33
+
34
+ npm -v # 查看 npm 版本
35
+ ```
36
+
37
+
38
+
39
+ * **Git**:用于版本控制与依赖拉取
40
+
41
+ 下载地址:[git-s](https://git-scm.com/)[cm.co](https://git-scm.com/)[m](https://git-scm.com/)
42
+
43
+ ### 2.2 平台专属依赖(按需安装)
44
+
45
+ #### 2.2.1 HarmonyOS平台
46
+
47
+ 1. DevEco下载地址:[https://developer.huawei.com](https://developer.huawei.com/consumer/cn/download/)
48
+
49
+ 2. 命令化工具下载地址:[https://developer.huawei.com](https://developer.huawei.com/consumer/cn/download/command-line-tools-for-hmos)
50
+
51
+ 3. 安装操作方法:[https://developer.huawei.com](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-commandline-get)
52
+
53
+ #### 2.2.2 Android 平台
54
+
55
+
56
+ * **Android Studio**:用于 Android SDK 管理与模拟器运行
57
+
58
+ 下载地址:[d](https://developer.android.com/studio)[evelo](https://developer.android.com/studio)[per.a](https://developer.android.com/studio)[ndroi](https://developer.android.com/studio)[d.com](https://developer.android.com/studio)[/stud](https://developer.android.com/studio)[io](https://developer.android.com/studio)
59
+
60
+ 安装后需配置:
61
+
62
+ 1. 安装 **SDK Platforms**:选择 Android 13(Tiramisu)及以上版本
63
+
64
+ 2. 安装 **SDK Tools**:勾选 "Android SDK Build-Tools"、"Android Emulator"、"Android SDK Platform-Tools"
65
+
66
+ 3. 配置环境变量 `ANDROID_HOME`(指向 SDK 安装目录,如 `C:\Users\<用户名>\AppData\Local\Android\Sdk`)
67
+
68
+ #### 2.2.3 iOS 平台(仅 macOS 支持)
69
+
70
+
71
+
72
+ * **Xcode**:v14.0 及以上(含 iOS 模拟器与开发证书工具)
73
+
74
+ 下载地址:Mac App Store 或 [devel](https://developer.apple.com/xcode/)[oper.](https://developer.apple.com/xcode/)[apple](https://developer.apple.com/xcode/)[.com/](https://developer.apple.com/xcode/)[xcode](https://developer.apple.com/xcode/)
75
+
76
+ 安装后需:
77
+
78
+ 1. 打开 Xcode 并同意许可协议
79
+
80
+ 2. 安装额外组件(Xcode 会自动提示)
81
+
82
+ 3. 配置 Apple 开发者账号(用于应用签名)
83
+
84
+ ### 2.3 安装 hcordova CLI
85
+
86
+ 通过 npm 全局安装 hcordova 命令行工具,用于项目创建、构建与管理:
87
+
88
+
89
+
90
+ ```
91
+ npm install -g hcordova
92
+ ```
93
+
94
+ 安装后验证:
95
+
96
+
97
+
98
+ ```
99
+ hcordova -v # 输出 hcordova 版本(如 1.0.0)即表示成功
100
+ ```
101
+
102
+ ## 3. 项目初始化与基础操作
103
+
104
+ ### 3.1 创建项目
105
+
106
+
107
+ #### 方式 1:新建项目(从零开始)
108
+
109
+
110
+
111
+ ```
112
+ 语法:cordova create <项目目录> <应用包名> <应用名称>
113
+
114
+ cordova create MyApp com.example.MyApp MyHarmonyApp
115
+
116
+ 进入项目目录
117
+
118
+ cd MyApp
119
+ ```
120
+
121
+ ### 3.2 平台管理
122
+
123
+ Cordova 项目需先添加目标平台,才能进行构建与运行。
124
+
125
+ #### 添加平台
126
+
127
+
128
+
129
+ ```
130
+ 添加 HarmonyOs 平台
131
+
132
+ hcordova platform add harmonyos
133
+
134
+ 添加 Android 平台
135
+
136
+ hcordova platform add android
137
+
138
+ 添加 iOS 平台(仅 macOS)
139
+
140
+ hcordova platform add ios
141
+ ```
142
+
143
+ #### 查看已添加平台
144
+
145
+
146
+
147
+ ```
148
+ hcordova platform ls
149
+
150
+ 输出示例:Installed platforms:
151
+ HarmonyOS (installed)
152
+ android 12.0.0
153
+ ios 7.0.0
154
+ ```
155
+
156
+ #### 更新 / 移除平台
157
+
158
+
159
+
160
+ ```
161
+ 移除 HarmonyOS 平台
162
+
163
+ cordova platform remove harmonyos
164
+
165
+ 移除 iOS 平台
166
+
167
+ cordova platform remove ios
168
+ ```
169
+
170
+ ### 3.3 插件管理
171
+
172
+ HCordova 通过 **插件** 扩展应用能力(如调用相机、获取定位),核心插件由 Apache 维护,第三方插件可从 [npm](https://www.npmjs.com/) 获取。HarmonyOS插件有鸿蒙官方维护,[gitcode](https://gitcode.com/OpenHarmony-Cordova)获取
173
+
174
+ #### 安装插件
175
+
176
+
177
+
178
+ ```
179
+ 安装相机插件(核心插件)
180
+
181
+ hcordova plugin add cordova-plugin-camera
182
+
183
+
184
+ 安装自定义本地插件(需指定插件目录)
185
+
186
+ hcordova plugin add ../local-plugin-directory
187
+ ```
188
+
189
+ #### 查看已安装插件
190
+
191
+
192
+
193
+ ```
194
+ hcordova plugin ls
195
+
196
+ 输出示例:cordova-plugin-camera 7.0.0 "Camera"
197
+ ```
198
+
199
+ #### 移除插件
200
+
201
+
202
+
203
+ ```
204
+ hcordova plugin remove cordova-plugin-camera
205
+ ```
206
+
207
+ ## 4. 开发与调试
208
+
209
+ ### 4.1 HarmonyOS系统
210
+
211
+ ```
212
+ 项目构建成功后,推荐使用DevEco进行开发和调试,当前命令化工具不支持开发调试
213
+ ```
214
+
215
+ ### 4.2 本地浏览器预览(快速调试)
216
+
217
+ 通过 Cordova 浏览器平台,可在电脑浏览器中快速预览应用界面与逻辑(不支持原生插件):
218
+
219
+ ```
220
+ 添加浏览器平台(首次使用需添加)
221
+
222
+ hcordova platform add browser
223
+
224
+ 运行浏览器预览
225
+
226
+ hcordova run browser
227
+
228
+ 效果:自动打开浏览器,地址为 http://localhost:8000
229
+ ```
230
+
231
+ ### 4.3 模拟器 / 真机运行
232
+
233
+ #### 运行 Android 应用
234
+
235
+
236
+
237
+ ```
238
+ 方式 1:自动检测模拟器/真机并运行
239
+
240
+ cordova run android
241
+
242
+ 方式 2:仅运行到模拟器
243
+
244
+ cordova emulate android
245
+
246
+ 方式 3:带调试模式运行(支持 Chrome 开发者工具调试)
247
+
248
+ cordova run android --debug
249
+ ```
250
+
251
+ #### 运行 iOS 应用(仅 macOS)
252
+
253
+
254
+
255
+ ```
256
+ 方式 1:自动检测模拟器/真机并运行
257
+
258
+ cordova run ios
259
+
260
+ 方式 2:指定模拟器型号(如 iPhone 15)
261
+
262
+ cordova run ios --emulator="iPhone 15"
263
+
264
+ 方式 3:带调试模式运行(支持 Safari 开发者工具调试)
265
+
266
+ cordova run ios --debug
267
+ ```
268
+
269
+ ### 4.3 日志查看
270
+
271
+ #### Android 日志
272
+
273
+ 通过 `adb`(Android 调试桥)查看应用运行日志:
274
+
275
+
276
+
277
+ ```
278
+ 查看所有日志(筛选 Cordova 相关内容)
279
+
280
+ adb logcat | grep "Cordova"
281
+
282
+ 仅查看错误日志
283
+
284
+ adb logcat \*:E
285
+ ```
286
+
287
+ #### iOS 日志
288
+
289
+
290
+
291
+ ```
292
+ 查看 iOS 应用日志
293
+
294
+ cordova logs ios
295
+
296
+ 或通过 Xcode 查看:Xcode → Window → Devices and Simulators → 选择设备/应用 → View Logs
297
+ ```
298
+
299
+
300
+ ## 5. 项目目录结构说明
301
+
302
+
303
+
304
+ ```
305
+ your-cordova-app/
306
+ |—— harmonyos #鸿蒙工程目录
307
+
308
+ |—— oh-plugins #鸿蒙专用插件
309
+
310
+ ├── config.xml # 项目配置文件(应用名称、版本、权限、插件配置等)
311
+
312
+ ├── www/ # Web 代码目录(核心开发目录)
313
+
314
+ │ ├── index.html # 应用入口页面
315
+
316
+ │ ├── css/ # 样式文件目录
317
+
318
+ │ ├── js/ # 脚本文件目录(含 cordova.js,自动注入)
319
+
320
+ │ └── img/ # 图片资源目录
321
+
322
+ ├── platforms/ # 平台目录(自动生成,存放 Android/iOS 原生项目)
323
+
324
+ ├── plugins/ # 插件目录(自动生成,存放已安装插件)
325
+
326
+ ├── hooks/ # 钩子脚本目录(可选,用于自定义构建流程)
327
+
328
+ └── package.json # 项目依赖配置文件
329
+ ```
330
+
331
+ ## 6. 参考资源
332
+
333
+
334
+
335
+ * **官方文档**:[A](https://cordova.apache.org/docs/en/latest/)[pache](https://cordova.apache.org/docs/en/latest/)[ Cord](https://cordova.apache.org/docs/en/latest/)[ova 文](https://cordova.apache.org/docs/en/latest/)[档](https://cordova.apache.org/docs/en/latest/)
336
+
337
+ * **Apache Cordova核心插件列表**:[Cord](https://cordova.apache.org/plugins/)[ova P](https://cordova.apache.org/plugins/)[lugin](https://cordova.apache.org/plugins/)[s](https://cordova.apache.org/plugins/)
338
+
339
+ * **Harmony Cordova插件列表**:[gitcode](https://gitcode.com/OpenHarmony-Cordova)
340
+
341
+ * **HarmonyOS 发布指南**: [DevEco发布应用](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-publish-app)
342
+
343
+ * **Android 发布指南**:[Googl](https://developer.android.com/studio/publish)[e Pla](https://developer.android.com/studio/publish)[y 应用发](https://developer.android.com/studio/publish)[布](https://developer.android.com/studio/publish)
344
+
345
+ * **iOS 发布指南**:[App S](https://developer.apple.com/app-store/submission/)[tore](https://developer.apple.com/app-store/submission/)[ 应用发布](https://developer.apple.com/app-store/submission/)
346
+
package/bin/hcordova ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+
3
+ /*
4
+ * Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ const BaseCLI = require('../src/base-cli');
20
+
21
+ try {
22
+ const cli = new BaseCLI();
23
+ cli.run(process.argv.slice(2));
24
+ } catch (error) {
25
+ console.error('Error:', error.message);
26
+ process.exit(1);
27
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "hcordova",
3
+ "version": "1.0.0",
4
+ "description": "Cordova CLI with HarmonyOS support",
5
+ "main": "src/base-cli.js",
6
+ "bin": {
7
+ "hcordova": "./bin/hcordova"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [
13
+ "cordova",
14
+ "harmonyos",
15
+ "mobile",
16
+ "app",
17
+ "hcordova"
18
+ ],
19
+ "author": "Huawei Device, Inc. Ltd. and 马弓手",
20
+ "license": "Apache-2.0",
21
+ "homepage": "https://gitcode.com/OpenHarmony-Cordova/hcordova",
22
+ "bugs":"https://gitcode.com/OpenHarmony-Cordova/hcordova/issues",
23
+ "dependencies": {
24
+ "chalk": "^4.1.2",
25
+ "commander": "^9.5.0",
26
+ "cordova": "^12.0.0",
27
+ "xml2js": "^0.6.2",
28
+ "fs-extra": "^11.3.2",
29
+ "inquirer": "^8.2.7",
30
+ "json5": "^2.2.3"
31
+ },
32
+ "engines": {
33
+ "node": ">=16.13.0"
34
+ },
35
+ "devDependencies": {
36
+ "jest": "^29.0.0",
37
+ "eslint": "^8.0.0"
38
+ }
39
+ }