@@ -4996,243 +4996,243 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ "__spreadArrays": () => (/* binding */ __spreadArrays),
|
||||
/* harmony export */ "__values": () => (/* binding */ __values)
|
||||
/* harmony export */ });
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
return __assign.apply(this, arguments);
|
||||
}
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
function __decorate(decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
}
|
||||
|
||||
function __param(paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
}
|
||||
|
||||
function __metadata(metadataKey, metadataValue) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
||||
}
|
||||
|
||||
function __awaiter(thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
}
|
||||
|
||||
function __generator(thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
}
|
||||
|
||||
var __createBinding = Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
});
|
||||
|
||||
function __exportStar(m, o) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
||||
}
|
||||
|
||||
function __values(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
}
|
||||
|
||||
function __read(o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spread() {
|
||||
for (var ar = [], i = 0; i < arguments.length; i++)
|
||||
ar = ar.concat(__read(arguments[i]));
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spreadArrays() {
|
||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||||
r[k] = a[j];
|
||||
return r;
|
||||
}
|
||||
|
||||
function __spreadArray(to, from) {
|
||||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
||||
to[j] = from[i];
|
||||
return to;
|
||||
}
|
||||
|
||||
function __await(v) {
|
||||
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
||||
}
|
||||
|
||||
function __asyncGenerator(thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
}
|
||||
|
||||
function __asyncDelegator(o) {
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
||||
}
|
||||
|
||||
function __asyncValues(o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
}
|
||||
|
||||
function __makeTemplateObject(cooked, raw) {
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
|
||||
var __setModuleDefault = Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
};
|
||||
|
||||
function __importStar(mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
}
|
||||
|
||||
function __importDefault(mod) {
|
||||
return (mod && mod.__esModule) ? mod : { default: mod };
|
||||
}
|
||||
|
||||
function __classPrivateFieldGet(receiver, privateMap) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to get private field on non-instance");
|
||||
}
|
||||
return privateMap.get(receiver);
|
||||
}
|
||||
|
||||
function __classPrivateFieldSet(receiver, privateMap, value) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
}
|
||||
privateMap.set(receiver, value);
|
||||
return value;
|
||||
}
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
return __assign.apply(this, arguments);
|
||||
}
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
function __decorate(decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
}
|
||||
|
||||
function __param(paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
}
|
||||
|
||||
function __metadata(metadataKey, metadataValue) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
||||
}
|
||||
|
||||
function __awaiter(thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
}
|
||||
|
||||
function __generator(thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
}
|
||||
|
||||
var __createBinding = Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
});
|
||||
|
||||
function __exportStar(m, o) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
||||
}
|
||||
|
||||
function __values(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
}
|
||||
|
||||
function __read(o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spread() {
|
||||
for (var ar = [], i = 0; i < arguments.length; i++)
|
||||
ar = ar.concat(__read(arguments[i]));
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spreadArrays() {
|
||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||||
r[k] = a[j];
|
||||
return r;
|
||||
}
|
||||
|
||||
function __spreadArray(to, from) {
|
||||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
||||
to[j] = from[i];
|
||||
return to;
|
||||
}
|
||||
|
||||
function __await(v) {
|
||||
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
||||
}
|
||||
|
||||
function __asyncGenerator(thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
}
|
||||
|
||||
function __asyncDelegator(o) {
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
||||
}
|
||||
|
||||
function __asyncValues(o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
}
|
||||
|
||||
function __makeTemplateObject(cooked, raw) {
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
|
||||
var __setModuleDefault = Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
};
|
||||
|
||||
function __importStar(mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
}
|
||||
|
||||
function __importDefault(mod) {
|
||||
return (mod && mod.__esModule) ? mod : { default: mod };
|
||||
}
|
||||
|
||||
function __classPrivateFieldGet(receiver, privateMap) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to get private field on non-instance");
|
||||
}
|
||||
return privateMap.get(receiver);
|
||||
}
|
||||
|
||||
function __classPrivateFieldSet(receiver, privateMap, value) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
}
|
||||
privateMap.set(receiver, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -51956,7 +51956,7 @@ function ɵɵresolveBody(element) {
|
||||
*/
|
||||
|
||||
|
||||
const INTERPOLATION_DELIMITER = `<60>`;
|
||||
const INTERPOLATION_DELIMITER = `<EFBFBD>`;
|
||||
/**
|
||||
* Unwrap a value which might be behind a closure (for forward declaration reasons).
|
||||
*/
|
||||
@@ -52069,7 +52069,7 @@ function getExpressionChangedErrorDetails(lView, bindingIndex, oldValue, newValu
|
||||
} // metadata is not available for this expression, check if this expression is a part of the
|
||||
// property interpolation by going from the current binding index left and look for a string that
|
||||
// contains INTERPOLATION_DELIMITER, the layout in tView.data for this case will look like this:
|
||||
// [..., 'id<69>Prefix <20> and <20> suffix', null, null, null, ...]
|
||||
// [..., 'id<EFBFBD>Prefix <EFBFBD> and <EFBFBD> suffix', null, null, null, ...]
|
||||
|
||||
|
||||
if (metadata === null) {
|
||||
@@ -56810,7 +56810,7 @@ function executeViewQueryFn(flags, viewQueryFn, component) {
|
||||
* `LView`). Metadata are represented as `INTERPOLATION_DELIMITER`-delimited string with the
|
||||
* following format:
|
||||
* - `propertyName` for bound properties;
|
||||
* - `propertyName<6D>prefix<69>interpolation_static_part1<74>..interpolation_static_partN<74>suffix` for
|
||||
* - `propertyName<EFBFBD>prefix<EFBFBD>interpolation_static_part1<EFBFBD>..interpolation_static_partN<EFBFBD>suffix` for
|
||||
* interpolated properties.
|
||||
*
|
||||
* @param tData `TData` where meta-data will be saved;
|
||||
@@ -64853,13 +64853,13 @@ class OpCodeParser {
|
||||
*/
|
||||
|
||||
|
||||
const BINDING_REGEXP = /<2F>(\d+):?\d*<2A>/gi;
|
||||
const ICU_REGEXP = /({\s*<2A>\d+:?\d*<2A>\s*,\s*\S{6}\s*,[\s\S]*})/gi;
|
||||
const NESTED_ICU = /<2F>(\d+)<29>/;
|
||||
const ICU_BLOCK_REGEXP = /^\s*(<28>\d+:?\d*<2A>)\s*,\s*(select|plural)\s*,/;
|
||||
const MARKER = `<60>`;
|
||||
const SUBTEMPLATE_REGEXP = /<2F>\/?\*(\d+:\d+)<29>/gi;
|
||||
const PH_REGEXP = /<2F>(\/?[#*]\d+):?\d*<2A>/gi;
|
||||
const BINDING_REGEXP = /<EFBFBD>(\d+):?\d*<EFBFBD>/gi;
|
||||
const ICU_REGEXP = /({\s*<EFBFBD>\d+:?\d*<EFBFBD>\s*,\s*\S{6}\s*,[\s\S]*})/gi;
|
||||
const NESTED_ICU = /<EFBFBD>(\d+)<EFBFBD>/;
|
||||
const ICU_BLOCK_REGEXP = /^\s*(<EFBFBD>\d+:?\d*<EFBFBD>)\s*,\s*(select|plural)\s*,/;
|
||||
const MARKER = `<EFBFBD>`;
|
||||
const SUBTEMPLATE_REGEXP = /<EFBFBD>\/?\*(\d+:\d+)<EFBFBD>/gi;
|
||||
const PH_REGEXP = /<EFBFBD>(\/?[#*]\d+):?\d*<EFBFBD>/gi;
|
||||
/**
|
||||
* Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
|
||||
* https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32
|
||||
@@ -64942,7 +64942,7 @@ function i18nStartFirstCreatePass(tView, parentTNodeIndex, lView, index, message
|
||||
}
|
||||
} else {
|
||||
// Odd indexes are placeholders (elements and sub-templates)
|
||||
// At this point value is something like: '/#1:2' (originally coming from '<27>/#1:2<>')
|
||||
// At this point value is something like: '/#1:2' (originally coming from '<EFBFBD>/#1:2<EFBFBD>')
|
||||
const isClosing = value.charCodeAt(0) === 47
|
||||
/* CharCode.SLASH */
|
||||
;
|
||||
@@ -65298,7 +65298,7 @@ function icuStart(tView, lView, updateOpCodes, parentIdx, icuExpression, anchorI
|
||||
// It is an nested ICU expression
|
||||
const icuIndex = nestedIcus.push(value) - 1; // Replace nested ICU expression by a comment node
|
||||
|
||||
valueArr[j] = `<!--<2D>${icuIndex}<7D>-->`;
|
||||
valueArr[j] = `<!--<EFBFBD>${icuIndex}<EFBFBD>-->`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65597,11 +65597,11 @@ function addCreateAttribute(create, newIndex, attr) {
|
||||
|
||||
|
||||
const ROOT_TEMPLATE_ID = 0;
|
||||
const PP_MULTI_VALUE_PLACEHOLDERS_REGEXP = /\[(<28>.+?<3F>?)\]/;
|
||||
const PP_PLACEHOLDERS_REGEXP = /\[(<28>.+?<3F>?)\]|(<28>\/?\*\d+:\d+<2B>)/g;
|
||||
const PP_MULTI_VALUE_PLACEHOLDERS_REGEXP = /\[(<EFBFBD>.+?<3F>?)\]/;
|
||||
const PP_PLACEHOLDERS_REGEXP = /\[(<EFBFBD>.+?<3F>?)\]|(<EFBFBD>\/?\*\d+:\d+<EFBFBD>)/g;
|
||||
const PP_ICU_VARS_REGEXP = /({\s*)(VAR_(PLURAL|SELECT)(_\d+)?)(\s*,)/g;
|
||||
const PP_ICU_PLACEHOLDERS_REGEXP = /{([A-Z0-9_]+)}/g;
|
||||
const PP_ICUS_REGEXP = /<2F>I18N_EXP_(ICU(_\d+)?)<29>/g;
|
||||
const PP_ICUS_REGEXP = /<EFBFBD>I18N_EXP_(ICU(_\d+)?)<EFBFBD>/g;
|
||||
const PP_CLOSE_TEMPLATE_REGEXP = /\/\*/;
|
||||
const PP_TEMPLATE_ID_REGEXP = /\d+\:(\d+)/;
|
||||
/**
|
||||
@@ -65611,10 +65611,10 @@ const PP_TEMPLATE_ID_REGEXP = /\d+\:(\d+)/;
|
||||
* format (that might contain some markers that we need to replace) to the final
|
||||
* form, consumable by i18nStart instruction. Post processing steps include:
|
||||
*
|
||||
* 1. Resolve all multi-value cases (like [<5B>*1:1<><31>#2:1<>|<7C>#4:1<>|<7C>5<EFBFBD>])
|
||||
* 1. Resolve all multi-value cases (like [<EFBFBD>*1:1<EFBFBD><EFBFBD>#2:1<EFBFBD>|<EFBFBD>#4:1<EFBFBD>|<EFBFBD>5<EFBFBD>])
|
||||
* 2. Replace all ICU vars (like "VAR_PLURAL")
|
||||
* 3. Replace all placeholders used inside ICUs in a form of {PLACEHOLDER}
|
||||
* 4. Replace all ICU references with corresponding values (like <20>ICU_EXP_ICU_1<5F>)
|
||||
* 4. Replace all ICU references with corresponding values (like <EFBFBD>ICU_EXP_ICU_1<EFBFBD>)
|
||||
* in case multiple ICUs have the same placeholder name
|
||||
*
|
||||
* @param message Raw translation string for post processing
|
||||
@@ -65627,13 +65627,13 @@ const PP_TEMPLATE_ID_REGEXP = /\d+\:(\d+)/;
|
||||
|
||||
function i18nPostprocess(message, replacements = {}) {
|
||||
/**
|
||||
* Step 1: resolve all multi-value placeholders like [<5B>#5<>|<7C>*1:1<><31>#2:1<>|<7C>#4:1<>]
|
||||
* Step 1: resolve all multi-value placeholders like [<EFBFBD>#5<EFBFBD>|<EFBFBD>*1:1<EFBFBD><EFBFBD>#2:1<EFBFBD>|<EFBFBD>#4:1<EFBFBD>]
|
||||
*
|
||||
* Note: due to the way we process nested templates (BFS), multi-value placeholders are typically
|
||||
* grouped by templates, for example: [<5B>#5<>|<7C>#6<>|<7C>#1:1<>|<7C>#3:2<>] where <20>#5<> and <20>#6<> belong to root
|
||||
* template, <20>#1:1<> belong to nested template with index 1 and <20>#1:2<> - nested template with index
|
||||
* 3. However in real templates the order might be different: i.e. <20>#1:1<> and/or <20>#3:2<> may go in
|
||||
* front of <20>#6<>. The post processing step restores the right order by keeping track of the
|
||||
* grouped by templates, for example: [<EFBFBD>#5<EFBFBD>|<EFBFBD>#6<EFBFBD>|<EFBFBD>#1:1<EFBFBD>|<EFBFBD>#3:2<EFBFBD>] where <EFBFBD>#5<EFBFBD> and <EFBFBD>#6<EFBFBD> belong to root
|
||||
* template, <EFBFBD>#1:1<EFBFBD> belong to nested template with index 1 and <EFBFBD>#1:2<EFBFBD> - nested template with index
|
||||
* 3. However in real templates the order might be different: i.e. <EFBFBD>#1:1<EFBFBD> and/or <EFBFBD>#3:2<EFBFBD> may go in
|
||||
* front of <EFBFBD>#6<EFBFBD>. The post processing step restores the right order by keeping track of the
|
||||
* template id stack and looks for placeholders that belong to the currently active template.
|
||||
*/
|
||||
let result = message;
|
||||
@@ -65704,7 +65704,7 @@ function i18nPostprocess(message, replacements = {}) {
|
||||
return replacements.hasOwnProperty(key) ? replacements[key] : match;
|
||||
});
|
||||
/**
|
||||
* Step 4: replace all ICU references with corresponding values (like <20>ICU_EXP_ICU_1<5F>) in case
|
||||
* Step 4: replace all ICU references with corresponding values (like <EFBFBD>ICU_EXP_ICU_1<EFBFBD>) in case
|
||||
* multiple ICUs have the same placeholder name
|
||||
*/
|
||||
|
||||
@@ -65739,14 +65739,14 @@ function i18nPostprocess(message, replacements = {}) {
|
||||
* contain placeholders which associate inner elements and sub-templates within the translation.
|
||||
*
|
||||
* The translation `message` placeholders are:
|
||||
* - `<60>{index}(:{block})<29>`: *Binding Placeholder*: Marks a location where an expression will be
|
||||
* - `<EFBFBD>{index}(:{block})<EFBFBD>`: *Binding Placeholder*: Marks a location where an expression will be
|
||||
* interpolated into. The placeholder `index` points to the expression binding index. An optional
|
||||
* `block` that matches the sub-template in which it was declared.
|
||||
* - `<60>#{index}(:{block})<29>`/`<60>/#{index}(:{block})<29>`: *Element Placeholder*: Marks the beginning
|
||||
* - `<EFBFBD>#{index}(:{block})<EFBFBD>`/`<EFBFBD>/#{index}(:{block})<EFBFBD>`: *Element Placeholder*: Marks the beginning
|
||||
* and end of DOM element that were embedded in the original translation block. The placeholder
|
||||
* `index` points to the element index in the template instructions set. An optional `block` that
|
||||
* matches the sub-template in which it was declared.
|
||||
* - `<60>*{index}:{block}<7D>`/`<60>/*{index}:{block}<7D>`: *Sub-template Placeholder*: Sub-templates must be
|
||||
* - `<EFBFBD>*{index}:{block}<EFBFBD>`/`<EFBFBD>/*{index}:{block}<EFBFBD>`: *Sub-template Placeholder*: Sub-templates must be
|
||||
* split up and translated separately in each angular template function. The `index` points to the
|
||||
* `template` instruction index. A `block` that matches the sub-template in which it was declared.
|
||||
*
|
||||
@@ -65801,14 +65801,14 @@ function ɵɵi18nEnd() {
|
||||
* contain placeholders which associate inner elements and sub-templates within the translation.
|
||||
*
|
||||
* The translation `message` placeholders are:
|
||||
* - `<60>{index}(:{block})<29>`: *Binding Placeholder*: Marks a location where an expression will be
|
||||
* - `<EFBFBD>{index}(:{block})<EFBFBD>`: *Binding Placeholder*: Marks a location where an expression will be
|
||||
* interpolated into. The placeholder `index` points to the expression binding index. An optional
|
||||
* `block` that matches the sub-template in which it was declared.
|
||||
* - `<60>#{index}(:{block})<29>`/`<60>/#{index}(:{block})<29>`: *Element Placeholder*: Marks the beginning
|
||||
* - `<EFBFBD>#{index}(:{block})<EFBFBD>`/`<EFBFBD>/#{index}(:{block})<EFBFBD>`: *Element Placeholder*: Marks the beginning
|
||||
* and end of DOM element that were embedded in the original translation block. The placeholder
|
||||
* `index` points to the element index in the template instructions set. An optional `block` that
|
||||
* matches the sub-template in which it was declared.
|
||||
* - `<60>*{index}:{block}<7D>`/`<60>/*{index}:{block}<7D>`: *Sub-template Placeholder*: Sub-templates must be
|
||||
* - `<EFBFBD>*{index}:{block}<EFBFBD>`/`<EFBFBD>/*{index}:{block}<EFBFBD>`: *Sub-template Placeholder*: Sub-templates must be
|
||||
* split up and translated separately in each angular template function. The `index` points to the
|
||||
* `template` instruction index. A `block` that matches the sub-template in which it was declared.
|
||||
*
|
||||
@@ -65877,10 +65877,10 @@ function ɵɵi18nApply(index) {
|
||||
* format (that might contain some markers that we need to replace) to the final
|
||||
* form, consumable by i18nStart instruction. Post processing steps include:
|
||||
*
|
||||
* 1. Resolve all multi-value cases (like [<5B>*1:1<><31>#2:1<>|<7C>#4:1<>|<7C>5<EFBFBD>])
|
||||
* 1. Resolve all multi-value cases (like [<EFBFBD>*1:1<EFBFBD><EFBFBD>#2:1<EFBFBD>|<EFBFBD>#4:1<EFBFBD>|<EFBFBD>5<EFBFBD>])
|
||||
* 2. Replace all ICU vars (like "VAR_PLURAL")
|
||||
* 3. Replace all placeholders used inside ICUs in a form of {PLACEHOLDER}
|
||||
* 4. Replace all ICU references with corresponding values (like <20>ICU_EXP_ICU_1<5F>)
|
||||
* 4. Replace all ICU references with corresponding values (like <EFBFBD>ICU_EXP_ICU_1<EFBFBD>)
|
||||
* in case multiple ICUs have the same placeholder name
|
||||
*
|
||||
* @param message Raw translation string for post processing
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,33 +7,33 @@ import (
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"time"
|
||||
slog "go.unistack.org/micro/v4/logger/slog"
|
||||
appconfig "git.unistack.org/unistack-org/pkgdash/internal/config"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/database"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/handler"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage"
|
||||
_ "git.unistack.org/unistack-org/pkgdash/internal/storage/sqlite"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/worker"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4"
|
||||
yamlcodec "go.unistack.org/micro-codec-yaml/v4"
|
||||
envconfig "go.unistack.org/micro-config-env/v4"
|
||||
fileconfig "go.unistack.org/micro-config-file/v4"
|
||||
vaultconfig "go.unistack.org/micro-config-vault/v4"
|
||||
victoriameter "go.unistack.org/micro-meter-victoriametrics/v4"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
healthhandler "go.unistack.org/micro-server-http/v4/handler/health"
|
||||
meterhandler "go.unistack.org/micro-server-http/v4/handler/meter"
|
||||
spahandler "go.unistack.org/micro-server-http/v4/handler/spa"
|
||||
swaggerui "go.unistack.org/micro-server-http/v4/handler/swagger-ui"
|
||||
"go.unistack.org/micro/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/meter"
|
||||
"go.unistack.org/micro/v4/options"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
rutil "go.unistack.org/micro/v4/util/reflect"
|
||||
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
yamlcodec "go.unistack.org/micro-codec-yaml/v3"
|
||||
envconfig "go.unistack.org/micro-config-env/v3"
|
||||
fileconfig "go.unistack.org/micro-config-file/v3"
|
||||
vaultconfig "go.unistack.org/micro-config-vault/v3"
|
||||
victoriameter "go.unistack.org/micro-meter-victoriametrics/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
healthhandler "go.unistack.org/micro-server-http/v3/handler/health"
|
||||
meterhandler "go.unistack.org/micro-server-http/v3/handler/meter"
|
||||
spahandler "go.unistack.org/micro-server-http/v3/handler/spa"
|
||||
swaggerui "go.unistack.org/micro-server-http/v3/handler/swagger-ui"
|
||||
"go.unistack.org/micro/v3"
|
||||
"go.unistack.org/micro/v3/config"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
slog "go.unistack.org/micro/v3/logger/slog"
|
||||
"go.unistack.org/micro/v3/meter"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
rutil "go.unistack.org/micro/v3/util/reflect"
|
||||
appconfig "go.unistack.org/pkgdash/internal/config"
|
||||
"go.unistack.org/pkgdash/internal/database"
|
||||
"go.unistack.org/pkgdash/internal/handler"
|
||||
"go.unistack.org/pkgdash/internal/storage"
|
||||
_ "go.unistack.org/pkgdash/internal/storage/sqlite"
|
||||
"go.unistack.org/pkgdash/internal/worker"
|
||||
pb "go.unistack.org/pkgdash/proto"
|
||||
)
|
||||
|
||||
const appName = "pkgdash"
|
||||
@@ -53,16 +53,16 @@ func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
logger.DefaultLogger = slog.NewLogger(logger.WithLevel(logger.DebugLevel))
|
||||
if err := logger.DefaultLogger.Init(); err != nil {
|
||||
logger.Fatal(ctx, "failed to init logger")
|
||||
log := slog.NewLogger(logger.WithLevel(logger.DebugLevel))
|
||||
if err := log.Init(); err != nil {
|
||||
log.Fatal(ctx, "failed to init logger")
|
||||
}
|
||||
|
||||
cfg := appconfig.NewConfig(appName, AppVersion) // create new empty config
|
||||
vc := vaultconfig.NewConfig(
|
||||
config.AllowFail(true), // that may be not exists
|
||||
config.Struct(cfg), // load from vault
|
||||
options.Codec(jsoncodec.NewCodec()), // vault config in json
|
||||
config.AllowFail(true), // that may be not exists
|
||||
config.Struct(cfg), // load from vault
|
||||
config.Codec(jsoncodec.NewCodec()), // vault config in json
|
||||
config.BeforeLoad(func(ctx context.Context, c config.Config) error {
|
||||
return c.Init(
|
||||
vaultconfig.HTTPClient(&http.Client{
|
||||
@@ -84,10 +84,10 @@ func main() {
|
||||
config.Struct(cfg), // pass config struct
|
||||
),
|
||||
fileconfig.NewConfig( // load from file
|
||||
config.AllowFail(true), // that may be not exists
|
||||
config.Struct(cfg), // pass config struct
|
||||
options.Codec(yamlcodec.NewCodec()), // file config in json
|
||||
fileconfig.Path("./local.yaml"), // nearby file
|
||||
config.AllowFail(true), // that may be not exists
|
||||
config.Struct(cfg), // pass config struct
|
||||
config.Codec(yamlcodec.NewCodec()), // file config in json
|
||||
fileconfig.Path("./local.yaml"), // nearby file
|
||||
),
|
||||
envconfig.NewConfig( // load from environment
|
||||
config.Struct(cfg), // pass config struct
|
||||
@@ -95,11 +95,11 @@ func main() {
|
||||
vc,
|
||||
}, config.LoadOverride(true),
|
||||
); err != nil {
|
||||
logger.Fatal(ctx, "failed to load config: %v", err)
|
||||
log.Fatal(ctx, "failed to load config: %v", err)
|
||||
}
|
||||
|
||||
if err := config.Validate(ctx, cfg); err != nil {
|
||||
logger.Fatal(ctx, "failed to validate config: %v", err)
|
||||
log.Fatal(ctx, "failed to validate config: %v", err)
|
||||
}
|
||||
|
||||
swaggerui.Config["url"] = "../service.swagger.yaml"
|
||||
@@ -108,7 +108,7 @@ func main() {
|
||||
meter.Path(cfg.Meter.Path),
|
||||
meter.WriteFDMetrics(true),
|
||||
meter.WriteProcessMetrics(true),
|
||||
options.Address(cfg.Meter.Addr),
|
||||
meter.Address(cfg.Meter.Addr),
|
||||
)
|
||||
|
||||
svc := micro.NewService()
|
||||
@@ -118,89 +118,86 @@ func main() {
|
||||
micro.Name(cfg.Server.Name),
|
||||
micro.Version(cfg.Server.Version),
|
||||
); err != nil {
|
||||
logger.Fatal(ctx, "failed to init service: %v", err)
|
||||
log.Fatal(ctx, "failed to init service: %v", err)
|
||||
}
|
||||
|
||||
assetsUI, err := fs.Sub(assets, "assets/ui")
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to get assets: %v", err)
|
||||
log.Fatal(ctx, "failed to get assets: %v", err)
|
||||
}
|
||||
|
||||
if err := svc.Server("http").Init(
|
||||
options.Address(cfg.Server.Addr),
|
||||
options.Name(cfg.Server.Name),
|
||||
server.Address(cfg.Server.Addr),
|
||||
server.Name(cfg.Server.Name),
|
||||
server.Version(cfg.Server.Version),
|
||||
options.Codecs("application/json", jsonpbcodec.NewCodec()),
|
||||
options.Address(cfg.Server.Addr),
|
||||
options.Context(ctx),
|
||||
server.Codec("application/json", jsonpbcodec.NewCodec()),
|
||||
httpsrv.PathHandler(http.MethodGet, "/ui/*", spahandler.Handler("/ui/", assetsUI)),
|
||||
httpsrv.PathHandler(http.MethodHead, "/ui/*", spahandler.Handler("/ui/", assetsUI)),
|
||||
httpsrv.PathHandler(http.MethodGet, "/swagger-ui/*", swaggerui.Handler("/swagger-ui")),
|
||||
); err != nil {
|
||||
logger.Fatal(ctx, "failed to init service: %v", err)
|
||||
log.Fatal(ctx, "failed to init service: %v", err)
|
||||
}
|
||||
|
||||
if err := database.ParseDSN(cfg.Database); err != nil {
|
||||
logger.Fatal(ctx, "failed to init database: %v", err)
|
||||
log.Fatal(ctx, "failed to init database: %v", err)
|
||||
}
|
||||
|
||||
db, err := database.Connect(ctx, cfg.Database, logger.DefaultLogger)
|
||||
db, err := database.Connect(ctx, cfg.Database, log)
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to connect database: %v", err)
|
||||
log.Fatal(ctx, "failed to connect database: %v", err)
|
||||
}
|
||||
|
||||
store, err := storage.NewStorage(cfg.Database.Type, db)
|
||||
store, err := storage.NewStorage(cfg.Database.Type, log, db)
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to init storage: %v", err)
|
||||
log.Fatal(ctx, "failed to init storage: %v", err)
|
||||
}
|
||||
|
||||
h, err := handler.NewHandler(store)
|
||||
h, err := handler.NewHandler(log, store)
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to create handler: %v", err)
|
||||
log.Fatal(ctx, "failed to create handler: %v", err)
|
||||
}
|
||||
|
||||
log := logger.NewLogger(
|
||||
logger.WithLevel(logger.ParseLevel(cfg.Server.LoggerLevel)),
|
||||
logger.WithCallerSkipCount(3),
|
||||
)
|
||||
if err := svc.Init(micro.Logger(log)); err != nil {
|
||||
logger.Fatal(ctx, "failed to init service: %v", err)
|
||||
if err := svc.Init(
|
||||
micro.Logger(
|
||||
log.Clone(logger.WithLevel(logger.ParseLevel(cfg.Server.LoggerLevel))),
|
||||
),
|
||||
); err != nil {
|
||||
log.Fatal(ctx, "failed to init service", err)
|
||||
}
|
||||
|
||||
if err := pb.RegisterPkgdashServiceServer(svc.Server("http"), h); err != nil {
|
||||
logger.Fatal(ctx, "failed to register handler: %v", err)
|
||||
if err := pb.RegisterPkgdashServer(svc.Server("http"), h); err != nil {
|
||||
log.Fatal(ctx, "failed to register handler", err)
|
||||
}
|
||||
|
||||
intsvc := httpsrv.NewServer(
|
||||
options.Codecs("application/json", jsoncodec.NewCodec()),
|
||||
options.Address(cfg.Meter.Addr),
|
||||
options.Context(ctx),
|
||||
server.Codec("application/json", jsoncodec.NewCodec()),
|
||||
server.Address(cfg.Meter.Addr),
|
||||
)
|
||||
|
||||
if err := intsvc.Init(); err != nil {
|
||||
logger.Fatal(ctx, "failed to init http srv: %v", err)
|
||||
log.Fatal(ctx, "failed to init http srv: %v", err)
|
||||
}
|
||||
|
||||
if err := healthhandler.RegisterHealthServiceServer(intsvc, healthhandler.NewHandler()); err != nil {
|
||||
logger.Fatal(ctx, "failed to set http handler: %v", err)
|
||||
log.Fatal(ctx, "failed to set http handler: %v", err)
|
||||
}
|
||||
|
||||
if err := meterhandler.RegisterMeterServiceServer(intsvc, meterhandler.NewHandler()); err != nil {
|
||||
logger.Fatal(ctx, "failed to set http handler: %v", err)
|
||||
log.Fatal(ctx, "failed to set http handler: %v", err)
|
||||
}
|
||||
|
||||
if err := intsvc.Start(); err != nil {
|
||||
logger.Fatal(ctx, "failed to run http srv: %v", err)
|
||||
log.Fatal(ctx, "failed to run http srv: %v", err)
|
||||
}
|
||||
|
||||
cw, err := vc.Watch(ctx, config.WatchCoalesce(true), config.WatchInterval(1*time.Second, 5*time.Second))
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to watch config: %v", err)
|
||||
log.Fatal(ctx, "failed to watch config: %v", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := cw.Stop(); err != nil {
|
||||
logger.Error(ctx, err.Error())
|
||||
log.Error(ctx, err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -208,11 +205,11 @@ func main() {
|
||||
for {
|
||||
changes, err := cw.Next()
|
||||
if err != nil {
|
||||
logger.Error(ctx, "failed to get config update: %v", err)
|
||||
log.Error(ctx, "failed to get config update: %v", err)
|
||||
}
|
||||
for k, v := range changes {
|
||||
if err = rutil.SetFieldByPath(cfg, v, k); err != nil {
|
||||
logger.Error(ctx, "failed to set config update: %v", err)
|
||||
log.Error(ctx, "failed to set config update: %v", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -221,8 +218,8 @@ func main() {
|
||||
switch k {
|
||||
case "Server.LoggerLevel":
|
||||
if lvl, ok := changes[k].(string); ok {
|
||||
logger.Info(ctx, "logger level changed to %s", lvl)
|
||||
logger.DefaultLogger.Level(logger.ParseLevel(lvl))
|
||||
log.Info(ctx, "logger level changed to %s", lvl)
|
||||
log.Level(logger.ParseLevel(lvl))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,10 +228,10 @@ func main() {
|
||||
}()
|
||||
|
||||
go func() {
|
||||
worker.Run(ctx, store, time.Duration(cfg.App.CheckInterval))
|
||||
worker.Run(ctx, log, store, time.Duration(cfg.App.CheckInterval))
|
||||
}()
|
||||
|
||||
if err = svc.Run(); err != nil {
|
||||
logger.Fatal(ctx, "failed to run svc: %v", err)
|
||||
log.Fatal(ctx, "failed to run svc: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,23 +17,22 @@ import (
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/configcli"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/modules"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/source"
|
||||
"github.com/go-git/go-git/v5"
|
||||
gitconfig "github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
httpauth "github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
"github.com/jdx/go-netrc"
|
||||
yamlcodec "go.unistack.org/micro-codec-yaml/v4"
|
||||
envconfig "go.unistack.org/micro-config-env/v4"
|
||||
fileconfig "go.unistack.org/micro-config-file/v4"
|
||||
microflag "go.unistack.org/micro-config-flag/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/logger/slog"
|
||||
"go.unistack.org/micro/v4/options"
|
||||
yamlcodec "go.unistack.org/micro-codec-yaml/v3"
|
||||
envconfig "go.unistack.org/micro-config-env/v3"
|
||||
fileconfig "go.unistack.org/micro-config-file/v3"
|
||||
microflag "go.unistack.org/micro-config-flag/v3"
|
||||
"go.unistack.org/micro/v3/config"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/logger/slog"
|
||||
"go.unistack.org/pkgdash/internal/configcli"
|
||||
"go.unistack.org/pkgdash/internal/modules"
|
||||
"go.unistack.org/pkgdash/internal/source"
|
||||
"golang.org/x/mod/modfile"
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
@@ -98,10 +97,10 @@ func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
logger.DefaultLogger = slog.NewLogger()
|
||||
log := slog.NewLogger()
|
||||
|
||||
if err = logger.DefaultLogger.Init(logger.WithCallerSkipCount(3), logger.WithLevel(logger.DebugLevel)); err != nil {
|
||||
logger.Error(ctx, fmt.Sprintf("logger init error: %v", err))
|
||||
if err = log.Init(logger.WithLevel(logger.DebugLevel)); err != nil {
|
||||
log.Error(ctx, fmt.Sprintf("logger init error: %v", err))
|
||||
}
|
||||
|
||||
cfg := configcli.NewConfig()
|
||||
@@ -117,7 +116,7 @@ func main() {
|
||||
},
|
||||
config.LoadOverride(true),
|
||||
); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to load config: %v", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("failed to load config: %v", err))
|
||||
}
|
||||
|
||||
for _, configDir := range configDirs {
|
||||
@@ -130,15 +129,15 @@ func main() {
|
||||
c := fileconfig.NewConfig(
|
||||
config.AllowFail(false),
|
||||
config.Struct(cfg),
|
||||
options.Codec(yamlcodec.NewCodec()),
|
||||
config.Codec(yamlcodec.NewCodec()),
|
||||
fileconfig.Path(path),
|
||||
)
|
||||
err = c.Init()
|
||||
if err != nil {
|
||||
logger.Error(ctx, fmt.Sprintf("failed to init config: %v", err))
|
||||
log.Error(ctx, fmt.Sprintf("failed to init config: %v", err))
|
||||
}
|
||||
if err = c.Load(ctx, config.LoadOverride(true)); err != nil {
|
||||
logger.Error(ctx, fmt.Sprintf("failed to load config: %v", err))
|
||||
log.Error(ctx, fmt.Sprintf("failed to load config: %v", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,11 +154,11 @@ func main() {
|
||||
c := microflag.NewConfig(config.Struct(cliCfg), microflag.FlagErrorHandling(flag.ContinueOnError))
|
||||
|
||||
if err = c.Init(); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("init cli cfg failed: %v", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("init cli cfg failed: %v", err))
|
||||
}
|
||||
|
||||
if err = c.Load(ctx); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("load cli cfg failed: %v", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("load cli cfg failed: %v", err))
|
||||
}
|
||||
|
||||
if cliCfg.Path == "" && cliCfg.Command == "" {
|
||||
@@ -178,11 +177,11 @@ func main() {
|
||||
}
|
||||
buf, err := os.ReadFile(name)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(ctx, "failed to read file", err)
|
||||
}
|
||||
mfile, err := modfile.Parse(name, buf, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(ctx, "failed to parse file", err)
|
||||
}
|
||||
|
||||
mvs := make(map[string]modules.Update)
|
||||
@@ -195,7 +194,7 @@ func main() {
|
||||
OnUpdate: func(u modules.Update) {
|
||||
var modpath string // new mod path with major
|
||||
if u.Err != nil {
|
||||
logger.Error(ctx, fmt.Sprintf("%s: failed: %v", u.Module.Path, u.Err))
|
||||
log.Error(ctx, fmt.Sprintf("%s: failed: %v", u.Module.Path, u.Err))
|
||||
return
|
||||
}
|
||||
modpath = u.Module.Path
|
||||
@@ -219,18 +218,34 @@ func main() {
|
||||
|
||||
modules.Updates(updateOptions)
|
||||
|
||||
if err = getRepoMgmt(ctx, cfg); err != nil { // Filling in empty config fields.
|
||||
logger.Error(ctx, err.Error())
|
||||
if err = getRepoMgmt(ctx, log, cfg); err != nil { // Filling in empty config fields.
|
||||
log.Error(ctx, err.Error())
|
||||
}
|
||||
|
||||
gitSource := source.NewSourceControl(*cfg)
|
||||
if len(cfg.Branches) == 0 {
|
||||
branchName, err := getCurrentBranch(ctx)
|
||||
if err != nil {
|
||||
log.Fatal(ctx, "failed to get current branch", err)
|
||||
}
|
||||
cfg.Branches = append(cfg.Branches, branchName)
|
||||
}
|
||||
|
||||
Execute(ctx, gitSource, mvs, *cliCfg, *cfg)
|
||||
if cfg.Source.Repository == "" {
|
||||
reposiotry, err := getCurrentRepository(ctx)
|
||||
if err != nil {
|
||||
log.Fatal(ctx, "failed to get current repository", err)
|
||||
}
|
||||
cfg.Source.Repository = reposiotry
|
||||
}
|
||||
|
||||
logger.Info(ctx, "Pkgdash successfully updated dependencies")
|
||||
gitSource := source.NewSourceControl(*cfg, log)
|
||||
|
||||
Execute(ctx, log, gitSource, mvs, *cliCfg, *cfg)
|
||||
|
||||
log.Info(ctx, "Pkgdash successfully updated dependencies")
|
||||
}
|
||||
|
||||
func Execute(ctx context.Context, gitSource source.SourceControl, mvs map[string]modules.Update, cliCfg configcli.Cli, cfg configcli.Config) {
|
||||
func Execute(ctx context.Context, log logger.Logger, gitSource source.SourceControl, mvs map[string]modules.Update, cliCfg configcli.Cli, cfg configcli.Config) {
|
||||
var mod modules.Update
|
||||
var ok bool
|
||||
var path string
|
||||
@@ -244,81 +259,131 @@ func Execute(ctx context.Context, gitSource source.SourceControl, mvs map[string
|
||||
if cliCfg.Path != "" { // update one dep
|
||||
path = cliCfg.Path
|
||||
if mod, ok = mvs[path]; !ok {
|
||||
logger.Fatal(ctx, fmt.Sprintf("For %s update not exist", path))
|
||||
log.Fatal(ctx, fmt.Sprintf("For %s update not exist", path))
|
||||
}
|
||||
logger.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
||||
log.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
||||
for _, branch := range cfg.Branches {
|
||||
if err := gitSource.RequestOpen(ctx, branch, path, mod); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
|
||||
}
|
||||
}
|
||||
logger.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
||||
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
||||
return
|
||||
}
|
||||
for _, branch := range cfg.Branches { // update all dep
|
||||
for path, mod = range mvs {
|
||||
logger.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
||||
log.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
||||
err := gitSource.RequestOpen(ctx, branch, path, mod)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "already exists") {
|
||||
logger.Debug(ctx, fmt.Sprintf("skip %s, branch already exists", path))
|
||||
log.Debug(ctx, fmt.Sprintf("skip %s, branch already exists", path))
|
||||
continue
|
||||
}
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
|
||||
}
|
||||
logger.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
||||
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
||||
}
|
||||
}
|
||||
case "close":
|
||||
if cliCfg.Path != "" { // close one dep
|
||||
path = cliCfg.Path
|
||||
logger.Debug(ctx, fmt.Sprintf("Start close for %s", path))
|
||||
log.Debug(ctx, fmt.Sprintf("Start close for %s", path))
|
||||
for _, branch := range cfg.Branches {
|
||||
if err := gitSource.RequestClose(ctx, branch, path); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to close pr: %v", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("failed to close pr: %v", err))
|
||||
}
|
||||
}
|
||||
logger.Debug(ctx, fmt.Sprintf("Close successful for %s", path))
|
||||
log.Debug(ctx, fmt.Sprintf("Close successful for %s", path))
|
||||
return
|
||||
}
|
||||
for _, branch := range cfg.Branches {
|
||||
logger.Info(ctx, fmt.Sprintf("Start getting pr for %s", branch))
|
||||
log.Info(ctx, fmt.Sprintf("Start getting pr for %s", branch))
|
||||
rMap, err := gitSource.RequestList(ctx, branch)
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("Error with getting pr list for branch: %s", branch))
|
||||
log.Fatal(ctx, fmt.Sprintf("Error with getting pr list for branch: %s", branch))
|
||||
}
|
||||
|
||||
logger.Info(ctx, fmt.Sprintf("for %s:\n%s", branch, rMap))
|
||||
logger.Info(ctx, fmt.Sprintf("Start close pr for base branch %s", branch))
|
||||
log.Info(ctx, fmt.Sprintf("for %s:\n%s", branch, rMap))
|
||||
log.Info(ctx, fmt.Sprintf("Start close pr for base branch %s", branch))
|
||||
|
||||
for path, _ = range rMap {
|
||||
logger.Debug(ctx, fmt.Sprintf("Start close for %s", path))
|
||||
for path = range rMap {
|
||||
log.Debug(ctx, fmt.Sprintf("Start close for %s", path))
|
||||
if err = gitSource.RequestClose(ctx, branch, path); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to close pr: %v", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("failed to close pr: %v", err))
|
||||
}
|
||||
logger.Debug(ctx, fmt.Sprintf("Close successful for %s", path))
|
||||
log.Debug(ctx, fmt.Sprintf("Close successful for %s", path))
|
||||
}
|
||||
}
|
||||
case "list":
|
||||
for _, branch := range cfg.Branches {
|
||||
rMap, err := gitSource.RequestList(ctx, branch)
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("RequestList: error %s", err))
|
||||
log.Fatal(ctx, fmt.Sprintf("RequestList: error %s", err))
|
||||
}
|
||||
|
||||
prList[branch] = rMap
|
||||
}
|
||||
js, err := json.Marshal(prList)
|
||||
if err != nil {
|
||||
logger.Error(ctx, fmt.Sprintf("error: %s", err))
|
||||
log.Error(ctx, fmt.Sprintf("error: %s", err))
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("for %s:\n%s", cfg.Source.Repository, js))
|
||||
fmt.Printf("for %s:\n%s\n", cfg.Source.Repository, js)
|
||||
default:
|
||||
fmt.Print(initMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func getRepoMgmt(ctx context.Context, cfg *configcli.Config) error {
|
||||
func getCurrentRepository(ctx context.Context) (string, error) {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
p := filepath.Clean(wd)
|
||||
|
||||
repo, err := git.PlainOpen(p)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
cfg, err := repo.Config()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for k, v := range cfg.Remotes {
|
||||
if k != "origin" {
|
||||
continue
|
||||
}
|
||||
|
||||
return v.URLs[0], nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("failed to get remotes")
|
||||
}
|
||||
|
||||
func getCurrentBranch(ctx context.Context) (string, error) {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
p := filepath.Clean(wd)
|
||||
|
||||
repo, err := git.PlainOpen(p)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ref, err := repo.Head()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return ref.Name().Short(), nil
|
||||
}
|
||||
|
||||
func getRepoMgmt(ctx context.Context, log logger.Logger, cfg *configcli.Config) error {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -327,27 +392,38 @@ func getRepoMgmt(ctx context.Context, cfg *configcli.Config) error {
|
||||
p := filepath.Clean(wd)
|
||||
for _, configDir := range configDirs {
|
||||
_, err := os.Stat(filepath.Join(p, configDir))
|
||||
if name, ok := repoMgmt[configDir]; ok && cfg.Source.TypeGit == "" && err == nil {
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Info(ctx, fmt.Sprintf("check config dir %s", configDir))
|
||||
if name, ok := repoMgmt[configDir]; ok && cfg.Source.TypeGit == "" {
|
||||
cfg.Source.TypeGit = name
|
||||
}
|
||||
if api, ok := repoAPI[configDir]; ok && cfg.Source.APIURL == "" && err == nil {
|
||||
if api, ok := repoAPI[configDir]; ok && cfg.Source.APIURL == "" {
|
||||
cfg.Source.APIURL = api
|
||||
}
|
||||
}
|
||||
if p == "/" && cfg.Source.TypeGit == "" && cfg.Source.APIURL == "" {
|
||||
return fmt.Errorf("unknown")
|
||||
}
|
||||
p = filepath.Clean(filepath.Join(p, ".."))
|
||||
// p = filepath.Clean(filepath.Join(p, ".."))
|
||||
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("pkgdash/main can t get info about user: %s", err))
|
||||
}
|
||||
n, err := netrc.Parse(filepath.Join(usr.HomeDir, ".netrc"))
|
||||
if err != nil {
|
||||
logger.Error(ctx, "pkgdash/main can t parse .netrc: %s", err)
|
||||
log.Fatal(ctx, fmt.Sprintf("pkgdash/main cant get info about user: %s", err))
|
||||
}
|
||||
|
||||
log.Info(ctx, fmt.Sprintf("try to configure scm source %v", cfg.Source))
|
||||
|
||||
netrcfile := filepath.Join(usr.HomeDir, ".netrc")
|
||||
log.Info(ctx, "try to parse netrc file "+netrcfile)
|
||||
n, err := netrc.Parse(netrcfile)
|
||||
if err != nil {
|
||||
log.Error(ctx, "pkgdash/main cant parse .netrc: %s", err)
|
||||
}
|
||||
|
||||
log.Info(ctx, "try to configure scm for "+cfg.Source.APIURL)
|
||||
if cfg.Source.Owner == "" {
|
||||
cfg.Source.Owner = n.Machine(cfg.Source.APIURL).Get("login")
|
||||
}
|
||||
@@ -360,7 +436,7 @@ func getRepoMgmt(ctx context.Context, cfg *configcli.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string, mods map[string]modules.Update) error {
|
||||
func giteaPullRequest(ctx context.Context, log logger.Logger, cfg *configcli.Config, branch string, mods map[string]modules.Update) error {
|
||||
envAPIURL := os.Getenv("GITHUB_API_URL")
|
||||
envREPOSITORY := os.Getenv("GITHUB_REPOSITORY")
|
||||
envTOKEN := os.Getenv("GITHUB_TOKEN")
|
||||
@@ -370,34 +446,34 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
|
||||
tplTitle, err := template.New("pull_request_title").Parse(cfg.PullRequestTitle)
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to parse template: %v", err)
|
||||
log.Fatal(ctx, "failed to parse template: %v", err)
|
||||
}
|
||||
|
||||
wTitle := bytes.NewBuffer(nil)
|
||||
|
||||
tplBody, err := template.New("pull_request_body").Parse(cfg.PullRequestBody)
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to parse template: %v", err)
|
||||
log.Fatal(ctx, "failed to parse template: %v", err)
|
||||
}
|
||||
|
||||
wBody := bytes.NewBuffer(nil)
|
||||
|
||||
repo, err := git.PlainOpenWithOptions(".", &git.PlainOpenOptions{DetectDotGit: true})
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to open repo: %v", err)
|
||||
log.Fatal(ctx, "failed to open repo: %v", err)
|
||||
}
|
||||
|
||||
if err = repo.FetchContext(ctx, &git.FetchOptions{
|
||||
Auth: &httpauth.BasicAuth{Username: envTOKEN, Password: envTOKEN},
|
||||
Force: true,
|
||||
}); err != nil && err != git.NoErrAlreadyUpToDate {
|
||||
logger.Fatal(ctx, "failed to fetch repo: %v", err)
|
||||
log.Fatal(ctx, "failed to fetch repo: %v", err)
|
||||
}
|
||||
|
||||
var headRef *plumbing.Reference
|
||||
refIter, err := repo.Branches()
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to get branches: %v", err)
|
||||
log.Fatal(ctx, "failed to get branches: %v", err)
|
||||
}
|
||||
for {
|
||||
ref, err := refIter.Next()
|
||||
@@ -412,14 +488,14 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
refIter.Close()
|
||||
|
||||
if headRef == nil {
|
||||
logger.Fatal(ctx, "failed to get repo branch head")
|
||||
log.Fatal(ctx, "failed to get repo branch head")
|
||||
}
|
||||
|
||||
logger.Info(ctx, "repo head %s", headRef)
|
||||
log.Info(ctx, "repo head %s", headRef)
|
||||
|
||||
wtree, err := repo.Worktree()
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to get worktree: %v", err)
|
||||
log.Fatal(ctx, "failed to get worktree: %v", err)
|
||||
}
|
||||
|
||||
type giteaPull struct {
|
||||
@@ -450,13 +526,13 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(buf, &pulls); err != nil {
|
||||
logger.Fatal(ctx, "failed to decode response %s err: %v", buf, err)
|
||||
log.Fatal(ctx, "failed to decode response %s err: %v", buf, err)
|
||||
}
|
||||
|
||||
for path := range mods {
|
||||
for _, pull := range pulls {
|
||||
if strings.Contains(pull.Title, path) && pull.Base.Ref == branch {
|
||||
logger.Info(ctx, "skip %s as pr already exists %s", path, pull.URL)
|
||||
log.Info(ctx, "skip %s as pr already exists %s", path, pull.URL)
|
||||
delete(mods, path)
|
||||
}
|
||||
}
|
||||
@@ -466,11 +542,11 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
wTitle.Reset()
|
||||
wBody.Reset()
|
||||
|
||||
logger.Info(ctx, "update %s from %s to %s", path, mod.Module.Version, mod.Version)
|
||||
log.Info(ctx, "update %s from %s to %s", path, mod.Module.Version, mod.Version)
|
||||
|
||||
logger.Info(ctx, "reset worktree")
|
||||
log.Info(ctx, "reset worktree")
|
||||
if err = wtree.Reset(&git.ResetOptions{Mode: git.HardReset}); err != nil {
|
||||
logger.Fatal(ctx, "failed to reset repo branch: %v", err)
|
||||
log.Fatal(ctx, "failed to reset repo branch: %v", err)
|
||||
}
|
||||
|
||||
if err = wtree.PullContext(ctx, &git.PullOptions{
|
||||
@@ -480,17 +556,17 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
Force: true,
|
||||
RemoteName: "origin",
|
||||
}); err != nil && err != git.NoErrAlreadyUpToDate {
|
||||
logger.Fatal(ctx, "failed to pull repo: %v", err)
|
||||
log.Fatal(ctx, "failed to pull repo: %v", err)
|
||||
}
|
||||
|
||||
logger.Info(ctx, "checkout ref %s", headRef)
|
||||
log.Info(ctx, "checkout ref %s", headRef)
|
||||
if err = wtree.Checkout(&git.CheckoutOptions{
|
||||
Hash: headRef.Hash(),
|
||||
Branch: plumbing.NewBranchReferenceName(fmt.Sprintf("pkgdash/go_modules/%s-%s", path, mod.Version)),
|
||||
Create: true,
|
||||
Force: true,
|
||||
}); err != nil {
|
||||
logger.Fatal(ctx, "failed to checkout tree: %v", err)
|
||||
log.Fatal(ctx, "failed to checkout tree: %v", err)
|
||||
}
|
||||
|
||||
epath, err := exec.LookPath("go")
|
||||
@@ -498,7 +574,7 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to find go command: %v", err)
|
||||
log.Fatal(ctx, "failed to find go command: %v", err)
|
||||
}
|
||||
|
||||
var cmd *exec.Cmd
|
||||
@@ -506,25 +582,25 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
|
||||
cmd = exec.CommandContext(ctx, epath, "mod", "edit", fmt.Sprintf("-require=%s@%s", path, mod.Version))
|
||||
if out, err = cmd.CombinedOutput(); err != nil {
|
||||
logger.Fatal(ctx, "failed to run go mod edit: %s err: %v", out, err)
|
||||
log.Fatal(ctx, "failed to run go mod edit: %s err: %v", out, err)
|
||||
}
|
||||
|
||||
cmd = exec.CommandContext(ctx, epath, "mod", "tidy")
|
||||
if out, err = cmd.CombinedOutput(); err != nil {
|
||||
logger.Fatal(ctx, "failed to run go mod tidy: %s err: %v", out, err)
|
||||
log.Fatal(ctx, "failed to run go mod tidy: %s err: %v", out, err)
|
||||
}
|
||||
|
||||
logger.Info(ctx, "worktree add go.mod")
|
||||
log.Info(ctx, "worktree add go.mod")
|
||||
if _, err = wtree.Add("go.mod"); err != nil {
|
||||
logger.Fatal(ctx, "failed to add file: %v", err)
|
||||
log.Fatal(ctx, "failed to add file: %v", err)
|
||||
}
|
||||
|
||||
logger.Info(ctx, "worktree add go.sum")
|
||||
log.Info(ctx, "worktree add go.sum")
|
||||
if _, err = wtree.Add("go.sum"); err != nil {
|
||||
logger.Fatal(ctx, "failed to add file: %v", err)
|
||||
log.Fatal(ctx, "failed to add file: %v", err)
|
||||
}
|
||||
|
||||
logger.Info(ctx, "worktree commit")
|
||||
log.Info(ctx, "worktree commit")
|
||||
_, err = wtree.Commit(wTitle.String(), &git.CommitOptions{
|
||||
Parents: []plumbing.Hash{headRef.Hash()},
|
||||
Author: &object.Signature{
|
||||
@@ -534,27 +610,27 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to commit: %v", err)
|
||||
log.Fatal(ctx, "failed to commit: %v", err)
|
||||
}
|
||||
|
||||
// newref := plumbing.NewHashReference(plumbing.ReferenceName(fmt.Sprintf("refs/heads/pkgdash/go_modules/%s-%s", path, mod.Version)), headRef.Hash())
|
||||
|
||||
/*
|
||||
if err = repo.Storer.SetReference(newref); err != nil {
|
||||
logger.Fatal(ctx, "failed to create repo branch: %v", err)
|
||||
log.Fatal(ctx, "failed to create repo branch: %v", err)
|
||||
}
|
||||
*/
|
||||
|
||||
refspec := gitconfig.RefSpec(fmt.Sprintf("+refs/heads/pkgdash/go_modules/%s-%s:refs/heads/pkgdash/go_modules/%s-%s", path, mod.Version, path, mod.Version))
|
||||
|
||||
logger.Info(ctx, "try to push refspec %s", refspec)
|
||||
log.Info(ctx, "try to push refspec %s", refspec)
|
||||
|
||||
if err = repo.PushContext(ctx, &git.PushOptions{
|
||||
RefSpecs: []gitconfig.RefSpec{refspec},
|
||||
Auth: &httpauth.BasicAuth{Username: envTOKEN, Password: envTOKEN},
|
||||
Force: true,
|
||||
}); err != nil {
|
||||
logger.Fatal(ctx, "failed to push repo branch: %v", err)
|
||||
log.Fatal(ctx, "failed to push repo branch: %v", err)
|
||||
}
|
||||
|
||||
data := map[string]string{
|
||||
@@ -564,10 +640,10 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
}
|
||||
|
||||
if err = tplTitle.Execute(wTitle, data); err != nil {
|
||||
logger.Fatal(ctx, "failed to execute template: %v", err)
|
||||
log.Fatal(ctx, "failed to execute template: %v", err)
|
||||
}
|
||||
if err = tplBody.Execute(wBody, data); err != nil {
|
||||
logger.Fatal(ctx, "failed to execute template: %v", err)
|
||||
log.Fatal(ctx, "failed to execute template: %v", err)
|
||||
}
|
||||
|
||||
body := map[string]string{
|
||||
@@ -576,14 +652,14 @@ func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string,
|
||||
"head": fmt.Sprintf("pkgdash/go_modules/%s-%s", path, mod.Version),
|
||||
"title": wTitle.String(),
|
||||
}
|
||||
logger.Info(ctx, "raw body: %#+v", body)
|
||||
log.Info(ctx, "raw body: %#+v", body)
|
||||
|
||||
buf, err = json.Marshal(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info(ctx, "marshal body: %s", buf)
|
||||
log.Info(ctx, "marshal body: %s", buf)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, envAPIURL+"/repos/"+envREPOSITORY+"/pulls?token="+envTOKEN, bytes.NewReader(buf))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user