@pisell/common 0.0.19 → 1.0.1

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 (279) hide show
  1. package/.fatherrc.ts +7 -0
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +1 -38
  4. package/{lib/components → es}/button/index.d.ts +5 -4
  5. package/es/button/index.d.ts.map +1 -0
  6. package/es/button/index.js +33 -0
  7. package/{es/components → lib}/button/index.d.ts +5 -4
  8. package/lib/button/index.d.ts.map +1 -0
  9. package/lib/{components/avatar → button}/index.js +14 -11
  10. package/package.json +20 -77
  11. package/src/button/index.md +17 -0
  12. package/src/button/index.tsx +38 -0
  13. package/tsconfig.json +14 -0
  14. package/LICENSE +0 -21
  15. package/es/bin/pisell.js +0 -2
  16. package/es/business-components/colorInput/index.d.ts +0 -21
  17. package/es/business-components/colorInput/index.js +0 -43
  18. package/es/business-components/colorInput/index.less +0 -10
  19. package/es/business-components/index.d.ts +0 -11
  20. package/es/business-components/index.js +0 -7
  21. package/es/business-components/rechargeOption/index.d.ts +0 -36
  22. package/es/business-components/rechargeOption/index.js +0 -132
  23. package/es/business-components/rechargeOption/index.less +0 -0
  24. package/es/business-components/selectTag/index.d.ts +0 -25
  25. package/es/business-components/selectTag/index.js +0 -179
  26. package/es/business-components/selectTag/index.less +0 -22
  27. package/es/business-components/sortModal/index.d.ts +0 -30
  28. package/es/business-components/sortModal/index.js +0 -85
  29. package/es/business-components/sortModal/index.less +0 -29
  30. package/es/business-components/statistics/index.d.ts +0 -12
  31. package/es/business-components/statistics/index.js +0 -38
  32. package/es/business-components/statistics/index.less +0 -64
  33. package/es/business-components/tagModal/index.d.ts +0 -17
  34. package/es/business-components/tagModal/index.js +0 -58
  35. package/es/business-hooks/index.d.ts +0 -2
  36. package/es/business-hooks/index.js +0 -2
  37. package/es/business-hooks/useModal/index.d.ts +0 -31
  38. package/es/business-hooks/useModal/index.js +0 -91
  39. package/es/business-hooks/useModal/index.less +0 -0
  40. package/es/business-hooks/useTagModal/index.d.ts +0 -17
  41. package/es/business-hooks/useTagModal/index.js +0 -47
  42. package/es/components/ColorPicker/index.d.ts +0 -22
  43. package/es/components/ColorPicker/index.js +0 -51
  44. package/es/components/ColorPicker/index.less +0 -17
  45. package/es/components/DragSort/index.d.ts +0 -2
  46. package/es/components/DragSort/index.js +0 -68
  47. package/es/components/EditorPreview/index.d.ts +0 -5
  48. package/es/components/EditorPreview/index.js +0 -14
  49. package/es/components/EditorPreview/index.less +0 -81
  50. package/es/components/Iconfont/index.d.ts +0 -6
  51. package/es/components/Iconfont/index.js +0 -29
  52. package/es/components/Iconfont/index.less +0 -0
  53. package/es/components/agreement/Detail/index.d.ts +0 -3
  54. package/es/components/agreement/Detail/index.js +0 -77
  55. package/es/components/agreement/Detail/serve.d.ts +0 -1
  56. package/es/components/agreement/Detail/serve.js +0 -6
  57. package/es/components/agreement/index.d.ts +0 -11
  58. package/es/components/agreement/index.js +0 -45
  59. package/es/components/agreement/index.less +0 -20
  60. package/es/components/avatar/index.d.ts +0 -13
  61. package/es/components/avatar/index.js +0 -25
  62. package/es/components/button/index.js +0 -36
  63. package/es/components/card/index.d.ts +0 -5
  64. package/es/components/card/index.js +0 -16
  65. package/es/components/card/index.less +0 -9
  66. package/es/components/checkbox/index.d.ts +0 -20
  67. package/es/components/checkbox/index.js +0 -43
  68. package/es/components/configProvider/index.d.ts +0 -113
  69. package/es/components/configProvider/index.js +0 -114
  70. package/es/components/datePicker/index.d.ts +0 -9
  71. package/es/components/datePicker/index.js +0 -17
  72. package/es/components/index.d.ts +0 -30
  73. package/es/components/index.js +0 -16
  74. package/es/components/input/index.d.ts +0 -35
  75. package/es/components/input/index.js +0 -97
  76. package/es/components/inputNumber/index.d.ts +0 -9
  77. package/es/components/inputNumber/index.js +0 -17
  78. package/es/components/pagination/index.d.ts +0 -10
  79. package/es/components/pagination/index.js +0 -18
  80. package/es/components/radio/index.d.ts +0 -13
  81. package/es/components/radio/index.js +0 -28
  82. package/es/components/select/index.d.ts +0 -9
  83. package/es/components/select/index.js +0 -17
  84. package/es/components/switch/index.d.ts +0 -10
  85. package/es/components/switch/index.js +0 -18
  86. package/es/config/index.d.ts +0 -30
  87. package/es/config/index.js +0 -18
  88. package/es/config/request.d.ts +0 -7
  89. package/es/config/request.js +0 -67
  90. package/es/config/utils.d.ts +0 -0
  91. package/es/config/utils.js +0 -0
  92. package/es/hooks/index.d.ts +0 -8
  93. package/es/hooks/index.js +0 -8
  94. package/es/hooks/useCountDown/index.d.ts +0 -10
  95. package/es/hooks/useCountDown/index.js +0 -48
  96. package/es/hooks/useDocumentScroll/index.d.ts +0 -8
  97. package/es/hooks/useDocumentScroll/index.js +0 -41
  98. package/es/hooks/useDocumentScroll/index.less +0 -0
  99. package/es/hooks/useMousemove/index.d.ts +0 -8
  100. package/es/hooks/useMousemove/index.js +0 -61
  101. package/es/hooks/useResponsive/index.d.ts +0 -2
  102. package/es/hooks/useResponsive/index.js +0 -29
  103. package/es/hooks/useResponsive/index.less +0 -0
  104. package/es/hooks/useSize/index.d.ts +0 -2
  105. package/es/hooks/useSize/index.js +0 -27
  106. package/es/hooks/useSize/index.less +0 -0
  107. package/es/hooks/useStateMulti/index.d.ts +0 -2
  108. package/es/hooks/useStateMulti/index.js +0 -29
  109. package/es/hooks/useStateWithCb/index.d.ts +0 -2
  110. package/es/hooks/useStateWithCb/index.js +0 -42
  111. package/es/hooks/useTable/index.d.ts +0 -12
  112. package/es/hooks/useTable/index.js +0 -74
  113. package/es/hooks/useTable/index.less +0 -0
  114. package/es/hooks/useTableModal/index.d.ts +0 -12
  115. package/es/hooks/useTableModal/index.js +0 -25
  116. package/es/hooks/useTableModal/index.less +0 -0
  117. package/es/hooks/useUrlState/index.d.ts +0 -2
  118. package/es/hooks/useUrlState/index.js +0 -56
  119. package/es/hooks/useWebSocket/index.d.ts +0 -13
  120. package/es/hooks/useWebSocket/index.js +0 -121
  121. package/es/index.d.ts +0 -4
  122. package/es/index.js +0 -4
  123. package/es/locales/en-US.d.ts +0 -11
  124. package/es/locales/en-US.js +0 -10
  125. package/es/locales/index.d.ts +0 -1
  126. package/es/locales/index.js +0 -23
  127. package/es/locales/zh-CN.d.ts +0 -11
  128. package/es/locales/zh-CN.js +0 -10
  129. package/es/locales/zh-TW.d.ts +0 -11
  130. package/es/locales/zh-TW.js +0 -10
  131. package/es/script/constants/index.js +0 -8
  132. package/es/script/deploy.js +0 -47
  133. package/es/script/index.js +0 -40
  134. package/es/script/package.json +0 -4
  135. package/es/script/release/index.js +0 -161
  136. package/es/script/release/release.js +0 -163
  137. package/es/script/uploadCode/index.js +0 -278
  138. package/es/script/uploadCode/uploadCode.js +0 -401
  139. package/es/script/utils/index.js +0 -321
  140. package/es/utils/index.d.ts +0 -3
  141. package/es/utils/index.js +0 -3
  142. package/es/utils/otherUtils.d.ts +0 -8
  143. package/es/utils/otherUtils.js +0 -12
  144. package/es/utils/storage.d.ts +0 -30
  145. package/es/utils/storage.js +0 -70
  146. package/es/utils/typeUtils.d.ts +0 -42
  147. package/es/utils/typeUtils.js +0 -86
  148. package/lib/bin/pisell.js +0 -26
  149. package/lib/business-components/colorInput/index.d.ts +0 -21
  150. package/lib/business-components/colorInput/index.js +0 -70
  151. package/lib/business-components/colorInput/index.less +0 -10
  152. package/lib/business-components/index.d.ts +0 -11
  153. package/lib/business-components/index.js +0 -54
  154. package/lib/business-components/rechargeOption/index.d.ts +0 -36
  155. package/lib/business-components/rechargeOption/index.js +0 -112
  156. package/lib/business-components/rechargeOption/index.less +0 -0
  157. package/lib/business-components/selectTag/index.d.ts +0 -25
  158. package/lib/business-components/selectTag/index.js +0 -181
  159. package/lib/business-components/selectTag/index.less +0 -22
  160. package/lib/business-components/sortModal/index.d.ts +0 -30
  161. package/lib/business-components/sortModal/index.js +0 -100
  162. package/lib/business-components/sortModal/index.less +0 -29
  163. package/lib/business-components/statistics/index.d.ts +0 -12
  164. package/lib/business-components/statistics/index.js +0 -63
  165. package/lib/business-components/statistics/index.less +0 -64
  166. package/lib/business-components/tagModal/index.d.ts +0 -17
  167. package/lib/business-components/tagModal/index.js +0 -66
  168. package/lib/business-hooks/index.d.ts +0 -2
  169. package/lib/business-hooks/index.js +0 -42
  170. package/lib/business-hooks/useModal/index.d.ts +0 -31
  171. package/lib/business-hooks/useModal/index.js +0 -68
  172. package/lib/business-hooks/useModal/index.less +0 -0
  173. package/lib/business-hooks/useTagModal/index.d.ts +0 -17
  174. package/lib/business-hooks/useTagModal/index.js +0 -61
  175. package/lib/components/ColorPicker/index.d.ts +0 -22
  176. package/lib/components/ColorPicker/index.js +0 -80
  177. package/lib/components/ColorPicker/index.less +0 -17
  178. package/lib/components/DragSort/index.d.ts +0 -2
  179. package/lib/components/DragSort/index.js +0 -101
  180. package/lib/components/EditorPreview/index.d.ts +0 -5
  181. package/lib/components/EditorPreview/index.js +0 -37
  182. package/lib/components/EditorPreview/index.less +0 -81
  183. package/lib/components/Iconfont/index.d.ts +0 -6
  184. package/lib/components/Iconfont/index.js +0 -48
  185. package/lib/components/Iconfont/index.less +0 -0
  186. package/lib/components/agreement/Detail/index.d.ts +0 -3
  187. package/lib/components/agreement/Detail/index.js +0 -86
  188. package/lib/components/agreement/Detail/serve.d.ts +0 -1
  189. package/lib/components/agreement/Detail/serve.js +0 -30
  190. package/lib/components/agreement/index.d.ts +0 -11
  191. package/lib/components/agreement/index.js +0 -82
  192. package/lib/components/agreement/index.less +0 -20
  193. package/lib/components/avatar/index.d.ts +0 -13
  194. package/lib/components/button/index.js +0 -36
  195. package/lib/components/card/index.d.ts +0 -5
  196. package/lib/components/card/index.js +0 -42
  197. package/lib/components/card/index.less +0 -9
  198. package/lib/components/checkbox/index.d.ts +0 -20
  199. package/lib/components/checkbox/index.js +0 -36
  200. package/lib/components/configProvider/index.d.ts +0 -113
  201. package/lib/components/configProvider/index.js +0 -159
  202. package/lib/components/datePicker/index.d.ts +0 -9
  203. package/lib/components/datePicker/index.js +0 -31
  204. package/lib/components/index.d.ts +0 -30
  205. package/lib/components/index.js +0 -83
  206. package/lib/components/input/index.d.ts +0 -35
  207. package/lib/components/input/index.js +0 -53
  208. package/lib/components/inputNumber/index.d.ts +0 -9
  209. package/lib/components/inputNumber/index.js +0 -31
  210. package/lib/components/pagination/index.d.ts +0 -10
  211. package/lib/components/pagination/index.js +0 -42
  212. package/lib/components/radio/index.d.ts +0 -13
  213. package/lib/components/radio/index.js +0 -36
  214. package/lib/components/select/index.d.ts +0 -9
  215. package/lib/components/select/index.js +0 -36
  216. package/lib/components/switch/index.d.ts +0 -10
  217. package/lib/components/switch/index.js +0 -42
  218. package/lib/config/index.d.ts +0 -30
  219. package/lib/config/index.js +0 -39
  220. package/lib/config/request.d.ts +0 -7
  221. package/lib/config/request.js +0 -76
  222. package/lib/config/utils.d.ts +0 -0
  223. package/lib/config/utils.js +0 -0
  224. package/lib/hooks/index.d.ts +0 -8
  225. package/lib/hooks/index.js +0 -57
  226. package/lib/hooks/useCountDown/index.d.ts +0 -10
  227. package/lib/hooks/useCountDown/index.js +0 -57
  228. package/lib/hooks/useDocumentScroll/index.d.ts +0 -8
  229. package/lib/hooks/useDocumentScroll/index.js +0 -54
  230. package/lib/hooks/useDocumentScroll/index.less +0 -0
  231. package/lib/hooks/useMousemove/index.d.ts +0 -8
  232. package/lib/hooks/useMousemove/index.js +0 -70
  233. package/lib/hooks/useResponsive/index.d.ts +0 -2
  234. package/lib/hooks/useResponsive/index.js +0 -47
  235. package/lib/hooks/useResponsive/index.less +0 -0
  236. package/lib/hooks/useSize/index.d.ts +0 -2
  237. package/lib/hooks/useSize/index.js +0 -45
  238. package/lib/hooks/useSize/index.less +0 -0
  239. package/lib/hooks/useStateMulti/index.d.ts +0 -2
  240. package/lib/hooks/useStateMulti/index.js +0 -43
  241. package/lib/hooks/useStateWithCb/index.d.ts +0 -2
  242. package/lib/hooks/useStateWithCb/index.js +0 -53
  243. package/lib/hooks/useTable/index.d.ts +0 -12
  244. package/lib/hooks/useTable/index.js +0 -75
  245. package/lib/hooks/useTable/index.less +0 -0
  246. package/lib/hooks/useTableModal/index.d.ts +0 -12
  247. package/lib/hooks/useTableModal/index.js +0 -43
  248. package/lib/hooks/useTableModal/index.less +0 -0
  249. package/lib/hooks/useUrlState/index.d.ts +0 -2
  250. package/lib/hooks/useUrlState/index.js +0 -59
  251. package/lib/hooks/useWebSocket/index.d.ts +0 -13
  252. package/lib/hooks/useWebSocket/index.js +0 -91
  253. package/lib/index.d.ts +0 -4
  254. package/lib/index.js +0 -22
  255. package/lib/locales/en-US.d.ts +0 -11
  256. package/lib/locales/en-US.js +0 -36
  257. package/lib/locales/index.d.ts +0 -1
  258. package/lib/locales/index.js +0 -59
  259. package/lib/locales/zh-CN.d.ts +0 -11
  260. package/lib/locales/zh-CN.js +0 -36
  261. package/lib/locales/zh-TW.d.ts +0 -11
  262. package/lib/locales/zh-TW.js +0 -36
  263. package/lib/script/constants/index.js +0 -35
  264. package/lib/script/deploy.js +0 -61
  265. package/lib/script/index.js +0 -61
  266. package/lib/script/package.json +0 -4
  267. package/lib/script/release/index.js +0 -116
  268. package/lib/script/release/release.js +0 -89
  269. package/lib/script/uploadCode/index.js +0 -202
  270. package/lib/script/uploadCode/uploadCode.js +0 -208
  271. package/lib/script/utils/index.js +0 -248
  272. package/lib/utils/index.d.ts +0 -3
  273. package/lib/utils/index.js +0 -21
  274. package/lib/utils/otherUtils.d.ts +0 -8
  275. package/lib/utils/otherUtils.js +0 -31
  276. package/lib/utils/storage.d.ts +0 -30
  277. package/lib/utils/storage.js +0 -63
  278. package/lib/utils/typeUtils.d.ts +0 -42
  279. package/lib/utils/typeUtils.js +0 -75
