@pisell/common 1.0.58 → 1.0.60
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.
- package/.fatherrc.ts +7 -7
- package/CHANGELOG.md +16 -1
- package/README.md +2 -2
- package/es/bin/pisell.js +1 -5
- package/es/index.d.ts +2 -4
- package/es/index.js +1 -5
- package/es/script/aws/index.js +212 -129
- package/es/script/constants/index.js +75 -84
- package/es/script/deploy.js +44 -33
- package/es/script/index.js +37 -43
- package/es/script/package.json +4 -4
- package/es/script/release/index.js +152 -85
- package/es/script/release/release.js +168 -83
- package/es/script/uploadCode/index.js +309 -239
- package/es/script/uploadCode/uploadCode.js +433 -220
- package/es/script/utils/index.js +381 -265
- package/lib/bin/pisell.js +24 -4
- package/lib/index.d.ts +2 -3
- package/lib/index.js +23 -4
- package/lib/script/aws/index.js +124 -139
- package/lib/script/constants/index.js +110 -85
- package/lib/script/deploy.js +55 -34
- package/lib/script/index.js +56 -41
- package/lib/script/package.json +4 -4
- package/lib/script/release/index.js +108 -90
- package/lib/script/release/release.js +85 -82
- package/lib/script/uploadCode/index.js +230 -244
- package/lib/script/uploadCode/uploadCode.js +225 -222
- package/lib/script/utils/index.js +264 -270
- package/package.json +2 -2
- package/src/bin/pisell.js +3 -3
- package/src/script/aws/index.js +138 -138
- package/src/script/constants/index.js +86 -86
- package/src/script/deploy.js +29 -29
- package/src/script/index.js +45 -45
- package/src/script/package.json +4 -4
- package/src/script/release/index.js +119 -119
- package/src/script/release/release.js +87 -87
- package/src/script/uploadCode/index.js +284 -284
- package/src/script/uploadCode/uploadCode.js +255 -255
- package/src/script/utils/index.js +331 -331
- package/tsconfig.json +14 -14
- package/tsdown.config.ts +93 -93
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +0 -28
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +0 -16
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +0 -11
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +0 -29
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +0 -16
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +0 -11
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +0 -18
- package/lib/_virtual/rolldown_runtime.js +0 -29
package/.fatherrc.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineConfig } from 'father';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
// more father config: https://github.com/umijs/father/blob/master/docs/config.md
|
|
5
|
-
esm: { output: 'es' },
|
|
6
|
-
cjs: { output: 'lib' },
|
|
7
|
-
});
|
|
1
|
+
import { defineConfig } from 'father';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
// more father config: https://github.com/umijs/father/blob/master/docs/config.md
|
|
5
|
+
esm: { output: 'es' },
|
|
6
|
+
cjs: { output: 'lib' },
|
|
7
|
+
});
|
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
# @pisell/common
|
|
2
2
|
|
|
3
|
+
## 1.0.60
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c57aa0c2b]
|
|
8
|
+
- @pisell/utils@1.0.59
|
|
9
|
+
|
|
10
|
+
## 1.0.59
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [f341d62bb]
|
|
15
|
+
- @pisell/utils@1.0.58
|
|
16
|
+
|
|
3
17
|
## 1.0.58
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
6
20
|
|
|
7
|
-
- Updated dependencies [
|
|
21
|
+
- Updated dependencies [b2454da56]
|
|
22
|
+
- Updated dependencies [f3d720331]
|
|
8
23
|
- @pisell/utils@1.0.57
|
|
9
24
|
|
|
10
25
|
## 1.0.57
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @pisell/common
|
|
2
|
-
|
|
1
|
+
# @pisell/common
|
|
2
|
+
|
|
3
3
|
pisell使用的通用组件库
|
package/es/bin/pisell.js
CHANGED
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/script/aws/index.js
CHANGED
|
@@ -1,135 +1,218 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
6
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
7
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
8
|
+
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
9
|
+
import fs from 'fs';
|
|
10
|
+
import mime from 'mime-types';
|
|
11
|
+
import path from 'path';
|
|
2
12
|
import { getServerConfig } from "../utils/index.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
var filterFiles = ['index.html', 'umi.server.js', 'umi.server.d.ts'];
|
|
14
|
+
var __dirname = process.cwd();
|
|
15
|
+
var s3Client = null;
|
|
16
|
+
var bucketName = '';
|
|
7
17
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
try {
|
|
66
|
-
const response = yield s3Client.send(command);
|
|
67
|
-
console.log(`上传成功: ${fileKey}`);
|
|
68
|
-
return {
|
|
69
|
-
fileName: fileKey,
|
|
70
|
-
location: response.Location
|
|
71
|
-
};
|
|
72
|
-
} catch (err) {
|
|
73
|
-
console.error(`上传失败: ${fileKey}`, err);
|
|
74
|
-
throw new Error(`上传失败: ${fileKey}, ${err.message}`);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return function uploadFile(_x2, _x3, _x4) {
|
|
78
|
-
return _ref2.apply(this, arguments);
|
|
79
|
-
};
|
|
18
|
+
/*******
|
|
19
|
+
* @title: 初始化
|
|
20
|
+
* @description:
|
|
21
|
+
* @return {*}
|
|
22
|
+
* @Author: zhiwei.Wang
|
|
23
|
+
* @Date: 2023-11-24 14:05
|
|
24
|
+
*/
|
|
25
|
+
var init = /*#__PURE__*/function () {
|
|
26
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(directory) {
|
|
27
|
+
var serverConfig, awsConfig;
|
|
28
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
29
|
+
while (1) switch (_context.prev = _context.next) {
|
|
30
|
+
case 0:
|
|
31
|
+
_context.prev = 0;
|
|
32
|
+
_context.next = 3;
|
|
33
|
+
return getServerConfig(directory);
|
|
34
|
+
case 3:
|
|
35
|
+
serverConfig = _context.sent;
|
|
36
|
+
// aws配置
|
|
37
|
+
awsConfig = serverConfig.aws;
|
|
38
|
+
if (!awsConfig) {
|
|
39
|
+
_context.next = 12;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
bucketName = awsConfig.bucketName;
|
|
43
|
+
|
|
44
|
+
// 创建实例
|
|
45
|
+
s3Client = new S3Client({
|
|
46
|
+
region: awsConfig.region,
|
|
47
|
+
credentials: {
|
|
48
|
+
accessKeyId: awsConfig.accessKeyId,
|
|
49
|
+
secretAccessKey: awsConfig.secretAccessKey
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
console.log('aws 初始化成功');
|
|
53
|
+
return _context.abrupt("return", serverConfig.aws);
|
|
54
|
+
case 12:
|
|
55
|
+
console.log('未获取到aws权限');
|
|
56
|
+
return _context.abrupt("return", false);
|
|
57
|
+
case 14:
|
|
58
|
+
_context.next = 20;
|
|
59
|
+
break;
|
|
60
|
+
case 16:
|
|
61
|
+
_context.prev = 16;
|
|
62
|
+
_context.t0 = _context["catch"](0);
|
|
63
|
+
console.log(_context.t0);
|
|
64
|
+
return _context.abrupt("return", false);
|
|
65
|
+
case 20:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _callee, null, [[0, 16]]);
|
|
70
|
+
}));
|
|
71
|
+
return function init(_x) {
|
|
72
|
+
return _ref.apply(this, arguments);
|
|
73
|
+
};
|
|
80
74
|
}();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
75
|
+
|
|
76
|
+
// 上传文件到S3指定目录
|
|
77
|
+
var uploadFile = /*#__PURE__*/function () {
|
|
78
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(directory, fileKey, filePath) {
|
|
79
|
+
var fileStream, contentType, uploadParams, command, response;
|
|
80
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
81
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
82
|
+
case 0:
|
|
83
|
+
fileStream = fs.createReadStream(filePath); // 根据文件扩展名获取MIME类型
|
|
84
|
+
contentType = mime.lookup(filePath);
|
|
85
|
+
uploadParams = {
|
|
86
|
+
Bucket: bucketName,
|
|
87
|
+
Key: "".concat(directory, "/").concat(fileKey),
|
|
88
|
+
// 指定目录路径
|
|
89
|
+
Body: fileStream,
|
|
90
|
+
ContentType: contentType,
|
|
91
|
+
ContentDisposition: 'inline',
|
|
92
|
+
ACL: 'public-read' // 设置ACL权限为公共读取
|
|
93
|
+
};
|
|
94
|
+
command = new PutObjectCommand(uploadParams);
|
|
95
|
+
_context2.prev = 4;
|
|
96
|
+
_context2.next = 7;
|
|
97
|
+
return s3Client.send(command);
|
|
98
|
+
case 7:
|
|
99
|
+
response = _context2.sent;
|
|
100
|
+
console.log("\u4E0A\u4F20\u6210\u529F: ".concat(fileKey));
|
|
101
|
+
return _context2.abrupt("return", {
|
|
102
|
+
fileName: fileKey,
|
|
103
|
+
location: response.Location
|
|
104
|
+
});
|
|
105
|
+
case 12:
|
|
106
|
+
_context2.prev = 12;
|
|
107
|
+
_context2.t0 = _context2["catch"](4);
|
|
108
|
+
console.error("\u4E0A\u4F20\u5931\u8D25: ".concat(fileKey), _context2.t0);
|
|
109
|
+
throw new Error("\u4E0A\u4F20\u5931\u8D25: ".concat(fileKey, ", ").concat(_context2.t0.message));
|
|
110
|
+
case 16:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context2.stop();
|
|
113
|
+
}
|
|
114
|
+
}, _callee2, null, [[4, 12]]);
|
|
115
|
+
}));
|
|
116
|
+
return function uploadFile(_x2, _x3, _x4) {
|
|
117
|
+
return _ref2.apply(this, arguments);
|
|
118
|
+
};
|
|
116
119
|
}();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
* @
|
|
120
|
-
* @
|
|
121
|
-
* @
|
|
122
|
-
* @
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
120
|
+
|
|
121
|
+
/*******
|
|
122
|
+
* @title: 递归上传文件夹内容
|
|
123
|
+
* @description:
|
|
124
|
+
* @return {*}
|
|
125
|
+
* @Author: zhiwei.Wang
|
|
126
|
+
* @Date: 2023-11-24 14:06
|
|
127
|
+
*/
|
|
128
|
+
export var uploadFolderContents = /*#__PURE__*/function () {
|
|
129
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(directory) {
|
|
130
|
+
var folderPath,
|
|
131
|
+
files,
|
|
132
|
+
uploadPromises,
|
|
133
|
+
_iterator,
|
|
134
|
+
_step,
|
|
135
|
+
file,
|
|
136
|
+
filePath,
|
|
137
|
+
fileStats,
|
|
138
|
+
fileKey,
|
|
139
|
+
uploadPromise,
|
|
140
|
+
subDirectory,
|
|
141
|
+
subFolderPromise,
|
|
142
|
+
_args3 = arguments;
|
|
143
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
144
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
145
|
+
case 0:
|
|
146
|
+
folderPath = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : path.resolve(__dirname, 'dist');
|
|
147
|
+
files = fs.readdirSync(folderPath); // promise all 储存
|
|
148
|
+
uploadPromises = [];
|
|
149
|
+
_iterator = _createForOfIteratorHelper(files);
|
|
150
|
+
try {
|
|
151
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
152
|
+
file = _step.value;
|
|
153
|
+
filePath = path.join(folderPath, file);
|
|
154
|
+
fileStats = fs.statSync(filePath); // 文件上传, 文件夹递归循环
|
|
155
|
+
if (fileStats.isFile()) {
|
|
156
|
+
fileKey = path.relative(folderPath, filePath); // 过滤不需要上传的文件
|
|
157
|
+
if (!filterFiles.includes(fileKey)) {
|
|
158
|
+
uploadPromise = uploadFile(directory, fileKey, filePath);
|
|
159
|
+
uploadPromises.push(uploadPromise);
|
|
160
|
+
}
|
|
161
|
+
// 文件夹
|
|
162
|
+
} else if (fileStats.isDirectory()) {
|
|
163
|
+
subDirectory = path.join(directory, file);
|
|
164
|
+
subFolderPromise = uploadFolderContents(subDirectory, filePath);
|
|
165
|
+
uploadPromises.push(subFolderPromise);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} catch (err) {
|
|
169
|
+
_iterator.e(err);
|
|
170
|
+
} finally {
|
|
171
|
+
_iterator.f();
|
|
172
|
+
}
|
|
173
|
+
return _context3.abrupt("return", Promise.all(uploadPromises).then(function (res) {
|
|
174
|
+
console.log('全部上传完成', res.length);
|
|
175
|
+
return res;
|
|
176
|
+
}).catch(function (err) {
|
|
177
|
+
throw new Error("\u4E0A\u4F20cdn\u5931\u8D25: ".concat(err.message));
|
|
178
|
+
}));
|
|
179
|
+
case 6:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context3.stop();
|
|
182
|
+
}
|
|
183
|
+
}, _callee3);
|
|
184
|
+
}));
|
|
185
|
+
return function uploadFolderContents(_x5) {
|
|
186
|
+
return _ref3.apply(this, arguments);
|
|
187
|
+
};
|
|
132
188
|
}();
|
|
133
189
|
|
|
134
|
-
|
|
135
|
-
|
|
190
|
+
/*******
|
|
191
|
+
* @title: 上传资源到oss
|
|
192
|
+
* @description:
|
|
193
|
+
* @return {*}
|
|
194
|
+
* @Author: zhiwei.Wang
|
|
195
|
+
* @Date: 2023-11-24 14:04
|
|
196
|
+
*/
|
|
197
|
+
export var uploadStaticToOSS = /*#__PURE__*/function () {
|
|
198
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(directory) {
|
|
199
|
+
var folderPath,
|
|
200
|
+
_args4 = arguments;
|
|
201
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
202
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
203
|
+
case 0:
|
|
204
|
+
folderPath = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : path.resolve(__dirname, 'dist');
|
|
205
|
+
_context4.next = 3;
|
|
206
|
+
return init(directory);
|
|
207
|
+
case 3:
|
|
208
|
+
return _context4.abrupt("return", uploadFolderContents(directory, folderPath));
|
|
209
|
+
case 4:
|
|
210
|
+
case "end":
|
|
211
|
+
return _context4.stop();
|
|
212
|
+
}
|
|
213
|
+
}, _callee4);
|
|
214
|
+
}));
|
|
215
|
+
return function uploadStaticToOSS(_x6) {
|
|
216
|
+
return _ref4.apply(this, arguments);
|
|
217
|
+
};
|
|
218
|
+
}();
|
|
@@ -1,86 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
1
|
+
var outPathMap = {
|
|
2
|
+
my_pisel_shop: {
|
|
3
|
+
prod: '../data/release/project/my_pisel_shop',
|
|
4
|
+
release: '../data/release/project/my_pisel_shop',
|
|
5
|
+
pre: '../data/release/project/my_pisel_shop'
|
|
6
|
+
},
|
|
7
|
+
admin: {
|
|
8
|
+
prod: '../data/release/project/pisell_v2',
|
|
9
|
+
release: '../data/release/project/pisell_v2',
|
|
10
|
+
pre: '../data/release/project/pisell_v2'
|
|
11
|
+
},
|
|
12
|
+
my_pisel_pc_v2: {
|
|
13
|
+
prod: '../data/release/project/my_pisel_pc_v2',
|
|
14
|
+
release: '../data/release/project/my_pisel_pc_v2',
|
|
15
|
+
pre: '../data/release/project/my_pisel_pc_v2'
|
|
16
|
+
},
|
|
17
|
+
my_pisel_h5_v2: {
|
|
18
|
+
prod: '../data/release/project/my_pisel_h5_v2',
|
|
19
|
+
release: '../data/release/project/my_pisel_h5_v2',
|
|
20
|
+
pre: '../data/release/project/my_pisel_h5_v2'
|
|
21
|
+
},
|
|
22
|
+
xzero: {
|
|
23
|
+
prod: '../data/release/project/xzero',
|
|
24
|
+
release: '../data/release/project/xzero',
|
|
25
|
+
pre: '../data/release/project/xzero'
|
|
26
|
+
},
|
|
27
|
+
saas_admin: {
|
|
28
|
+
prod: '../data/release/project/saas_admin',
|
|
29
|
+
release: '../data/release/project/saas_admin',
|
|
30
|
+
pre: '../data/release/project/saas_admin'
|
|
31
|
+
},
|
|
32
|
+
saas_shop: {
|
|
33
|
+
prod: '../data/release/project/saas_shop',
|
|
34
|
+
release: '../data/release/project/saas_shop',
|
|
35
|
+
pre: '../data/release/project/saas_shop'
|
|
36
|
+
},
|
|
37
|
+
saas_kds: {
|
|
38
|
+
prod: '../data/release/project/saas_kds',
|
|
39
|
+
release: '../data/release/project/saas_kds',
|
|
40
|
+
pre: '../data/release/project/saas_kds'
|
|
41
|
+
},
|
|
42
|
+
saas_ads: {
|
|
43
|
+
prod: '../data/release/project/saas_ads',
|
|
44
|
+
release: '../data/release/project/saas_ads',
|
|
45
|
+
pre: '../data/release/project/saas_ads'
|
|
46
|
+
},
|
|
47
|
+
saas_home: {
|
|
48
|
+
prod: '../data/release/project/saas_home',
|
|
49
|
+
release: '../data/release/project/saas_home',
|
|
50
|
+
pre: '../data/release/project/saas_home'
|
|
51
|
+
},
|
|
52
|
+
docs: {
|
|
53
|
+
prod: '../data/release/project/docs',
|
|
54
|
+
release: '../data/release/project/docs',
|
|
55
|
+
pre: '../data/release/project/docs'
|
|
56
|
+
},
|
|
57
|
+
saas_shop_pos: {
|
|
58
|
+
prod: '../data/release/project/saas_shop_pos',
|
|
59
|
+
release: '../data/release/project/saas_shop_pos',
|
|
60
|
+
pre: '../data/release/project/saas_shop_pos'
|
|
61
|
+
}
|
|
63
62
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
var isSsrMap = {
|
|
64
|
+
my_pisel_shop: false,
|
|
65
|
+
admin: false,
|
|
66
|
+
my_pisel_pc_v2: true,
|
|
67
|
+
my_pisel_h5_v2: true,
|
|
68
|
+
xzero: false,
|
|
69
|
+
docs: false,
|
|
70
|
+
saas_admin: false,
|
|
71
|
+
saas_shop: false,
|
|
72
|
+
saas_kds: false,
|
|
73
|
+
saas_ads: false,
|
|
74
|
+
saas_shop_pos: false
|
|
76
75
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"@pisell/lowcode-renderer",
|
|
80
|
-
"@pisell/common",
|
|
81
|
-
"@pisell/utils",
|
|
82
|
-
"@pisell/materials"
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
export { checkPackages, isSsrMap, outPathMap };
|
|
76
|
+
var checkPackages = ['@pisell/date-picker', '@pisell/lowcode-renderer', '@pisell/common', '@pisell/utils', '@pisell/materials'];
|
|
77
|
+
export { outPathMap, isSsrMap, checkPackages };
|