@serverless-devs/s 0.0.45 → 0.1.4-18cdd23b

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 (379) hide show
  1. package/LICENSE +201 -21
  2. package/OWNERS +33 -0
  3. package/_config.yml +1 -0
  4. package/bin/s +1 -1
  5. package/lib/daemon/lib.js +327 -0
  6. package/lib/daemon/report.js +50 -0
  7. package/lib/daemon/update-cli.js +20 -0
  8. package/lib/daemon/update-component.js +21 -0
  9. package/lib/daemon/update-templates.js +19 -0
  10. package/lib/index.js +1732 -0
  11. package/package.json +73 -61
  12. package/readme.md +127 -0
  13. package/.eslintrc +0 -75
  14. package/README.md +0 -65
  15. package/bin/s-config +0 -2
  16. package/bin/s-config-add +0 -2
  17. package/bin/s-config-delete +0 -2
  18. package/bin/s-config-get +0 -3
  19. package/bin/s-config-update +0 -3
  20. package/bin/s-deploy +0 -2
  21. package/bin/s-gui +0 -2
  22. package/bin/s-init +0 -2
  23. package/bin/s-platform +0 -2
  24. package/bin/s-platform-delete +0 -2
  25. package/bin/s-platform-init +0 -2
  26. package/bin/s-platform-login +0 -2
  27. package/bin/s-platform-publish +0 -2
  28. package/bin/s-remove +0 -2
  29. package/bin/s-search +0 -2
  30. package/bin/s-set +0 -2
  31. package/bin/s-set-analysis +0 -2
  32. package/bin/s-set-language +0 -2
  33. package/bin/s-set-output-color +0 -2
  34. package/compile.tsconfig.json +0 -12
  35. package/configs/base.tsconfig.json +0 -25
  36. package/lib/command/command-manager.d.ts +0 -12
  37. package/lib/command/command-manager.d.ts.map +0 -1
  38. package/lib/command/command-manager.js +0 -144
  39. package/lib/command/command-manager.js.map +0 -1
  40. package/lib/command/index.d.ts +0 -2
  41. package/lib/command/index.d.ts.map +0 -1
  42. package/lib/command/index.js +0 -41
  43. package/lib/command/index.js.map +0 -1
  44. package/lib/component/hook.d.ts +0 -17
  45. package/lib/component/hook.d.ts.map +0 -1
  46. package/lib/component/hook.js +0 -201
  47. package/lib/component/hook.js.map +0 -1
  48. package/lib/component/index.d.ts +0 -53
  49. package/lib/component/index.d.ts.map +0 -1
  50. package/lib/component/index.js +0 -577
  51. package/lib/component/index.js.map +0 -1
  52. package/lib/config/add/add-manager.d.ts +0 -23
  53. package/lib/config/add/add-manager.d.ts.map +0 -1
  54. package/lib/config/add/add-manager.js +0 -282
  55. package/lib/config/add/add-manager.js.map +0 -1
  56. package/lib/config/add/index.d.ts +0 -2
  57. package/lib/config/add/index.d.ts.map +0 -1
  58. package/lib/config/add/index.js +0 -77
  59. package/lib/config/add/index.js.map +0 -1
  60. package/lib/config/common/common.d.ts +0 -7
  61. package/lib/config/common/common.d.ts.map +0 -1
  62. package/lib/config/common/common.js +0 -175
  63. package/lib/config/common/common.js.map +0 -1
  64. package/lib/config/delete/delete-manager.d.ts +0 -11
  65. package/lib/config/delete/delete-manager.d.ts.map +0 -1
  66. package/lib/config/delete/delete-manager.js +0 -133
  67. package/lib/config/delete/delete-manager.js.map +0 -1
  68. package/lib/config/delete/index.d.ts +0 -2
  69. package/lib/config/delete/index.d.ts.map +0 -1
  70. package/lib/config/delete/index.js +0 -77
  71. package/lib/config/delete/index.js.map +0 -1
  72. package/lib/config/get/get-manager.d.ts +0 -14
  73. package/lib/config/get/get-manager.d.ts.map +0 -1
  74. package/lib/config/get/get-manager.js +0 -205
  75. package/lib/config/get/get-manager.js.map +0 -1
  76. package/lib/config/get/index.d.ts +0 -2
  77. package/lib/config/get/index.d.ts.map +0 -1
  78. package/lib/config/get/index.js +0 -86
  79. package/lib/config/get/index.js.map +0 -1
  80. package/lib/config/index.d.ts +0 -2
  81. package/lib/config/index.d.ts.map +0 -1
  82. package/lib/config/index.js +0 -15
  83. package/lib/config/index.js.map +0 -1
  84. package/lib/config/update/index.d.ts +0 -2
  85. package/lib/config/update/index.d.ts.map +0 -1
  86. package/lib/config/update/index.js +0 -83
  87. package/lib/config/update/index.js.map +0 -1
  88. package/lib/config/update/update-manager.d.ts +0 -23
  89. package/lib/config/update/update-manager.d.ts.map +0 -1
  90. package/lib/config/update/update-manager.js +0 -208
  91. package/lib/config/update/update-manager.js.map +0 -1
  92. package/lib/constants/static-variable.d.ts +0 -12
  93. package/lib/constants/static-variable.d.ts.map +0 -1
  94. package/lib/constants/static-variable.js +0 -15
  95. package/lib/constants/static-variable.js.map +0 -1
  96. package/lib/entity.d.ts +0 -11
  97. package/lib/entity.d.ts.map +0 -1
  98. package/lib/entity.js +0 -3
  99. package/lib/entity.js.map +0 -1
  100. package/lib/error/command-error.d.ts +0 -5
  101. package/lib/error/command-error.d.ts.map +0 -1
  102. package/lib/error/command-error.js +0 -26
  103. package/lib/error/command-error.js.map +0 -1
  104. package/lib/error/config-delete-error.d.ts +0 -5
  105. package/lib/error/config-delete-error.d.ts.map +0 -1
  106. package/lib/error/config-delete-error.js +0 -26
  107. package/lib/error/config-delete-error.js.map +0 -1
  108. package/lib/error/config-error.d.ts +0 -5
  109. package/lib/error/config-error.d.ts.map +0 -1
  110. package/lib/error/config-error.js +0 -26
  111. package/lib/error/config-error.js.map +0 -1
  112. package/lib/error/config-get-error.d.ts +0 -5
  113. package/lib/error/config-get-error.d.ts.map +0 -1
  114. package/lib/error/config-get-error.js +0 -26
  115. package/lib/error/config-get-error.js.map +0 -1
  116. package/lib/error/config-update-error.d.ts +0 -5
  117. package/lib/error/config-update-error.d.ts.map +0 -1
  118. package/lib/error/config-update-error.js +0 -26
  119. package/lib/error/config-update-error.js.map +0 -1
  120. package/lib/error/init-error.d.ts +0 -5
  121. package/lib/error/init-error.d.ts.map +0 -1
  122. package/lib/error/init-error.js +0 -26
  123. package/lib/error/init-error.js.map +0 -1
  124. package/lib/error/login-error.d.ts +0 -5
  125. package/lib/error/login-error.d.ts.map +0 -1
  126. package/lib/error/login-error.js +0 -26
  127. package/lib/error/login-error.js.map +0 -1
  128. package/lib/error/platform-delete-error.d.ts +0 -5
  129. package/lib/error/platform-delete-error.d.ts.map +0 -1
  130. package/lib/error/platform-delete-error.js +0 -26
  131. package/lib/error/platform-delete-error.js.map +0 -1
  132. package/lib/error/platform-init-error.d.ts +0 -5
  133. package/lib/error/platform-init-error.d.ts.map +0 -1
  134. package/lib/error/platform-init-error.js +0 -26
  135. package/lib/error/platform-init-error.js.map +0 -1
  136. package/lib/error/platform-publish-error.d.ts +0 -5
  137. package/lib/error/platform-publish-error.d.ts.map +0 -1
  138. package/lib/error/platform-publish-error.js +0 -26
  139. package/lib/error/platform-publish-error.js.map +0 -1
  140. package/lib/error/search-error.d.ts +0 -5
  141. package/lib/error/search-error.d.ts.map +0 -1
  142. package/lib/error/search-error.js +0 -26
  143. package/lib/error/search-error.js.map +0 -1
  144. package/lib/error/serverless-error.d.ts +0 -4
  145. package/lib/error/serverless-error.d.ts.map +0 -1
  146. package/lib/error/serverless-error.js +0 -20
  147. package/lib/error/serverless-error.js.map +0 -1
  148. package/lib/error/set-analysis-error.d.ts +0 -5
  149. package/lib/error/set-analysis-error.d.ts.map +0 -1
  150. package/lib/error/set-analysis-error.js +0 -26
  151. package/lib/error/set-analysis-error.js.map +0 -1
  152. package/lib/error/set-language-error.d.ts +0 -5
  153. package/lib/error/set-language-error.d.ts.map +0 -1
  154. package/lib/error/set-language-error.js +0 -26
  155. package/lib/error/set-language-error.js.map +0 -1
  156. package/lib/gui/gui-service.d.ts +0 -11
  157. package/lib/gui/gui-service.d.ts.map +0 -1
  158. package/lib/gui/gui-service.js +0 -276
  159. package/lib/gui/gui-service.js.map +0 -1
  160. package/lib/gui/index.d.ts +0 -2
  161. package/lib/gui/index.d.ts.map +0 -1
  162. package/lib/gui/index.js +0 -67
  163. package/lib/gui/index.js.map +0 -1
  164. package/lib/init/init-manager.d.ts +0 -9
  165. package/lib/init/init-manager.d.ts.map +0 -1
  166. package/lib/init/init-manager.js +0 -171
  167. package/lib/init/init-manager.js.map +0 -1
  168. package/lib/init/init-message.d.ts +0 -6
  169. package/lib/init/init-message.d.ts.map +0 -1
  170. package/lib/init/init-message.js +0 -9
  171. package/lib/init/init-message.js.map +0 -1
  172. package/lib/init/init.d.ts +0 -2
  173. package/lib/init/init.d.ts.map +0 -1
  174. package/lib/init/init.js +0 -87
  175. package/lib/init/init.js.map +0 -1
  176. package/lib/platform/delete/index.d.ts +0 -2
  177. package/lib/platform/delete/index.d.ts.map +0 -1
  178. package/lib/platform/delete/index.js +0 -89
  179. package/lib/platform/delete/index.js.map +0 -1
  180. package/lib/platform/delete/platform-delete-manager.d.ts +0 -4
  181. package/lib/platform/delete/platform-delete-manager.d.ts.map +0 -1
  182. package/lib/platform/delete/platform-delete-manager.js +0 -100
  183. package/lib/platform/delete/platform-delete-manager.js.map +0 -1
  184. package/lib/platform/index.d.ts +0 -2
  185. package/lib/platform/index.d.ts.map +0 -1
  186. package/lib/platform/index.js +0 -25
  187. package/lib/platform/index.js.map +0 -1
  188. package/lib/platform/init/index.d.ts +0 -2
  189. package/lib/platform/init/index.d.ts.map +0 -1
  190. package/lib/platform/init/index.js +0 -70
  191. package/lib/platform/init/index.js.map +0 -1
  192. package/lib/platform/init/platform-init-manager.d.ts +0 -4
  193. package/lib/platform/init/platform-init-manager.d.ts.map +0 -1
  194. package/lib/platform/init/platform-init-manager.js +0 -24
  195. package/lib/platform/init/platform-init-manager.js.map +0 -1
  196. package/lib/platform/login/index.d.ts +0 -2
  197. package/lib/platform/login/index.d.ts.map +0 -1
  198. package/lib/platform/login/index.js +0 -68
  199. package/lib/platform/login/index.js.map +0 -1
  200. package/lib/platform/login/login-manager.d.ts +0 -15
  201. package/lib/platform/login/login-manager.d.ts.map +0 -1
  202. package/lib/platform/login/login-manager.js +0 -176
  203. package/lib/platform/login/login-manager.js.map +0 -1
  204. package/lib/platform/publish/index.d.ts +0 -2
  205. package/lib/platform/publish/index.d.ts.map +0 -1
  206. package/lib/platform/publish/index.js +0 -93
  207. package/lib/platform/publish/index.js.map +0 -1
  208. package/lib/platform/publish/platform-publish-manager.d.ts +0 -5
  209. package/lib/platform/publish/platform-publish-manager.d.ts.map +0 -1
  210. package/lib/platform/publish/platform-publish-manager.js +0 -115
  211. package/lib/platform/publish/platform-publish-manager.js.map +0 -1
  212. package/lib/plugin/index.d.ts +0 -20
  213. package/lib/plugin/index.d.ts.map +0 -1
  214. package/lib/plugin/index.js +0 -175
  215. package/lib/plugin/index.js.map +0 -1
  216. package/lib/s.d.ts +0 -2
  217. package/lib/s.d.ts.map +0 -1
  218. package/lib/s.js +0 -134
  219. package/lib/s.js.map +0 -1
  220. package/lib/search/search.d.ts +0 -2
  221. package/lib/search/search.d.ts.map +0 -1
  222. package/lib/search/search.js +0 -233
  223. package/lib/search/search.js.map +0 -1
  224. package/lib/set/analysis/index.d.ts +0 -2
  225. package/lib/set/analysis/index.d.ts.map +0 -1
  226. package/lib/set/analysis/index.js +0 -84
  227. package/lib/set/analysis/index.js.map +0 -1
  228. package/lib/set/index.d.ts +0 -2
  229. package/lib/set/index.d.ts.map +0 -1
  230. package/lib/set/index.js +0 -16
  231. package/lib/set/index.js.map +0 -1
  232. package/lib/set/language/index.d.ts +0 -2
  233. package/lib/set/language/index.d.ts.map +0 -1
  234. package/lib/set/language/index.js +0 -73
  235. package/lib/set/language/index.js.map +0 -1
  236. package/lib/set/output-color/index.d.ts +0 -2
  237. package/lib/set/output-color/index.d.ts.map +0 -1
  238. package/lib/set/output-color/index.js +0 -87
  239. package/lib/set/output-color/index.js.map +0 -1
  240. package/lib/utils/analysis.d.ts +0 -12
  241. package/lib/utils/analysis.d.ts.map +0 -1
  242. package/lib/utils/analysis.js +0 -42
  243. package/lib/utils/analysis.js.map +0 -1
  244. package/lib/utils/check-version.d.ts +0 -13
  245. package/lib/utils/check-version.d.ts.map +0 -1
  246. package/lib/utils/check-version.js +0 -241
  247. package/lib/utils/check-version.js.map +0 -1
  248. package/lib/utils/command.d.ts +0 -14
  249. package/lib/utils/command.d.ts.map +0 -1
  250. package/lib/utils/command.js +0 -251
  251. package/lib/utils/command.js.map +0 -1
  252. package/lib/utils/common.d.ts +0 -4
  253. package/lib/utils/common.d.ts.map +0 -1
  254. package/lib/utils/common.js +0 -50
  255. package/lib/utils/common.js.map +0 -1
  256. package/lib/utils/download-manager.d.ts +0 -23
  257. package/lib/utils/download-manager.d.ts.map +0 -1
  258. package/lib/utils/download-manager.js +0 -302
  259. package/lib/utils/download-manager.js.map +0 -1
  260. package/lib/utils/handler-set-config.d.ts +0 -14
  261. package/lib/utils/handler-set-config.d.ts.map +0 -1
  262. package/lib/utils/handler-set-config.js +0 -122
  263. package/lib/utils/handler-set-config.js.map +0 -1
  264. package/lib/utils/i18n.d.ts +0 -3
  265. package/lib/utils/i18n.d.ts.map +0 -1
  266. package/lib/utils/i18n.js +0 -21
  267. package/lib/utils/i18n.js.map +0 -1
  268. package/lib/utils/locales/en.json +0 -9
  269. package/lib/utils/locales/zh.json +0 -203
  270. package/lib/utils/logger.d.ts +0 -18
  271. package/lib/utils/logger.d.ts.map +0 -1
  272. package/lib/utils/logger.js +0 -196
  273. package/lib/utils/logger.js.map +0 -1
  274. package/lib/utils/package-type.d.ts +0 -6
  275. package/lib/utils/package-type.d.ts.map +0 -1
  276. package/lib/utils/package-type.js +0 -10
  277. package/lib/utils/package-type.js.map +0 -1
  278. package/lib/utils/parse.d.ts +0 -26
  279. package/lib/utils/parse.d.ts.map +0 -1
  280. package/lib/utils/parse.js +0 -229
  281. package/lib/utils/parse.js.map +0 -1
  282. package/lib/utils/repo-template-entity.d.ts +0 -12
  283. package/lib/utils/repo-template-entity.d.ts.map +0 -1
  284. package/lib/utils/repo-template-entity.js +0 -3
  285. package/lib/utils/repo-template-entity.js.map +0 -1
  286. package/lib/utils/start-service.d.ts +0 -22
  287. package/lib/utils/start-service.d.ts.map +0 -1
  288. package/lib/utils/start-service.js +0 -97
  289. package/lib/utils/start-service.js.map +0 -1
  290. package/lib/utils/storage.d.ts +0 -3
  291. package/lib/utils/storage.d.ts.map +0 -1
  292. package/lib/utils/storage.js +0 -23
  293. package/lib/utils/storage.js.map +0 -1
  294. package/lib/utils/url-parser.d.ts +0 -8
  295. package/lib/utils/url-parser.d.ts.map +0 -1
  296. package/lib/utils/url-parser.js +0 -58
  297. package/lib/utils/url-parser.js.map +0 -1
  298. package/scripts/tests/deploy/parse.ts +0 -0
  299. package/scripts/tests/download-manager-test.ts +0 -135
  300. package/scripts/tests/init-manager-test.ts +0 -232
  301. package/scripts/tests/url-parser-test.ts +0 -44
  302. package/src/command/command-manager.ts +0 -83
  303. package/src/command/index.ts +0 -42
  304. package/src/component/hook.ts +0 -88
  305. package/src/component/index.ts +0 -433
  306. package/src/config/add/add-manager.ts +0 -207
  307. package/src/config/add/index.ts +0 -45
  308. package/src/config/common/common.ts +0 -186
  309. package/src/config/delete/delete-manager.ts +0 -51
  310. package/src/config/delete/index.ts +0 -38
  311. package/src/config/get/get-manager.ts +0 -148
  312. package/src/config/get/index.ts +0 -49
  313. package/src/config/index.ts +0 -13
  314. package/src/config/update/index.ts +0 -46
  315. package/src/config/update/update-manager.ts +0 -120
  316. package/src/constants/static-variable.ts +0 -12
  317. package/src/entity.ts +0 -10
  318. package/src/error/command-error.ts +0 -7
  319. package/src/error/config-delete-error.ts +0 -7
  320. package/src/error/config-error.ts +0 -7
  321. package/src/error/config-get-error.ts +0 -7
  322. package/src/error/config-update-error.ts +0 -7
  323. package/src/error/init-error.ts +0 -7
  324. package/src/error/login-error.ts +0 -7
  325. package/src/error/platform-delete-error.ts +0 -7
  326. package/src/error/platform-init-error.ts +0 -7
  327. package/src/error/platform-publish-error.ts +0 -7
  328. package/src/error/search-error.ts +0 -7
  329. package/src/error/serverless-error.ts +0 -17
  330. package/src/error/set-analysis-error.ts +0 -7
  331. package/src/error/set-language-error.ts +0 -7
  332. package/src/gui/gui-service.ts +0 -183
  333. package/src/gui/index.ts +0 -26
  334. package/src/init/init-manager.ts +0 -104
  335. package/src/init/init-message.ts +0 -8
  336. package/src/init/init.ts +0 -56
  337. package/src/platform/delete/index.ts +0 -46
  338. package/src/platform/delete/platform-delete-manager.ts +0 -46
  339. package/src/platform/index.ts +0 -26
  340. package/src/platform/init/index.ts +0 -33
  341. package/src/platform/init/platform-init-manager.ts +0 -17
  342. package/src/platform/login/index.ts +0 -25
  343. package/src/platform/login/login-manager.ts +0 -121
  344. package/src/platform/publish/index.ts +0 -52
  345. package/src/platform/publish/platform-publish-manager.ts +0 -69
  346. package/src/plugin/index.ts +0 -96
  347. package/src/s.ts +0 -83
  348. package/src/search/search.ts +0 -127
  349. package/src/set/analysis/index.ts +0 -45
  350. package/src/set/index.ts +0 -19
  351. package/src/set/language/index.ts +0 -39
  352. package/src/set/output-color/index.ts +0 -49
  353. package/src/utils/analysis.ts +0 -36
  354. package/src/utils/check-version.ts +0 -139
  355. package/src/utils/command.ts +0 -123
  356. package/src/utils/common.ts +0 -47
  357. package/src/utils/download-manager.ts +0 -197
  358. package/src/utils/handler-set-config.ts +0 -83
  359. package/src/utils/i18n.ts +0 -21
  360. package/src/utils/locales/en.json +0 -9
  361. package/src/utils/locales/zh.json +0 -228
  362. package/src/utils/logger.ts +0 -84
  363. package/src/utils/package-type.ts +0 -3
  364. package/src/utils/parse.ts +0 -176
  365. package/src/utils/repo-template-entity.ts +0 -14
  366. package/src/utils/start-service.ts +0 -64
  367. package/src/utils/storage.ts +0 -20
  368. package/src/utils/url-parser.ts +0 -60
  369. package/templates/application/common/publish.yaml +0 -16
  370. package/templates/application/common/readme.md +0 -99
  371. package/templates/application/common/src/index.js +0 -13
  372. package/templates/application/common/src/template.yaml +0 -16
  373. package/templates/component/common/publish.yaml +0 -24
  374. package/templates/component/common/readme.md +0 -386
  375. package/templates/component/common/src/index.js +0 -18
  376. package/templates/component/common/src/package.json +0 -7
  377. package/templates/plugin/common/publish.yaml +0 -9
  378. package/templates/plugin/common/readme.md +0 -128
  379. package/templates/plugin/common/src/index.js +0 -9
