@baic/yolk-cli 2.1.0-alpha.8 → 2.1.0-github.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 (636) hide show
  1. package/compiled/commander/index.d.ts +430 -0
  2. package/compiled/commander/index.js +1970 -0
  3. package/compiled/commander/package.json +1 -0
  4. package/compiled/glob/index.d.ts +101 -0
  5. package/compiled/glob/index.js +2218 -0
  6. package/compiled/glob/package.json +1 -0
  7. package/compiled/minimatch/index.d.ts +312 -0
  8. package/compiled/minimatch/index.js +1254 -0
  9. package/compiled/minimatch/package.json +1 -0
  10. package/compiled/mkdirp/index.d.ts +114 -0
  11. package/compiled/mkdirp/index.js +348 -0
  12. package/compiled/mkdirp/package.json +1 -0
  13. package/compiled/mustache/index.d.ts +423 -0
  14. package/compiled/mustache/index.js +828 -0
  15. package/compiled/mustache/package.json +1 -0
  16. package/compiled/prettier/index.d.ts +892 -0
  17. package/compiled/prettier/index.js +48593 -0
  18. package/compiled/prettier/package.json +1 -0
  19. package/compiled/rimraf/index.d.ts +48 -0
  20. package/compiled/rimraf/index.js +449 -0
  21. package/compiled/rimraf/package.json +1 -0
  22. package/compiled/staged-git-files/index.js +267 -0
  23. package/compiled/staged-git-files/package.json +1 -0
  24. package/es/.prettierrc.js +13 -0
  25. package/es/index.d.ts +1 -0
  26. package/es/index.js +1 -1
  27. package/es/yolk.js +1 -1
  28. package/lib/.prettierrc.js +13 -0
  29. package/lib/index.d.ts +1 -0
  30. package/lib/index.js +1 -1
  31. package/lib/yolk.js +1 -1
  32. package/package.json +38 -26
  33. package/templates/ice-mobile/.eslintrc +1 -1
  34. package/templates/ice-mobile/.gitignore.tpl +10 -3
  35. package/templates/ice-mobile/.icerc.ts +2 -2
  36. package/templates/ice-mobile/.npmrc.tpl +2 -0
  37. package/templates/ice-mobile/.prettierignore +4 -5
  38. package/templates/ice-mobile/.prettierrc.js +1 -0
  39. package/templates/ice-mobile/README.md.tpl +1 -1
  40. package/templates/ice-mobile/package.json.tpl +5 -0
  41. package/templates/ice-mobile/public/index.html +15 -0
  42. package/templates/ice-mobile/src/app.tsx +1 -1
  43. package/templates/ice-mobile/src/pages/demo/examples/Input.tsx +1 -2
  44. package/templates/ice-mobile/src/pages/demo/examples/List/4.tsx +2 -2
  45. package/templates/ice-mobile/src/pages/demo/examples/NumberInput/1.tsx +1 -2
  46. package/templates/ice-mobile/src/pages/demo/examples/NumberInput/2.tsx +1 -2
  47. package/templates/ice-mobile/src/pages/demo/examples/NumberInput/3.tsx +1 -2
  48. package/templates/ice-mobile/src/pages/demo/examples/NumberInput/4.tsx +1 -2
  49. package/templates/ice-mobile/src/routes.ts +2 -1
  50. package/templates/ice-mobile-h5+app/.eslintrc +6 -0
  51. package/templates/ice-mobile-h5+app/.gitignore.tpl +37 -0
  52. package/templates/ice-mobile-h5+app/.icerc.ts +6 -0
  53. package/templates/ice-mobile-h5+app/.npmrc.tpl +2 -0
  54. package/templates/ice-mobile-h5+app/.prettierignore +8 -0
  55. package/templates/ice-mobile-h5+app/.prettierrc.js +1 -0
  56. package/templates/ice-mobile-h5+app/.stylelintrc +3 -0
  57. package/templates/ice-mobile-h5+app/README.md.tpl +34 -0
  58. package/templates/ice-mobile-h5+app/h5+app/manifest.json +87 -0
  59. package/templates/ice-mobile-h5+app/package.json.tpl +16 -0
  60. package/templates/ice-mobile-h5+app/public/favicon.ico +0 -0
  61. package/templates/ice-mobile-h5+app/public/index.html +15 -0
  62. package/templates/ice-mobile-h5+app/src/app.tsx +5 -0
  63. package/templates/ice-mobile-h5+app/src/common/request.ts +3 -0
  64. package/templates/ice-mobile-h5+app/src/common/util.ts +7 -0
  65. package/templates/ice-mobile-h5+app/src/components/index.ts +0 -0
  66. package/templates/ice-mobile-h5+app/src/global.less +3 -0
  67. package/templates/ice-mobile-h5+app/src/layouts/index.tsx +5 -0
  68. package/templates/ice-mobile-h5+app/src/pages/404.tsx +10 -0
  69. package/templates/ice-mobile-h5+app/src/pages/demo/examples/BarCode.tsx +4 -0
  70. package/templates/ice-mobile-h5+app/src/pages/demo/examples/Iconfont.tsx +18 -0
  71. package/templates/ice-mobile-h5+app/src/pages/demo/examples/Input.tsx +16 -0
  72. package/templates/ice-mobile-h5+app/src/pages/demo/examples/List/1.tsx +12 -0
  73. package/templates/ice-mobile-h5+app/src/pages/demo/examples/List/2.tsx +29 -0
  74. package/templates/ice-mobile-h5+app/src/pages/demo/examples/List/3.tsx +29 -0
  75. package/templates/ice-mobile-h5+app/src/pages/demo/examples/List/4.tsx +55 -0
  76. package/templates/ice-mobile-h5+app/src/pages/demo/examples/List/mock.ts +30 -0
  77. package/templates/ice-mobile-h5+app/src/pages/demo/examples/Loading.tsx +12 -0
  78. package/templates/ice-mobile-h5+app/src/pages/demo/examples/NumberInput/1.tsx +16 -0
  79. package/templates/ice-mobile-h5+app/src/pages/demo/examples/NumberInput/2.tsx +16 -0
  80. package/templates/ice-mobile-h5+app/src/pages/demo/examples/NumberInput/3.tsx +16 -0
  81. package/templates/ice-mobile-h5+app/src/pages/demo/examples/NumberInput/4.tsx +16 -0
  82. package/templates/ice-mobile-h5+app/src/pages/demo/examples/PagingList/1.tsx +6 -0
  83. package/templates/ice-mobile-h5+app/src/pages/demo/examples/QrCode.tsx +4 -0
  84. package/templates/ice-mobile-h5+app/src/pages/demo/examples/Required.tsx +4 -0
  85. package/templates/ice-mobile-h5+app/src/pages/demo/examples/TimerButton.tsx +4 -0
  86. package/templates/ice-mobile-h5+app/src/pages/demo/examples/usePreload.tsx +9 -0
  87. package/templates/ice-mobile-h5+app/src/pages/demo/index.tsx +87 -0
  88. package/templates/ice-mobile-h5+app/src/pages/index.tsx +3 -0
  89. package/templates/ice-mobile-h5+app/src/routes.ts +29 -0
  90. package/templates/ice-mobile-h5+app/src/types/user.d.ts +3 -0
  91. package/templates/ice-mobile-h5+app/tsconfig.json +3 -0
  92. package/templates/ice-mobile-h5+app/typings.d.ts +1 -0
  93. package/templates/ice-mobile-native/.eslintrc +6 -0
  94. package/templates/ice-mobile-native/.gitignore.tpl +42 -0
  95. package/templates/ice-mobile-native/.icerc.ts +8 -0
  96. package/templates/ice-mobile-native/.npmrc.tpl +2 -0
  97. package/templates/ice-mobile-native/.prettierignore +8 -0
  98. package/templates/ice-mobile-native/.prettierrc.js +1 -0
  99. package/templates/ice-mobile-native/.stylelintrc +3 -0
  100. package/templates/ice-mobile-native/README.md.tpl +34 -0
  101. package/templates/ice-mobile-native/android/app/6209ba977ffec7d62675a4e254ebc209.keystore +0 -0
  102. package/templates/ice-mobile-native/android/app/build.gradle +66 -0
  103. package/templates/ice-mobile-native/android/app/libs/Bluetooth-release.aar +0 -0
  104. package/templates/ice-mobile-native/android/app/libs/PosPrinterSDK.jar +0 -0
  105. package/templates/ice-mobile-native/android/app/libs/android-gif-drawable-release@1.2.23.aar +0 -0
  106. package/templates/ice-mobile-native/android/app/libs/lib.5plus.base-release.aar +0 -0
  107. package/templates/ice-mobile-native/android/app/libs/oaid_sdk_1.0.25.aar +0 -0
  108. package/templates/ice-mobile-native/android/app/libs/webview-x5-release.aar +0 -0
  109. package/templates/ice-mobile-native/android/app/proguard-rules.pro +303 -0
  110. package/templates/ice-mobile-native/android/app/src/main/AndroidManifest.xml +98 -0
  111. package/templates/ice-mobile-native/android/app/src/main/assets/apps/H5ECA1DEE/www/manifest.json +89 -0
  112. package/templates/ice-mobile-native/android/app/src/main/assets/data/dcloud_control.xml +6 -0
  113. package/templates/ice-mobile-native/android/app/src/main/assets/data/dcloud_error.html +92 -0
  114. package/templates/ice-mobile-native/android/app/src/main/assets/data/dcloud_properties.xml +19 -0
  115. package/templates/ice-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/JSBridge/FunctionCreator.java +119 -0
  116. package/templates/ice-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/MPandoraEntryActivity.java +17 -0
  117. package/templates/ice-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/Xprinter/FunctionFactory/Creator.java +17 -0
  118. package/templates/ice-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/Xprinter/FunctionFactory/Error.java +26 -0
  119. package/templates/ice-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/Xprinter/JSPlugin.java +265 -0
  120. package/templates/ice-mobile-native/android/app/src/main/res/drawable/icon.png +0 -0
  121. package/templates/ice-mobile-native/android/app/src/main/res/values/colors.xml +5 -0
  122. package/templates/ice-mobile-native/android/app/src/main/res/values/strings.xml +3 -0
  123. package/templates/ice-mobile-native/android/build.gradle +9 -0
  124. package/templates/ice-mobile-native/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  125. package/templates/ice-mobile-native/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  126. package/templates/ice-mobile-native/android/gradle.properties +22 -0
  127. package/templates/ice-mobile-native/android/gradlew +185 -0
  128. package/templates/ice-mobile-native/android/gradlew.bat +89 -0
  129. package/templates/ice-mobile-native/android/settings.gradle +16 -0
  130. package/templates/ice-mobile-native/ios/HBuilder/HBuilder.entitlements +5 -0
  131. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/1024x1024.png +0 -0
  132. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/120x120-1.png +0 -0
  133. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/120x120.png +0 -0
  134. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/180x180.png +0 -0
  135. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/40x40.png +0 -0
  136. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/58x58.png +0 -0
  137. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/60x60.png +0 -0
  138. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/80x80.png +0 -0
  139. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/87x87.png +0 -0
  140. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/Contents.json +62 -0
  141. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/Contents.json +6 -0
  142. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/Image.imageset/Contents.json +20 -0
  143. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/120x120.png +0 -0
  144. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/180x180.png +0 -0
  145. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/60x60.png +0 -0
  146. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/Contents.json +26 -0
  147. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/control_brightness.imageset/Contents.json +21 -0
  148. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/control_brightness.imageset/brightness@2x.png +0 -0
  149. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/exitfullscreen.imageset/Contents.json +22 -0
  150. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/exitfullscreen.imageset/shrinkscreen@2x.png +0 -0
  151. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/exitfullscreen.imageset/shrinkscreen@3x.png +0 -0
  152. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/exposure_slider_max.imageset/Contents.json +22 -0
  153. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/exposure_slider_max.imageset//346/233/235/345/205/211-1.png +0 -0
  154. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/exposure_slider_max.imageset//346/233/235/345/205/211.png +0 -0
  155. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_border.imageset/Contents.json +22 -0
  156. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_border.imageset//345/257/271/347/204/246/346/241/206-1.png +0 -0
  157. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_border.imageset//345/257/271/347/204/246/346/241/206.png +0 -0
  158. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_line.imageset/Contents.json +21 -0
  159. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_line.imageset//345/257/271/347/204/246/347/272/277.png +0 -0
  160. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_thumb.imageset/Contents.json +22 -0
  161. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_thumb.imageset//345/257/271/347/204/246/345/272/225-1.png +0 -0
  162. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_thumb.imageset//345/257/271/347/204/246/345/272/225.png +0 -0
  163. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/full-screen.imageset/Contents.json +22 -0
  164. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/full-screen.imageset/fullscreen@2x.png +0 -0
  165. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/full-screen.imageset/fullscreen@3x.png +0 -0
  166. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/Contents.json +23 -0
  167. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/play.png +0 -0
  168. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/play@2x.png +0 -0
  169. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/play@3x.png +0 -0
  170. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/Contents.json +23 -0
  171. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/player_back.png +0 -0
  172. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/player_back@2x.png +0 -0
  173. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/player_back@3x.png +0 -0
  174. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/Contents.json +23 -0
  175. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/play.png +0 -0
  176. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/play@2x.png +0 -0
  177. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/play@3x.png +0 -0
  178. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/Contents.json +23 -0
  179. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/player-stop.png +0 -0
  180. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/player-stop@2x.png +0 -0
  181. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/player-stop@3x.png +0 -0
  182. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteoff.imageset/Contents.json +22 -0
  183. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteoff.imageset/video_ic_muteoff@2x.png +0 -0
  184. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteoff.imageset/video_ic_muteoff@3x.png +0 -0
  185. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteon.imageset/Contents.json +22 -0
  186. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteon.imageset/video_ic_muteon@2x.png +0 -0
  187. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteon.imageset/video_ic_muteon@3x.png +0 -0
  188. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_volume.imageset/Contents.json +22 -0
  189. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_volume.imageset/video_volume@2x.png +0 -0
  190. package/templates/ice-mobile-native/ios/HBuilder/Images.xcassets/video_volume.imageset/video_volume@3x.png +0 -0
  191. package/templates/ice-mobile-native/ios/HBuilder-Hello/120x120.png +0 -0
  192. package/templates/ice-mobile-native/ios/HBuilder-Hello/180x180.png +0 -0
  193. package/templates/ice-mobile-native/ios/HBuilder-Hello/AppDelegate.h +16 -0
  194. package/templates/ice-mobile-native/ios/HBuilder-Hello/AppDelegate.m +225 -0
  195. package/templates/ice-mobile-native/ios/HBuilder-Hello/Base.lproj/LaunchScreen.storyboard +65 -0
  196. package/templates/ice-mobile-native/ios/HBuilder-Hello/English.lproj/Localizable.strings +13 -0
  197. package/templates/ice-mobile-native/ios/HBuilder-Hello/HBuilder-Hello-Info.plist +486 -0
  198. package/templates/ice-mobile-native/ios/HBuilder-Hello/HBuilder-Hello-Prefix.pch +16 -0
  199. package/templates/ice-mobile-native/ios/HBuilder-Hello/LaunchScreen.storyboard +67 -0
  200. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/manifest.json +79 -0
  201. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/1024x1024.png +0 -0
  202. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/120x120.png +0 -0
  203. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/144x144.png +0 -0
  204. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/152x152.png +0 -0
  205. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/167x167.png +0 -0
  206. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/180x180.png +0 -0
  207. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/192x192.png +0 -0
  208. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/20x20.png +0 -0
  209. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/29x29.png +0 -0
  210. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/40x40.png +0 -0
  211. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/58x58.png +0 -0
  212. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/60x60.png +0 -0
  213. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/72x72.png +0 -0
  214. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/76x76.png +0 -0
  215. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/80x80.png +0 -0
  216. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/87x87.png +0 -0
  217. package/templates/ice-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/96x96.png +0 -0
  218. package/templates/ice-mobile-native/ios/HBuilder-Hello/ViewController.h +19 -0
  219. package/templates/ice-mobile-native/ios/HBuilder-Hello/ViewController.m +161 -0
  220. package/templates/ice-mobile-native/ios/HBuilder-Hello/Xprinter.h +19 -0
  221. package/templates/ice-mobile-native/ios/HBuilder-Hello/Xprinter.m +235 -0
  222. package/templates/ice-mobile-native/ios/HBuilder-Hello/control.xml +107 -0
  223. package/templates/ice-mobile-native/ios/HBuilder-Hello/en.lproj/InfoPlist.strings +4 -0
  224. package/templates/ice-mobile-native/ios/HBuilder-Hello/en.lproj/Localizable.strings +12 -0
  225. package/templates/ice-mobile-native/ios/HBuilder-Hello/main.m +18 -0
  226. package/templates/ice-mobile-native/ios/HBuilder-Hello/zh-Hans.lproj/InfoPlist.strings +4 -0
  227. package/templates/ice-mobile-native/ios/HBuilder-Hello/zh-Hans.lproj/LaunchScreen.strings +3 -0
  228. package/templates/ice-mobile-native/ios/HBuilder-Hello/zh-Hans.lproj/Localizable.strings +13 -0
  229. package/templates/ice-mobile-native/ios/HBuilder-Hello.xcodeproj/project.pbxproj +1607 -0
  230. package/templates/ice-mobile-native/package.json.tpl +16 -0
  231. package/templates/ice-mobile-native/public/favicon.ico +0 -0
  232. package/templates/ice-mobile-native/public/index.html +15 -0
  233. package/templates/ice-mobile-native/src/app.tsx +5 -0
  234. package/templates/ice-mobile-native/src/common/Xprinter.ts +58 -0
  235. package/templates/ice-mobile-native/src/common/bluetooth.ts +354 -0
  236. package/templates/ice-mobile-native/src/common/bridge.ts +59 -0
  237. package/templates/ice-mobile-native/src/common/request.ts +3 -0
  238. package/templates/ice-mobile-native/src/common/util.ts +7 -0
  239. package/templates/ice-mobile-native/src/components/index.ts +0 -0
  240. package/templates/ice-mobile-native/src/global.less +3 -0
  241. package/templates/ice-mobile-native/src/layouts/index.tsx +5 -0
  242. package/templates/ice-mobile-native/src/pages/404.tsx +10 -0
  243. package/templates/ice-mobile-native/src/pages/demo/examples/BarCode.tsx +4 -0
  244. package/templates/ice-mobile-native/src/pages/demo/examples/Iconfont.tsx +18 -0
  245. package/templates/ice-mobile-native/src/pages/demo/examples/Input.tsx +16 -0
  246. package/templates/ice-mobile-native/src/pages/demo/examples/List/1.tsx +12 -0
  247. package/templates/ice-mobile-native/src/pages/demo/examples/List/2.tsx +29 -0
  248. package/templates/ice-mobile-native/src/pages/demo/examples/List/3.tsx +29 -0
  249. package/templates/ice-mobile-native/src/pages/demo/examples/List/4.tsx +55 -0
  250. package/templates/ice-mobile-native/src/pages/demo/examples/List/mock.ts +30 -0
  251. package/templates/ice-mobile-native/src/pages/demo/examples/Loading.tsx +12 -0
  252. package/templates/ice-mobile-native/src/pages/demo/examples/NumberInput/1.tsx +16 -0
  253. package/templates/ice-mobile-native/src/pages/demo/examples/NumberInput/2.tsx +16 -0
  254. package/templates/ice-mobile-native/src/pages/demo/examples/NumberInput/3.tsx +16 -0
  255. package/templates/ice-mobile-native/src/pages/demo/examples/NumberInput/4.tsx +16 -0
  256. package/templates/ice-mobile-native/src/pages/demo/examples/PagingList/1.tsx +6 -0
  257. package/templates/ice-mobile-native/src/pages/demo/examples/QrCode.tsx +4 -0
  258. package/templates/ice-mobile-native/src/pages/demo/examples/Required.tsx +4 -0
  259. package/templates/ice-mobile-native/src/pages/demo/examples/TimerButton.tsx +4 -0
  260. package/templates/ice-mobile-native/src/pages/demo/examples/Xprinter/index.tsx +64 -0
  261. package/templates/ice-mobile-native/src/pages/demo/examples/Xprinter/style.less +16 -0
  262. package/templates/ice-mobile-native/src/pages/demo/examples/usePreload.tsx +9 -0
  263. package/templates/ice-mobile-native/src/pages/demo/index.tsx +89 -0
  264. package/templates/ice-mobile-native/src/pages/index.tsx +3 -0
  265. package/templates/ice-mobile-native/src/routes.ts +29 -0
  266. package/templates/ice-mobile-native/src/types/user.d.ts +3 -0
  267. package/templates/ice-mobile-native/tsconfig.json +3 -0
  268. package/templates/ice-mobile-native/typings.d.ts +1 -0
  269. package/templates/ice-web/.eslintrc +1 -1
  270. package/templates/ice-web/.gitignore.tpl +10 -3
  271. package/templates/ice-web/.icerc.ts +1 -1
  272. package/templates/ice-web/.npmrc.tpl +2 -0
  273. package/templates/ice-web/.prettierignore +4 -5
  274. package/templates/ice-web/.prettierrc.js +1 -0
  275. package/templates/ice-web/README.md.tpl +1 -1
  276. package/templates/ice-web/package.json.tpl +5 -0
  277. package/templates/ice-web/public/index.html +15 -0
  278. package/templates/ice-web/src/app.tsx +1 -1
  279. package/templates/ice-web/src/pages/demo/examples/BankInput.tsx +1 -2
  280. package/templates/ice-web/src/pages/demo/examples/Grid/5.tsx +1 -2
  281. package/templates/ice-web/src/pages/demo/examples/Input/2.tsx +2 -1
  282. package/templates/ice-web/src/pages/demo/examples/RangeNumber/2.tsx +1 -2
  283. package/templates/ice-web/src/pages/demo/examples/SearchLayout.tsx +2 -2
  284. package/templates/ice-web/src/pages/demo/examples/Wrapper.tsx +1 -1
  285. package/templates/ice-web/src/routes.ts +2 -1
  286. package/templates/ice-web-screen/.eslintrc +6 -0
  287. package/templates/ice-web-screen/.gitignore.tpl +37 -0
  288. package/templates/ice-web-screen/.icerc.ts +3 -0
  289. package/templates/ice-web-screen/.npmrc.tpl +2 -0
  290. package/templates/ice-web-screen/.prettierignore +8 -0
  291. package/templates/ice-web-screen/.prettierrc.js +1 -0
  292. package/templates/ice-web-screen/.stylelintrc +3 -0
  293. package/templates/ice-web-screen/README.md.tpl +34 -0
  294. package/templates/ice-web-screen/package.json.tpl +17 -0
  295. package/templates/ice-web-screen/public/favicon.ico +0 -0
  296. package/templates/ice-web-screen/public/index.html +15 -0
  297. package/templates/ice-web-screen/src/app.tsx +5 -0
  298. package/templates/ice-web-screen/src/common/request.ts +3 -0
  299. package/templates/ice-web-screen/src/common/util.ts +15 -0
  300. package/templates/ice-web-screen/src/components/index.ts +1 -0
  301. package/templates/ice-web-screen/src/components/resize-container/index.tsx +95 -0
  302. package/templates/ice-web-screen/src/components/resize-container/style.module.less +3 -0
  303. package/templates/ice-web-screen/src/constants.ts +7 -0
  304. package/templates/ice-web-screen/src/global.less +31 -0
  305. package/templates/ice-web-screen/src/hooks/use-size.ts +18 -0
  306. package/templates/ice-web-screen/src/layouts/16_9/fixed.less +18 -0
  307. package/templates/ice-web-screen/src/layouts/16_9/index.tsx +34 -0
  308. package/templates/ice-web-screen/src/layouts/16_9/style.module.less +19 -0
  309. package/templates/ice-web-screen/src/layouts/components/index.ts +0 -0
  310. package/templates/ice-web-screen/src/layouts/controller/index.tsx +79 -0
  311. package/templates/ice-web-screen/src/layouts/index.tsx +11 -0
  312. package/templates/ice-web-screen/src/pages/404.tsx +17 -0
  313. package/templates/ice-web-screen/src/pages/index.tsx +3 -0
  314. package/templates/ice-web-screen/src/pages/template/16_9/index.tsx +13 -0
  315. package/templates/ice-web-screen/src/pages/template/16_9/style.module.less +7 -0
  316. package/templates/ice-web-screen/src/pages/template/components/charts/demo-line/index.tsx +274 -0
  317. package/templates/ice-web-screen/src/pages/template/components/charts/index.ts +1 -0
  318. package/templates/ice-web-screen/src/pages/template/components/index.ts +1 -0
  319. package/templates/ice-web-screen/src/pages/template/controller/index.tsx +85 -0
  320. package/templates/ice-web-screen/src/pages/template/index.tsx +15 -0
  321. package/templates/ice-web-screen/src/pages/template/style.module.less +3 -0
  322. package/templates/ice-web-screen/src/routes.ts +29 -0
  323. package/templates/ice-web-screen/src/styles/vars.less +5 -0
  324. package/templates/ice-web-screen/src/types/user.d.ts +3 -0
  325. package/templates/ice-web-screen/tsconfig.json +3 -0
  326. package/templates/ice-web-screen/typings.d.ts +1 -0
  327. package/templates/miniprogram/.eslintrc +1 -1
  328. package/templates/miniprogram/.gitignore.tpl +12 -11
  329. package/templates/miniprogram/.npmrc.tpl +2 -0
  330. package/templates/miniprogram/.prettierignore +5 -1
  331. package/templates/miniprogram/.prettierrc.js +1 -0
  332. package/templates/miniprogram/README.md.tpl +2 -2
  333. package/templates/miniprogram/global.d.ts +1 -33
  334. package/templates/miniprogram/package.json.tpl +6 -2
  335. package/templates/miniprogram/src/pages/demo/examples/Input.tsx +11 -2
  336. package/templates/miniprogram/src/pages/demo/{index.module.scss → style.scss} +0 -0
  337. package/templates/miniprogram/src/pages/index/index.tsx +3 -1
  338. package/templates/miniprogram/src/pages/index/{index.module.scss → style.scss} +0 -0
  339. package/templates/umi-mobile/.eslintrc +1 -1
  340. package/templates/umi-mobile/.gitignore.tpl +8 -5
  341. package/templates/umi-mobile/.npmrc.tpl +2 -0
  342. package/templates/umi-mobile/.prettierignore +6 -2
  343. package/templates/umi-mobile/.prettierrc.js +1 -0
  344. package/templates/umi-mobile/.umirc.ts.tpl +2 -1
  345. package/templates/umi-mobile/README.md.tpl +2 -2
  346. package/templates/umi-mobile/package.json.tpl +5 -0
  347. package/templates/umi-mobile/src/app.tsx +1 -1
  348. package/templates/umi-mobile/src/pages/demo/examples/Input.tsx +1 -2
  349. package/templates/umi-mobile/src/pages/demo/examples/List/4.tsx +2 -2
  350. package/templates/umi-mobile/src/pages/demo/examples/NumberInput/1.tsx +1 -2
  351. package/templates/umi-mobile/src/pages/demo/examples/NumberInput/2.tsx +1 -2
  352. package/templates/umi-mobile/src/pages/demo/examples/NumberInput/3.tsx +1 -2
  353. package/templates/umi-mobile/src/pages/demo/examples/NumberInput/4.tsx +1 -2
  354. package/templates/umi-mobile-h5+app/.eslintrc +6 -0
  355. package/templates/umi-mobile-h5+app/.gitignore.tpl +37 -0
  356. package/templates/umi-mobile-h5+app/.npmrc.tpl +2 -0
  357. package/templates/umi-mobile-h5+app/.prettierignore +12 -0
  358. package/templates/umi-mobile-h5+app/.prettierrc.js +1 -0
  359. package/templates/umi-mobile-h5+app/.stylelintrc +3 -0
  360. package/templates/umi-mobile-h5+app/.umirc.ts.tpl +8 -0
  361. package/templates/umi-mobile-h5+app/LICENSE +21 -0
  362. package/templates/umi-mobile-h5+app/README.md.tpl +34 -0
  363. package/templates/umi-mobile-h5+app/h5+app/manifest.json +87 -0
  364. package/templates/umi-mobile-h5+app/package.json.tpl +16 -0
  365. package/templates/umi-mobile-h5+app/public/favicon.ico +0 -0
  366. package/templates/umi-mobile-h5+app/src/app.tsx +19 -0
  367. package/templates/umi-mobile-h5+app/src/common/request.ts +3 -0
  368. package/templates/umi-mobile-h5+app/src/common/util.ts +7 -0
  369. package/templates/umi-mobile-h5+app/src/components/index.ts +0 -0
  370. package/templates/umi-mobile-h5+app/src/global.less +3 -0
  371. package/templates/umi-mobile-h5+app/src/layouts/index.tsx +3 -0
  372. package/templates/umi-mobile-h5+app/src/pages/404.tsx +10 -0
  373. package/templates/umi-mobile-h5+app/src/pages/demo/examples/BarCode.tsx +4 -0
  374. package/templates/umi-mobile-h5+app/src/pages/demo/examples/Iconfont.tsx +18 -0
  375. package/templates/umi-mobile-h5+app/src/pages/demo/examples/Input.tsx +16 -0
  376. package/templates/umi-mobile-h5+app/src/pages/demo/examples/List/1.tsx +12 -0
  377. package/templates/umi-mobile-h5+app/src/pages/demo/examples/List/2.tsx +29 -0
  378. package/templates/umi-mobile-h5+app/src/pages/demo/examples/List/3.tsx +29 -0
  379. package/templates/umi-mobile-h5+app/src/pages/demo/examples/List/4.tsx +55 -0
  380. package/templates/umi-mobile-h5+app/src/pages/demo/examples/List/mock.ts +30 -0
  381. package/templates/umi-mobile-h5+app/src/pages/demo/examples/Loading.tsx +12 -0
  382. package/templates/umi-mobile-h5+app/src/pages/demo/examples/NumberInput/1.tsx +16 -0
  383. package/templates/umi-mobile-h5+app/src/pages/demo/examples/NumberInput/2.tsx +16 -0
  384. package/templates/umi-mobile-h5+app/src/pages/demo/examples/NumberInput/3.tsx +16 -0
  385. package/templates/umi-mobile-h5+app/src/pages/demo/examples/NumberInput/4.tsx +16 -0
  386. package/templates/umi-mobile-h5+app/src/pages/demo/examples/PagingList/1.tsx +6 -0
  387. package/templates/umi-mobile-h5+app/src/pages/demo/examples/QrCode.tsx +4 -0
  388. package/templates/umi-mobile-h5+app/src/pages/demo/examples/Required.tsx +4 -0
  389. package/templates/umi-mobile-h5+app/src/pages/demo/examples/TimerButton.tsx +4 -0
  390. package/templates/umi-mobile-h5+app/src/pages/demo/examples/usePreload.tsx +9 -0
  391. package/templates/umi-mobile-h5+app/src/pages/demo/index.tsx +87 -0
  392. package/templates/umi-mobile-h5+app/src/pages/index.tsx +3 -0
  393. package/templates/umi-mobile-h5+app/src/types/user.d.ts +3 -0
  394. package/templates/umi-mobile-h5+app/tsconfig.json +3 -0
  395. package/templates/umi-mobile-h5+app/typings.d.ts +1 -0
  396. package/templates/umi-mobile-native/.eslintrc +6 -0
  397. package/templates/umi-mobile-native/.gitignore.tpl +42 -0
  398. package/templates/umi-mobile-native/.npmrc.tpl +2 -0
  399. package/templates/umi-mobile-native/.prettierignore +12 -0
  400. package/templates/umi-mobile-native/.prettierrc.js +1 -0
  401. package/templates/umi-mobile-native/.stylelintrc +3 -0
  402. package/templates/umi-mobile-native/.umirc.ts.tpl +10 -0
  403. package/templates/umi-mobile-native/LICENSE +21 -0
  404. package/templates/umi-mobile-native/README.md.tpl +34 -0
  405. package/templates/umi-mobile-native/android/app/6209ba977ffec7d62675a4e254ebc209.keystore +0 -0
  406. package/templates/umi-mobile-native/android/app/build.gradle +66 -0
  407. package/templates/umi-mobile-native/android/app/libs/Bluetooth-release.aar +0 -0
  408. package/templates/umi-mobile-native/android/app/libs/PosPrinterSDK.jar +0 -0
  409. package/templates/umi-mobile-native/android/app/libs/android-gif-drawable-release@1.2.23.aar +0 -0
  410. package/templates/umi-mobile-native/android/app/libs/lib.5plus.base-release.aar +0 -0
  411. package/templates/umi-mobile-native/android/app/libs/oaid_sdk_1.0.25.aar +0 -0
  412. package/templates/umi-mobile-native/android/app/libs/webview-x5-release.aar +0 -0
  413. package/templates/umi-mobile-native/android/app/proguard-rules.pro +303 -0
  414. package/templates/umi-mobile-native/android/app/src/main/AndroidManifest.xml +98 -0
  415. package/templates/umi-mobile-native/android/app/src/main/assets/apps/H5ECA1DEE/www/manifest.json +89 -0
  416. package/templates/umi-mobile-native/android/app/src/main/assets/data/dcloud_control.xml +6 -0
  417. package/templates/umi-mobile-native/android/app/src/main/assets/data/dcloud_error.html +92 -0
  418. package/templates/umi-mobile-native/android/app/src/main/assets/data/dcloud_properties.xml +19 -0
  419. package/templates/umi-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/JSBridge/FunctionCreator.java +119 -0
  420. package/templates/umi-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/MPandoraEntryActivity.java +17 -0
  421. package/templates/umi-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/Xprinter/FunctionFactory/Creator.java +17 -0
  422. package/templates/umi-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/Xprinter/FunctionFactory/Error.java +26 -0
  423. package/templates/umi-mobile-native/android/app/src/main/java/plus/H5ECA1DEE/Xprinter/JSPlugin.java +265 -0
  424. package/templates/umi-mobile-native/android/app/src/main/res/drawable/icon.png +0 -0
  425. package/templates/umi-mobile-native/android/app/src/main/res/values/colors.xml +5 -0
  426. package/templates/umi-mobile-native/android/app/src/main/res/values/strings.xml +3 -0
  427. package/templates/umi-mobile-native/android/build.gradle +9 -0
  428. package/templates/umi-mobile-native/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  429. package/templates/umi-mobile-native/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  430. package/templates/umi-mobile-native/android/gradle.properties +22 -0
  431. package/templates/umi-mobile-native/android/gradlew +185 -0
  432. package/templates/umi-mobile-native/android/gradlew.bat +89 -0
  433. package/templates/umi-mobile-native/android/settings.gradle +16 -0
  434. package/templates/umi-mobile-native/ios/HBuilder/HBuilder.entitlements +5 -0
  435. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/1024x1024.png +0 -0
  436. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/120x120-1.png +0 -0
  437. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/120x120.png +0 -0
  438. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/180x180.png +0 -0
  439. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/40x40.png +0 -0
  440. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/58x58.png +0 -0
  441. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/60x60.png +0 -0
  442. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/80x80.png +0 -0
  443. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/87x87.png +0 -0
  444. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/AppIcon.appiconset/Contents.json +62 -0
  445. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/Contents.json +6 -0
  446. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/Image.imageset/Contents.json +20 -0
  447. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/120x120.png +0 -0
  448. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/180x180.png +0 -0
  449. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/60x60.png +0 -0
  450. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/app.imageset/Contents.json +26 -0
  451. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/control_brightness.imageset/Contents.json +21 -0
  452. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/control_brightness.imageset/brightness@2x.png +0 -0
  453. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/exitfullscreen.imageset/Contents.json +22 -0
  454. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/exitfullscreen.imageset/shrinkscreen@2x.png +0 -0
  455. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/exitfullscreen.imageset/shrinkscreen@3x.png +0 -0
  456. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/exposure_slider_max.imageset/Contents.json +22 -0
  457. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/exposure_slider_max.imageset//346/233/235/345/205/211-1.png +0 -0
  458. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/exposure_slider_max.imageset//346/233/235/345/205/211.png +0 -0
  459. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_border.imageset/Contents.json +22 -0
  460. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_border.imageset//345/257/271/347/204/246/346/241/206-1.png +0 -0
  461. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_border.imageset//345/257/271/347/204/246/346/241/206.png +0 -0
  462. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_line.imageset/Contents.json +21 -0
  463. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_line.imageset//345/257/271/347/204/246/347/272/277.png +0 -0
  464. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_thumb.imageset/Contents.json +22 -0
  465. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_thumb.imageset//345/257/271/347/204/246/345/272/225-1.png +0 -0
  466. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/focus_slider_thumb.imageset//345/257/271/347/204/246/345/272/225.png +0 -0
  467. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/full-screen.imageset/Contents.json +22 -0
  468. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/full-screen.imageset/fullscreen@2x.png +0 -0
  469. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/full-screen.imageset/fullscreen@3x.png +0 -0
  470. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/Contents.json +23 -0
  471. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/play.png +0 -0
  472. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/play@2x.png +0 -0
  473. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/play.imageset/play@3x.png +0 -0
  474. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/Contents.json +23 -0
  475. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/player_back.png +0 -0
  476. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/player_back@2x.png +0 -0
  477. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_back.imageset/player_back@3x.png +0 -0
  478. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/Contents.json +23 -0
  479. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/play.png +0 -0
  480. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/play@2x.png +0 -0
  481. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_play.imageset/play@3x.png +0 -0
  482. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/Contents.json +23 -0
  483. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/player-stop.png +0 -0
  484. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/player-stop@2x.png +0 -0
  485. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/player_stop.imageset/player-stop@3x.png +0 -0
  486. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteoff.imageset/Contents.json +22 -0
  487. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteoff.imageset/video_ic_muteoff@2x.png +0 -0
  488. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteoff.imageset/video_ic_muteoff@3x.png +0 -0
  489. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteon.imageset/Contents.json +22 -0
  490. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteon.imageset/video_ic_muteon@2x.png +0 -0
  491. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_ic_muteon.imageset/video_ic_muteon@3x.png +0 -0
  492. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_volume.imageset/Contents.json +22 -0
  493. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_volume.imageset/video_volume@2x.png +0 -0
  494. package/templates/umi-mobile-native/ios/HBuilder/Images.xcassets/video_volume.imageset/video_volume@3x.png +0 -0
  495. package/templates/umi-mobile-native/ios/HBuilder-Hello/120x120.png +0 -0
  496. package/templates/umi-mobile-native/ios/HBuilder-Hello/180x180.png +0 -0
  497. package/templates/umi-mobile-native/ios/HBuilder-Hello/AppDelegate.h +16 -0
  498. package/templates/umi-mobile-native/ios/HBuilder-Hello/AppDelegate.m +225 -0
  499. package/templates/umi-mobile-native/ios/HBuilder-Hello/Base.lproj/LaunchScreen.storyboard +65 -0
  500. package/templates/umi-mobile-native/ios/HBuilder-Hello/English.lproj/Localizable.strings +13 -0
  501. package/templates/umi-mobile-native/ios/HBuilder-Hello/HBuilder-Hello-Info.plist +486 -0
  502. package/templates/umi-mobile-native/ios/HBuilder-Hello/HBuilder-Hello-Prefix.pch +16 -0
  503. package/templates/umi-mobile-native/ios/HBuilder-Hello/LaunchScreen.storyboard +67 -0
  504. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/manifest.json +79 -0
  505. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/1024x1024.png +0 -0
  506. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/120x120.png +0 -0
  507. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/144x144.png +0 -0
  508. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/152x152.png +0 -0
  509. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/167x167.png +0 -0
  510. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/180x180.png +0 -0
  511. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/192x192.png +0 -0
  512. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/20x20.png +0 -0
  513. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/29x29.png +0 -0
  514. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/40x40.png +0 -0
  515. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/58x58.png +0 -0
  516. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/60x60.png +0 -0
  517. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/72x72.png +0 -0
  518. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/76x76.png +0 -0
  519. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/80x80.png +0 -0
  520. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/87x87.png +0 -0
  521. package/templates/umi-mobile-native/ios/HBuilder-Hello/Pandora/apps/H5ECA1DEE/www/unpackage/res/icons/96x96.png +0 -0
  522. package/templates/umi-mobile-native/ios/HBuilder-Hello/ViewController.h +19 -0
  523. package/templates/umi-mobile-native/ios/HBuilder-Hello/ViewController.m +161 -0
  524. package/templates/umi-mobile-native/ios/HBuilder-Hello/Xprinter.h +19 -0
  525. package/templates/umi-mobile-native/ios/HBuilder-Hello/Xprinter.m +235 -0
  526. package/templates/umi-mobile-native/ios/HBuilder-Hello/control.xml +107 -0
  527. package/templates/umi-mobile-native/ios/HBuilder-Hello/en.lproj/InfoPlist.strings +4 -0
  528. package/templates/umi-mobile-native/ios/HBuilder-Hello/en.lproj/Localizable.strings +12 -0
  529. package/templates/umi-mobile-native/ios/HBuilder-Hello/main.m +18 -0
  530. package/templates/umi-mobile-native/ios/HBuilder-Hello/zh-Hans.lproj/InfoPlist.strings +4 -0
  531. package/templates/umi-mobile-native/ios/HBuilder-Hello/zh-Hans.lproj/LaunchScreen.strings +3 -0
  532. package/templates/umi-mobile-native/ios/HBuilder-Hello/zh-Hans.lproj/Localizable.strings +13 -0
  533. package/templates/umi-mobile-native/ios/HBuilder-Hello.xcodeproj/project.pbxproj +1607 -0
  534. package/templates/umi-mobile-native/package.json.tpl +16 -0
  535. package/templates/umi-mobile-native/public/favicon.ico +0 -0
  536. package/templates/umi-mobile-native/src/app.tsx +19 -0
  537. package/templates/umi-mobile-native/src/common/Xprinter.ts +58 -0
  538. package/templates/umi-mobile-native/src/common/bluetooth.ts +354 -0
  539. package/templates/umi-mobile-native/src/common/bridge.ts +59 -0
  540. package/templates/umi-mobile-native/src/common/request.ts +3 -0
  541. package/templates/umi-mobile-native/src/common/util.ts +7 -0
  542. package/templates/umi-mobile-native/src/components/index.ts +0 -0
  543. package/templates/umi-mobile-native/src/global.less +3 -0
  544. package/templates/umi-mobile-native/src/images/head.png +0 -0
  545. package/templates/umi-mobile-native/src/layouts/index.tsx +3 -0
  546. package/templates/umi-mobile-native/src/pages/404.tsx +10 -0
  547. package/templates/umi-mobile-native/src/pages/demo/examples/BarCode.tsx +4 -0
  548. package/templates/umi-mobile-native/src/pages/demo/examples/Iconfont.tsx +18 -0
  549. package/templates/umi-mobile-native/src/pages/demo/examples/Input.tsx +16 -0
  550. package/templates/umi-mobile-native/src/pages/demo/examples/List/1.tsx +12 -0
  551. package/templates/umi-mobile-native/src/pages/demo/examples/List/2.tsx +29 -0
  552. package/templates/umi-mobile-native/src/pages/demo/examples/List/3.tsx +29 -0
  553. package/templates/umi-mobile-native/src/pages/demo/examples/List/4.tsx +55 -0
  554. package/templates/umi-mobile-native/src/pages/demo/examples/List/mock.ts +30 -0
  555. package/templates/umi-mobile-native/src/pages/demo/examples/Loading.tsx +12 -0
  556. package/templates/umi-mobile-native/src/pages/demo/examples/NumberInput/1.tsx +16 -0
  557. package/templates/umi-mobile-native/src/pages/demo/examples/NumberInput/2.tsx +16 -0
  558. package/templates/umi-mobile-native/src/pages/demo/examples/NumberInput/3.tsx +16 -0
  559. package/templates/umi-mobile-native/src/pages/demo/examples/NumberInput/4.tsx +16 -0
  560. package/templates/umi-mobile-native/src/pages/demo/examples/PagingList/1.tsx +6 -0
  561. package/templates/umi-mobile-native/src/pages/demo/examples/QrCode.tsx +4 -0
  562. package/templates/umi-mobile-native/src/pages/demo/examples/Required.tsx +4 -0
  563. package/templates/umi-mobile-native/src/pages/demo/examples/TimerButton.tsx +4 -0
  564. package/templates/umi-mobile-native/src/pages/demo/examples/Xprinter/index.tsx +64 -0
  565. package/templates/umi-mobile-native/src/pages/demo/examples/Xprinter/style.less +16 -0
  566. package/templates/umi-mobile-native/src/pages/demo/examples/usePreload.tsx +9 -0
  567. package/templates/umi-mobile-native/src/pages/demo/index.tsx +89 -0
  568. package/templates/umi-mobile-native/src/pages/index.tsx +9 -0
  569. package/templates/umi-mobile-native/src/pages/style.less +6 -0
  570. package/templates/umi-mobile-native/src/types/user.d.ts +3 -0
  571. package/templates/umi-mobile-native/tsconfig.json +3 -0
  572. package/templates/umi-mobile-native/typings.d.ts +1 -0
  573. package/templates/umi-web/.eslintrc +1 -1
  574. package/templates/umi-web/.gitignore.tpl +8 -5
  575. package/templates/umi-web/.npmrc.tpl +2 -0
  576. package/templates/umi-web/.prettierignore +6 -2
  577. package/templates/umi-web/.prettierrc.js +1 -0
  578. package/templates/umi-web/.umirc.ts.tpl +1 -1
  579. package/templates/umi-web/README.md.tpl +1 -1
  580. package/templates/umi-web/package.json.tpl +5 -0
  581. package/templates/umi-web/src/app.tsx +1 -1
  582. package/templates/umi-web/src/pages/demo/examples/BankInput.tsx +1 -2
  583. package/templates/umi-web/src/pages/demo/examples/Grid/5.tsx +1 -2
  584. package/templates/umi-web/src/pages/demo/examples/Input/2.tsx +2 -1
  585. package/templates/umi-web/src/pages/demo/examples/RangeNumber/2.tsx +1 -2
  586. package/templates/umi-web/src/pages/demo/examples/SearchLayout.tsx +2 -2
  587. package/templates/umi-web/src/pages/demo/examples/Wrapper.tsx +1 -1
  588. package/templates/umi-web-screen/.eslintrc +6 -0
  589. package/templates/umi-web-screen/.gitignore.tpl +37 -0
  590. package/templates/umi-web-screen/.npmrc.tpl +2 -0
  591. package/templates/umi-web-screen/.prettierignore +12 -0
  592. package/templates/umi-web-screen/.prettierrc.js +1 -0
  593. package/templates/umi-web-screen/.stylelintrc +3 -0
  594. package/templates/umi-web-screen/.umirc.ts.tpl +8 -0
  595. package/templates/umi-web-screen/LICENSE +21 -0
  596. package/templates/umi-web-screen/README.md.tpl +34 -0
  597. package/templates/umi-web-screen/package.json.tpl +17 -0
  598. package/templates/umi-web-screen/public/favicon.ico +0 -0
  599. package/templates/umi-web-screen/src/app.tsx +19 -0
  600. package/templates/umi-web-screen/src/common/request.ts +3 -0
  601. package/templates/umi-web-screen/src/common/util.ts +15 -0
  602. package/templates/umi-web-screen/src/components/index.ts +1 -0
  603. package/templates/umi-web-screen/src/components/resize-container/index.tsx +95 -0
  604. package/templates/umi-web-screen/src/components/resize-container/style.less +3 -0
  605. package/templates/umi-web-screen/src/constants.ts +7 -0
  606. package/templates/umi-web-screen/src/global.less +28 -0
  607. package/templates/umi-web-screen/src/hooks/use-size.ts +18 -0
  608. package/templates/umi-web-screen/src/layouts/16_9/fixed.less +16 -0
  609. package/templates/umi-web-screen/src/layouts/16_9/index.tsx +30 -0
  610. package/templates/umi-web-screen/src/layouts/16_9/style.less +17 -0
  611. package/templates/umi-web-screen/src/layouts/components/index.ts +0 -0
  612. package/templates/umi-web-screen/src/layouts/controller/index.tsx +79 -0
  613. package/templates/umi-web-screen/src/layouts/index.tsx +11 -0
  614. package/templates/umi-web-screen/src/pages/404.tsx +17 -0
  615. package/templates/umi-web-screen/src/pages/index.tsx +3 -0
  616. package/templates/umi-web-screen/src/pages/template/16_9/index.tsx +13 -0
  617. package/templates/umi-web-screen/src/pages/template/16_9/style.less +7 -0
  618. package/templates/umi-web-screen/src/pages/template/components/charts/demo-line/index.tsx +274 -0
  619. package/templates/umi-web-screen/src/pages/template/components/charts/index.ts +1 -0
  620. package/templates/umi-web-screen/src/pages/template/components/index.ts +1 -0
  621. package/templates/umi-web-screen/src/pages/template/controller/index.tsx +85 -0
  622. package/templates/umi-web-screen/src/pages/template/index.tsx +15 -0
  623. package/templates/umi-web-screen/src/pages/template/style.less +3 -0
  624. package/templates/umi-web-screen/src/styles/vars.less +5 -0
  625. package/templates/umi-web-screen/src/types/user.d.ts +3 -0
  626. package/templates/umi-web-screen/tsconfig.json +3 -0
  627. package/templates/umi-web-screen/typings.d.ts +1 -0
  628. package/templates/ice-mobile/.prettierrc +0 -11
  629. package/templates/ice-web/.eslintcache +0 -1
  630. package/templates/ice-web/.prettierrc +0 -11
  631. package/templates/miniprogram/.editorconfig +0 -12
  632. package/templates/miniprogram/.prettierrc +0 -12
  633. package/templates/miniprogram/src/pages/demo/index.module.scss.d.ts +0 -5
  634. package/templates/miniprogram/src/pages/index/index.module.scss.d.ts +0 -5
  635. package/templates/umi-mobile/.prettierrc +0 -11
  636. package/templates/umi-web/.prettierrc +0 -11