@@ -1,208 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/script/uploadCode/uploadCode.js
30
- var uploadCode_exports = {};
31
- __export(uploadCode_exports, {
32
- default: () => uploadCode_default
33
- });
34
- module.exports = __toCommonJS(uploadCode_exports);
35
- var import_archiver = __toESM(require("archiver"));
36
- var import_path = __toESM(require("path"));
37
- var import_constants = require("../constants/index.js");
38
- var import_utils = require("../utils/index.js");
39
- var UploadCode = class {
40
- constructor(props) {
41
- const { project, env, version, changelog, is_release } = props;
42
- this.projectName = project.fileName;
43
- this.projectRelativePath = project.path;
44
- this.env = env;
45
- this.version = version;
46
- this.changelog = changelog;
47
- this.is_release = is_release;
48
- this.currentVersion = "";
49
- this.projectAbsolutePath = "";
50
- this.conn = null;
51
- this.serverConfig = null;
52
- this.outPath = import_constants.outPathMap[this.projectName][this.env];
53
- }
54
- /**
55
- * @Title: 设置服务器连接配置
56
- * @Describe:
57
- * @Author: Zsj
58
- */
59
- setConfig(serverConfig) {
60
- this.serverConfig = serverConfig;
61
- return this.serverConfig;
62
- }
63
- /**
64
- * @Title: 发布前检查环境和参数是否正确
65
- * @Describe:
66
- * @Author: Zsj
67
- */
68
- async check() {
69
- const serverConfigMap = await (0, import_utils.getServerConfig)();
70
- if (!serverConfigMap) {
71
- console.log("未找到发布脚本!");
72
- return false;
73
- }
74
- cd(this.projectRelativePath);
75
- this.projectAbsolutePath = process.cwd();
76
- if (!await (0, import_utils.isWorkingTreeClean)()) {
77
- console.log("工作区不干净, 请先提交代码");
78
- return false;
79
- }
80
- let serverConfig = this.setConfig(serverConfigMap[this.env]);
81
- if (this.env === "prod") {
82
- serverConfig.privateKey = fs.readFileSync(
83
- import_path.default.join(process.env.HOME, ".ssh", "id_rsa")
84
- );
85
- }
86
- if (this.env === "release") {
87
- serverConfig = this.setConfig(serverConfigMap.cn[this.env]);
88
- }
89
- if (!serverConfig) {
90
- console.log("您当前没有权限!");
91
- return false;
92
- }
93
- console.log("当前主项目分支", await (0, import_utils.getGitCurrentBranch)());
94
- return true;
95
- }
96
- /**
97
- * @Title: 更新项目中version 并加入changelog
98
- * @Describe:
99
- * @Author: Zsj
100
- */
101
- async updateVersion() {
102
- if (this.env === "prod") {
103
- await $`npm version ${this.version} -m "%s ${this.changelog}"`;
104
- let { version } = await fs.readJson("./package.json");
105
- this.currentVersion = version;
106
- }
107
- if (this.env !== "prod") {
108
- await $`npm version ${this.version} --no-git-tag-version`;
109
- await $`git add package.json`;
110
- let { version } = await fs.readJson("./package.json");
111
- this.currentVersion = version;
112
- await $`git commit -m "chore: ${this.currentVersion} ${this.changelog}"`;
113
- }
114
- return this.currentVersion;
115
- }
116
- /**
117
- * @Title: 根据env执行打包
118
- * @Describe:
119
- * @Author: Zsj
120
- */
121
- async build() {
122
- await $`npm run build:${this.env}`;
123
- }
124
- /**
125
- * @Title: 压缩dist文件为zip
126
- * @Describe:
127
- * @Author: Zsj
128
- */
129
- async compress() {
130
- return new Promise((resolve, reject) => {
131
- const __dirname = process.cwd();
132
- const zipFile = import_path.default.resolve(__dirname, `${this.currentVersion}.zip`);
133
- const originFilePath = import_path.default.resolve(__dirname, "dist");
134
- const output = fs.createWriteStream(zipFile);
135
- const archive = (0, import_archiver.default)("zip", {
136
- zlib: { level: 9 }
137
- // 设置压缩级别
138
- });
139
- archive.on("error", function(err) {
140
- reject(err);
141
- });
142
- output.on("close", function() {
143
- resolve(true);
144
- });
145
- archive.pipe(output);
146
- archive.directory(originFilePath, "/dist");
147
- archive.finalize();
148
- });
149
- }
150
- /**
151
- * @Title: 连接服务器
152
- * @Describe:
153
- * @Author: Zsj
154
- */
155
- async connectServer() {
156
- if (!this.serverConfig) {
157
- console.log("未找到发布配置!");
158
- return null;
159
- }
160
- this.conn = await (0, import_utils.connectServer)(this.serverConfig);
161
- return this.conn;
162
- }
163
- /**
164
- * @Title: 本地zip文件上传到服务器
165
- * @Describe:
166
- * @Author: Zsj
167
- */
168
- async serverUpload() {
169
- const localPath = import_path.default.resolve(
170
- this.projectAbsolutePath,
171
- `${this.currentVersion}.zip`
172
- );
173
- const remotePath = `${this.outPath}/${this.currentVersion}.zip`;
174
- return await (0, import_utils.serverUpload)(this.conn, { localPath, remotePath });
175
- }
176
- /**
177
- * @Title: 服务器中解压文件
178
- * @Describe:
179
- * @Author: Zsj
180
- */
181
- async serverUnpack() {
182
- return await (0, import_utils.serverUnpack)(this.conn, {
183
- path: this.outPath,
184
- fileName: `${this.currentVersion}`,
185
- fullFileName: `${this.currentVersion}.zip`,
186
- changelog: this.changelog
187
- });
188
- }
189
- /**
190
- * @Title: 删除本地zip文件
191
- * @Describe:
192
- * @Author: Zsj
193
- */
194
- deleteLocalZip() {
195
- return $`rm -rf ${this.currentVersion}.zip`;
196
- }
197
- /**
198
- * @Title: 断开服务连接
199
- * @Describe:
200
- * @Author: Zsj
201
- */
202
- async disconnectServer() {
203
- return await this.conn.end();
204
- }
205
- };
206
- var uploadCode_default = UploadCode;
207
- // Annotate the CommonJS export names for ESM import in node:
208
- 0 && (module.exports = {});
@@ -1,248 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/script/utils/index.js
30
- var utils_exports = {};
31
- __export(utils_exports, {
32
- connectServer: () => connectServer,
33
- getCurrentProjectName: () => getCurrentProjectName,
34
- getCurrentUserName: () => getCurrentUserName,
35
- getGitCurrentBranch: () => getGitCurrentBranch,
36
- getServerConfig: () => getServerConfig,
37
- isWorkingTreeClean: () => isWorkingTreeClean,
38
- loadJSON: () => loadJSON,
39
- releaseProject: () => releaseProject,
40
- sendWebhook: () => sendWebhook,
41
- serverUnpack: () => serverUnpack,
42
- serverUpload: () => serverUpload,
43
- versionSort: () => versionSort
44
- });
45
- module.exports = __toCommonJS(utils_exports);
46
- var dotenv = __toESM(require("dotenv"));
47
- var import_path = __toESM(require("path"));
48
- var import_ssh2 = __toESM(require("ssh2"));
49
- var isWorkingTreeClean = async () => {
50
- const v = await $`git status --porcelain`;
51
- return v.stdout === "";
52
- };
53
- var getGitCurrentBranch = async () => {
54
- const v = await $`git symbolic-ref --short HEAD`;
55
- return v.stdout;
56
- };
57
- var getServerConfig = async () => {
58
- return await fs.readJson("../lm_config.json");
59
- };
60
- var connectServer = (config2) => {
61
- const conn = new import_ssh2.default.Client();
62
- return new Promise((resolve, reject) => {
63
- conn.on("ready", () => {
64
- resolve(conn);
65
- }).on("error", (err) => {
66
- console.log(err, "connect error");
67
- reject();
68
- }).connect(config2);
69
- });
70
- };
71
- var serverUpload = (conn, { localPath, remotePath }) => {
72
- if (!conn)
73
- return Promise.reject("未连接服务器");
74
- return new Promise((resolve, reject) => {
75
- conn.sftp((err, sftp) => {
76
- if (err) {
77
- console.log(err);
78
- reject(err);
79
- return;
80
- }
81
- sftp.fastPut(
82
- localPath,
83
- remotePath,
84
- {
85
- step: (total, nb, fsize) => {
86
- console.table([
87
- {
88
- 标题: "当前已上传",
89
- 值: `${(total / fsize * 100).toFixed(2)}%`
90
- },
91
- {
92
- 标题: "每次上传",
93
- 值: `${(nb / 1024 / 1024).toFixed(2)}M`
94
- },
95
- {
96
- 标题: "总大小",
97
- 值: `${(fsize / 1024 / 1024).toFixed(2)}M`
98
- }
99
- ]);
100
- }
101
- },
102
- (err2) => {
103
- if (err2) {
104
- console.log(err2);
105
- reject(err2);
106
- return;
107
- }
108
- console.log("上传成功");
109
- resolve(conn);
110
- }
111
- );
112
- });
113
- });
114
- };
115
- var serverUnpack = (conn, { path: path2, fileName, fullFileName, changelog }) => {
116
- if (!conn)
117
- return Promise.reject("未连接服务器");
118
- return new Promise((resolve, reject) => {
119
- conn.shell((err, stream) => {
120
- if (err) {
121
- console.log(err);
122
- reject(err);
123
- return;
124
- }
125
- stream.end(
126
- `
127
- cd ${path2}
128
- unzip ${fullFileName} -d ${fileName} && mv ${fileName}/dist/* ${fileName}/ && rmdir ${fileName}/dist
129
- rm -rf ${fullFileName}
130
- echo "${changelog}" > ./${fileName}/changelog.md
131
- sh deleteOldVersion.sh
132
- exit
133
- `
134
- // 打开到path
135
- // 解压 1.0.0.zip 文件到 1.0.0 移动dist中内容到 1.0.0内 删除dist
136
- // 删除1.0.0.zip
137
- // 写入changelog到changelog.md
138
- // 执行deleteOldVersion脚本 删除过早版本
139
- ).on("data", (data) => {
140
- console.log(data.toString());
141
- }).on("close", () => {
142
- console.log("✅上传完成");
143
- resolve();
144
- });
145
- });
146
- });
147
- };
148
- var releaseProject = (conn, { path: path2, fileName }) => {
149
- return new Promise((resolve, reject) => {
150
- conn.shell((err, stream) => {
151
- if (err) {
152
- console.log(err);
153
- reject(err);
154
- return;
155
- }
156
- stream.end(
157
- `
158
- cd ${path2}
159
- cp -R -f pre-master next-master
160
- rm -rf pre-master
161
- \\cp -R -f ${fileName}/* next-master
162
- cp -R -f ${fileName} pre-master
163
- rm -rf master
164
- cp -R next-master master
165
- rm -rf next-master
166
- exit
167
- `
168
- // 打开到path
169
- // 复制pre-master到next-master
170
- // 删除pre-master
171
- // 复制1.0.0到next-master
172
- // 复制1.0.0到pre-master
173
- // 删除master
174
- // 复制next-master到master
175
- // 删除next-master
176
- ).on("data", (data) => {
177
- console.log(data.toString());
178
- }).on("close", () => {
179
- console.log("✅发布完成");
180
- resolve();
181
- });
182
- });
183
- });
184
- };
185
- var versionSort = (versionList) => {
186
- return versionList.sort((a, b) => {
187
- const aParts = a.split(".");
188
- const bParts = b.split(".");
189
- for (let i = 0; i < aParts.length && i < bParts.length; i++) {
190
- const aNum = parseInt(aParts[i]);
191
- const bNum = parseInt(bParts[i]);
192
- if (aNum !== bNum) {
193
- return bNum - aNum;
194
- }
195
- }
196
- return bParts.length - aParts.length;
197
- });
198
- };
199
- var getCurrentProjectName = () => {
200
- return loadJSON(import_path.default.join(process.cwd(), "./package.json")).name;
201
- };
202
- var loadJSON = (path2) => JSON.parse(fs.readFileSync(path2));
203
- var getCurrentUserName = async () => {
204
- const { stdout } = await $`git config user.name`;
205
- return stdout;
206
- };
207
- var createFeishuMessageContent = (contentArr) => {
208
- return JSON.stringify(
209
- contentArr.map((item) => {
210
- return [
211
- { tag: "text", text: `${item.key}: ` },
212
- { tag: "text", text: `${item.value}` }
213
- ];
214
- })
215
- );
216
- };
217
- var sendWebhook = async ({ title, content }) => {
218
- var _a, _b, _c, _d;
219
- const contentStr = createFeishuMessageContent(content);
220
- if (!((_b = (_a = dotenv.config()) == null ? void 0 : _a.parsed) == null ? void 0 : _b.WEBHOOK))
221
- return;
222
- const response = await fetch((_d = (_c = dotenv.config()) == null ? void 0 : _c.parsed) == null ? void 0 : _d.WEBHOOK, {
223
- headers: {
224
- "Content-Type": "application/json"
225
- },
226
- method: "POST",
227
- body: JSON.stringify({
228
- msg_type: "post",
229
- content: `{"post":{"zh_cn":{"title":"${title}","content":${contentStr}}}}`
230
- })
231
- });
232
- return await response.json();
233
- };
234
- // Annotate the CommonJS export names for ESM import in node:
235
- 0 && (module.exports = {
236
- connectServer,
237
- getCurrentProjectName,
238
- getCurrentUserName,
239
- getGitCurrentBranch,
240
- getServerConfig,
241
- isWorkingTreeClean,
242
- loadJSON,
243
- releaseProject,
244
- sendWebhook,
245
- serverUnpack,
246
- serverUpload,
247
- versionSort
248
- });
@@ -1,3 +0,0 @@
1
- export * from './otherUtils';
2
- export * from './storage';
3
- export * from './typeUtils';
@@ -1,21 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/utils/index.ts
17
- var utils_exports = {};
18
- module.exports = __toCommonJS(utils_exports);
19
- __reExport(utils_exports, require("./otherUtils"), module.exports);
20
- __reExport(utils_exports, require("./storage"), module.exports);
21
- __reExport(utils_exports, require("./typeUtils"), module.exports);
@@ -1,8 +0,0 @@
1
- /**
2
- * @Description: 生成唯一id
3
- * @Author: wzw
4
- * @Date: 2020-12-01 14:20:29
5
- * @param {*}
6
- * @return {*}
7
- */
8
- export declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
@@ -1,31 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/utils/otherUtils.ts
20
- var otherUtils_exports = {};
21
- __export(otherUtils_exports, {
22
- getUniqueId: () => getUniqueId
23
- });
24
- module.exports = __toCommonJS(otherUtils_exports);
25
- var getUniqueId = (prefix = "", maxLength = 11) => {
26
- return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
27
- };
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- getUniqueId
31
- });
@@ -1,30 +0,0 @@
1
- /**
2
- * @title: 设置storage
3
- * @description:
4
- * @param {*} T
5
- * @param {*} param2
6
- * @return {*}
7
- * @Author: Wzw
8
- * @Date: 2022-02-21 10:30
9
- */
10
- export declare const setStorage: (key: string, value: any, type?: 'local' | 'session', prefix?: string) => any;
11
- /**
12
- * @title: 获取storage
13
- * @description:
14
- * @param {string} key
15
- * @param {string} prefix
16
- * @return {*}
17
- * @Author: Wzw
18
- * @Date: 2022-02-21 10:30
19
- */
20
- export declare const getStorage: (key: string, prefix?: string, type?: 'local' | 'session') => any;
21
- /**
22
- * @title: 删除storage
23
- * @description:
24
- * @param {string} key
25
- * @param {string} prefix
26
- * @return {*}
27
- * @Author: Wzw
28
- * @Date: 2022-02-21 10:30
29
- */
30
- export declare const removeStorage: (key: string, prefix?: string, type?: 'local' | 'session') => void;
@@ -1,63 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/utils/storage.ts
20
- var storage_exports = {};
21
- __export(storage_exports, {
22
- getStorage: () => getStorage,
23
- removeStorage: () => removeStorage,
24
- setStorage: () => setStorage
25
- });
26
- module.exports = __toCommonJS(storage_exports);
27
- var default_prefix = "shop_";
28
- var setStorage = (key, value, type, prefix) => {
29
- const _value = value;
30
- let _key = (prefix || default_prefix) + key;
31
- if (type === void 0 || type === "local") {
32
- localStorage.setItem(_key, _value);
33
- } else {
34
- sessionStorage.setItem(_key, _value);
35
- }
36
- };
37
- var getStorage = (key, prefix, type) => {
38
- let _key = (prefix || default_prefix) + key;
39
- if (key === "umi_locale") {
40
- _key = key;
41
- }
42
- if (type === void 0 || type === "local") {
43
- let _localValue = localStorage.getItem(_key) || "";
44
- return _localValue;
45
- } else {
46
- let _sessionValue = sessionStorage.getItem(_key) || "";
47
- return _sessionValue;
48
- }
49
- };
50
- var removeStorage = (key, prefix, type) => {
51
- let _key = (prefix || default_prefix) + key;
52
- if (type === void 0 || type === "local") {
53
- localStorage.removeItem(_key);
54
- } else {
55
- sessionStorage.removeItem(_key);
56
- }
57
- };
58
- // Annotate the CommonJS export names for ESM import in node:
59
- 0 && (module.exports = {
60
- getStorage,
61
- removeStorage,
62
- setStorage
63
- });
@@ -1,42 +0,0 @@
1
- /**
2
- * 判断是否是函数
3
- * @param obj
4
- */
5
- export declare const isFunction: (obj: any) => obj is Function;
6
- /**
7
- * 判断是否是数组
8
- * @param obj
9
- */
10
- export declare const isArr: (obj: any) => obj is any[];
11
- /**
12
- * 判断是否是字符串
13
- * @param obj
14
- */
15
- export declare const isString: (obj: any) => obj is string;
16
- /**
17
- * 判断是否是数字
18
- * @param obj
19
- */
20
- export declare const isNumber: (obj: any) => obj is number;
21
- /**
22
- * 判断是否是undefined
23
- * @param obj
24
- */
25
- export declare const isUndefined: (obj: any) => obj is undefined;
26
- /**
27
- * 判断是否是boolean
28
- * @param obj
29
- */
30
- export declare const isBoolean: (obj: any) => obj is boolean;
31
- /**
32
- * 判断是否是json字符串
33
- * @param v
34
- */
35
- export declare const isJson: (v: any) => boolean;
36
- /**
37
- * @Title: 判断是否为对象
38
- * @Describe:
39
- * @Author: Wzw
40
- * @param {any} obj
41
- */
42
- export declare const isPlainObject: (obj: any) => boolean;