@pisell/common 1.0.57 → 1.0.58
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/CHANGELOG.md +7 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +28 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +16 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +11 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +12 -0
- package/es/bin/pisell.js +5 -1
- package/es/index.d.ts +3 -1
- package/es/index.js +5 -1
- package/es/script/aws/index.js +127 -210
- package/es/script/constants/index.js +84 -69
- package/es/script/deploy.js +33 -44
- package/es/script/index.js +43 -37
- package/es/script/release/index.js +83 -150
- package/es/script/release/release.js +82 -167
- package/es/script/uploadCode/index.js +238 -308
- package/es/script/uploadCode/uploadCode.js +219 -432
- package/es/script/utils/index.js +255 -369
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +29 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +16 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +11 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +18 -0
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/bin/pisell.js +4 -24
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -23
- package/lib/script/aws/index.js +139 -124
- package/lib/script/constants/index.js +85 -104
- package/lib/script/deploy.js +34 -55
- package/lib/script/index.js +41 -56
- package/lib/script/release/index.js +90 -108
- package/lib/script/release/release.js +82 -85
- package/lib/script/uploadCode/index.js +244 -229
- package/lib/script/uploadCode/uploadCode.js +222 -224
- package/lib/script/utils/index.js +270 -264
- package/package.json +2 -2
- package/src/script/constants/index.js +6 -0
- package/src/script/uploadCode/index.js +1 -0
- package/src/script/uploadCode/uploadCode.js +1 -0
- package/src/script/utils/index.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/asyncToGenerator.js
|
|
2
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3
|
+
try {
|
|
4
|
+
var i = n[a](c), u = i.value;
|
|
5
|
+
} catch (n$1) {
|
|
6
|
+
e(n$1);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
10
|
+
}
|
|
11
|
+
function _asyncToGenerator(n) {
|
|
12
|
+
return function() {
|
|
13
|
+
var t = this, e = arguments;
|
|
14
|
+
return new Promise(function(r, o) {
|
|
15
|
+
var a = n.apply(t, e);
|
|
16
|
+
function _next(n$1) {
|
|
17
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n$1);
|
|
18
|
+
}
|
|
19
|
+
function _throw(n$1) {
|
|
20
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n$1);
|
|
21
|
+
}
|
|
22
|
+
_next(void 0);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { _asyncToGenerator };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toPropertyKey } from "./toPropertyKey.js";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/defineProperty.js
|
|
4
|
+
function _defineProperty(e, r, t) {
|
|
5
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6
|
+
value: t,
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
configurable: !0,
|
|
9
|
+
writable: !0
|
|
10
|
+
}) : e[r] = t, e;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { _defineProperty };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { _defineProperty } from "./defineProperty.js";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/objectSpread2.js
|
|
4
|
+
function ownKeys(e, r) {
|
|
5
|
+
var t = Object.keys(e);
|
|
6
|
+
if (Object.getOwnPropertySymbols) {
|
|
7
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
8
|
+
r && (o = o.filter(function(r$1) {
|
|
9
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
10
|
+
})), t.push.apply(t, o);
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function _objectSpread2(e) {
|
|
15
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
16
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
17
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
18
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
19
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
20
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { _objectSpread2 };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.js";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/toPrimitive.js
|
|
4
|
+
function toPrimitive(t, r) {
|
|
5
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
6
|
+
var e = t[Symbol.toPrimitive];
|
|
7
|
+
if (void 0 !== e) {
|
|
8
|
+
var i = e.call(t, r || "default");
|
|
9
|
+
if ("object" != _typeof(i)) return i;
|
|
10
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
11
|
+
}
|
|
12
|
+
return ("string" === r ? String : Number)(t);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { toPrimitive };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.js";
|
|
2
|
+
import { toPrimitive } from "./toPrimitive.js";
|
|
3
|
+
|
|
4
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/toPropertyKey.js
|
|
5
|
+
function toPropertyKey(t) {
|
|
6
|
+
var i = toPrimitive(t, "string");
|
|
7
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { toPropertyKey };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
5
|
+
return typeof o$1;
|
|
6
|
+
} : function(o$1) {
|
|
7
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _typeof };
|
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,218 +1,135 @@
|
|
|
1
|
-
|
|
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';
|
|
1
|
+
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js";
|
|
12
2
|
import { getServerConfig } from "../utils/index.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
import path from "path";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
6
|
+
import mime from "mime-types";
|
|
17
7
|
|
|
8
|
+
//#region src/script/aws/index.js
|
|
9
|
+
const filterFiles = [
|
|
10
|
+
"index.html",
|
|
11
|
+
"umi.server.js",
|
|
12
|
+
"umi.server.d.ts"
|
|
13
|
+
];
|
|
14
|
+
const __dirname = process.cwd();
|
|
15
|
+
let s3Client = null;
|
|
16
|
+
let bucketName = "";
|
|
18
17
|
/*******
|
|
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
|
-
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
|
-
};
|
|
18
|
+
* @title: 初始化
|
|
19
|
+
* @description:
|
|
20
|
+
* @return {*}
|
|
21
|
+
* @Author: zhiwei.Wang
|
|
22
|
+
* @Date: 2023-11-24 14:05
|
|
23
|
+
*/
|
|
24
|
+
const init = function() {
|
|
25
|
+
var _ref = _asyncToGenerator(function* (directory) {
|
|
26
|
+
try {
|
|
27
|
+
const serverConfig = yield getServerConfig(directory);
|
|
28
|
+
let awsConfig = serverConfig.aws;
|
|
29
|
+
if (awsConfig) {
|
|
30
|
+
bucketName = awsConfig.bucketName;
|
|
31
|
+
s3Client = new S3Client({
|
|
32
|
+
region: awsConfig.region,
|
|
33
|
+
credentials: {
|
|
34
|
+
accessKeyId: awsConfig.accessKeyId,
|
|
35
|
+
secretAccessKey: awsConfig.secretAccessKey
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
console.log("aws 初始化成功");
|
|
39
|
+
return serverConfig.aws;
|
|
40
|
+
} else {
|
|
41
|
+
console.log("未获取到aws权限");
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.log(err);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return function init(_x) {
|
|
50
|
+
return _ref.apply(this, arguments);
|
|
51
|
+
};
|
|
74
52
|
}();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
};
|
|
53
|
+
const uploadFile = function() {
|
|
54
|
+
var _ref2 = _asyncToGenerator(function* (directory, fileKey, filePath) {
|
|
55
|
+
const fileStream = fs.createReadStream(filePath);
|
|
56
|
+
const contentType = mime.lookup(filePath);
|
|
57
|
+
const command = new PutObjectCommand({
|
|
58
|
+
Bucket: bucketName,
|
|
59
|
+
Key: `${directory}/${fileKey}`,
|
|
60
|
+
Body: fileStream,
|
|
61
|
+
ContentType: contentType,
|
|
62
|
+
ContentDisposition: "inline",
|
|
63
|
+
ACL: "public-read"
|
|
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
|
+
};
|
|
119
80
|
}();
|
|
120
|
-
|
|
121
81
|
/*******
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
};
|
|
82
|
+
* @title: 递归上传文件夹内容
|
|
83
|
+
* @description:
|
|
84
|
+
* @return {*}
|
|
85
|
+
* @Author: zhiwei.Wang
|
|
86
|
+
* @Date: 2023-11-24 14:06
|
|
87
|
+
*/
|
|
88
|
+
const uploadFolderContents = function() {
|
|
89
|
+
var _ref3 = _asyncToGenerator(function* (directory, folderPath = path.resolve(__dirname, "dist")) {
|
|
90
|
+
const files = fs.readdirSync(folderPath);
|
|
91
|
+
const uploadPromises = [];
|
|
92
|
+
for (const file of files) {
|
|
93
|
+
const filePath = path.join(folderPath, file);
|
|
94
|
+
const fileStats = fs.statSync(filePath);
|
|
95
|
+
if (fileStats.isFile()) {
|
|
96
|
+
const fileKey = path.relative(folderPath, filePath);
|
|
97
|
+
if (!filterFiles.includes(fileKey)) {
|
|
98
|
+
const uploadPromise = uploadFile(directory, fileKey, filePath);
|
|
99
|
+
uploadPromises.push(uploadPromise);
|
|
100
|
+
}
|
|
101
|
+
} else if (fileStats.isDirectory()) {
|
|
102
|
+
const subFolderPromise = uploadFolderContents(path.join(directory, file), filePath);
|
|
103
|
+
uploadPromises.push(subFolderPromise);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Promise.all(uploadPromises).then((res) => {
|
|
107
|
+
console.log("全部上传完成", res.length);
|
|
108
|
+
return res;
|
|
109
|
+
}).catch((err) => {
|
|
110
|
+
throw new Error(`上传cdn失败: ${err.message}`);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return function uploadFolderContents(_x5) {
|
|
114
|
+
return _ref3.apply(this, arguments);
|
|
115
|
+
};
|
|
188
116
|
}();
|
|
189
|
-
|
|
190
117
|
/*******
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
}();
|
|
118
|
+
* @title: 上传资源到oss
|
|
119
|
+
* @description:
|
|
120
|
+
* @return {*}
|
|
121
|
+
* @Author: zhiwei.Wang
|
|
122
|
+
* @Date: 2023-11-24 14:04
|
|
123
|
+
*/
|
|
124
|
+
const uploadStaticToOSS = function() {
|
|
125
|
+
var _ref4 = _asyncToGenerator(function* (directory, folderPath = path.resolve(__dirname, "dist")) {
|
|
126
|
+
yield init(directory);
|
|
127
|
+
return uploadFolderContents(directory, folderPath);
|
|
128
|
+
});
|
|
129
|
+
return function uploadStaticToOSS(_x6) {
|
|
130
|
+
return _ref4.apply(this, arguments);
|
|
131
|
+
};
|
|
132
|
+
}();
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { uploadFolderContents, uploadStaticToOSS };
|