@@ -0,0 +1,1970 @@
1
+ /******/ (function() { // webpackBootstrap
2
+ /******/ var __webpack_modules__ = ({
3
+
4
+ /***/ 138:
5
+ /***/ (function(module, exports, __nccwpck_require__) {
6
+
7
+ /**
8
+ * Module dependencies.
9
+ */
10
+
11
+ const EventEmitter = (__nccwpck_require__(361).EventEmitter);
12
+ const spawn = (__nccwpck_require__(81).spawn);
13
+ const path = __nccwpck_require__(17);
14
+ const fs = __nccwpck_require__(147);
15
+
16
+ // @ts-check
17
+
18
+ class Option {
19
+ /**
20
+ * Initialize a new `Option` with the given `flags` and `description`.
21
+ *
22
+ * @param {string} flags
23
+ * @param {string} description
24
+ * @api public
25
+ */
26
+
27
+ constructor(flags, description) {
28
+ this.flags = flags;
29
+ this.required = flags.includes('<'); // A value must be supplied when the option is specified.
30
+ this.optional = flags.includes('['); // A value is optional when the option is specified.
31
+ // variadic test ignores <value,...> et al which might be used to describe custom splitting of single argument
32
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags); // The option can take multiple values.
33
+ this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.
34
+ const optionFlags = _parseOptionFlags(flags);
35
+ this.short = optionFlags.shortFlag;
36
+ this.long = optionFlags.longFlag;
37
+ this.negate = false;
38
+ if (this.long) {
39
+ this.negate = this.long.startsWith('--no-');
40
+ }
41
+ this.description = description || '';
42
+ this.defaultValue = undefined;
43
+ }
44
+
45
+ /**
46
+ * Return option name.
47
+ *
48
+ * @return {string}
49
+ * @api private
50
+ */
51
+
52
+ name() {
53
+ if (this.long) {
54
+ return this.long.replace(/^--/, '');
55
+ }
56
+ return this.short.replace(/^-/, '');
57
+ };
58
+
59
+ /**
60
+ * Return option name, in a camelcase format that can be used
61
+ * as a object attribute key.
62
+ *
63
+ * @return {string}
64
+ * @api private
65
+ */
66
+
67
+ attributeName() {
68
+ return camelcase(this.name().replace(/^no-/, ''));
69
+ };
70
+
71
+ /**
72
+ * Check if `arg` matches the short or long flag.
73
+ *
74
+ * @param {string} arg
75
+ * @return {boolean}
76
+ * @api private
77
+ */
78
+
79
+ is(arg) {
80
+ return this.short === arg || this.long === arg;
81
+ };
82
+ }
83
+
84
+ /**
85
+ * CommanderError class
86
+ * @class
87
+ */
88
+ class CommanderError extends Error {
89
+ /**
90
+ * Constructs the CommanderError class
91
+ * @param {number} exitCode suggested exit code which could be used with process.exit
92
+ * @param {string} code an id string representing the error
93
+ * @param {string} message human-readable description of the error
94
+ * @constructor
95
+ */
96
+ constructor(exitCode, code, message) {
97
+ super(message);
98
+ // properly capture stack trace in Node.js
99
+ Error.captureStackTrace(this, this.constructor);
100
+ this.name = this.constructor.name;
101
+ this.code = code;
102
+ this.exitCode = exitCode;
103
+ this.nestedError = undefined;
104
+ }
105
+ }
106
+
107
+ class Command extends EventEmitter {
108
+ /**
109
+ * Initialize a new `Command`.
110
+ *
111
+ * @param {string} [name]
112
+ * @api public
113
+ */
114
+
115
+ constructor(name) {
116
+ super();
117
+ this.commands = [];
118
+ this.options = [];
119
+ this.parent = null;
120
+ this._allowUnknownOption = false;
121
+ this._args = [];
122
+ this.rawArgs = null;
123
+ this._scriptPath = null;
124
+ this._name = name || '';
125
+ this._optionValues = {};
126
+ this._storeOptionsAsProperties = true; // backwards compatible by default
127
+ this._storeOptionsAsPropertiesCalled = false;
128
+ this._passCommandToAction = true; // backwards compatible by default
129
+ this._actionResults = [];
130
+ this._actionHandler = null;
131
+ this._executableHandler = false;
132
+ this._executableFile = null; // custom name for executable
133
+ this._defaultCommandName = null;
134
+ this._exitCallback = null;
135
+ this._aliases = [];
136
+ this._combineFlagAndOptionalValue = true;
137
+
138
+ this._hidden = false;
139
+ this._hasHelpOption = true;
140
+ this._helpFlags = '-h, --help';
141
+ this._helpDescription = 'display help for command';
142
+ this._helpShortFlag = '-h';
143
+ this._helpLongFlag = '--help';
144
+ this._hasImplicitHelpCommand = undefined; // Deliberately undefined, not decided whether true or false
145
+ this._helpCommandName = 'help';
146
+ this._helpCommandnameAndArgs = 'help [command]';
147
+ this._helpCommandDescription = 'display help for command';
148
+ }
149
+
150
+ /**
151
+ * Define a command.
152
+ *
153
+ * There are two styles of command: pay attention to where to put the description.
154
+ *
155
+ * Examples:
156
+ *
157
+ * // Command implemented using action handler (description is supplied separately to `.command`)
158
+ * program
159
+ * .command('clone <source> [destination]')
160
+ * .description('clone a repository into a newly created directory')
161
+ * .action((source, destination) => {
162
+ * console.log('clone command called');
163
+ * });
164
+ *
165
+ * // Command implemented using separate executable file (description is second parameter to `.command`)
166
+ * program
167
+ * .command('start <service>', 'start named service')
168
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
169
+ *
170
+ * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
171
+ * @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
172
+ * @param {Object} [execOpts] - configuration options (for executable)
173
+ * @return {Command} returns new command for action handler, or `this` for executable command
174
+ * @api public
175
+ */
176
+
177
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
178
+ let desc = actionOptsOrExecDesc;
179
+ let opts = execOpts;
180
+ if (typeof desc === 'object' && desc !== null) {
181
+ opts = desc;
182
+ desc = null;
183
+ }
184
+ opts = opts || {};
185
+ const args = nameAndArgs.split(/ +/);
186
+ const cmd = this.createCommand(args.shift());
187
+
188
+ if (desc) {
189
+ cmd.description(desc);
190
+ cmd._executableHandler = true;
191
+ }
192
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
193
+
194
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
195
+ cmd._hasHelpOption = this._hasHelpOption;
196
+ cmd._helpFlags = this._helpFlags;
197
+ cmd._helpDescription = this._helpDescription;
198
+ cmd._helpShortFlag = this._helpShortFlag;
199
+ cmd._helpLongFlag = this._helpLongFlag;
200
+ cmd._helpCommandName = this._helpCommandName;
201
+ cmd._helpCommandnameAndArgs = this._helpCommandnameAndArgs;
202
+ cmd._helpCommandDescription = this._helpCommandDescription;
203
+ cmd._exitCallback = this._exitCallback;
204
+ cmd._storeOptionsAsProperties = this._storeOptionsAsProperties;
205
+ cmd._passCommandToAction = this._passCommandToAction;
206
+ cmd._combineFlagAndOptionalValue = this._combineFlagAndOptionalValue;
207
+
208
+ cmd._executableFile = opts.executableFile || null; // Custom name for executable file, set missing to null to match constructor
209
+ this.commands.push(cmd);
210
+ cmd._parseExpectedArgs(args);
211
+ cmd.parent = this;
212
+
213
+ if (desc) return this;
214
+ return cmd;
215
+ };
216
+
217
+ /**
218
+ * Factory routine to create a new unattached command.
219
+ *
220
+ * See .command() for creating an attached subcommand, which uses this routine to
221
+ * create the command. You can override createCommand to customise subcommands.
222
+ *
223
+ * @param {string} [name]
224
+ * @return {Command} new command
225
+ * @api public
226
+ */
227
+
228
+ createCommand(name) {
229
+ return new Command(name);
230
+ };
231
+
232
+ /**
233
+ * Add a prepared subcommand.
234
+ *
235
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
236
+ *
237
+ * @param {Command} cmd - new subcommand
238
+ * @param {Object} [opts] - configuration options
239
+ * @return {Command} `this` command for chaining
240
+ * @api public
241
+ */
242
+
243
+ addCommand(cmd, opts) {
244
+ if (!cmd._name) throw new Error('Command passed to .addCommand() must have a name');
245
+
246
+ // To keep things simple, block automatic name generation for deeply nested executables.
247
+ // Fail fast and detect when adding rather than later when parsing.
248
+ function checkExplicitNames(commandArray) {
249
+ commandArray.forEach((cmd) => {
250
+ if (cmd._executableHandler && !cmd._executableFile) {
251
+ throw new Error(`Must specify executableFile for deeply nested executable: ${cmd.name()}`);
252
+ }
253
+ checkExplicitNames(cmd.commands);
254
+ });
255
+ }
256
+ checkExplicitNames(cmd.commands);
257
+
258
+ opts = opts || {};
259
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
260
+ if (opts.noHelp || opts.hidden) cmd._hidden = true; // modifying passed command due to existing implementation
261
+
262
+ this.commands.push(cmd);
263
+ cmd.parent = this;
264
+ return this;
265
+ };
266
+
267
+ /**
268
+ * Define argument syntax for the command.
269
+ *
270
+ * @api public
271
+ */
272
+
273
+ arguments(desc) {
274
+ return this._parseExpectedArgs(desc.split(/ +/));
275
+ };
276
+
277
+ /**
278
+ * Override default decision whether to add implicit help command.
279
+ *
280
+ * addHelpCommand() // force on
281
+ * addHelpCommand(false); // force off
282
+ * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
283
+ *
284
+ * @return {Command} `this` command for chaining
285
+ * @api public
286
+ */
287
+
288
+ addHelpCommand(enableOrNameAndArgs, description) {
289
+ if (enableOrNameAndArgs === false) {
290
+ this._hasImplicitHelpCommand = false;
291
+ } else {
292
+ this._hasImplicitHelpCommand = true;
293
+ if (typeof enableOrNameAndArgs === 'string') {
294
+ this._helpCommandName = enableOrNameAndArgs.split(' ')[0];
295
+ this._helpCommandnameAndArgs = enableOrNameAndArgs;
296
+ }
297
+ this._helpCommandDescription = description || this._helpCommandDescription;
298
+ }
299
+ return this;
300
+ };
301
+
302
+ /**
303
+ * @return {boolean}
304
+ * @api private
305
+ */
306
+
307
+ _lazyHasImplicitHelpCommand() {
308
+ if (this._hasImplicitHelpCommand === undefined) {
309
+ this._hasImplicitHelpCommand = this.commands.length && !this._actionHandler && !this._findCommand('help');
310
+ }
311
+ return this._hasImplicitHelpCommand;
312
+ };
313
+
314
+ /**
315
+ * Parse expected `args`.
316
+ *
317
+ * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
318
+ *
319
+ * @param {Array} args
320
+ * @return {Command} `this` command for chaining
321
+ * @api private
322
+ */
323
+
324
+ _parseExpectedArgs(args) {
325
+ if (!args.length) return;
326
+ args.forEach((arg) => {
327
+ const argDetails = {
328
+ required: false,
329
+ name: '',
330
+ variadic: false
331
+ };
332
+
333
+ switch (arg[0]) {
334
+ case '<':
335
+ argDetails.required = true;
336
+ argDetails.name = arg.slice(1, -1);
337
+ break;
338
+ case '[':
339
+ argDetails.name = arg.slice(1, -1);
340
+ break;
341
+ }
342
+
343
+ if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') {
344
+ argDetails.variadic = true;
345
+ argDetails.name = argDetails.name.slice(0, -3);
346
+ }
347
+ if (argDetails.name) {
348
+ this._args.push(argDetails);
349
+ }
350
+ });
351
+ this._args.forEach((arg, i) => {
352
+ if (arg.variadic && i < this._args.length - 1) {
353
+ throw new Error(`only the last argument can be variadic '${arg.name}'`);
354
+ }
355
+ });
356
+ return this;
357
+ };
358
+
359
+ /**
360
+ * Register callback to use as replacement for calling process.exit.
361
+ *
362
+ * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
363
+ * @return {Command} `this` command for chaining
364
+ * @api public
365
+ */
366
+
367
+ exitOverride(fn) {
368
+ if (fn) {
369
+ this._exitCallback = fn;
370
+ } else {
371
+ this._exitCallback = (err) => {
372
+ if (err.code !== 'commander.executeSubCommandAsync') {
373
+ throw err;
374
+ } else {
375
+ // Async callback from spawn events, not useful to throw.
376
+ }
377
+ };
378
+ }
379
+ return this;
380
+ };
381
+
382
+ /**
383
+ * Call process.exit, and _exitCallback if defined.
384
+ *
385
+ * @param {number} exitCode exit code for using with process.exit
386
+ * @param {string} code an id string representing the error
387
+ * @param {string} message human-readable description of the error
388
+ * @return never
389
+ * @api private
390
+ */
391
+
392
+ _exit(exitCode, code, message) {
393
+ if (this._exitCallback) {
394
+ this._exitCallback(new CommanderError(exitCode, code, message));
395
+ // Expecting this line is not reached.
396
+ }
397
+ process.exit(exitCode);
398
+ };
399
+
400
+ /**
401
+ * Register callback `fn` for the command.
402
+ *
403
+ * Examples:
404
+ *
405
+ * program
406
+ * .command('help')
407
+ * .description('display verbose help')
408
+ * .action(function() {
409
+ * // output help here
410
+ * });
411
+ *
412
+ * @param {Function} fn
413
+ * @return {Command} `this` command for chaining
414
+ * @api public
415
+ */
416
+
417
+ action(fn) {
418
+ const listener = (args) => {
419
+ // The .action callback takes an extra parameter which is the command or options.
420
+ const expectedArgsCount = this._args.length;
421
+ const actionArgs = args.slice(0, expectedArgsCount);
422
+ if (this._passCommandToAction) {
423
+ actionArgs[expectedArgsCount] = this;
424
+ } else {
425
+ actionArgs[expectedArgsCount] = this.opts();
426
+ }
427
+ // Add the extra arguments so available too.
428
+ if (args.length > expectedArgsCount) {
429
+ actionArgs.push(args.slice(expectedArgsCount));
430
+ }
431
+
432
+ const actionResult = fn.apply(this, actionArgs);
433
+ // Remember result in case it is async. Assume parseAsync getting called on root.
434
+ let rootCommand = this;
435
+ while (rootCommand.parent) {
436
+ rootCommand = rootCommand.parent;
437
+ }
438
+ rootCommand._actionResults.push(actionResult);
439
+ };
440
+ this._actionHandler = listener;
441
+ return this;
442
+ };
443
+
444
+ /**
445
+ * Internal routine to check whether there is a clash storing option value with a Command property.
446
+ *
447
+ * @param {Option} option
448
+ * @api private
449
+ */
450
+
451
+ _checkForOptionNameClash(option) {
452
+ if (!this._storeOptionsAsProperties || this._storeOptionsAsPropertiesCalled) {
453
+ // Storing options safely, or user has been explicit and up to them.
454
+ return;
455
+ }
456
+ // User may override help, and hard to tell if worth warning.
457
+ if (option.name() === 'help') {
458
+ return;
459
+ }
460
+
461
+ const commandProperty = this._getOptionValue(option.attributeName());
462
+ if (commandProperty === undefined) {
463
+ // no clash
464
+ return;
465
+ }
466
+
467
+ let foundClash = true;
468
+ if (option.negate) {
469
+ // It is ok if define foo before --no-foo.
470
+ const positiveLongFlag = option.long.replace(/^--no-/, '--');
471
+ foundClash = !this._findOption(positiveLongFlag);
472
+ } else if (option.long) {
473
+ const negativeLongFlag = option.long.replace(/^--/, '--no-');
474
+ foundClash = !this._findOption(negativeLongFlag);
475
+ }
476
+
477
+ if (foundClash) {
478
+ throw new Error(`option '${option.name()}' clashes with existing property '${option.attributeName()}' on Command
479
+ - call storeOptionsAsProperties(false) to store option values safely,
480
+ - or call storeOptionsAsProperties(true) to suppress this check,
481
+ - or change option name
482
+
483
+ Read more on https://git.io/JJc0W`);
484
+ }
485
+ };
486
+
487
+ /**
488
+ * Internal implementation shared by .option() and .requiredOption()
489
+ *
490
+ * @param {Object} config
491
+ * @param {string} flags
492
+ * @param {string} description
493
+ * @param {Function|*} [fn] - custom option processing function or default value
494
+ * @param {*} [defaultValue]
495
+ * @return {Command} `this` command for chaining
496
+ * @api private
497
+ */
498
+
499
+ _optionEx(config, flags, description, fn, defaultValue) {
500
+ const option = new Option(flags, description);
501
+ const oname = option.name();
502
+ const name = option.attributeName();
503
+ option.mandatory = !!config.mandatory;
504
+
505
+ this._checkForOptionNameClash(option);
506
+
507
+ // default as 3rd arg
508
+ if (typeof fn !== 'function') {
509
+ if (fn instanceof RegExp) {
510
+ // This is a bit simplistic (especially no error messages), and probably better handled by caller using custom option processing.
511
+ // No longer documented in README, but still present for backwards compatibility.
512
+ const regex = fn;
513
+ fn = (val, def) => {
514
+ const m = regex.exec(val);
515
+ return m ? m[0] : def;
516
+ };
517
+ } else {
518
+ defaultValue = fn;
519
+ fn = null;
520
+ }
521
+ }
522
+
523
+ // preassign default value for --no-*, [optional], <required>, or plain flag if boolean value
524
+ if (option.negate || option.optional || option.required || typeof defaultValue === 'boolean') {
525
+ // when --no-foo we make sure default is true, unless a --foo option is already defined
526
+ if (option.negate) {
527
+ const positiveLongFlag = option.long.replace(/^--no-/, '--');
528
+ defaultValue = this._findOption(positiveLongFlag) ? this._getOptionValue(name) : true;
529
+ }
530
+ // preassign only if we have a default
531
+ if (defaultValue !== undefined) {
532
+ this._setOptionValue(name, defaultValue);
533
+ option.defaultValue = defaultValue;
534
+ }
535
+ }
536
+
537
+ // register the option
538
+ this.options.push(option);
539
+
540
+ // when it's passed assign the value
541
+ // and conditionally invoke the callback
542
+ this.on('option:' + oname, (val) => {
543
+ const oldValue = this._getOptionValue(name);
544
+
545
+ // custom processing
546
+ if (val !== null && fn) {
547
+ val = fn(val, oldValue === undefined ? defaultValue : oldValue);
548
+ } else if (val !== null && option.variadic) {
549
+ if (oldValue === defaultValue || !Array.isArray(oldValue)) {
550
+ val = [val];
551
+ } else {
552
+ val = oldValue.concat(val);
553
+ }
554
+ }
555
+
556
+ // unassigned or boolean value
557
+ if (typeof oldValue === 'boolean' || typeof oldValue === 'undefined') {
558
+ // if no value, negate false, and we have a default, then use it!
559
+ if (val == null) {
560
+ this._setOptionValue(name, option.negate
561
+ ? false
562
+ : defaultValue || true);
563
+ } else {
564
+ this._setOptionValue(name, val);
565
+ }
566
+ } else if (val !== null) {
567
+ // reassign
568
+ this._setOptionValue(name, option.negate ? false : val);
569
+ }
570
+ });
571
+
572
+ return this;
573
+ };
574
+
575
+ /**
576
+ * Define option with `flags`, `description` and optional
577
+ * coercion `fn`.
578
+ *
579
+ * The `flags` string should contain both the short and long flags,
580
+ * separated by comma, a pipe or space. The following are all valid
581
+ * all will output this way when `--help` is used.
582
+ *
583
+ * "-p, --pepper"
584
+ * "-p|--pepper"
585
+ * "-p --pepper"
586
+ *
587
+ * Examples:
588
+ *
589
+ * // simple boolean defaulting to undefined
590
+ * program.option('-p, --pepper', 'add pepper');
591
+ *
592
+ * program.pepper
593
+ * // => undefined
594
+ *
595
+ * --pepper
596
+ * program.pepper
597
+ * // => true
598
+ *
599
+ * // simple boolean defaulting to true (unless non-negated option is also defined)
600
+ * program.option('-C, --no-cheese', 'remove cheese');
601
+ *
602
+ * program.cheese
603
+ * // => true
604
+ *
605
+ * --no-cheese
606
+ * program.cheese
607
+ * // => false
608
+ *
609
+ * // required argument
610
+ * program.option('-C, --chdir <path>', 'change the working directory');
611
+ *
612
+ * --chdir /tmp
613
+ * program.chdir
614
+ * // => "/tmp"
615
+ *
616
+ * // optional argument
617
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
618
+ *
619
+ * @param {string} flags
620
+ * @param {string} description
621
+ * @param {Function|*} [fn] - custom option processing function or default value
622
+ * @param {*} [defaultValue]
623
+ * @return {Command} `this` command for chaining
624
+ * @api public
625
+ */
626
+
627
+ option(flags, description, fn, defaultValue) {
628
+ return this._optionEx({}, flags, description, fn, defaultValue);
629
+ };
630
+
631
+ /**
632
+ * Add a required option which must have a value after parsing. This usually means
633
+ * the option must be specified on the command line. (Otherwise the same as .option().)
634
+ *
635
+ * The `flags` string should contain both the short and long flags, separated by comma, a pipe or space.
636
+ *
637
+ * @param {string} flags
638
+ * @param {string} description
639
+ * @param {Function|*} [fn] - custom option processing function or default value
640
+ * @param {*} [defaultValue]
641
+ * @return {Command} `this` command for chaining
642
+ * @api public
643
+ */
644
+
645
+ requiredOption(flags, description, fn, defaultValue) {
646
+ return this._optionEx({ mandatory: true }, flags, description, fn, defaultValue);
647
+ };
648
+
649
+ /**
650
+ * Alter parsing of short flags with optional values.
651
+ *
652
+ * Examples:
653
+ *
654
+ * // for `.option('-f,--flag [value]'):
655
+ * .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
656
+ * .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
657
+ *
658
+ * @param {Boolean} [arg] - if `true` or omitted, an optional value can be specified directly after the flag.
659
+ * @api public
660
+ */
661
+ combineFlagAndOptionalValue(arg) {
662
+ this._combineFlagAndOptionalValue = (arg === undefined) || arg;
663
+ return this;
664
+ };
665
+
666
+ /**
667
+ * Allow unknown options on the command line.
668
+ *
669
+ * @param {Boolean} [arg] - if `true` or omitted, no error will be thrown
670
+ * for unknown options.
671
+ * @api public
672
+ */
673
+ allowUnknownOption(arg) {
674
+ this._allowUnknownOption = (arg === undefined) || arg;
675
+ return this;
676
+ };
677
+
678
+ /**
679
+ * Whether to store option values as properties on command object,
680
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
681
+ *
682
+ * @param {boolean} value
683
+ * @return {Command} `this` command for chaining
684
+ * @api public
685
+ */
686
+
687
+ storeOptionsAsProperties(value) {
688
+ this._storeOptionsAsPropertiesCalled = true;
689
+ this._storeOptionsAsProperties = (value === undefined) || value;
690
+ if (this.options.length) {
691
+ throw new Error('call .storeOptionsAsProperties() before adding options');
692
+ }
693
+ return this;
694
+ };
695
+
696
+ /**
697
+ * Whether to pass command to action handler,
698
+ * or just the options (specify false).
699
+ *
700
+ * @param {boolean} value
701
+ * @return {Command} `this` command for chaining
702
+ * @api public
703
+ */
704
+
705
+ passCommandToAction(value) {
706
+ this._passCommandToAction = (value === undefined) || value;
707
+ return this;
708
+ };
709
+
710
+ /**
711
+ * Store option value
712
+ *
713
+ * @param {string} key
714
+ * @param {Object} value
715
+ * @api private
716
+ */
717
+
718
+ _setOptionValue(key, value) {
719
+ if (this._storeOptionsAsProperties) {
720
+ this[key] = value;
721
+ } else {
722
+ this._optionValues[key] = value;
723
+ }
724
+ };
725
+
726
+ /**
727
+ * Retrieve option value
728
+ *
729
+ * @param {string} key
730
+ * @return {Object} value
731
+ * @api private
732
+ */
733
+
734
+ _getOptionValue(key) {
735
+ if (this._storeOptionsAsProperties) {
736
+ return this[key];
737
+ }
738
+ return this._optionValues[key];
739
+ };
740
+
741
+ /**
742
+ * Parse `argv`, setting options and invoking commands when defined.
743
+ *
744
+ * The default expectation is that the arguments are from node and have the application as argv[0]
745
+ * and the script being run in argv[1], with user parameters after that.
746
+ *
747
+ * Examples:
748
+ *
749
+ * program.parse(process.argv);
750
+ * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
751
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
752
+ *
753
+ * @param {string[]} [argv] - optional, defaults to process.argv
754
+ * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
755
+ * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
756
+ * @return {Command} `this` command for chaining
757
+ * @api public
758
+ */
759
+
760
+ parse(argv, parseOptions) {
761
+ if (argv !== undefined && !Array.isArray(argv)) {
762
+ throw new Error('first parameter to parse must be array or undefined');
763
+ }
764
+ parseOptions = parseOptions || {};
765
+
766
+ // Default to using process.argv
767
+ if (argv === undefined) {
768
+ argv = process.argv;
769
+ // @ts-ignore
770
+ if (process.versions && process.versions.electron) {
771
+ parseOptions.from = 'electron';
772
+ }
773
+ }
774
+ this.rawArgs = argv.slice();
775
+
776
+ // make it a little easier for callers by supporting various argv conventions
777
+ let userArgs;
778
+ switch (parseOptions.from) {
779
+ case undefined:
780
+ case 'node':
781
+ this._scriptPath = argv[1];
782
+ userArgs = argv.slice(2);
783
+ break;
784
+ case 'electron':
785
+ // @ts-ignore
786
+ if (process.defaultApp) {
787
+ this._scriptPath = argv[1];
788
+ userArgs = argv.slice(2);
789
+ } else {
790
+ userArgs = argv.slice(1);
791
+ }
792
+ break;
793
+ case 'user':
794
+ userArgs = argv.slice(0);
795
+ break;
796
+ default:
797
+ throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
798
+ }
799
+ if (!this._scriptPath && process.mainModule) {
800
+ this._scriptPath = process.mainModule.filename;
801
+ }
802
+
803
+ // Guess name, used in usage in help.
804
+ this._name = this._name || (this._scriptPath && path.basename(this._scriptPath, path.extname(this._scriptPath)));
805
+
806
+ // Let's go!
807
+ this._parseCommand([], userArgs);
808
+
809
+ return this;
810
+ };
811
+
812
+ /**
813
+ * Parse `argv`, setting options and invoking commands when defined.
814
+ *
815
+ * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
816
+ *
817
+ * The default expectation is that the arguments are from node and have the application as argv[0]
818
+ * and the script being run in argv[1], with user parameters after that.
819
+ *
820
+ * Examples:
821
+ *
822
+ * program.parseAsync(process.argv);
823
+ * program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
824
+ * program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
825
+ *
826
+ * @param {string[]} [argv]
827
+ * @param {Object} [parseOptions]
828
+ * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
829
+ * @return {Promise}
830
+ * @api public
831
+ */
832
+
833
+ parseAsync(argv, parseOptions) {
834
+ this.parse(argv, parseOptions);
835
+ return Promise.all(this._actionResults).then(() => this);
836
+ };
837
+
838
+ /**
839
+ * Execute a sub-command executable.
840
+ *
841
+ * @api private
842
+ */
843
+
844
+ _executeSubCommand(subcommand, args) {
845
+ args = args.slice();
846
+ let launchWithNode = false; // Use node for source targets so do not need to get permissions correct, and on Windows.
847
+ const sourceExt = ['.js', '.ts', '.tsx', '.mjs'];
848
+
849
+ // Not checking for help first. Unlikely to have mandatory and executable, and can't robustly test for help flags in external command.
850
+ this._checkForMissingMandatoryOptions();
851
+
852
+ // Want the entry script as the reference for command name and directory for searching for other files.
853
+ let scriptPath = this._scriptPath;
854
+ // Fallback in case not set, due to how Command created or called.
855
+ if (!scriptPath && process.mainModule) {
856
+ scriptPath = process.mainModule.filename;
857
+ }
858
+
859
+ let baseDir;
860
+ try {
861
+ const resolvedLink = fs.realpathSync(scriptPath);
862
+ baseDir = path.dirname(resolvedLink);
863
+ } catch (e) {
864
+ baseDir = '.'; // dummy, probably not going to find executable!
865
+ }
866
+
867
+ // name of the subcommand, like `pm-install`
868
+ let bin = path.basename(scriptPath, path.extname(scriptPath)) + '-' + subcommand._name;
869
+ if (subcommand._executableFile) {
870
+ bin = subcommand._executableFile;
871
+ }
872
+
873
+ const localBin = path.join(baseDir, bin);
874
+ if (fs.existsSync(localBin)) {
875
+ // prefer local `./<bin>` to bin in the $PATH
876
+ bin = localBin;
877
+ } else {
878
+ // Look for source files.
879
+ sourceExt.forEach((ext) => {
880
+ if (fs.existsSync(`${localBin}${ext}`)) {
881
+ bin = `${localBin}${ext}`;
882
+ }
883
+ });
884
+ }
885
+ launchWithNode = sourceExt.includes(path.extname(bin));
886
+
887
+ let proc;
888
+ if (process.platform !== 'win32') {
889
+ if (launchWithNode) {
890
+ args.unshift(bin);
891
+ // add executable arguments to spawn
892
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
893
+
894
+ proc = spawn(process.argv[0], args, { stdio: 'inherit' });
895
+ } else {
896
+ proc = spawn(bin, args, { stdio: 'inherit' });
897
+ }
898
+ } else {
899
+ args.unshift(bin);
900
+ // add executable arguments to spawn
901
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
902
+ proc = spawn(process.execPath, args, { stdio: 'inherit' });
903
+ }
904
+
905
+ const signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];
906
+ signals.forEach((signal) => {
907
+ // @ts-ignore
908
+ process.on(signal, () => {
909
+ if (proc.killed === false && proc.exitCode === null) {
910
+ proc.kill(signal);
911
+ }
912
+ });
913
+ });
914
+
915
+ // By default terminate process when spawned process terminates.
916
+ // Suppressing the exit if exitCallback defined is a bit messy and of limited use, but does allow process to stay running!
917
+ const exitCallback = this._exitCallback;
918
+ if (!exitCallback) {
919
+ proc.on('close', process.exit.bind(process));
920
+ } else {
921
+ proc.on('close', () => {
922
+ exitCallback(new CommanderError(process.exitCode || 0, 'commander.executeSubCommandAsync', '(close)'));
923
+ });
924
+ }
925
+ proc.on('error', (err) => {
926
+ // @ts-ignore
927
+ if (err.code === 'ENOENT') {
928
+ const executableMissing = `'${bin}' does not exist
929
+ - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
930
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name`;
931
+ throw new Error(executableMissing);
932
+ // @ts-ignore
933
+ } else if (err.code === 'EACCES') {
934
+ throw new Error(`'${bin}' not executable`);
935
+ }
936
+ if (!exitCallback) {
937
+ process.exit(1);
938
+ } else {
939
+ const wrappedError = new CommanderError(1, 'commander.executeSubCommandAsync', '(error)');
940
+ wrappedError.nestedError = err;
941
+ exitCallback(wrappedError);
942
+ }
943
+ });
944
+
945
+ // Store the reference to the child process
946
+ this.runningCommand = proc;
947
+ };
948
+
949
+ /**
950
+ * @api private
951
+ */
952
+ _dispatchSubcommand(commandName, operands, unknown) {
953
+ const subCommand = this._findCommand(commandName);
954
+ if (!subCommand) this._helpAndError();
955
+
956
+ if (subCommand._executableHandler) {
957
+ this._executeSubCommand(subCommand, operands.concat(unknown));
958
+ } else {
959
+ subCommand._parseCommand(operands, unknown);
960
+ }
961
+ };
962
+
963
+ /**
964
+ * Process arguments in context of this command.
965
+ *
966
+ * @api private
967
+ */
968
+
969
+ _parseCommand(operands, unknown) {
970
+ const parsed = this.parseOptions(unknown);
971
+ operands = operands.concat(parsed.operands);
972
+ unknown = parsed.unknown;
973
+ this.args = operands.concat(unknown);
974
+
975
+ if (operands && this._findCommand(operands[0])) {
976
+ this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
977
+ } else if (this._lazyHasImplicitHelpCommand() && operands[0] === this._helpCommandName) {
978
+ if (operands.length === 1) {
979
+ this.help();
980
+ } else {
981
+ this._dispatchSubcommand(operands[1], [], [this._helpLongFlag]);
982
+ }
983
+ } else if (this._defaultCommandName) {
984
+ outputHelpIfRequested(this, unknown); // Run the help for default command from parent rather than passing to default command
985
+ this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
986
+ } else {
987
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
988
+ // probably missing subcommand and no handler, user needs help
989
+ this._helpAndError();
990
+ }
991
+
992
+ outputHelpIfRequested(this, parsed.unknown);
993
+ this._checkForMissingMandatoryOptions();
994
+ if (parsed.unknown.length > 0) {
995
+ this.unknownOption(parsed.unknown[0]);
996
+ }
997
+
998
+ if (this._actionHandler) {
999
+ const args = this.args.slice();
1000
+ this._args.forEach((arg, i) => {
1001
+ if (arg.required && args[i] == null) {
1002
+ this.missingArgument(arg.name);
1003
+ } else if (arg.variadic) {
1004
+ args[i] = args.splice(i);
1005
+ }
1006
+ });
1007
+
1008
+ this._actionHandler(args);
1009
+ this.emit('command:' + this.name(), operands, unknown);
1010
+ } else if (operands.length) {
1011
+ if (this._findCommand('*')) {
1012
+ this._dispatchSubcommand('*', operands, unknown);
1013
+ } else if (this.listenerCount('command:*')) {
1014
+ this.emit('command:*', operands, unknown);
1015
+ } else if (this.commands.length) {
1016
+ this.unknownCommand();
1017
+ }
1018
+ } else if (this.commands.length) {
1019
+ // This command has subcommands and nothing hooked up at this level, so display help.
1020
+ this._helpAndError();
1021
+ } else {
1022
+ // fall through for caller to handle after calling .parse()
1023
+ }
1024
+ }
1025
+ };
1026
+
1027
+ /**
1028
+ * Find matching command.
1029
+ *
1030
+ * @api private
1031
+ */
1032
+ _findCommand(name) {
1033
+ if (!name) return undefined;
1034
+ return this.commands.find(cmd => cmd._name === name || cmd._aliases.includes(name));
1035
+ };
1036
+
1037
+ /**
1038
+ * Return an option matching `arg` if any.
1039
+ *
1040
+ * @param {string} arg
1041
+ * @return {Option}
1042
+ * @api private
1043
+ */
1044
+
1045
+ _findOption(arg) {
1046
+ return this.options.find(option => option.is(arg));
1047
+ };
1048
+
1049
+ /**
1050
+ * Display an error message if a mandatory option does not have a value.
1051
+ * Lazy calling after checking for help flags from leaf subcommand.
1052
+ *
1053
+ * @api private
1054
+ */
1055
+
1056
+ _checkForMissingMandatoryOptions() {
1057
+ // Walk up hierarchy so can call in subcommand after checking for displaying help.
1058
+ for (let cmd = this; cmd; cmd = cmd.parent) {
1059
+ cmd.options.forEach((anOption) => {
1060
+ if (anOption.mandatory && (cmd._getOptionValue(anOption.attributeName()) === undefined)) {
1061
+ cmd.missingMandatoryOptionValue(anOption);
1062
+ }
1063
+ });
1064
+ }
1065
+ };
1066
+
1067
+ /**
1068
+ * Parse options from `argv` removing known options,
1069
+ * and return argv split into operands and unknown arguments.
1070
+ *
1071
+ * Examples:
1072
+ *
1073
+ * argv => operands, unknown
1074
+ * --known kkk op => [op], []
1075
+ * op --known kkk => [op], []
1076
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
1077
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
1078
+ *
1079
+ * @param {String[]} argv
1080
+ * @return {{operands: String[], unknown: String[]}}
1081
+ * @api public
1082
+ */
1083
+
1084
+ parseOptions(argv) {
1085
+ const operands = []; // operands, not options or values
1086
+ const unknown = []; // first unknown option and remaining unknown args
1087
+ let dest = operands;
1088
+ const args = argv.slice();
1089
+
1090
+ function maybeOption(arg) {
1091
+ return arg.length > 1 && arg[0] === '-';
1092
+ }
1093
+
1094
+ // parse options
1095
+ let activeVariadicOption = null;
1096
+ while (args.length) {
1097
+ const arg = args.shift();
1098
+
1099
+ // literal
1100
+ if (arg === '--') {
1101
+ if (dest === unknown) dest.push(arg);
1102
+ dest.push(...args);
1103
+ break;
1104
+ }
1105
+
1106
+ if (activeVariadicOption && !maybeOption(arg)) {
1107
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
1108
+ continue;
1109
+ }
1110
+ activeVariadicOption = null;
1111
+
1112
+ if (maybeOption(arg)) {
1113
+ const option = this._findOption(arg);
1114
+ // recognised option, call listener to assign value with possible custom processing
1115
+ if (option) {
1116
+ if (option.required) {
1117
+ const value = args.shift();
1118
+ if (value === undefined) this.optionMissingArgument(option);
1119
+ this.emit(`option:${option.name()}`, value);
1120
+ } else if (option.optional) {
1121
+ let value = null;
1122
+ // historical behaviour is optional value is following arg unless an option
1123
+ if (args.length > 0 && !maybeOption(args[0])) {
1124
+ value = args.shift();
1125
+ }
1126
+ this.emit(`option:${option.name()}`, value);
1127
+ } else { // boolean flag
1128
+ this.emit(`option:${option.name()}`);
1129
+ }
1130
+ activeVariadicOption = option.variadic ? option : null;
1131
+ continue;
1132
+ }
1133
+ }
1134
+
1135
+ // Look for combo options following single dash, eat first one if known.
1136
+ if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') {
1137
+ const option = this._findOption(`-${arg[1]}`);
1138
+ if (option) {
1139
+ if (option.required || (option.optional && this._combineFlagAndOptionalValue)) {
1140
+ // option with value following in same argument
1141
+ this.emit(`option:${option.name()}`, arg.slice(2));
1142
+ } else {
1143
+ // boolean option, emit and put back remainder of arg for further processing
1144
+ this.emit(`option:${option.name()}`);
1145
+ args.unshift(`-${arg.slice(2)}`);
1146
+ }
1147
+ continue;
1148
+ }
1149
+ }
1150
+
1151
+ // Look for known long flag with value, like --foo=bar
1152
+ if (/^--[^=]+=/.test(arg)) {
1153
+ const index = arg.indexOf('=');
1154
+ const option = this._findOption(arg.slice(0, index));
1155
+ if (option && (option.required || option.optional)) {
1156
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
1157
+ continue;
1158
+ }
1159
+ }
1160
+
1161
+ // looks like an option but unknown, unknowns from here
1162
+ if (arg.length > 1 && arg[0] === '-') {
1163
+ dest = unknown;
1164
+ }
1165
+
1166
+ // add arg
1167
+ dest.push(arg);
1168
+ }
1169
+
1170
+ return { operands, unknown };
1171
+ };
1172
+
1173
+ /**
1174
+ * Return an object containing options as key-value pairs
1175
+ *
1176
+ * @return {Object}
1177
+ * @api public
1178
+ */
1179
+ opts() {
1180
+ if (this._storeOptionsAsProperties) {
1181
+ // Preserve original behaviour so backwards compatible when still using properties
1182
+ const result = {};
1183
+ const len = this.options.length;
1184
+
1185
+ for (let i = 0; i < len; i++) {
1186
+ const key = this.options[i].attributeName();
1187
+ result[key] = key === this._versionOptionName ? this._version : this[key];
1188
+ }
1189
+ return result;
1190
+ }
1191
+
1192
+ return this._optionValues;
1193
+ };
1194
+
1195
+ /**
1196
+ * Argument `name` is missing.
1197
+ *
1198
+ * @param {string} name
1199
+ * @api private
1200
+ */
1201
+
1202
+ missingArgument(name) {
1203
+ const message = `error: missing required argument '${name}'`;
1204
+ console.error(message);
1205
+ this._exit(1, 'commander.missingArgument', message);
1206
+ };
1207
+
1208
+ /**
1209
+ * `Option` is missing an argument, but received `flag` or nothing.
1210
+ *
1211
+ * @param {Option} option
1212
+ * @param {string} [flag]
1213
+ * @api private
1214
+ */
1215
+
1216
+ optionMissingArgument(option, flag) {
1217
+ let message;
1218
+ if (flag) {
1219
+ message = `error: option '${option.flags}' argument missing, got '${flag}'`;
1220
+ } else {
1221
+ message = `error: option '${option.flags}' argument missing`;
1222
+ }
1223
+ console.error(message);
1224
+ this._exit(1, 'commander.optionMissingArgument', message);
1225
+ };
1226
+
1227
+ /**
1228
+ * `Option` does not have a value, and is a mandatory option.
1229
+ *
1230
+ * @param {Option} option
1231
+ * @api private
1232
+ */
1233
+
1234
+ missingMandatoryOptionValue(option) {
1235
+ const message = `error: required option '${option.flags}' not specified`;
1236
+ console.error(message);
1237
+ this._exit(1, 'commander.missingMandatoryOptionValue', message);
1238
+ };
1239
+
1240
+ /**
1241
+ * Unknown option `flag`.
1242
+ *
1243
+ * @param {string} flag
1244
+ * @api private
1245
+ */
1246
+
1247
+ unknownOption(flag) {
1248
+ if (this._allowUnknownOption) return;
1249
+ const message = `error: unknown option '${flag}'`;
1250
+ console.error(message);
1251
+ this._exit(1, 'commander.unknownOption', message);
1252
+ };
1253
+
1254
+ /**
1255
+ * Unknown command.
1256
+ *
1257
+ * @api private
1258
+ */
1259
+
1260
+ unknownCommand() {
1261
+ const partCommands = [this.name()];
1262
+ for (let parentCmd = this.parent; parentCmd; parentCmd = parentCmd.parent) {
1263
+ partCommands.unshift(parentCmd.name());
1264
+ }
1265
+ const fullCommand = partCommands.join(' ');
1266
+ const message = `error: unknown command '${this.args[0]}'.` +
1267
+ (this._hasHelpOption ? ` See '${fullCommand} ${this._helpLongFlag}'.` : '');
1268
+ console.error(message);
1269
+ this._exit(1, 'commander.unknownCommand', message);
1270
+ };
1271
+
1272
+ /**
1273
+ * Set the program version to `str`.
1274
+ *
1275
+ * This method auto-registers the "-V, --version" flag
1276
+ * which will print the version number when passed.
1277
+ *
1278
+ * You can optionally supply the flags and description to override the defaults.
1279
+ *
1280
+ * @param {string} str
1281
+ * @param {string} [flags]
1282
+ * @param {string} [description]
1283
+ * @return {this | string} `this` command for chaining, or version string if no arguments
1284
+ * @api public
1285
+ */
1286
+
1287
+ version(str, flags, description) {
1288
+ if (str === undefined) return this._version;
1289
+ this._version = str;
1290
+ flags = flags || '-V, --version';
1291
+ description = description || 'output the version number';
1292
+ const versionOption = new Option(flags, description);
1293
+ this._versionOptionName = versionOption.attributeName();
1294
+ this.options.push(versionOption);
1295
+ this.on('option:' + versionOption.name(), () => {
1296
+ process.stdout.write(str + '\n');
1297
+ this._exit(0, 'commander.version', str);
1298
+ });
1299
+ return this;
1300
+ };
1301
+
1302
+ /**
1303
+ * Set the description to `str`.
1304
+ *
1305
+ * @param {string} str
1306
+ * @param {Object} [argsDescription]
1307
+ * @return {string|Command}
1308
+ * @api public
1309
+ */
1310
+
1311
+ description(str, argsDescription) {
1312
+ if (str === undefined && argsDescription === undefined) return this._description;
1313
+ this._description = str;
1314
+ this._argsDescription = argsDescription;
1315
+ return this;
1316
+ };
1317
+
1318
+ /**
1319
+ * Set an alias for the command.
1320
+ *
1321
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
1322
+ *
1323
+ * @param {string} [alias]
1324
+ * @return {string|Command}
1325
+ * @api public
1326
+ */
1327
+
1328
+ alias(alias) {
1329
+ if (alias === undefined) return this._aliases[0]; // just return first, for backwards compatibility
1330
+
1331
+ let command = this;
1332
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
1333
+ // assume adding alias for last added executable subcommand, rather than this
1334
+ command = this.commands[this.commands.length - 1];
1335
+ }
1336
+
1337
+ if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
1338
+
1339
+ command._aliases.push(alias);
1340
+ return this;
1341
+ };
1342
+
1343
+ /**
1344
+ * Set aliases for the command.
1345
+ *
1346
+ * Only the first alias is shown in the auto-generated help.
1347
+ *
1348
+ * @param {string[]} [aliases]
1349
+ * @return {string[]|Command}
1350
+ * @api public
1351
+ */
1352
+
1353
+ aliases(aliases) {
1354
+ // Getter for the array of aliases is the main reason for having aliases() in addition to alias().
1355
+ if (aliases === undefined) return this._aliases;
1356
+
1357
+ aliases.forEach((alias) => this.alias(alias));
1358
+ return this;
1359
+ };
1360
+
1361
+ /**
1362
+ * Set / get the command usage `str`.
1363
+ *
1364
+ * @param {string} [str]
1365
+ * @return {String|Command}
1366
+ * @api public
1367
+ */
1368
+
1369
+ usage(str) {
1370
+ if (str === undefined) {
1371
+ if (this._usage) return this._usage;
1372
+
1373
+ const args = this._args.map((arg) => {
1374
+ return humanReadableArgName(arg);
1375
+ });
1376
+ return [].concat(
1377
+ (this.options.length || this._hasHelpOption ? '[options]' : []),
1378
+ (this.commands.length ? '[command]' : []),
1379
+ (this._args.length ? args : [])
1380
+ ).join(' ');
1381
+ }
1382
+
1383
+ this._usage = str;
1384
+ return this;
1385
+ };
1386
+
1387
+ /**
1388
+ * Get or set the name of the command
1389
+ *
1390
+ * @param {string} [str]
1391
+ * @return {String|Command}
1392
+ * @api public
1393
+ */
1394
+
1395
+ name(str) {
1396
+ if (str === undefined) return this._name;
1397
+ this._name = str;
1398
+ return this;
1399
+ };
1400
+
1401
+ /**
1402
+ * Return prepared commands.
1403
+ *
1404
+ * @return {Array}
1405
+ * @api private
1406
+ */
1407
+
1408
+ prepareCommands() {
1409
+ const commandDetails = this.commands.filter((cmd) => {
1410
+ return !cmd._hidden;
1411
+ }).map((cmd) => {
1412
+ const args = cmd._args.map((arg) => {
1413
+ return humanReadableArgName(arg);
1414
+ }).join(' ');
1415
+
1416
+ return [
1417
+ cmd._name +
1418
+ (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
1419
+ (cmd.options.length ? ' [options]' : '') +
1420
+ (args ? ' ' + args : ''),
1421
+ cmd._description
1422
+ ];
1423
+ });
1424
+
1425
+ if (this._lazyHasImplicitHelpCommand()) {
1426
+ commandDetails.push([this._helpCommandnameAndArgs, this._helpCommandDescription]);
1427
+ }
1428
+ return commandDetails;
1429
+ };
1430
+
1431
+ /**
1432
+ * Return the largest command length.
1433
+ *
1434
+ * @return {number}
1435
+ * @api private
1436
+ */
1437
+
1438
+ largestCommandLength() {
1439
+ const commands = this.prepareCommands();
1440
+ return commands.reduce((max, command) => {
1441
+ return Math.max(max, command[0].length);
1442
+ }, 0);
1443
+ };
1444
+
1445
+ /**
1446
+ * Return the largest option length.
1447
+ *
1448
+ * @return {number}
1449
+ * @api private
1450
+ */
1451
+
1452
+ largestOptionLength() {
1453
+ const options = [].slice.call(this.options);
1454
+ options.push({
1455
+ flags: this._helpFlags
1456
+ });
1457
+
1458
+ return options.reduce((max, option) => {
1459
+ return Math.max(max, option.flags.length);
1460
+ }, 0);
1461
+ };
1462
+
1463
+ /**
1464
+ * Return the largest arg length.
1465
+ *
1466
+ * @return {number}
1467
+ * @api private
1468
+ */
1469
+
1470
+ largestArgLength() {
1471
+ return this._args.reduce((max, arg) => {
1472
+ return Math.max(max, arg.name.length);
1473
+ }, 0);
1474
+ };
1475
+
1476
+ /**
1477
+ * Return the pad width.
1478
+ *
1479
+ * @return {number}
1480
+ * @api private
1481
+ */
1482
+
1483
+ padWidth() {
1484
+ let width = this.largestOptionLength();
1485
+ if (this._argsDescription && this._args.length) {
1486
+ if (this.largestArgLength() > width) {
1487
+ width = this.largestArgLength();
1488
+ }
1489
+ }
1490
+
1491
+ if (this.commands && this.commands.length) {
1492
+ if (this.largestCommandLength() > width) {
1493
+ width = this.largestCommandLength();
1494
+ }
1495
+ }
1496
+
1497
+ return width;
1498
+ };
1499
+
1500
+ /**
1501
+ * Return help for options.
1502
+ *
1503
+ * @return {string}
1504
+ * @api private
1505
+ */
1506
+
1507
+ optionHelp() {
1508
+ const width = this.padWidth();
1509
+ const columns = process.stdout.columns || 80;
1510
+ const descriptionWidth = columns - width - 4;
1511
+ function padOptionDetails(flags, description) {
1512
+ return pad(flags, width) + ' ' + optionalWrap(description, descriptionWidth, width + 2);
1513
+ };
1514
+
1515
+ // Explicit options (including version)
1516
+ const help = this.options.map((option) => {
1517
+ const fullDesc = option.description +
1518
+ ((!option.negate && option.defaultValue !== undefined) ? ' (default: ' + JSON.stringify(option.defaultValue) + ')' : '');
1519
+ return padOptionDetails(option.flags, fullDesc);
1520
+ });
1521
+
1522
+ // Implicit help
1523
+ const showShortHelpFlag = this._hasHelpOption && this._helpShortFlag && !this._findOption(this._helpShortFlag);
1524
+ const showLongHelpFlag = this._hasHelpOption && !this._findOption(this._helpLongFlag);
1525
+ if (showShortHelpFlag || showLongHelpFlag) {
1526
+ let helpFlags = this._helpFlags;
1527
+ if (!showShortHelpFlag) {
1528
+ helpFlags = this._helpLongFlag;
1529
+ } else if (!showLongHelpFlag) {
1530
+ helpFlags = this._helpShortFlag;
1531
+ }
1532
+ help.push(padOptionDetails(helpFlags, this._helpDescription));
1533
+ }
1534
+
1535
+ return help.join('\n');
1536
+ };
1537
+
1538
+ /**
1539
+ * Return command help documentation.
1540
+ *
1541
+ * @return {string}
1542
+ * @api private
1543
+ */
1544
+
1545
+ commandHelp() {
1546
+ if (!this.commands.length && !this._lazyHasImplicitHelpCommand()) return '';
1547
+
1548
+ const commands = this.prepareCommands();
1549
+ const width = this.padWidth();
1550
+
1551
+ const columns = process.stdout.columns || 80;
1552
+ const descriptionWidth = columns - width - 4;
1553
+
1554
+ return [
1555
+ 'Commands:',
1556
+ commands.map((cmd) => {
1557
+ const desc = cmd[1] ? ' ' + cmd[1] : '';
1558
+ return (desc ? pad(cmd[0], width) : cmd[0]) + optionalWrap(desc, descriptionWidth, width + 2);
1559
+ }).join('\n').replace(/^/gm, ' '),
1560
+ ''
1561
+ ].join('\n');
1562
+ };
1563
+
1564
+ /**
1565
+ * Return program help documentation.
1566
+ *
1567
+ * @return {string}
1568
+ * @api public
1569
+ */
1570
+
1571
+ helpInformation() {
1572
+ let desc = [];
1573
+ if (this._description) {
1574
+ desc = [
1575
+ this._description,
1576
+ ''
1577
+ ];
1578
+
1579
+ const argsDescription = this._argsDescription;
1580
+ if (argsDescription && this._args.length) {
1581
+ const width = this.padWidth();
1582
+ const columns = process.stdout.columns || 80;
1583
+ const descriptionWidth = columns - width - 5;
1584
+ desc.push('Arguments:');
1585
+ this._args.forEach((arg) => {
1586
+ desc.push(' ' + pad(arg.name, width) + ' ' + wrap(argsDescription[arg.name] || '', descriptionWidth, width + 4));
1587
+ });
1588
+ desc.push('');
1589
+ }
1590
+ }
1591
+
1592
+ let cmdName = this._name;
1593
+ if (this._aliases[0]) {
1594
+ cmdName = cmdName + '|' + this._aliases[0];
1595
+ }
1596
+ let parentCmdNames = '';
1597
+ for (let parentCmd = this.parent; parentCmd; parentCmd = parentCmd.parent) {
1598
+ parentCmdNames = parentCmd.name() + ' ' + parentCmdNames;
1599
+ }
1600
+ const usage = [
1601
+ 'Usage: ' + parentCmdNames + cmdName + ' ' + this.usage(),
1602
+ ''
1603
+ ];
1604
+
1605
+ let cmds = [];
1606
+ const commandHelp = this.commandHelp();
1607
+ if (commandHelp) cmds = [commandHelp];
1608
+
1609
+ let options = [];
1610
+ if (this._hasHelpOption || this.options.length > 0) {
1611
+ options = [
1612
+ 'Options:',
1613
+ '' + this.optionHelp().replace(/^/gm, ' '),
1614
+ ''
1615
+ ];
1616
+ }
1617
+
1618
+ return usage
1619
+ .concat(desc)
1620
+ .concat(options)
1621
+ .concat(cmds)
1622
+ .join('\n');
1623
+ };
1624
+
1625
+ /**
1626
+ * Output help information for this command.
1627
+ *
1628
+ * When listener(s) are available for the helpLongFlag
1629
+ * those callbacks are invoked.
1630
+ *
1631
+ * @api public
1632
+ */
1633
+
1634
+ outputHelp(cb) {
1635
+ if (!cb) {
1636
+ cb = (passthru) => {
1637
+ return passthru;
1638
+ };
1639
+ }
1640
+ const cbOutput = cb(this.helpInformation());
1641
+ if (typeof cbOutput !== 'string' && !Buffer.isBuffer(cbOutput)) {
1642
+ throw new Error('outputHelp callback must return a string or a Buffer');
1643
+ }
1644
+ process.stdout.write(cbOutput);
1645
+ this.emit(this._helpLongFlag);
1646
+ };
1647
+
1648
+ /**
1649
+ * You can pass in flags and a description to override the help
1650
+ * flags and help description for your command. Pass in false to
1651
+ * disable the built-in help option.
1652
+ *
1653
+ * @param {string | boolean} [flags]
1654
+ * @param {string} [description]
1655
+ * @return {Command} `this` command for chaining
1656
+ * @api public
1657
+ */
1658
+
1659
+ helpOption(flags, description) {
1660
+ if (typeof flags === 'boolean') {
1661
+ this._hasHelpOption = flags;
1662
+ return this;
1663
+ }
1664
+ this._helpFlags = flags || this._helpFlags;
1665
+ this._helpDescription = description || this._helpDescription;
1666
+
1667
+ const helpFlags = _parseOptionFlags(this._helpFlags);
1668
+ this._helpShortFlag = helpFlags.shortFlag;
1669
+ this._helpLongFlag = helpFlags.longFlag;
1670
+
1671
+ return this;
1672
+ };
1673
+
1674
+ /**
1675
+ * Output help information and exit.
1676
+ *
1677
+ * @param {Function} [cb]
1678
+ * @api public
1679
+ */
1680
+
1681
+ help(cb) {
1682
+ this.outputHelp(cb);
1683
+ // exitCode: preserving original behaviour which was calling process.exit()
1684
+ // message: do not have all displayed text available so only passing placeholder.
1685
+ this._exit(process.exitCode || 0, 'commander.help', '(outputHelp)');
1686
+ };
1687
+
1688
+ /**
1689
+ * Output help information and exit. Display for error situations.
1690
+ *
1691
+ * @api private
1692
+ */
1693
+
1694
+ _helpAndError() {
1695
+ this.outputHelp();
1696
+ // message: do not have all displayed text available so only passing placeholder.
1697
+ this._exit(1, 'commander.help', '(outputHelp)');
1698
+ };
1699
+ };
1700
+
1701
+ /**
1702
+ * Expose the root command.
1703
+ */
1704
+
1705
+ exports = module.exports = new Command();
1706
+ exports.program = exports; // More explicit access to global command.
1707
+
1708
+ /**
1709
+ * Expose classes
1710
+ */
1711
+
1712
+ exports.Command = Command;
1713
+ exports.Option = Option;
1714
+ exports.CommanderError = CommanderError;
1715
+
1716
+ /**
1717
+ * Camel-case the given `flag`
1718
+ *
1719
+ * @param {string} flag
1720
+ * @return {string}
1721
+ * @api private
1722
+ */
1723
+
1724
+ function camelcase(flag) {
1725
+ return flag.split('-').reduce((str, word) => {
1726
+ return str + word[0].toUpperCase() + word.slice(1);
1727
+ });
1728
+ }
1729
+
1730
+ /**
1731
+ * Pad `str` to `width`.
1732
+ *
1733
+ * @param {string} str
1734
+ * @param {number} width
1735
+ * @return {string}
1736
+ * @api private
1737
+ */
1738
+
1739
+ function pad(str, width) {
1740
+ const len = Math.max(0, width - str.length);
1741
+ return str + Array(len + 1).join(' ');
1742
+ }
1743
+
1744
+ /**
1745
+ * Wraps the given string with line breaks at the specified width while breaking
1746
+ * words and indenting every but the first line on the left.
1747
+ *
1748
+ * @param {string} str
1749
+ * @param {number} width
1750
+ * @param {number} indent
1751
+ * @return {string}
1752
+ * @api private
1753
+ */
1754
+ function wrap(str, width, indent) {
1755
+ const regex = new RegExp('.{1,' + (width - 1) + '}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)', 'g');
1756
+ const lines = str.match(regex) || [];
1757
+ return lines.map((line, i) => {
1758
+ if (line.slice(-1) === '\n') {
1759
+ line = line.slice(0, line.length - 1);
1760
+ }
1761
+ return ((i > 0 && indent) ? Array(indent + 1).join(' ') : '') + line.trimRight();
1762
+ }).join('\n');
1763
+ }
1764
+
1765
+ /**
1766
+ * Optionally wrap the given str to a max width of width characters per line
1767
+ * while indenting with indent spaces. Do not wrap if insufficient width or
1768
+ * string is manually formatted.
1769
+ *
1770
+ * @param {string} str
1771
+ * @param {number} width
1772
+ * @param {number} indent
1773
+ * @return {string}
1774
+ * @api private
1775
+ */
1776
+ function optionalWrap(str, width, indent) {
1777
+ // Detect manually wrapped and indented strings by searching for line breaks
1778
+ // followed by multiple spaces/tabs.
1779
+ if (str.match(/[\n]\s+/)) return str;
1780
+ // Do not wrap to narrow columns (or can end up with a word per line).
1781
+ const minWidth = 40;
1782
+ if (width < minWidth) return str;
1783
+
1784
+ return wrap(str, width, indent);
1785
+ }
1786
+
1787
+ /**
1788
+ * Output help information if help flags specified
1789
+ *
1790
+ * @param {Command} cmd - command to output help for
1791
+ * @param {Array} args - array of options to search for help flags
1792
+ * @api private
1793
+ */
1794
+
1795
+ function outputHelpIfRequested(cmd, args) {
1796
+ const helpOption = cmd._hasHelpOption && args.find(arg => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
1797
+ if (helpOption) {
1798
+ cmd.outputHelp();
1799
+ // (Do not have all displayed text available so only passing placeholder.)
1800
+ cmd._exit(0, 'commander.helpDisplayed', '(outputHelp)');
1801
+ }
1802
+ }
1803
+
1804
+ /**
1805
+ * Takes an argument and returns its human readable equivalent for help usage.
1806
+ *
1807
+ * @param {Object} arg
1808
+ * @return {string}
1809
+ * @api private
1810
+ */
1811
+
1812
+ function humanReadableArgName(arg) {
1813
+ const nameOutput = arg.name + (arg.variadic === true ? '...' : '');
1814
+
1815
+ return arg.required
1816
+ ? '<' + nameOutput + '>'
1817
+ : '[' + nameOutput + ']';
1818
+ }
1819
+
1820
+ /**
1821
+ * Parse the short and long flag out of something like '-m,--mixed <value>'
1822
+ *
1823
+ * @api private
1824
+ */
1825
+
1826
+ function _parseOptionFlags(flags) {
1827
+ let shortFlag;
1828
+ let longFlag;
1829
+ // Use original very loose parsing to maintain backwards compatibility for now,
1830
+ // which allowed for example unintended `-sw, --short-word` [sic].
1831
+ const flagParts = flags.split(/[ |,]+/);
1832
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
1833
+ longFlag = flagParts.shift();
1834
+ // Add support for lone short flag without significantly changing parsing!
1835
+ if (!shortFlag && /^-[^-]$/.test(longFlag)) {
1836
+ shortFlag = longFlag;
1837
+ longFlag = undefined;
1838
+ }
1839
+ return { shortFlag, longFlag };
1840
+ }
1841
+
1842
+ /**
1843
+ * Scan arguments and increment port number for inspect calls (to avoid conflicts when spawning new command).
1844
+ *
1845
+ * @param {string[]} args - array of arguments from node.execArgv
1846
+ * @returns {string[]}
1847
+ * @api private
1848
+ */
1849
+
1850
+ function incrementNodeInspectorPort(args) {
1851
+ // Testing for these options:
1852
+ // --inspect[=[host:]port]
1853
+ // --inspect-brk[=[host:]port]
1854
+ // --inspect-port=[host:]port
1855
+ return args.map((arg) => {
1856
+ if (!arg.startsWith('--inspect')) {
1857
+ return arg;
1858
+ }
1859
+ let debugOption;
1860
+ let debugHost = '127.0.0.1';
1861
+ let debugPort = '9229';
1862
+ let match;
1863
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
1864
+ // e.g. --inspect
1865
+ debugOption = match[1];
1866
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
1867
+ debugOption = match[1];
1868
+ if (/^\d+$/.test(match[3])) {
1869
+ // e.g. --inspect=1234
1870
+ debugPort = match[3];
1871
+ } else {
1872
+ // e.g. --inspect=localhost
1873
+ debugHost = match[3];
1874
+ }
1875
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
1876
+ // e.g. --inspect=localhost:1234
1877
+ debugOption = match[1];
1878
+ debugHost = match[3];
1879
+ debugPort = match[4];
1880
+ }
1881
+
1882
+ if (debugOption && debugPort !== '0') {
1883
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
1884
+ }
1885
+ return arg;
1886
+ });
1887
+ }
1888
+
1889
+
1890
+ /***/ }),
1891
+
1892
+ /***/ 81:
1893
+ /***/ (function(module) {
1894
+
1895
+ "use strict";
1896
+ module.exports = require("child_process");
1897
+
1898
+ /***/ }),
1899
+
1900
+ /***/ 361:
1901
+ /***/ (function(module) {
1902
+
1903
+ "use strict";
1904
+ module.exports = require("events");
1905
+
1906
+ /***/ }),
1907
+
1908
+ /***/ 147:
1909
+ /***/ (function(module) {
1910
+
1911
+ "use strict";
1912
+ module.exports = require("fs");
1913
+
1914
+ /***/ }),
1915
+
1916
+ /***/ 17:
1917
+ /***/ (function(module) {
1918
+
1919
+ "use strict";
1920
+ module.exports = require("path");
1921
+
1922
+ /***/ })
1923
+
1924
+ /******/ });
1925
+ /************************************************************************/
1926
+ /******/ // The module cache
1927
+ /******/ var __webpack_module_cache__ = {};
1928
+ /******/
1929
+ /******/ // The require function
1930
+ /******/ function __nccwpck_require__(moduleId) {
1931
+ /******/ // Check if module is in cache
1932
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
1933
+ /******/ if (cachedModule !== undefined) {
1934
+ /******/ return cachedModule.exports;
1935
+ /******/ }
1936
+ /******/ // Create a new module (and put it into the cache)
1937
+ /******/ var module = __webpack_module_cache__[moduleId] = {
1938
+ /******/ // no module.id needed
1939
+ /******/ // no module.loaded needed
1940
+ /******/ exports: {}
1941
+ /******/ };
1942
+ /******/
1943
+ /******/ // Execute the module function
1944
+ /******/ var threw = true;
1945
+ /******/ try {
1946
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
1947
+ /******/ threw = false;
1948
+ /******/ } finally {
1949
+ /******/ if(threw) delete __webpack_module_cache__[moduleId];
1950
+ /******/ }
1951
+ /******/
1952
+ /******/ // Return the exports of the module
1953
+ /******/ return module.exports;
1954
+ /******/ }
1955
+ /******/
1956
+ /************************************************************************/
1957
+ /******/ /* webpack/runtime/compat */
1958
+ /******/
1959
+ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
1960
+ /******/
1961
+ /************************************************************************/
1962
+ /******/
1963
+ /******/ // startup
1964
+ /******/ // Load entry module and return exports
1965
+ /******/ // This entry module is referenced by other modules so it can't be inlined
1966
+ /******/ var __webpack_exports__ = __nccwpck_require__(138);
1967
+ /******/ module.exports = __webpack_exports__;
1968
+ /******/
1969
+ /******/ })()
1970
+ ;