@@ -1,186 +0,0 @@
1
- import i18n from '../../utils/i18n';
2
-
3
- export const providerArray: Array<string> = ['alibaba', 'baidu', 'huawei', 'aws', 'azure', 'google', 'tencent'];
4
-
5
- export const providerObject: any = {
6
- alibaba: i18n.__('Alibaba Cloud'),
7
- baidu: i18n.__('Baidu Cloud'),
8
- huawei: i18n.__('Huawei Cloud'),
9
- aws: i18n.__('AWS Cloud'),
10
- azure: i18n.__('Azure Cloud'),
11
- google: i18n.__('Google Cloud'),
12
- tencent: i18n.__('Tencent Cloud')
13
- };
14
-
15
- export const providerCollection: any = {
16
- alibaba: [
17
- {
18
- type: 'input',
19
- message: 'AccountID',
20
- name: 'AccountID',
21
- default: '' // 默认值
22
- },
23
- {
24
- type: 'input',
25
- message: 'AccessKeyID',
26
- name: 'AccessKeyID',
27
- default: '' // 默认值
28
- },
29
- {
30
- type: 'input',
31
- message: 'AccessKeySecret',
32
- name: 'AccessKeySecret',
33
- default: '' // 默认值
34
- }
35
- ],
36
-
37
- aws: [
38
- {
39
- type: 'input',
40
- message: 'AccessKeyID',
41
- name: 'AccessKeyID',
42
- default: '' // 默认值
43
- },
44
-
45
- {
46
- type: 'input',
47
- message: 'SecretAccessKey',
48
- name: 'SecretAccessKey',
49
- default: '' // 默认值
50
- }
51
- ],
52
-
53
- huawei: [
54
- {
55
- type: 'input',
56
- message: 'AccessKeyID',
57
- name: 'AccessKeyID',
58
- default: '' // 默认值
59
- },
60
-
61
- {
62
- type: 'input',
63
- message: 'SecretAccessKey',
64
- name: 'SecretAccessKey',
65
- default: '' // 默认值
66
- }
67
- ],
68
-
69
- azure: [
70
- {
71
- type: 'input',
72
- message: 'KeyVault',
73
- name: 'KeyVault',
74
- default: '' // 默认值
75
- },
76
-
77
- {
78
- type: 'input',
79
- message: 'Secret',
80
- name: 'Secret',
81
- default: '' // 默认值
82
- }
83
- ],
84
-
85
- baidu: [
86
- {
87
- type: 'input',
88
- message: 'AccessKeyID',
89
- name: 'AccessKeyID',
90
- default: '' // 默认值
91
- },
92
-
93
- {
94
- type: 'input',
95
- message: 'SecretAccessKey',
96
- name: 'SecretAccessKey',
97
- default: '' // 默认值
98
- }
99
- ],
100
- google: [
101
- {
102
- type: 'input',
103
- message: 'AccountID',
104
- name: 'AccountID',
105
- default: '' // 默认值
106
- },
107
-
108
- {
109
- type: 'input',
110
- message: 'PrivateKeyData',
111
- name: 'PrivateKeyData',
112
- default: '' // 默认值
113
- }
114
- ],
115
-
116
- tencent: [
117
- {
118
- type: 'input',
119
- message: 'AccountID',
120
- name: 'AccountID',
121
- default: '' // 默认值
122
- },
123
- {
124
- type: 'input',
125
- message: 'SecretID',
126
- name: 'SecretID',
127
- default: '' // 默认值
128
- },
129
- {
130
- type: 'input',
131
- message: 'SecretKey',
132
- name: 'SecretKey',
133
- default: '' // 默认值
134
- }
135
- ]
136
- };
137
-
138
- export const providerAccessFormat: any = {
139
- alibaba: ['AccountID', 'AccessKeyID', 'AccessKeySecret'],
140
- aws: ['AccessKeyID', 'SecretAccessKey'],
141
- baidu: ['AccessKeyID', 'SecretAccessKey'],
142
- huawei: ['AccessKeyID', 'SecretAccessKey'],
143
- azure: ['KeyVault', 'Secret'],
144
- tencent: ['AccountID', 'SecretID', 'SecretKey'],
145
- google: ['AccountID', 'PrivateKeyData']
146
- };
147
-
148
- export const checkProviderList: Array<any> = [
149
- {
150
- type: 'list',
151
- name: 'provider',
152
- message: i18n.__('Please select a provider:'),
153
- choices: [
154
- { name: i18n.__('Alibaba Cloud (alibaba)'), value: 'alibaba' },
155
- { name: i18n.__('AWS (aws)'), value: 'aws' },
156
- { name: i18n.__('Azure (azure)'), value: 'azure' },
157
- { name: i18n.__('Baidu Cloud (baidu)'), value: 'baidu' },
158
- { name: i18n.__('Google Cloud (google)'), value: 'google' },
159
- { name: i18n.__('Huawei Cloud (huawei)'), value: 'huawei' },
160
- { name: i18n.__('Tencent Cloud (tencent)'), value: 'tencent' }
161
- ]
162
- }
163
- ];
164
-
165
- export function getInputData(program: any) {
166
- const inputSecretCheck: any = {};
167
- if (program.AccountID) {
168
- inputSecretCheck['AccountID'] = program.AccountID;
169
- }
170
- if (program.AccessKeyID) {
171
- inputSecretCheck['AccessKeyID'] = program.AccessKeyID;
172
- }
173
- if (program.AccessKeySecret) {
174
- inputSecretCheck['AccessKeySecret'] = program.AccessKeySecret;
175
- }
176
- if (program.SecretID) {
177
- inputSecretCheck['SecretID'] = program.SecretID;
178
- }
179
- if (program.SecretKey) {
180
- inputSecretCheck['SecretKey'] = program.SecretKey;
181
- }
182
- if (program.SecretAccessKey) {
183
- inputSecretCheck['SecretAccessKey'] = program.SecretAccessKey;
184
- }
185
- return inputSecretCheck;
186
- }
@@ -1,51 +0,0 @@
1
- const fs = require('fs');
2
- const os = require('os');
3
- const path = require('path');
4
- const yaml = require('js-yaml');
5
- import logger from '../../utils/logger';
6
- import { ConfigDeleteError } from '../../error/config-delete-error';
7
-
8
- export class DeleteManager {
9
- protected findProviderAliasFlag = true;
10
- protected globalPath: string;
11
- protected provider: string;
12
- protected aliasName: string;
13
- protected inputProviderAlias: string;
14
-
15
- constructor() {
16
- this.globalPath = path.join(os.homedir(), '.s/access.yaml');
17
- }
18
- async init(providerAlias: any) {
19
- const userInformation: any = yaml.safeLoad(fs.readFileSync(this.globalPath, 'utf8'));
20
-
21
- if (providerAlias['Provider'] && providerAlias['AliasName']) {
22
- this.provider = String(providerAlias['Provider']).toLocaleLowerCase();
23
- this.aliasName = String(providerAlias['AliasName']).toLocaleLowerCase();
24
- this.inputProviderAlias = `${this.provider}.${this.aliasName || 'default'}`;
25
-
26
- try {
27
- const userInformationKey: Array<string> = Object.keys(userInformation);
28
- for (const item of userInformationKey) {
29
- if (item === this.inputProviderAlias) {
30
- delete userInformation[item];
31
- this.findProviderAliasFlag = !this.findProviderAliasFlag;
32
- }
33
- }
34
- await this.isSuccessDle(userInformation);
35
- } catch (err) {
36
- throw new ConfigDeleteError('The configuration list is empty. You can add configuration through: s config add');
37
- }
38
- } else if (!providerAlias['Provider'] || !providerAlias['AliasName']) {
39
- //没有一起输入provider 和alias
40
- throw new ConfigDeleteError('Need to enter provider and aliasName at the same time. You can obtain the key information through: s config delete -h.');
41
- }
42
- }
43
- async isSuccessDle(userInformation: any) {
44
- if (!this.findProviderAliasFlag) {
45
- await fs.writeFileSync(this.globalPath, yaml.dump(userInformation));
46
- logger.success('Deletion succeeded');
47
- } else {
48
- throw new ConfigDeleteError('The key information is not found. You can obtain the key information through: s config get -l.');
49
- }
50
- }
51
- }
@@ -1,38 +0,0 @@
1
- import * as program from 'commander';
2
- import i18n from '../../utils/i18n';
3
- import { DeleteManager } from './delete-manager';
4
- import {ConfigError} from '../../error/config-error';
5
- import {CommandError} from '../../error/command-error';
6
-
7
- const description = i18n.__('s config delete help');
8
-
9
- program
10
- .name('s config delete')
11
- .usage('[options] [name]')
12
- .helpOption('-h,--help', i18n.__('Display help for command'))
13
- .option(
14
- '-p, --provider [name]',
15
- i18n.__('The cloud service provider. [alibaba/aws/azure/baidu/google/huawei/tencent]')
16
- )
17
- .option(
18
- '-a , --alias-name [name]',
19
- i18n.__('Key pair alia, if the alias is not set, use default instead')
20
- )
21
- .description(description)
22
- .parse(process.argv);
23
-
24
- (async () => {
25
- const providerAlias: Object = {
26
- Provider: program.provider,
27
- AliasName: program.aliasName
28
- };
29
-
30
- if (program.args.length === 0 && (program.provider == undefined || program.aliasName == undefined)) {
31
- program.help();
32
- } else if (program.args.length > 0) {
33
- throw new ConfigError('Please input right format , You can obtain the key information through: s config delete -h.');
34
- }
35
- await (new DeleteManager()).init(providerAlias);
36
- })().catch((err) => {
37
- throw new CommandError(err.message);
38
- });
@@ -1,148 +0,0 @@
1
- import {ConfigGetError} from '../../error/config-get-error';
2
- const os = require('os');
3
- const fs = require('fs');
4
- const path = require('path');
5
- const yaml = require('js-yaml');
6
- import { printn } from '../../utils/common';
7
- import { providerObject } from '../common/common';
8
- import logger from '../../utils/logger';
9
-
10
- export class GetManager {
11
- protected localPath: string = path.join(process.cwd(), '/access.yaml');
12
- protected globalPath: string = path.join(os.homedir(), `.s/access.yaml`);
13
- protected programArgsLength = 0;
14
- protected resUserInformation: any = {};
15
- protected providerAlias: string;
16
-
17
- constructor() {
18
- if (!fs.existsSync(path.join(process.cwd(), '/access.yaml'))) {
19
- this.localPath = path.join(process.cwd(), '/access.yml');
20
- }
21
-
22
- if (!fs.existsSync(this.globalPath)) {
23
- fs.writeFileSync(this.globalPath, '');
24
- }
25
- }
26
-
27
- async initAccessData(userInput: any) {
28
- await this.getManager(userInput, this.localPath);
29
- await this.getManager(userInput, this.globalPath);
30
- }
31
-
32
- async getManager(userInput: any, filePath: string) {
33
- try {
34
- let userInformation: any;
35
- try {
36
- userInformation = yaml.safeLoad(fs.readFileSync(filePath, 'utf8'));
37
- } catch (ex) {
38
- if (filePath === this.globalPath) {
39
- fs.writeFileSync(this.globalPath, '');
40
- }
41
- }
42
- if (userInformation !== null) {
43
- if (userInput['Provider']) {
44
- const provider: string = String(userInput['Provider']).toLocaleLowerCase();
45
- const userInformationKey: Array<string> = Object.keys(userInformation);
46
- if (userInput['AliasName']) {
47
- const aliasName: string = String(userInput['AliasName']).toLocaleLowerCase();
48
- this.providerAlias = this.localPath === filePath ? aliasName : `${provider}.${aliasName}`;
49
- userInformationKey.forEach((item) => {
50
- if (item === this.providerAlias) {
51
- this.resUserInformation[this.providerAlias] = userInformation[this.providerAlias];
52
- }
53
- });
54
- } else {
55
- userInformationKey.forEach((item) => {
56
- if (this.localPath === filePath) {
57
- this.resUserInformation[`project.${item}`] = userInformation[item];
58
- } else if (item.split('.')[0] === provider) {
59
- this.resUserInformation[item] = userInformation[item];
60
- }
61
- });
62
- }
63
- } else if (userInput['List']) {
64
- for (const item in userInformation) {
65
- if (filePath === this.localPath) {
66
- this.resUserInformation[`project.${item}`] = userInformation[item];
67
- } else {
68
- this.resUserInformation[item] = userInformation[item];
69
- }
70
- }
71
- }
72
- } else {
73
- if (this.localPath !== filePath) {
74
- throw new ConfigGetError('Query failed : User configuration is empty');
75
- }
76
- }
77
- } catch (ex) {
78
- this.resUserInformation = {};
79
- }
80
- }
81
-
82
- //返回单个provider.alias的值
83
- async getUserSecretID(userInput: any) {
84
- if (this.resUserInformation !== null) {
85
- if (userInput['Provider'] && userInput['AliasName']) {
86
- return this.resUserInformation[userInput['AliasName']] || this.resUserInformation[this.providerAlias];
87
- }
88
- // await this.initAccessData(userInput)
89
- return this.resUserInformation;
90
-
91
- }
92
- throw new ConfigGetError('Query failed : Please input right format. You can obtain the key information through: s config get -h');
93
-
94
- }
95
-
96
- outputFormat(resUserInformation: any): void {
97
-
98
- let sortUserKey: Array<string> = Object.keys(resUserInformation).sort(
99
- (a: string, b: string) => {
100
- if (a < b) {
101
- return -1;
102
- } else if (a > b) {
103
- return 1;
104
- }
105
- return 0;
106
-
107
- }
108
- );
109
-
110
- const sortUserKeyLength: number = sortUserKey.length;
111
- for (let i = 0; i < sortUserKeyLength; i++) {
112
- let provider: string = sortUserKey[i].split('.')[0];
113
- let aliasName: string = sortUserKey[i].split('.')[1];
114
- let resObject: any = resUserInformation[sortUserKey[i]];
115
-
116
- if (i === 0 || sortUserKey[i - 1].split('.')[0] != sortUserKey[i].split('.')[0]) {
117
- if (providerObject[provider]) {
118
- logger.info(`${providerObject[provider]}(${provider})`);
119
- } else {
120
- logger.info(`${provider}`);
121
- }
122
- }
123
- logger.log(` `);
124
- logger.info(` AliasName: ${aliasName}`);
125
- // eslint-disable-next-line guard-for-in
126
- for (let item in resObject) {
127
- const valueOfKey = item;
128
- let valueOfValue = resObject[item];
129
- const valueOfValueLength: any = valueOfValue.length;
130
- valueOfValue = valueOfValueLength > 6 ? valueOfValue.slice(0, 3) + printn(valueOfValueLength - 6, '*') + valueOfValue.slice(valueOfValueLength - 3, valueOfValueLength) : valueOfValue;
131
- logger.info(` ${valueOfKey}: ${valueOfValue} `);
132
- }
133
- // for (let [valueOfKey, valueOfValue] of Object.entries(resObject)) {
134
- // const valueOfValueLength: any = valueOfValue.length;
135
- // valueOfValue = valueOfValueLength > 6 ? valueOfValue.slice(0, 3) + printn(valueOfValueLength - 6, '*') + valueOfValue.slice(valueOfValueLength - 3, valueOfValueLength) : valueOfValue;
136
- // logger.info(` ${valueOfKey}: ${valueOfValue} `);
137
- // }
138
- logger.info(` `);
139
- }
140
- }
141
- consoleRes() {
142
- if (Object.keys(this.resUserInformation).length > 0) {
143
- this.outputFormat(this.resUserInformation);
144
- } else {
145
- throw new ConfigGetError('Query failed : The key information is not found. You can obtain the key information through: s config get -l');
146
- }
147
- }
148
- }
@@ -1,49 +0,0 @@
1
- import * as program from 'commander';
2
- import i18n from '../../utils/i18n';
3
- import logger from '../../utils/logger';
4
- import { ConfigError } from '../../error/config-error';
5
- import { GetManager } from './get-manager';
6
- import {CommandError} from '../../error/command-error';
7
-
8
- const wrongInput = 'Get failed: Please input right format. You can obtain the key information through: s config get -h';
9
- const description = i18n.__('s config get help');
10
-
11
- program
12
- .name('s config get')
13
- .usage('[options] [name]')
14
- .helpOption('-h, --help', i18n.__('Display help for command'))
15
- .option(
16
- '-p, --provider [name]',
17
- i18n.__('The cloud service provider. [alibaba/aws/azure/baidu/google/huawei/tencent]')
18
- )
19
- .option(
20
- '-a, --aliasName [name]',
21
- i18n.__('Key pair alia, if the alias is not set, use default instead')
22
- )
23
- .option('-l, --list [name]', i18n.__('Show user configuration list'))
24
- .description(description)
25
- .parse(process.argv);
26
-
27
- (async () => {
28
- const providerAlias: Object = {
29
- Provider: program.provider,
30
- AliasName: program.aliasName,
31
- List: program.list
32
- };
33
- if (
34
- program.args.length === 0 &&
35
- program.provider === undefined &&
36
- !program.list
37
- ) {
38
- program.help();
39
- } else if (program.args.length > 0) {
40
- logger.error(wrongInput);
41
- throw new ConfigError('Query failed');
42
- }
43
-
44
- const getManager = new GetManager();
45
- await getManager.initAccessData(providerAlias);
46
- getManager.consoleRes();
47
- })().catch((err) => {
48
- throw new CommandError(err.message);
49
- });
@@ -1,13 +0,0 @@
1
- import * as program from 'commander';
2
- import i18n from '../utils/i18n';
3
-
4
- program
5
- .name('s config')
6
- .usage('[commands] [options]')
7
- .helpOption('-h, --help', i18n.__('Display help for command'))
8
- .command('add', i18n.__('Add an account'))
9
- .command('get', i18n.__('Get accounts'))
10
- .command('delete', i18n.__('Delete an account'))
11
- .command('update', i18n.__('Update an account'))
12
- .description(i18n.__('You can configure provider accounts, including Alibaba Cloud, Baidu Cloud, Huawei Cloud, Tencent Cloud, etc.'))
13
- .parse(process.argv);
@@ -1,46 +0,0 @@
1
- import * as program from 'commander';
2
- import { getInputData } from '../common/common';
3
- import i18n from '../../utils/i18n';
4
- import { UpdateManager } from './update-manager';
5
- import {ConfigUpdateError} from '../../error/config-update-error';
6
- import {CommandError} from '../../error/command-error';
7
-
8
- const wrongInput = 'Update failed: Please input right format. You can obtain the key information through: s config update -h';
9
- const description = i18n.__('s config update help');
10
-
11
- program
12
- .name('s config update')
13
- .usage('[options] [name]')
14
- .helpOption('-h, --help', i18n.__('Display help for command'))
15
- .option(
16
- '-p, --provider [name]',
17
- i18n.__('The cloud service provider. [alibaba/aws/azure/baidu/google/huawei/tencent]')
18
- )
19
- .option(
20
- '-a , --alias-name [name]',
21
- i18n.__('Key pair alia, if the alias is not set, use default instead')
22
- )
23
- .option('--AccountID [name]', i18n.__('Update AccountID'))
24
- .option('--AccessKeyID [name]', i18n.__('Update AccessKeyID'))
25
- .option('--AccessKeySecret [name]', i18n.__('Update AccessKeySecret'))
26
- .option('--SecretID [name]', i18n.__('Update SecretID'))
27
- .option('--SecretKey [name]', i18n.__('Update SecretKey'))
28
- .option('--SecretAccessKey [name]', i18n.__('Update SecretAccessKey'))
29
- .option('--KeyVault [name]', i18n.__('Update KeyVault'))
30
- .option('--Secret [name]', i18n.__('Update Secret'))
31
- .option('--PrivateKeyData [name]', i18n.__('Update PrivateKeyData'))
32
- .description(description)
33
- .parse(process.argv);
34
-
35
- (async () => {
36
- if (program.args.length === 0 && (program.provider == undefined || program.aliasName == undefined)) {
37
- program.help();
38
- } else if (program.args.length > 0) {
39
- throw new ConfigUpdateError(wrongInput);
40
- }
41
- await (new UpdateManager()).updateManager(
42
- {Provider: program.provider, AliasName: program.aliasName},
43
- getInputData(program));
44
- })().catch((err) => {
45
- throw new CommandError(err.message);
46
- });
@@ -1,120 +0,0 @@
1
- import {printn} from '../../utils/common';
2
-
3
- const path = require('path');
4
- const os = require('os');
5
- const inquirer = require('inquirer');
6
- const fs = require('fs');
7
- const yaml = require('js-yaml');
8
- import logger from '../../utils/logger';
9
- import { ConfigUpdateError } from '../../error/config-update-error';
10
- import { providerCollection, providerAccessFormat, providerObject } from '../common/common';
11
- import i18n from '../../utils/i18n';
12
-
13
- interface ConfigMap {[key: string]: any;}
14
-
15
- export class UpdateManager {
16
- protected filePath: string;
17
- protected promptList: Array<any> = [];
18
- protected inputProviderAlias: string;
19
- protected oldSecretID: ConfigMap = {};
20
- protected inputSecretData: ConfigMap = {};
21
- protected userInformation: ConfigMap = {};
22
- protected context: Array<string>;
23
- protected provider: string;
24
- protected aliasName: string;
25
- constructor() {
26
- // 获得当前用户目录
27
- this.filePath = path.join(os.homedir(), '.s/access.yaml');
28
- }
29
-
30
- async updateManager(providerAlias: any, inputSecret: any) {
31
- this.userInformation = yaml.safeLoad( fs.readFileSync(this.filePath, 'utf8'));
32
- if (this.userInformation) {
33
- if (providerAlias['Provider'] && providerAlias['AliasName']) {
34
- this.provider = String(providerAlias['Provider']).toLocaleLowerCase();
35
- this.aliasName = String(providerAlias['AliasName']).toLocaleLowerCase();
36
- this.inputProviderAlias = `${this.provider}.${this.aliasName || 'default'}`;
37
-
38
- // 检查系统配置是否含有inputProviderAlias
39
- const hasProviderAlia: boolean = Object.keys(this.userInformation).includes(this.inputProviderAlias);
40
- if (hasProviderAlia) {
41
- if (Object.keys(inputSecret).length === 0) {
42
- await this.inputSecretZero(providerAlias);
43
- } else {
44
- await this.inputSecretNotZero(inputSecret);
45
- }
46
- } else {
47
- throw new ConfigUpdateError('The provider or alias information is not found. You can obtain the key information through: s config get -l');
48
- }
49
- }
50
- } else {
51
- throw new ConfigUpdateError('The configuration list is empty. You can add configuration through: s config add');
52
- }
53
- }
54
- async inputSecretZero(providerAlias: any) {
55
- try {
56
- Object.keys(providerCollection).forEach((item) => {
57
- if (item === this.provider) {
58
- this.promptList = providerCollection[item];
59
- }
60
- });
61
- } catch (err) {
62
- throw new ConfigUpdateError(err.message);
63
- }
64
- const tempAccess = this.userInformation[`${providerAlias['Provider']}.${providerAlias['AliasName'] || 'default'}`];
65
- for (let i = 0;i < this.promptList.length;i++) {
66
- const tempName = this.promptList[i]['name'];
67
- const valueOfValueLength = tempAccess[tempName].length;
68
- tempAccess[tempName] = valueOfValueLength > 6 ? tempAccess[tempName].slice(0, 3) + printn(valueOfValueLength - 6, '*') + tempAccess[tempName].slice(valueOfValueLength - 3, valueOfValueLength) : tempAccess[tempName];
69
- this.promptList[i]['default'] = tempAccess[tempName];
70
- }
71
- await inquirer.prompt(this.promptList).then((answers: any) => {
72
- this.inputSecretData = answers;
73
- });
74
- await this.userInputCheck(this.inputSecretData);
75
- }
76
-
77
- async inputSecretNotZero(inputSecret: any) {
78
- const hasProviderAlia: boolean = Object.keys(this.userInformation).includes(this.inputProviderAlias);
79
- if (hasProviderAlia) {
80
- await this.userInputCheck(inputSecret);
81
- }
82
- }
83
-
84
- // 校验用户输入的信息, 并更新用户信息
85
- async userInputCheck(inputSecret: any) {
86
- let providerAccessFormatSecret: Array<string> = providerAccessFormat[this.provider];
87
- this.oldSecretID = this.userInformation[this.inputProviderAlias];
88
- Object.keys(inputSecret).forEach((item) => {
89
- if (!providerAccessFormatSecret.includes(item)) {
90
- throw new ConfigUpdateError('Please Input Right Secret Format: [{{providerAccessFormatSecret}}]', {providerAccessFormatSecret: providerAccessFormatSecret});
91
- } else if (providerAccessFormatSecret.includes(item) && inputSecret[item]) {
92
- this.oldSecretID[item] = inputSecret[item];
93
- }
94
- });
95
-
96
- this.userInformation[this.inputProviderAlias] = this.oldSecretID;
97
- await this.writeFileWay(this.filePath, this.userInformation);
98
- this.output();
99
- }
100
-
101
- async writeFileWay(filePath: string, text: ConfigMap) {
102
- try {
103
- await fs.writeFileSync(filePath, yaml.dump(text));
104
- } catch (err) {
105
- throw new ConfigUpdateError(err.message);
106
- }
107
- logger.success('Update succeeded.');
108
- }
109
- output() {
110
- logger.log('');
111
- logger.info(i18n.__(' Provider: {{provider}}', { provider: `${providerObject[this.provider]}(${this.provider})`}));
112
- if (this.aliasName) {
113
- logger.info(i18n.__(' Alias: {{alias}}', { alias: this.aliasName }));
114
- }
115
- for (const item in this.oldSecretID) {
116
- logger.info(` ${item}: ${this.oldSecretID[item]}`);
117
- }
118
- logger.log('');
119
- }
120
- }
@@ -1,12 +0,0 @@
1
- export const SERVERLESS_HOST = 'https://tool.serverlessfans.com';
2
- export const SERVERLESS_API = 'https://tool.serverlessfans.com/api';
3
-
4
- export const SERVERLESS_CHECK_VERSION = SERVERLESS_HOST + '/version';
5
- export const SERVERLESS_GET_PACKAGE_PROVIDER = SERVERLESS_API + '/package/object/provider';
6
- export const SERVERLESS_GET_APP_INFO_URL = SERVERLESS_API + '/package/get/object/url';
7
- export const SERVERLESS_DELETE_PACKAGE_URL = SERVERLESS_API + '/package/object';
8
- export const SERVERLESS_LOGIN_URL = SERVERLESS_API + '/user/login';
9
- export const SERVERLESS_SEARCH_URL = SERVERLESS_API + '/package/object';
10
- export const SERVERLESS_CHECK_COMPONENT_VERSION = SERVERLESS_API + '/package/object/version';
11
- export const TEMPLATE_FILE = 'template.yaml';
12
- export const PROCESS_ENV_TEMPLATE_NAME = 'templateFile';
package/src/entity.ts DELETED
@@ -1,10 +0,0 @@
1
- export interface CommandType {
2
- type: string,
3
- message: string,
4
- name: string,
5
- default?: string,
6
- choices?: any
7
- }
8
- export interface InquirerCommand {
9
- [key: string]: CommandType;
10
- }
@@ -1,7 +0,0 @@
1
- import { ServerlessError } from './serverless-error';
2
-
3
- export class CommandError extends ServerlessError {
4
- constructor(message: string, params?: any) {
5
- super('Error', message, params);
6
- }
7
- }