@kevisual/cli 0.0.98 → 0.1.0
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/dist/assistant-opencode.js +1990 -724
- package/dist/assistant-server.js +1962 -2232
- package/dist/assistant.js +1844 -578
- package/dist/envision.js +127 -120
- package/package.json +8 -7
package/dist/assistant.js
CHANGED
|
@@ -14492,7 +14492,7 @@ var require_path = __commonJS((exports) => {
|
|
|
14492
14492
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14493
14493
|
exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = undefined;
|
|
14494
14494
|
var os2 = __require("os");
|
|
14495
|
-
var
|
|
14495
|
+
var path7 = __require("path");
|
|
14496
14496
|
var IS_WINDOWS_PLATFORM = os2.platform() === "win32";
|
|
14497
14497
|
var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
|
14498
14498
|
var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
@@ -14504,7 +14504,7 @@ var require_path = __commonJS((exports) => {
|
|
|
14504
14504
|
}
|
|
14505
14505
|
exports.unixify = unixify;
|
|
14506
14506
|
function makeAbsolute(cwd, filepath) {
|
|
14507
|
-
return
|
|
14507
|
+
return path7.resolve(cwd, filepath);
|
|
14508
14508
|
}
|
|
14509
14509
|
exports.makeAbsolute = makeAbsolute;
|
|
14510
14510
|
function removeLeadingDotSegment(entry2) {
|
|
@@ -15762,7 +15762,7 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
15762
15762
|
|
|
15763
15763
|
// ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
|
|
15764
15764
|
var require_constants2 = __commonJS((exports, module) => {
|
|
15765
|
-
var
|
|
15765
|
+
var path7 = __require("path");
|
|
15766
15766
|
var WIN_SLASH = "\\\\/";
|
|
15767
15767
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
15768
15768
|
var DOT_LITERAL = "\\.";
|
|
@@ -15884,7 +15884,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
15884
15884
|
CHAR_UNDERSCORE: 95,
|
|
15885
15885
|
CHAR_VERTICAL_LINE: 124,
|
|
15886
15886
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
15887
|
-
SEP:
|
|
15887
|
+
SEP: path7.sep,
|
|
15888
15888
|
extglobChars(chars) {
|
|
15889
15889
|
return {
|
|
15890
15890
|
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
@@ -15902,7 +15902,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
15902
15902
|
|
|
15903
15903
|
// ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
|
|
15904
15904
|
var require_utils2 = __commonJS((exports) => {
|
|
15905
|
-
var
|
|
15905
|
+
var path7 = __require("path");
|
|
15906
15906
|
var win32 = process.platform === "win32";
|
|
15907
15907
|
var {
|
|
15908
15908
|
REGEX_BACKSLASH,
|
|
@@ -15931,7 +15931,7 @@ var require_utils2 = __commonJS((exports) => {
|
|
|
15931
15931
|
if (options && typeof options.windows === "boolean") {
|
|
15932
15932
|
return options.windows;
|
|
15933
15933
|
}
|
|
15934
|
-
return win32 === true ||
|
|
15934
|
+
return win32 === true || path7.sep === "\\";
|
|
15935
15935
|
};
|
|
15936
15936
|
exports.escapeLast = (input, char, lastIdx) => {
|
|
15937
15937
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
@@ -17055,7 +17055,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
17055
17055
|
|
|
17056
17056
|
// ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
|
|
17057
17057
|
var require_picomatch = __commonJS((exports, module) => {
|
|
17058
|
-
var
|
|
17058
|
+
var path7 = __require("path");
|
|
17059
17059
|
var scan = require_scan();
|
|
17060
17060
|
var parse = require_parse2();
|
|
17061
17061
|
var utils2 = require_utils2();
|
|
@@ -17141,7 +17141,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17141
17141
|
};
|
|
17142
17142
|
picomatch2.matchBase = (input, glob2, options, posix = utils2.isWindows(options)) => {
|
|
17143
17143
|
const regex = glob2 instanceof RegExp ? glob2 : picomatch2.makeRe(glob2, options);
|
|
17144
|
-
return regex.test(
|
|
17144
|
+
return regex.test(path7.basename(input));
|
|
17145
17145
|
};
|
|
17146
17146
|
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
17147
17147
|
picomatch2.parse = (pattern2, options) => {
|
|
@@ -17362,7 +17362,7 @@ var require_micromatch = __commonJS((exports, module) => {
|
|
|
17362
17362
|
var require_pattern = __commonJS((exports) => {
|
|
17363
17363
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17364
17364
|
exports.isAbsolute = exports.partitionAbsoluteAndRelative = exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = undefined;
|
|
17365
|
-
var
|
|
17365
|
+
var path7 = __require("path");
|
|
17366
17366
|
var globParent2 = require_glob_parent();
|
|
17367
17367
|
var micromatch = require_micromatch();
|
|
17368
17368
|
var GLOBSTAR = "**";
|
|
@@ -17457,7 +17457,7 @@ var require_pattern = __commonJS((exports) => {
|
|
|
17457
17457
|
}
|
|
17458
17458
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
17459
17459
|
function isAffectDepthOfReadingPattern(pattern2) {
|
|
17460
|
-
const basename =
|
|
17460
|
+
const basename = path7.basename(pattern2);
|
|
17461
17461
|
return endsWithSlashGlobStar(pattern2) || isStaticPattern(basename);
|
|
17462
17462
|
}
|
|
17463
17463
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
@@ -17515,7 +17515,7 @@ var require_pattern = __commonJS((exports) => {
|
|
|
17515
17515
|
}
|
|
17516
17516
|
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
17517
17517
|
function isAbsolute(pattern2) {
|
|
17518
|
-
return
|
|
17518
|
+
return path7.isAbsolute(pattern2);
|
|
17519
17519
|
}
|
|
17520
17520
|
exports.isAbsolute = isAbsolute;
|
|
17521
17521
|
});
|
|
@@ -17678,10 +17678,10 @@ var require_utils3 = __commonJS((exports) => {
|
|
|
17678
17678
|
exports.array = array2;
|
|
17679
17679
|
var errno2 = require_errno();
|
|
17680
17680
|
exports.errno = errno2;
|
|
17681
|
-
var
|
|
17682
|
-
exports.fs =
|
|
17683
|
-
var
|
|
17684
|
-
exports.path =
|
|
17681
|
+
var fs7 = require_fs();
|
|
17682
|
+
exports.fs = fs7;
|
|
17683
|
+
var path7 = require_path();
|
|
17684
|
+
exports.path = path7;
|
|
17685
17685
|
var pattern2 = require_pattern();
|
|
17686
17686
|
exports.pattern = pattern2;
|
|
17687
17687
|
var stream2 = require_stream();
|
|
@@ -17777,8 +17777,8 @@ var require_tasks = __commonJS((exports) => {
|
|
|
17777
17777
|
var require_async = __commonJS((exports) => {
|
|
17778
17778
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17779
17779
|
exports.read = undefined;
|
|
17780
|
-
function read(
|
|
17781
|
-
settings2.fs.lstat(
|
|
17780
|
+
function read(path7, settings2, callback) {
|
|
17781
|
+
settings2.fs.lstat(path7, (lstatError, lstat) => {
|
|
17782
17782
|
if (lstatError !== null) {
|
|
17783
17783
|
callFailureCallback(callback, lstatError);
|
|
17784
17784
|
return;
|
|
@@ -17787,7 +17787,7 @@ var require_async = __commonJS((exports) => {
|
|
|
17787
17787
|
callSuccessCallback(callback, lstat);
|
|
17788
17788
|
return;
|
|
17789
17789
|
}
|
|
17790
|
-
settings2.fs.stat(
|
|
17790
|
+
settings2.fs.stat(path7, (statError, stat) => {
|
|
17791
17791
|
if (statError !== null) {
|
|
17792
17792
|
if (settings2.throwErrorOnBrokenSymbolicLink) {
|
|
17793
17793
|
callFailureCallback(callback, statError);
|
|
@@ -17816,13 +17816,13 @@ var require_async = __commonJS((exports) => {
|
|
|
17816
17816
|
var require_sync = __commonJS((exports) => {
|
|
17817
17817
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17818
17818
|
exports.read = undefined;
|
|
17819
|
-
function read(
|
|
17820
|
-
const lstat = settings2.fs.lstatSync(
|
|
17819
|
+
function read(path7, settings2) {
|
|
17820
|
+
const lstat = settings2.fs.lstatSync(path7);
|
|
17821
17821
|
if (!lstat.isSymbolicLink() || !settings2.followSymbolicLink) {
|
|
17822
17822
|
return lstat;
|
|
17823
17823
|
}
|
|
17824
17824
|
try {
|
|
17825
|
-
const stat = settings2.fs.statSync(
|
|
17825
|
+
const stat = settings2.fs.statSync(path7);
|
|
17826
17826
|
if (settings2.markSymbolicLink) {
|
|
17827
17827
|
stat.isSymbolicLink = () => true;
|
|
17828
17828
|
}
|
|
@@ -17841,12 +17841,12 @@ var require_sync = __commonJS((exports) => {
|
|
|
17841
17841
|
var require_fs2 = __commonJS((exports) => {
|
|
17842
17842
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17843
17843
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
|
|
17844
|
-
var
|
|
17844
|
+
var fs7 = __require("fs");
|
|
17845
17845
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
17846
|
-
lstat:
|
|
17847
|
-
stat:
|
|
17848
|
-
lstatSync:
|
|
17849
|
-
statSync:
|
|
17846
|
+
lstat: fs7.lstat,
|
|
17847
|
+
stat: fs7.stat,
|
|
17848
|
+
lstatSync: fs7.lstatSync,
|
|
17849
|
+
statSync: fs7.statSync
|
|
17850
17850
|
};
|
|
17851
17851
|
function createFileSystemAdapter(fsMethods) {
|
|
17852
17852
|
if (fsMethods === undefined) {
|
|
@@ -17860,13 +17860,13 @@ var require_fs2 = __commonJS((exports) => {
|
|
|
17860
17860
|
// ../node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js
|
|
17861
17861
|
var require_settings = __commonJS((exports) => {
|
|
17862
17862
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17863
|
-
var
|
|
17863
|
+
var fs7 = require_fs2();
|
|
17864
17864
|
|
|
17865
17865
|
class Settings {
|
|
17866
17866
|
constructor(_options = {}) {
|
|
17867
17867
|
this._options = _options;
|
|
17868
17868
|
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
|
17869
|
-
this.fs =
|
|
17869
|
+
this.fs = fs7.createFileSystemAdapter(this._options.fs);
|
|
17870
17870
|
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
|
17871
17871
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
17872
17872
|
}
|
|
@@ -17885,17 +17885,17 @@ var require_out = __commonJS((exports) => {
|
|
|
17885
17885
|
var sync2 = require_sync();
|
|
17886
17886
|
var settings_1 = require_settings();
|
|
17887
17887
|
exports.Settings = settings_1.default;
|
|
17888
|
-
function stat(
|
|
17888
|
+
function stat(path7, optionsOrSettingsOrCallback, callback) {
|
|
17889
17889
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
17890
|
-
async2.read(
|
|
17890
|
+
async2.read(path7, getSettings(), optionsOrSettingsOrCallback);
|
|
17891
17891
|
return;
|
|
17892
17892
|
}
|
|
17893
|
-
async2.read(
|
|
17893
|
+
async2.read(path7, getSettings(optionsOrSettingsOrCallback), callback);
|
|
17894
17894
|
}
|
|
17895
17895
|
exports.stat = stat;
|
|
17896
|
-
function statSync(
|
|
17896
|
+
function statSync(path7, optionsOrSettings) {
|
|
17897
17897
|
const settings2 = getSettings(optionsOrSettings);
|
|
17898
|
-
return sync2.read(
|
|
17898
|
+
return sync2.read(path7, settings2);
|
|
17899
17899
|
}
|
|
17900
17900
|
exports.statSync = statSync;
|
|
17901
17901
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -18011,8 +18011,8 @@ var require_fs3 = __commonJS((exports) => {
|
|
|
18011
18011
|
var require_utils4 = __commonJS((exports) => {
|
|
18012
18012
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18013
18013
|
exports.fs = undefined;
|
|
18014
|
-
var
|
|
18015
|
-
exports.fs =
|
|
18014
|
+
var fs7 = require_fs3();
|
|
18015
|
+
exports.fs = fs7;
|
|
18016
18016
|
});
|
|
18017
18017
|
|
|
18018
18018
|
// ../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/providers/common.js
|
|
@@ -18098,16 +18098,16 @@ var require_async2 = __commonJS((exports) => {
|
|
|
18098
18098
|
return;
|
|
18099
18099
|
}
|
|
18100
18100
|
const tasks2 = names.map((name) => {
|
|
18101
|
-
const
|
|
18101
|
+
const path7 = common2.joinPathSegments(directory, name, settings2.pathSegmentSeparator);
|
|
18102
18102
|
return (done) => {
|
|
18103
|
-
fsStat.stat(
|
|
18103
|
+
fsStat.stat(path7, settings2.fsStatSettings, (error2, stats) => {
|
|
18104
18104
|
if (error2 !== null) {
|
|
18105
18105
|
done(error2);
|
|
18106
18106
|
return;
|
|
18107
18107
|
}
|
|
18108
18108
|
const entry2 = {
|
|
18109
18109
|
name,
|
|
18110
|
-
path:
|
|
18110
|
+
path: path7,
|
|
18111
18111
|
dirent: utils2.fs.createDirentFromStats(name, stats)
|
|
18112
18112
|
};
|
|
18113
18113
|
if (settings2.stats) {
|
|
@@ -18195,14 +18195,14 @@ var require_sync2 = __commonJS((exports) => {
|
|
|
18195
18195
|
var require_fs4 = __commonJS((exports) => {
|
|
18196
18196
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18197
18197
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
|
|
18198
|
-
var
|
|
18198
|
+
var fs7 = __require("fs");
|
|
18199
18199
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
18200
|
-
lstat:
|
|
18201
|
-
stat:
|
|
18202
|
-
lstatSync:
|
|
18203
|
-
statSync:
|
|
18204
|
-
readdir:
|
|
18205
|
-
readdirSync:
|
|
18200
|
+
lstat: fs7.lstat,
|
|
18201
|
+
stat: fs7.stat,
|
|
18202
|
+
lstatSync: fs7.lstatSync,
|
|
18203
|
+
statSync: fs7.statSync,
|
|
18204
|
+
readdir: fs7.readdir,
|
|
18205
|
+
readdirSync: fs7.readdirSync
|
|
18206
18206
|
};
|
|
18207
18207
|
function createFileSystemAdapter(fsMethods) {
|
|
18208
18208
|
if (fsMethods === undefined) {
|
|
@@ -18216,16 +18216,16 @@ var require_fs4 = __commonJS((exports) => {
|
|
|
18216
18216
|
// ../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/settings.js
|
|
18217
18217
|
var require_settings2 = __commonJS((exports) => {
|
|
18218
18218
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18219
|
-
var
|
|
18219
|
+
var path7 = __require("path");
|
|
18220
18220
|
var fsStat = require_out();
|
|
18221
|
-
var
|
|
18221
|
+
var fs7 = require_fs4();
|
|
18222
18222
|
|
|
18223
18223
|
class Settings {
|
|
18224
18224
|
constructor(_options = {}) {
|
|
18225
18225
|
this._options = _options;
|
|
18226
18226
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
18227
|
-
this.fs =
|
|
18228
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
18227
|
+
this.fs = fs7.createFileSystemAdapter(this._options.fs);
|
|
18228
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path7.sep);
|
|
18229
18229
|
this.stats = this._getValue(this._options.stats, false);
|
|
18230
18230
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
18231
18231
|
this.fsStatSettings = new fsStat.Settings({
|
|
@@ -18249,17 +18249,17 @@ var require_out2 = __commonJS((exports) => {
|
|
|
18249
18249
|
var sync2 = require_sync2();
|
|
18250
18250
|
var settings_1 = require_settings2();
|
|
18251
18251
|
exports.Settings = settings_1.default;
|
|
18252
|
-
function scandir(
|
|
18252
|
+
function scandir(path7, optionsOrSettingsOrCallback, callback) {
|
|
18253
18253
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
18254
|
-
async2.read(
|
|
18254
|
+
async2.read(path7, getSettings(), optionsOrSettingsOrCallback);
|
|
18255
18255
|
return;
|
|
18256
18256
|
}
|
|
18257
|
-
async2.read(
|
|
18257
|
+
async2.read(path7, getSettings(optionsOrSettingsOrCallback), callback);
|
|
18258
18258
|
}
|
|
18259
18259
|
exports.scandir = scandir;
|
|
18260
|
-
function scandirSync(
|
|
18260
|
+
function scandirSync(path7, optionsOrSettings) {
|
|
18261
18261
|
const settings2 = getSettings(optionsOrSettings);
|
|
18262
|
-
return sync2.read(
|
|
18262
|
+
return sync2.read(path7, settings2);
|
|
18263
18263
|
}
|
|
18264
18264
|
exports.scandirSync = scandirSync;
|
|
18265
18265
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -18857,7 +18857,7 @@ var require_sync4 = __commonJS((exports) => {
|
|
|
18857
18857
|
// ../node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.js
|
|
18858
18858
|
var require_settings3 = __commonJS((exports) => {
|
|
18859
18859
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18860
|
-
var
|
|
18860
|
+
var path7 = __require("path");
|
|
18861
18861
|
var fsScandir = require_out2();
|
|
18862
18862
|
|
|
18863
18863
|
class Settings {
|
|
@@ -18868,7 +18868,7 @@ var require_settings3 = __commonJS((exports) => {
|
|
|
18868
18868
|
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
18869
18869
|
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
18870
18870
|
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
18871
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
18871
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path7.sep);
|
|
18872
18872
|
this.fsScandirSettings = new fsScandir.Settings({
|
|
18873
18873
|
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
18874
18874
|
fs: this._options.fs,
|
|
@@ -18924,7 +18924,7 @@ var require_out3 = __commonJS((exports) => {
|
|
|
18924
18924
|
// ../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/readers/reader.js
|
|
18925
18925
|
var require_reader2 = __commonJS((exports) => {
|
|
18926
18926
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18927
|
-
var
|
|
18927
|
+
var path7 = __require("path");
|
|
18928
18928
|
var fsStat = require_out();
|
|
18929
18929
|
var utils2 = require_utils3();
|
|
18930
18930
|
|
|
@@ -18938,7 +18938,7 @@ var require_reader2 = __commonJS((exports) => {
|
|
|
18938
18938
|
});
|
|
18939
18939
|
}
|
|
18940
18940
|
_getFullEntryPath(filepath) {
|
|
18941
|
-
return
|
|
18941
|
+
return path7.resolve(this._settings.cwd, filepath);
|
|
18942
18942
|
}
|
|
18943
18943
|
_makeEntry(stats, pattern2) {
|
|
18944
18944
|
const entry2 = {
|
|
@@ -19335,7 +19335,7 @@ var require_entry2 = __commonJS((exports) => {
|
|
|
19335
19335
|
// ../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/providers/provider.js
|
|
19336
19336
|
var require_provider = __commonJS((exports) => {
|
|
19337
19337
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19338
|
-
var
|
|
19338
|
+
var path7 = __require("path");
|
|
19339
19339
|
var deep_1 = require_deep();
|
|
19340
19340
|
var entry_1 = require_entry();
|
|
19341
19341
|
var error_1 = require_error2();
|
|
@@ -19350,7 +19350,7 @@ var require_provider = __commonJS((exports) => {
|
|
|
19350
19350
|
this.entryTransformer = new entry_2.default(this._settings);
|
|
19351
19351
|
}
|
|
19352
19352
|
_getRootDirectory(task) {
|
|
19353
|
-
return
|
|
19353
|
+
return path7.resolve(this._settings.cwd, task.base);
|
|
19354
19354
|
}
|
|
19355
19355
|
_getReaderOptions(task) {
|
|
19356
19356
|
const basePath = task.base === "." ? "" : task.base;
|
|
@@ -19519,16 +19519,16 @@ var require_sync6 = __commonJS((exports) => {
|
|
|
19519
19519
|
var require_settings4 = __commonJS((exports) => {
|
|
19520
19520
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19521
19521
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = undefined;
|
|
19522
|
-
var
|
|
19522
|
+
var fs7 = __require("fs");
|
|
19523
19523
|
var os2 = __require("os");
|
|
19524
19524
|
var CPU_COUNT = Math.max(os2.cpus().length, 1);
|
|
19525
19525
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
19526
|
-
lstat:
|
|
19527
|
-
lstatSync:
|
|
19528
|
-
stat:
|
|
19529
|
-
statSync:
|
|
19530
|
-
readdir:
|
|
19531
|
-
readdirSync:
|
|
19526
|
+
lstat: fs7.lstat,
|
|
19527
|
+
lstatSync: fs7.lstatSync,
|
|
19528
|
+
stat: fs7.stat,
|
|
19529
|
+
statSync: fs7.statSync,
|
|
19530
|
+
readdir: fs7.readdir,
|
|
19531
|
+
readdirSync: fs7.readdirSync
|
|
19532
19532
|
};
|
|
19533
19533
|
|
|
19534
19534
|
class Settings {
|
|
@@ -19705,11 +19705,11 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
19705
19705
|
else
|
|
19706
19706
|
delete emitter._events[evt];
|
|
19707
19707
|
}
|
|
19708
|
-
function
|
|
19708
|
+
function EventEmitter3() {
|
|
19709
19709
|
this._events = new Events;
|
|
19710
19710
|
this._eventsCount = 0;
|
|
19711
19711
|
}
|
|
19712
|
-
|
|
19712
|
+
EventEmitter3.prototype.eventNames = function eventNames() {
|
|
19713
19713
|
var names = [], events, name;
|
|
19714
19714
|
if (this._eventsCount === 0)
|
|
19715
19715
|
return names;
|
|
@@ -19722,7 +19722,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
19722
19722
|
}
|
|
19723
19723
|
return names;
|
|
19724
19724
|
};
|
|
19725
|
-
|
|
19725
|
+
EventEmitter3.prototype.listeners = function listeners(event) {
|
|
19726
19726
|
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
19727
19727
|
if (!handlers)
|
|
19728
19728
|
return [];
|
|
@@ -19733,7 +19733,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
19733
19733
|
}
|
|
19734
19734
|
return ee;
|
|
19735
19735
|
};
|
|
19736
|
-
|
|
19736
|
+
EventEmitter3.prototype.listenerCount = function listenerCount(event) {
|
|
19737
19737
|
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
19738
19738
|
if (!listeners)
|
|
19739
19739
|
return 0;
|
|
@@ -19741,7 +19741,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
19741
19741
|
return 1;
|
|
19742
19742
|
return listeners.length;
|
|
19743
19743
|
};
|
|
19744
|
-
|
|
19744
|
+
EventEmitter3.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
19745
19745
|
var evt = prefix ? prefix + event : event;
|
|
19746
19746
|
if (!this._events[evt])
|
|
19747
19747
|
return false;
|
|
@@ -19796,13 +19796,13 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
19796
19796
|
}
|
|
19797
19797
|
return true;
|
|
19798
19798
|
};
|
|
19799
|
-
|
|
19799
|
+
EventEmitter3.prototype.on = function on(event, fn, context) {
|
|
19800
19800
|
return addListener(this, event, fn, context, false);
|
|
19801
19801
|
};
|
|
19802
|
-
|
|
19802
|
+
EventEmitter3.prototype.once = function once(event, fn, context) {
|
|
19803
19803
|
return addListener(this, event, fn, context, true);
|
|
19804
19804
|
};
|
|
19805
|
-
|
|
19805
|
+
EventEmitter3.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
19806
19806
|
var evt = prefix ? prefix + event : event;
|
|
19807
19807
|
if (!this._events[evt])
|
|
19808
19808
|
return this;
|
|
@@ -19828,7 +19828,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
19828
19828
|
}
|
|
19829
19829
|
return this;
|
|
19830
19830
|
};
|
|
19831
|
-
|
|
19831
|
+
EventEmitter3.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
19832
19832
|
var evt;
|
|
19833
19833
|
if (event) {
|
|
19834
19834
|
evt = prefix ? prefix + event : event;
|
|
@@ -19840,12 +19840,12 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
19840
19840
|
}
|
|
19841
19841
|
return this;
|
|
19842
19842
|
};
|
|
19843
|
-
|
|
19844
|
-
|
|
19845
|
-
|
|
19846
|
-
|
|
19843
|
+
EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener;
|
|
19844
|
+
EventEmitter3.prototype.addListener = EventEmitter3.prototype.on;
|
|
19845
|
+
EventEmitter3.prefixed = prefix;
|
|
19846
|
+
EventEmitter3.EventEmitter = EventEmitter3;
|
|
19847
19847
|
if (typeof module !== "undefined") {
|
|
19848
|
-
module.exports =
|
|
19848
|
+
module.exports = EventEmitter3;
|
|
19849
19849
|
}
|
|
19850
19850
|
});
|
|
19851
19851
|
|
|
@@ -20958,15 +20958,15 @@ var require_route = __commonJS((exports, module) => {
|
|
|
20958
20958
|
};
|
|
20959
20959
|
}
|
|
20960
20960
|
function wrapConversion(toModel, graph) {
|
|
20961
|
-
const
|
|
20961
|
+
const path14 = [graph[toModel].parent, toModel];
|
|
20962
20962
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
20963
20963
|
let cur = graph[toModel].parent;
|
|
20964
20964
|
while (graph[cur].parent) {
|
|
20965
|
-
|
|
20965
|
+
path14.unshift(graph[cur].parent);
|
|
20966
20966
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
20967
20967
|
cur = graph[cur].parent;
|
|
20968
20968
|
}
|
|
20969
|
-
fn.conversion =
|
|
20969
|
+
fn.conversion = path14;
|
|
20970
20970
|
return fn;
|
|
20971
20971
|
}
|
|
20972
20972
|
module.exports = function(fromModel) {
|
|
@@ -26024,7 +26024,7 @@ __export(exports_manager, {
|
|
|
26024
26024
|
AppType: () => AppType
|
|
26025
26025
|
});
|
|
26026
26026
|
|
|
26027
|
-
// ../node_modules/.pnpm/@kevisual+use-config@1.0.
|
|
26027
|
+
// ../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
|
|
26028
26028
|
import { createRequire as createRequire2 } from "node:module";
|
|
26029
26029
|
import fs3 from "node:fs";
|
|
26030
26030
|
import path3 from "node:path";
|
|
@@ -26472,71 +26472,6 @@ var getConfigFile = (opts) => {
|
|
|
26472
26472
|
return lastLastPath;
|
|
26473
26473
|
return "";
|
|
26474
26474
|
};
|
|
26475
|
-
var getConfig = (opts) => {
|
|
26476
|
-
let quiet = opts?.quite ?? true;
|
|
26477
|
-
const showError = opts?.showError ?? false;
|
|
26478
|
-
if (opts?.dotenvOpts) {
|
|
26479
|
-
const prased = import_dotenv2.default.config({ quiet, ...opts.dotenvOpts }).parsed;
|
|
26480
|
-
if (prased) {
|
|
26481
|
-
return prased;
|
|
26482
|
-
} else {
|
|
26483
|
-
if (showError) {
|
|
26484
|
-
if (!quiet) {
|
|
26485
|
-
console.warn("config 读取失败");
|
|
26486
|
-
}
|
|
26487
|
-
throw new Error("未找到配置文件");
|
|
26488
|
-
}
|
|
26489
|
-
return {};
|
|
26490
|
-
}
|
|
26491
|
-
}
|
|
26492
|
-
const filePath = getConfigFile(opts);
|
|
26493
|
-
if (!quiet && filePath) {
|
|
26494
|
-
console.log("config pathname:", filePath);
|
|
26495
|
-
}
|
|
26496
|
-
if (!filePath) {
|
|
26497
|
-
if (showError) {
|
|
26498
|
-
if (!quiet) {
|
|
26499
|
-
console.warn("config 路径未找到");
|
|
26500
|
-
}
|
|
26501
|
-
throw new Error("未找到配置文件");
|
|
26502
|
-
}
|
|
26503
|
-
return {};
|
|
26504
|
-
}
|
|
26505
|
-
const value = import_dotenv2.default.config({ quiet: true, path: filePath }).parsed;
|
|
26506
|
-
return value;
|
|
26507
|
-
};
|
|
26508
|
-
var useConfig = (onlyInitConfig, force) => {
|
|
26509
|
-
const config = global.config;
|
|
26510
|
-
let _config = config || getConfig(onlyInitConfig);
|
|
26511
|
-
!config && (global["config"] = _config);
|
|
26512
|
-
if (force && onlyInitConfig) {
|
|
26513
|
-
const _newConfig = getConfig(onlyInitConfig);
|
|
26514
|
-
_config = mergeConfig(_newConfig);
|
|
26515
|
-
}
|
|
26516
|
-
return _config;
|
|
26517
|
-
};
|
|
26518
|
-
var mergeConfig = (config) => {
|
|
26519
|
-
const _config = global.config || {};
|
|
26520
|
-
Object.assign(_config, config);
|
|
26521
|
-
global.config = _config;
|
|
26522
|
-
return _config;
|
|
26523
|
-
};
|
|
26524
|
-
var useKey = (key, opts) => {
|
|
26525
|
-
let v = useConfig()[key];
|
|
26526
|
-
if (!v) {
|
|
26527
|
-
v = process.env[key];
|
|
26528
|
-
}
|
|
26529
|
-
if (!v) {
|
|
26530
|
-
return opts?.defaultValue || null;
|
|
26531
|
-
}
|
|
26532
|
-
if (opts?.isNumber && typeof v === "string") {
|
|
26533
|
-
return Number(v);
|
|
26534
|
-
}
|
|
26535
|
-
if (opts?.isBoolean && typeof v === "string") {
|
|
26536
|
-
return v === "true";
|
|
26537
|
-
}
|
|
26538
|
-
return v;
|
|
26539
|
-
};
|
|
26540
26475
|
var useFileStore = (str, opts) => {
|
|
26541
26476
|
const publicPath = process.cwd();
|
|
26542
26477
|
const filePath = path3.join(publicPath, str);
|
|
@@ -34076,274 +34011,1348 @@ var restart2 = promisify2(pm22.restart).bind(pm22);
|
|
|
34076
34011
|
var reload = promisify2(pm22.reload).bind(pm22);
|
|
34077
34012
|
var deleteProcess2 = promisify2(pm22.delete).bind(pm22);
|
|
34078
34013
|
var list2 = promisify2(pm22.list).bind(pm22);
|
|
34079
|
-
//
|
|
34080
|
-
import
|
|
34014
|
+
// ../node_modules/.pnpm/@kevisual+use-config@1.0.28_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
|
|
34015
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
34081
34016
|
import fs5 from "node:fs";
|
|
34082
|
-
|
|
34083
|
-
|
|
34084
|
-
|
|
34085
|
-
|
|
34086
|
-
|
|
34087
|
-
|
|
34088
|
-
|
|
34089
|
-
|
|
34090
|
-
|
|
34091
|
-
|
|
34092
|
-
|
|
34093
|
-
|
|
34017
|
+
import path5 from "node:path";
|
|
34018
|
+
var __create3 = Object.create;
|
|
34019
|
+
var __getProtoOf3 = Object.getPrototypeOf;
|
|
34020
|
+
var __defProp3 = Object.defineProperty;
|
|
34021
|
+
var __getOwnPropNames3 = Object.getOwnPropertyNames;
|
|
34022
|
+
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
34023
|
+
var __toESM3 = (mod, isNodeMode, target) => {
|
|
34024
|
+
target = mod != null ? __create3(__getProtoOf3(mod)) : {};
|
|
34025
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target;
|
|
34026
|
+
for (let key of __getOwnPropNames3(mod))
|
|
34027
|
+
if (!__hasOwnProp3.call(to, key))
|
|
34028
|
+
__defProp3(to, key, {
|
|
34029
|
+
get: () => mod[key],
|
|
34030
|
+
enumerable: true
|
|
34031
|
+
});
|
|
34032
|
+
return to;
|
|
34094
34033
|
};
|
|
34095
|
-
var
|
|
34096
|
-
|
|
34097
|
-
|
|
34098
|
-
|
|
34099
|
-
|
|
34100
|
-
|
|
34101
|
-
|
|
34102
|
-
|
|
34103
|
-
|
|
34104
|
-
|
|
34105
|
-
|
|
34106
|
-
|
|
34107
|
-
|
|
34108
|
-
|
|
34109
|
-
|
|
34034
|
+
var __commonJS3 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34035
|
+
var __require3 = /* @__PURE__ */ createRequire3(import.meta.url);
|
|
34036
|
+
var require_package3 = __commonJS3((exports, module) => {
|
|
34037
|
+
module.exports = {
|
|
34038
|
+
name: "dotenv",
|
|
34039
|
+
version: "17.2.3",
|
|
34040
|
+
description: "Loads environment variables from .env file",
|
|
34041
|
+
main: "lib/main.js",
|
|
34042
|
+
types: "lib/main.d.ts",
|
|
34043
|
+
exports: {
|
|
34044
|
+
".": {
|
|
34045
|
+
types: "./lib/main.d.ts",
|
|
34046
|
+
require: "./lib/main.js",
|
|
34047
|
+
default: "./lib/main.js"
|
|
34048
|
+
},
|
|
34049
|
+
"./config": "./config.js",
|
|
34050
|
+
"./config.js": "./config.js",
|
|
34051
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
34052
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
34053
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
34054
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
34055
|
+
"./package.json": "./package.json"
|
|
34056
|
+
},
|
|
34057
|
+
scripts: {
|
|
34058
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
34059
|
+
lint: "standard",
|
|
34060
|
+
pretest: "npm run lint && npm run dts-check",
|
|
34061
|
+
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
34062
|
+
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
34063
|
+
prerelease: "npm test",
|
|
34064
|
+
release: "standard-version"
|
|
34065
|
+
},
|
|
34066
|
+
repository: {
|
|
34067
|
+
type: "git",
|
|
34068
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
34069
|
+
},
|
|
34070
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
34071
|
+
funding: "https://dotenvx.com",
|
|
34072
|
+
keywords: [
|
|
34073
|
+
"dotenv",
|
|
34074
|
+
"env",
|
|
34075
|
+
".env",
|
|
34076
|
+
"environment",
|
|
34077
|
+
"variables",
|
|
34078
|
+
"config",
|
|
34079
|
+
"settings"
|
|
34080
|
+
],
|
|
34081
|
+
readmeFilename: "README.md",
|
|
34082
|
+
license: "BSD-2-Clause",
|
|
34083
|
+
devDependencies: {
|
|
34084
|
+
"@types/node": "^18.11.3",
|
|
34085
|
+
decache: "^4.6.2",
|
|
34086
|
+
sinon: "^14.0.1",
|
|
34087
|
+
standard: "^17.0.0",
|
|
34088
|
+
"standard-version": "^9.5.0",
|
|
34089
|
+
tap: "^19.2.0",
|
|
34090
|
+
typescript: "^4.8.4"
|
|
34091
|
+
},
|
|
34092
|
+
engines: {
|
|
34093
|
+
node: ">=12"
|
|
34094
|
+
},
|
|
34095
|
+
browser: {
|
|
34096
|
+
fs: false
|
|
34110
34097
|
}
|
|
34111
|
-
|
|
34112
|
-
|
|
34113
|
-
|
|
34114
|
-
|
|
34115
|
-
|
|
34116
|
-
|
|
34117
|
-
var
|
|
34118
|
-
|
|
34119
|
-
|
|
34120
|
-
|
|
34121
|
-
|
|
34122
|
-
|
|
34123
|
-
|
|
34124
|
-
|
|
34125
|
-
|
|
34126
|
-
|
|
34127
|
-
|
|
34128
|
-
|
|
34129
|
-
|
|
34130
|
-
|
|
34131
|
-
|
|
34132
|
-
|
|
34098
|
+
};
|
|
34099
|
+
});
|
|
34100
|
+
var require_main3 = __commonJS3((exports, module) => {
|
|
34101
|
+
var fs6 = __require3("fs");
|
|
34102
|
+
var path6 = __require3("path");
|
|
34103
|
+
var os2 = __require3("os");
|
|
34104
|
+
var crypto2 = __require3("crypto");
|
|
34105
|
+
var packageJson = require_package3();
|
|
34106
|
+
var version = packageJson.version;
|
|
34107
|
+
var TIPS = [
|
|
34108
|
+
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
|
34109
|
+
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
34110
|
+
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
34111
|
+
"\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
|
|
34112
|
+
"\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
34113
|
+
"\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops",
|
|
34114
|
+
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
34115
|
+
"\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
34116
|
+
"\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
|
|
34117
|
+
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
|
34118
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
34119
|
+
"⚙️ enable debug logging with { debug: true }",
|
|
34120
|
+
"⚙️ override existing env vars with { override: true }",
|
|
34121
|
+
"⚙️ suppress all logs with { quiet: true }",
|
|
34122
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
|
34123
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
34124
|
+
];
|
|
34125
|
+
function _getRandomTip() {
|
|
34126
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
34133
34127
|
}
|
|
34134
|
-
|
|
34135
|
-
|
|
34136
|
-
|
|
34137
|
-
|
|
34138
|
-
|
|
34139
|
-
import path6 from "node:path";
|
|
34140
|
-
var import_fast_glob = __toESM(require_out4(), 1);
|
|
34141
|
-
import fs6 from "node:fs";
|
|
34142
|
-
|
|
34143
|
-
// src/module/local-apps/src/modules/pm2.ts
|
|
34144
|
-
import { spawn } from "node:child_process";
|
|
34145
|
-
import pm23 from "pm2";
|
|
34146
|
-
import { promisify as promisify3 } from "node:util";
|
|
34147
|
-
var normalizeScriptPath2 = (scriptPath) => {
|
|
34148
|
-
if (process.platform === "win32") {
|
|
34149
|
-
return scriptPath.replace(/\\/g, "/");
|
|
34128
|
+
function parseBoolean(value) {
|
|
34129
|
+
if (typeof value === "string") {
|
|
34130
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
34131
|
+
}
|
|
34132
|
+
return Boolean(value);
|
|
34150
34133
|
}
|
|
34151
|
-
|
|
34152
|
-
|
|
34153
|
-
var connect2 = async (noDaemonMode = false) => {
|
|
34154
|
-
return new Promise((resolve, reject) => {
|
|
34155
|
-
pm23.connect(noDaemonMode, (err) => {
|
|
34156
|
-
if (err) {
|
|
34157
|
-
console.error("pm2 connect error", err);
|
|
34158
|
-
return reject(err);
|
|
34159
|
-
}
|
|
34160
|
-
resolve(true);
|
|
34161
|
-
});
|
|
34162
|
-
});
|
|
34163
|
-
};
|
|
34164
|
-
var disconnect2 = promisify3(pm23.disconnect).bind(pm23);
|
|
34165
|
-
var start3 = promisify3(pm23.start).bind(pm23);
|
|
34166
|
-
var stop3 = promisify3(pm23.stop).bind(pm23);
|
|
34167
|
-
var restart3 = promisify3(pm23.restart).bind(pm23);
|
|
34168
|
-
var reload2 = promisify3(pm23.reload).bind(pm23);
|
|
34169
|
-
var deleteProcess3 = promisify3(pm23.delete).bind(pm23);
|
|
34170
|
-
var list3 = promisify3(pm23.list).bind(pm23);
|
|
34171
|
-
var checkInstall = async (app) => {
|
|
34172
|
-
return new Promise((resolve, reject) => {
|
|
34173
|
-
const install = spawn("pnpm", ["install"], {
|
|
34174
|
-
cwd: app.path,
|
|
34175
|
-
stdio: "inherit"
|
|
34176
|
-
});
|
|
34177
|
-
install.on("close", (code) => {
|
|
34178
|
-
if (code !== 0) {
|
|
34179
|
-
console.log("install failed");
|
|
34180
|
-
return resolve(false);
|
|
34181
|
-
}
|
|
34182
|
-
console.log("install success");
|
|
34183
|
-
resolve(true);
|
|
34184
|
-
});
|
|
34185
|
-
});
|
|
34186
|
-
};
|
|
34187
|
-
|
|
34188
|
-
class Pm2Connect2 {
|
|
34189
|
-
needConnect = true;
|
|
34190
|
-
isConnected = false;
|
|
34191
|
-
constructor(needConnect = true) {
|
|
34192
|
-
this.needConnect = needConnect;
|
|
34134
|
+
function supportsAnsi() {
|
|
34135
|
+
return process.stdout.isTTY;
|
|
34193
34136
|
}
|
|
34194
|
-
|
|
34195
|
-
return
|
|
34196
|
-
setTimeout(resolve, ms);
|
|
34197
|
-
});
|
|
34137
|
+
function dim(text) {
|
|
34138
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
34198
34139
|
}
|
|
34199
|
-
|
|
34200
|
-
|
|
34201
|
-
|
|
34202
|
-
|
|
34203
|
-
|
|
34204
|
-
|
|
34140
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
34141
|
+
function parse(src) {
|
|
34142
|
+
const obj = {};
|
|
34143
|
+
let lines = src.toString();
|
|
34144
|
+
lines = lines.replace(/\r\n?/mg, `
|
|
34145
|
+
`);
|
|
34146
|
+
let match;
|
|
34147
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
34148
|
+
const key = match[1];
|
|
34149
|
+
let value = match[2] || "";
|
|
34150
|
+
value = value.trim();
|
|
34151
|
+
const maybeQuote = value[0];
|
|
34152
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
34153
|
+
if (maybeQuote === '"') {
|
|
34154
|
+
value = value.replace(/\\n/g, `
|
|
34155
|
+
`);
|
|
34156
|
+
value = value.replace(/\\r/g, "\r");
|
|
34205
34157
|
}
|
|
34206
|
-
|
|
34207
|
-
console.log("pm2 check connect error", e);
|
|
34158
|
+
obj[key] = value;
|
|
34208
34159
|
}
|
|
34160
|
+
return obj;
|
|
34209
34161
|
}
|
|
34210
|
-
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34162
|
+
function _parseVault(options) {
|
|
34163
|
+
options = options || {};
|
|
34164
|
+
const vaultPath = _vaultPath(options);
|
|
34165
|
+
options.path = vaultPath;
|
|
34166
|
+
const result = DotenvModule.configDotenv(options);
|
|
34167
|
+
if (!result.parsed) {
|
|
34168
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
34169
|
+
err.code = "MISSING_DATA";
|
|
34170
|
+
throw err;
|
|
34214
34171
|
}
|
|
34215
|
-
|
|
34216
|
-
|
|
34217
|
-
|
|
34218
|
-
|
|
34219
|
-
|
|
34220
|
-
|
|
34221
|
-
|
|
34172
|
+
const keys = _dotenvKey(options).split(",");
|
|
34173
|
+
const length = keys.length;
|
|
34174
|
+
let decrypted;
|
|
34175
|
+
for (let i = 0;i < length; i++) {
|
|
34176
|
+
try {
|
|
34177
|
+
const key = keys[i].trim();
|
|
34178
|
+
const attrs = _instructions(result, key);
|
|
34179
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
34180
|
+
break;
|
|
34181
|
+
} catch (error2) {
|
|
34182
|
+
if (i + 1 >= length) {
|
|
34183
|
+
throw error2;
|
|
34184
|
+
}
|
|
34185
|
+
}
|
|
34222
34186
|
}
|
|
34187
|
+
return DotenvModule.parse(decrypted);
|
|
34223
34188
|
}
|
|
34224
|
-
|
|
34225
|
-
|
|
34226
|
-
pm23.disconnect();
|
|
34227
|
-
await this.sleep(1000);
|
|
34228
|
-
} catch (e) {
|
|
34229
|
-
console.log("pm2 disconnect error", e);
|
|
34230
|
-
}
|
|
34231
|
-
this.isConnected = false;
|
|
34189
|
+
function _warn(message) {
|
|
34190
|
+
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
34232
34191
|
}
|
|
34233
|
-
|
|
34234
|
-
|
|
34235
|
-
class Pm2Manager2 {
|
|
34236
|
-
pm2Connect;
|
|
34237
|
-
appName;
|
|
34238
|
-
script;
|
|
34239
|
-
interpreter;
|
|
34240
|
-
needConnect = true;
|
|
34241
|
-
isConnect = false;
|
|
34242
|
-
env;
|
|
34243
|
-
constructor(opts) {
|
|
34244
|
-
this.appName = opts.appName;
|
|
34245
|
-
this.script = opts.script;
|
|
34246
|
-
this.interpreter = opts.interpreter;
|
|
34247
|
-
this.pm2Connect = opts.pm2Connect || new Pm2Connect2;
|
|
34248
|
-
this.env = opts.env || {};
|
|
34192
|
+
function _debug(message) {
|
|
34193
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
34249
34194
|
}
|
|
34250
|
-
|
|
34251
|
-
|
|
34252
|
-
try {
|
|
34253
|
-
await this.pm2Connect.checkConnect();
|
|
34254
|
-
const apps = await list3();
|
|
34255
|
-
return apps;
|
|
34256
|
-
} catch (e) {
|
|
34257
|
-
console.log("pm2 run error", e);
|
|
34258
|
-
return [];
|
|
34259
|
-
} finally {
|
|
34260
|
-
this.pm2Connect.checkDisconnect(_runOpts);
|
|
34261
|
-
}
|
|
34195
|
+
function _log(message) {
|
|
34196
|
+
console.log(`[dotenv@${version}] ${message}`);
|
|
34262
34197
|
}
|
|
34263
|
-
|
|
34264
|
-
|
|
34265
|
-
|
|
34266
|
-
if (!script) {
|
|
34267
|
-
console.error("script is required");
|
|
34268
|
-
return;
|
|
34198
|
+
function _dotenvKey(options) {
|
|
34199
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
34200
|
+
return options.DOTENV_KEY;
|
|
34269
34201
|
}
|
|
34270
|
-
|
|
34271
|
-
|
|
34272
|
-
name: appName,
|
|
34273
|
-
script: normalizedScript,
|
|
34274
|
-
cwd: process.cwd(),
|
|
34275
|
-
interpreter,
|
|
34276
|
-
...options,
|
|
34277
|
-
env: {
|
|
34278
|
-
NODE_ENV: "production",
|
|
34279
|
-
...env2,
|
|
34280
|
-
...options?.env
|
|
34281
|
-
}
|
|
34282
|
-
};
|
|
34283
|
-
try {
|
|
34284
|
-
await this.pm2Connect.checkConnect();
|
|
34285
|
-
const apps = await this.list({ needExit: false });
|
|
34286
|
-
const app = apps.find((app2) => app2.name === appName);
|
|
34287
|
-
if (app && app.pid === 0) {
|
|
34288
|
-
await start3(starter);
|
|
34289
|
-
return;
|
|
34290
|
-
} else if (!app) {
|
|
34291
|
-
await start3(starter);
|
|
34292
|
-
} else {
|
|
34293
|
-
console.log(`pm2 app ${appName} is running`);
|
|
34294
|
-
}
|
|
34295
|
-
} catch (e) {
|
|
34296
|
-
console.error("error", e);
|
|
34297
|
-
} finally {
|
|
34298
|
-
this.pm2Connect.checkDisconnect({ needExit });
|
|
34202
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
34203
|
+
return process.env.DOTENV_KEY;
|
|
34299
34204
|
}
|
|
34205
|
+
return "";
|
|
34300
34206
|
}
|
|
34301
|
-
|
|
34207
|
+
function _instructions(result, dotenvKey) {
|
|
34208
|
+
let uri;
|
|
34302
34209
|
try {
|
|
34303
|
-
|
|
34304
|
-
|
|
34305
|
-
|
|
34306
|
-
|
|
34307
|
-
|
|
34210
|
+
uri = new URL(dotenvKey);
|
|
34211
|
+
} catch (error2) {
|
|
34212
|
+
if (error2.code === "ERR_INVALID_URL") {
|
|
34213
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
34214
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
34215
|
+
throw err;
|
|
34308
34216
|
}
|
|
34309
|
-
|
|
34310
|
-
|
|
34311
|
-
|
|
34312
|
-
|
|
34217
|
+
throw error2;
|
|
34218
|
+
}
|
|
34219
|
+
const key = uri.password;
|
|
34220
|
+
if (!key) {
|
|
34221
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
34222
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
34223
|
+
throw err;
|
|
34224
|
+
}
|
|
34225
|
+
const environment = uri.searchParams.get("environment");
|
|
34226
|
+
if (!environment) {
|
|
34227
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
34228
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
34229
|
+
throw err;
|
|
34230
|
+
}
|
|
34231
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
34232
|
+
const ciphertext = result.parsed[environmentKey];
|
|
34233
|
+
if (!ciphertext) {
|
|
34234
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
34235
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
34236
|
+
throw err;
|
|
34313
34237
|
}
|
|
34238
|
+
return { ciphertext, key };
|
|
34314
34239
|
}
|
|
34315
|
-
|
|
34316
|
-
|
|
34317
|
-
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
|
|
34321
|
-
|
|
34240
|
+
function _vaultPath(options) {
|
|
34241
|
+
let possibleVaultPath = null;
|
|
34242
|
+
if (options && options.path && options.path.length > 0) {
|
|
34243
|
+
if (Array.isArray(options.path)) {
|
|
34244
|
+
for (const filepath of options.path) {
|
|
34245
|
+
if (fs6.existsSync(filepath)) {
|
|
34246
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
34247
|
+
}
|
|
34248
|
+
}
|
|
34249
|
+
} else {
|
|
34250
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
34322
34251
|
}
|
|
34323
|
-
}
|
|
34324
|
-
|
|
34325
|
-
}
|
|
34326
|
-
|
|
34252
|
+
} else {
|
|
34253
|
+
possibleVaultPath = path6.resolve(process.cwd(), ".env.vault");
|
|
34254
|
+
}
|
|
34255
|
+
if (fs6.existsSync(possibleVaultPath)) {
|
|
34256
|
+
return possibleVaultPath;
|
|
34327
34257
|
}
|
|
34258
|
+
return null;
|
|
34328
34259
|
}
|
|
34329
|
-
|
|
34330
|
-
|
|
34260
|
+
function _resolveHome(envPath) {
|
|
34261
|
+
return envPath[0] === "~" ? path6.join(os2.homedir(), envPath.slice(1)) : envPath;
|
|
34331
34262
|
}
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
|
|
34336
|
-
|
|
34337
|
-
if (app) {
|
|
34338
|
-
await deleteProcess3(app.name);
|
|
34339
|
-
}
|
|
34340
|
-
} catch (e) {
|
|
34341
|
-
console.error("error", e);
|
|
34342
|
-
} finally {
|
|
34343
|
-
this.pm2Connect.checkDisconnect(runOpts);
|
|
34263
|
+
function _configVault(options) {
|
|
34264
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
34265
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
34266
|
+
if (debug || !quiet) {
|
|
34267
|
+
_log("Loading env from encrypted .env.vault");
|
|
34344
34268
|
}
|
|
34269
|
+
const parsed = DotenvModule._parseVault(options);
|
|
34270
|
+
let processEnv = process.env;
|
|
34271
|
+
if (options && options.processEnv != null) {
|
|
34272
|
+
processEnv = options.processEnv;
|
|
34273
|
+
}
|
|
34274
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
34275
|
+
return { parsed };
|
|
34345
34276
|
}
|
|
34346
|
-
|
|
34277
|
+
function configDotenv(options) {
|
|
34278
|
+
const dotenvPath = path6.resolve(process.cwd(), ".env");
|
|
34279
|
+
let encoding = "utf8";
|
|
34280
|
+
let processEnv = process.env;
|
|
34281
|
+
if (options && options.processEnv != null) {
|
|
34282
|
+
processEnv = options.processEnv;
|
|
34283
|
+
}
|
|
34284
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
34285
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
34286
|
+
if (options && options.encoding) {
|
|
34287
|
+
encoding = options.encoding;
|
|
34288
|
+
} else {
|
|
34289
|
+
if (debug) {
|
|
34290
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
34291
|
+
}
|
|
34292
|
+
}
|
|
34293
|
+
let optionPaths = [dotenvPath];
|
|
34294
|
+
if (options && options.path) {
|
|
34295
|
+
if (!Array.isArray(options.path)) {
|
|
34296
|
+
optionPaths = [_resolveHome(options.path)];
|
|
34297
|
+
} else {
|
|
34298
|
+
optionPaths = [];
|
|
34299
|
+
for (const filepath of options.path) {
|
|
34300
|
+
optionPaths.push(_resolveHome(filepath));
|
|
34301
|
+
}
|
|
34302
|
+
}
|
|
34303
|
+
}
|
|
34304
|
+
let lastError;
|
|
34305
|
+
const parsedAll = {};
|
|
34306
|
+
for (const path22 of optionPaths) {
|
|
34307
|
+
try {
|
|
34308
|
+
const parsed = DotenvModule.parse(fs6.readFileSync(path22, { encoding }));
|
|
34309
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
34310
|
+
} catch (e) {
|
|
34311
|
+
if (debug) {
|
|
34312
|
+
_debug(`Failed to load ${path22} ${e.message}`);
|
|
34313
|
+
}
|
|
34314
|
+
lastError = e;
|
|
34315
|
+
}
|
|
34316
|
+
}
|
|
34317
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
34318
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
34319
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
34320
|
+
if (debug || !quiet) {
|
|
34321
|
+
const keysCount = Object.keys(populated).length;
|
|
34322
|
+
const shortPaths = [];
|
|
34323
|
+
for (const filePath of optionPaths) {
|
|
34324
|
+
try {
|
|
34325
|
+
const relative = path6.relative(process.cwd(), filePath);
|
|
34326
|
+
shortPaths.push(relative);
|
|
34327
|
+
} catch (e) {
|
|
34328
|
+
if (debug) {
|
|
34329
|
+
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
34330
|
+
}
|
|
34331
|
+
lastError = e;
|
|
34332
|
+
}
|
|
34333
|
+
}
|
|
34334
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
34335
|
+
}
|
|
34336
|
+
if (lastError) {
|
|
34337
|
+
return { parsed: parsedAll, error: lastError };
|
|
34338
|
+
} else {
|
|
34339
|
+
return { parsed: parsedAll };
|
|
34340
|
+
}
|
|
34341
|
+
}
|
|
34342
|
+
function config(options) {
|
|
34343
|
+
if (_dotenvKey(options).length === 0) {
|
|
34344
|
+
return DotenvModule.configDotenv(options);
|
|
34345
|
+
}
|
|
34346
|
+
const vaultPath = _vaultPath(options);
|
|
34347
|
+
if (!vaultPath) {
|
|
34348
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
34349
|
+
return DotenvModule.configDotenv(options);
|
|
34350
|
+
}
|
|
34351
|
+
return DotenvModule._configVault(options);
|
|
34352
|
+
}
|
|
34353
|
+
function decrypt(encrypted, keyStr) {
|
|
34354
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
34355
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
34356
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
34357
|
+
const authTag = ciphertext.subarray(-16);
|
|
34358
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
34359
|
+
try {
|
|
34360
|
+
const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
|
|
34361
|
+
aesgcm.setAuthTag(authTag);
|
|
34362
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
34363
|
+
} catch (error2) {
|
|
34364
|
+
const isRange = error2 instanceof RangeError;
|
|
34365
|
+
const invalidKeyLength = error2.message === "Invalid key length";
|
|
34366
|
+
const decryptionFailed = error2.message === "Unsupported state or unable to authenticate data";
|
|
34367
|
+
if (isRange || invalidKeyLength) {
|
|
34368
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
34369
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
34370
|
+
throw err;
|
|
34371
|
+
} else if (decryptionFailed) {
|
|
34372
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
34373
|
+
err.code = "DECRYPTION_FAILED";
|
|
34374
|
+
throw err;
|
|
34375
|
+
} else {
|
|
34376
|
+
throw error2;
|
|
34377
|
+
}
|
|
34378
|
+
}
|
|
34379
|
+
}
|
|
34380
|
+
function populate(processEnv, parsed, options = {}) {
|
|
34381
|
+
const debug = Boolean(options && options.debug);
|
|
34382
|
+
const override = Boolean(options && options.override);
|
|
34383
|
+
const populated = {};
|
|
34384
|
+
if (typeof parsed !== "object") {
|
|
34385
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
34386
|
+
err.code = "OBJECT_REQUIRED";
|
|
34387
|
+
throw err;
|
|
34388
|
+
}
|
|
34389
|
+
for (const key of Object.keys(parsed)) {
|
|
34390
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
34391
|
+
if (override === true) {
|
|
34392
|
+
processEnv[key] = parsed[key];
|
|
34393
|
+
populated[key] = parsed[key];
|
|
34394
|
+
}
|
|
34395
|
+
if (debug) {
|
|
34396
|
+
if (override === true) {
|
|
34397
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
34398
|
+
} else {
|
|
34399
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
34400
|
+
}
|
|
34401
|
+
}
|
|
34402
|
+
} else {
|
|
34403
|
+
processEnv[key] = parsed[key];
|
|
34404
|
+
populated[key] = parsed[key];
|
|
34405
|
+
}
|
|
34406
|
+
}
|
|
34407
|
+
return populated;
|
|
34408
|
+
}
|
|
34409
|
+
var DotenvModule = {
|
|
34410
|
+
configDotenv,
|
|
34411
|
+
_configVault,
|
|
34412
|
+
_parseVault,
|
|
34413
|
+
config,
|
|
34414
|
+
decrypt,
|
|
34415
|
+
parse,
|
|
34416
|
+
populate
|
|
34417
|
+
};
|
|
34418
|
+
exports.configDotenv = DotenvModule.configDotenv;
|
|
34419
|
+
exports._configVault = DotenvModule._configVault;
|
|
34420
|
+
exports._parseVault = DotenvModule._parseVault;
|
|
34421
|
+
exports.config = DotenvModule.config;
|
|
34422
|
+
exports.decrypt = DotenvModule.decrypt;
|
|
34423
|
+
exports.parse = DotenvModule.parse;
|
|
34424
|
+
exports.populate = DotenvModule.populate;
|
|
34425
|
+
module.exports = DotenvModule;
|
|
34426
|
+
});
|
|
34427
|
+
var import_dotenv3 = __toESM3(require_main3(), 1);
|
|
34428
|
+
var fileIsExist2 = (path22) => {
|
|
34429
|
+
try {
|
|
34430
|
+
fs5.accessSync(path22, fs5.constants.F_OK);
|
|
34431
|
+
return true;
|
|
34432
|
+
} catch (e) {
|
|
34433
|
+
return false;
|
|
34434
|
+
}
|
|
34435
|
+
};
|
|
34436
|
+
var getCwdDirname2 = () => {
|
|
34437
|
+
return process.cwd();
|
|
34438
|
+
};
|
|
34439
|
+
var getConfigFile2 = (opts) => {
|
|
34440
|
+
if (opts?.envConfigFile) {
|
|
34441
|
+
const filePath = path5.join(opts.cwd || getCwdDirname2(), opts.envConfigFile);
|
|
34442
|
+
if (fileIsExist2(filePath)) {
|
|
34443
|
+
return filePath;
|
|
34444
|
+
}
|
|
34445
|
+
}
|
|
34446
|
+
const fileName = opts?.fileName || ".env";
|
|
34447
|
+
const dirname = opts?.cwd || getCwdDirname2();
|
|
34448
|
+
const benPath = dirname + "/" + fileName;
|
|
34449
|
+
const ben = fileIsExist2(benPath);
|
|
34450
|
+
if (ben)
|
|
34451
|
+
return benPath;
|
|
34452
|
+
const lastPath = path5.join(dirname, "../" + fileName);
|
|
34453
|
+
const last = fileIsExist2(lastPath);
|
|
34454
|
+
if (last)
|
|
34455
|
+
return lastPath;
|
|
34456
|
+
const lastLastPath = path5.join(dirname, "../../" + fileName);
|
|
34457
|
+
const lastLast = fileIsExist2(lastLastPath);
|
|
34458
|
+
if (lastLast)
|
|
34459
|
+
return lastLastPath;
|
|
34460
|
+
return "";
|
|
34461
|
+
};
|
|
34462
|
+
var getConfig = (opts) => {
|
|
34463
|
+
let quiet = opts?.quite ?? true;
|
|
34464
|
+
const showError = opts?.showError ?? false;
|
|
34465
|
+
if (opts?.dotenvOpts) {
|
|
34466
|
+
const prased = import_dotenv3.default.config({ quiet, ...opts.dotenvOpts }).parsed;
|
|
34467
|
+
if (prased) {
|
|
34468
|
+
return prased;
|
|
34469
|
+
} else {
|
|
34470
|
+
if (showError) {
|
|
34471
|
+
if (!quiet) {
|
|
34472
|
+
console.warn("config 读取失败");
|
|
34473
|
+
}
|
|
34474
|
+
throw new Error("未找到配置文件");
|
|
34475
|
+
}
|
|
34476
|
+
return {};
|
|
34477
|
+
}
|
|
34478
|
+
}
|
|
34479
|
+
const filePath = getConfigFile2(opts);
|
|
34480
|
+
if (!quiet && filePath) {
|
|
34481
|
+
console.log("config pathname:", filePath);
|
|
34482
|
+
}
|
|
34483
|
+
if (!filePath) {
|
|
34484
|
+
if (showError) {
|
|
34485
|
+
if (!quiet) {
|
|
34486
|
+
console.warn("config 路径未找到");
|
|
34487
|
+
}
|
|
34488
|
+
throw new Error("未找到配置文件");
|
|
34489
|
+
}
|
|
34490
|
+
return {};
|
|
34491
|
+
}
|
|
34492
|
+
const value = import_dotenv3.default.config({ quiet: true, path: filePath }).parsed;
|
|
34493
|
+
return value;
|
|
34494
|
+
};
|
|
34495
|
+
var useConfig = (onlyInitConfig, force) => {
|
|
34496
|
+
const config = global.config;
|
|
34497
|
+
let _config = config || getConfig(onlyInitConfig);
|
|
34498
|
+
!config && (global["config"] = _config);
|
|
34499
|
+
if (force && onlyInitConfig) {
|
|
34500
|
+
const _newConfig = getConfig(onlyInitConfig);
|
|
34501
|
+
_config = mergeConfig(_newConfig);
|
|
34502
|
+
}
|
|
34503
|
+
return _config;
|
|
34504
|
+
};
|
|
34505
|
+
var mergeConfig = (config) => {
|
|
34506
|
+
const _config = global.config || {};
|
|
34507
|
+
Object.assign(_config, config);
|
|
34508
|
+
global.config = _config;
|
|
34509
|
+
return _config;
|
|
34510
|
+
};
|
|
34511
|
+
var useKey = (key, opts) => {
|
|
34512
|
+
let v = useConfig()[key];
|
|
34513
|
+
if (!v) {
|
|
34514
|
+
v = process.env[key];
|
|
34515
|
+
}
|
|
34516
|
+
if (!v) {
|
|
34517
|
+
return opts?.defaultValue || null;
|
|
34518
|
+
}
|
|
34519
|
+
if (opts?.isNumber && typeof v === "string") {
|
|
34520
|
+
return Number(v);
|
|
34521
|
+
}
|
|
34522
|
+
if (opts?.isBoolean && typeof v === "string") {
|
|
34523
|
+
return v === "true";
|
|
34524
|
+
}
|
|
34525
|
+
return v;
|
|
34526
|
+
};
|
|
34527
|
+
var useFileStore2 = (str, opts) => {
|
|
34528
|
+
const publicPath = process.cwd();
|
|
34529
|
+
const filePath = path5.join(publicPath, str);
|
|
34530
|
+
if (opts?.needExists) {
|
|
34531
|
+
if (!fileIsExist2(filePath)) {
|
|
34532
|
+
fs5.mkdirSync(filePath, { recursive: true });
|
|
34533
|
+
}
|
|
34534
|
+
}
|
|
34535
|
+
return filePath;
|
|
34536
|
+
};
|
|
34537
|
+
var isBrowser3 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
34538
|
+
function getDefaultExportFromCjs3(x) {
|
|
34539
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
34540
|
+
}
|
|
34541
|
+
var eventemitter32 = { exports: {} };
|
|
34542
|
+
var hasRequiredEventemitter32;
|
|
34543
|
+
function requireEventemitter32() {
|
|
34544
|
+
if (hasRequiredEventemitter32)
|
|
34545
|
+
return eventemitter32.exports;
|
|
34546
|
+
hasRequiredEventemitter32 = 1;
|
|
34547
|
+
(function(module) {
|
|
34548
|
+
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
34549
|
+
function Events() {}
|
|
34550
|
+
if (Object.create) {
|
|
34551
|
+
Events.prototype = Object.create(null);
|
|
34552
|
+
if (!new Events().__proto__)
|
|
34553
|
+
prefix = false;
|
|
34554
|
+
}
|
|
34555
|
+
function EE(fn, context, once) {
|
|
34556
|
+
this.fn = fn;
|
|
34557
|
+
this.context = context;
|
|
34558
|
+
this.once = once || false;
|
|
34559
|
+
}
|
|
34560
|
+
function addListener(emitter, event, fn, context, once) {
|
|
34561
|
+
if (typeof fn !== "function") {
|
|
34562
|
+
throw new TypeError("The listener must be a function");
|
|
34563
|
+
}
|
|
34564
|
+
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
34565
|
+
if (!emitter._events[evt])
|
|
34566
|
+
emitter._events[evt] = listener, emitter._eventsCount++;
|
|
34567
|
+
else if (!emitter._events[evt].fn)
|
|
34568
|
+
emitter._events[evt].push(listener);
|
|
34569
|
+
else
|
|
34570
|
+
emitter._events[evt] = [emitter._events[evt], listener];
|
|
34571
|
+
return emitter;
|
|
34572
|
+
}
|
|
34573
|
+
function clearEvent(emitter, evt) {
|
|
34574
|
+
if (--emitter._eventsCount === 0)
|
|
34575
|
+
emitter._events = new Events;
|
|
34576
|
+
else
|
|
34577
|
+
delete emitter._events[evt];
|
|
34578
|
+
}
|
|
34579
|
+
function EventEmitter2() {
|
|
34580
|
+
this._events = new Events;
|
|
34581
|
+
this._eventsCount = 0;
|
|
34582
|
+
}
|
|
34583
|
+
EventEmitter2.prototype.eventNames = function eventNames() {
|
|
34584
|
+
var names = [], events, name;
|
|
34585
|
+
if (this._eventsCount === 0)
|
|
34586
|
+
return names;
|
|
34587
|
+
for (name in events = this._events) {
|
|
34588
|
+
if (has.call(events, name))
|
|
34589
|
+
names.push(prefix ? name.slice(1) : name);
|
|
34590
|
+
}
|
|
34591
|
+
if (Object.getOwnPropertySymbols) {
|
|
34592
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
34593
|
+
}
|
|
34594
|
+
return names;
|
|
34595
|
+
};
|
|
34596
|
+
EventEmitter2.prototype.listeners = function listeners(event) {
|
|
34597
|
+
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
34598
|
+
if (!handlers)
|
|
34599
|
+
return [];
|
|
34600
|
+
if (handlers.fn)
|
|
34601
|
+
return [handlers.fn];
|
|
34602
|
+
for (var i = 0, l = handlers.length, ee = new Array(l);i < l; i++) {
|
|
34603
|
+
ee[i] = handlers[i].fn;
|
|
34604
|
+
}
|
|
34605
|
+
return ee;
|
|
34606
|
+
};
|
|
34607
|
+
EventEmitter2.prototype.listenerCount = function listenerCount(event) {
|
|
34608
|
+
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
34609
|
+
if (!listeners)
|
|
34610
|
+
return 0;
|
|
34611
|
+
if (listeners.fn)
|
|
34612
|
+
return 1;
|
|
34613
|
+
return listeners.length;
|
|
34614
|
+
};
|
|
34615
|
+
EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
34616
|
+
var evt = prefix ? prefix + event : event;
|
|
34617
|
+
if (!this._events[evt])
|
|
34618
|
+
return false;
|
|
34619
|
+
var listeners = this._events[evt], len = arguments.length, args2, i;
|
|
34620
|
+
if (listeners.fn) {
|
|
34621
|
+
if (listeners.once)
|
|
34622
|
+
this.removeListener(event, listeners.fn, undefined, true);
|
|
34623
|
+
switch (len) {
|
|
34624
|
+
case 1:
|
|
34625
|
+
return listeners.fn.call(listeners.context), true;
|
|
34626
|
+
case 2:
|
|
34627
|
+
return listeners.fn.call(listeners.context, a1), true;
|
|
34628
|
+
case 3:
|
|
34629
|
+
return listeners.fn.call(listeners.context, a1, a2), true;
|
|
34630
|
+
case 4:
|
|
34631
|
+
return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
34632
|
+
case 5:
|
|
34633
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
34634
|
+
case 6:
|
|
34635
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
34636
|
+
}
|
|
34637
|
+
for (i = 1, args2 = new Array(len - 1);i < len; i++) {
|
|
34638
|
+
args2[i - 1] = arguments[i];
|
|
34639
|
+
}
|
|
34640
|
+
listeners.fn.apply(listeners.context, args2);
|
|
34641
|
+
} else {
|
|
34642
|
+
var length = listeners.length, j;
|
|
34643
|
+
for (i = 0;i < length; i++) {
|
|
34644
|
+
if (listeners[i].once)
|
|
34645
|
+
this.removeListener(event, listeners[i].fn, undefined, true);
|
|
34646
|
+
switch (len) {
|
|
34647
|
+
case 1:
|
|
34648
|
+
listeners[i].fn.call(listeners[i].context);
|
|
34649
|
+
break;
|
|
34650
|
+
case 2:
|
|
34651
|
+
listeners[i].fn.call(listeners[i].context, a1);
|
|
34652
|
+
break;
|
|
34653
|
+
case 3:
|
|
34654
|
+
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
34655
|
+
break;
|
|
34656
|
+
case 4:
|
|
34657
|
+
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
34658
|
+
break;
|
|
34659
|
+
default:
|
|
34660
|
+
if (!args2)
|
|
34661
|
+
for (j = 1, args2 = new Array(len - 1);j < len; j++) {
|
|
34662
|
+
args2[j - 1] = arguments[j];
|
|
34663
|
+
}
|
|
34664
|
+
listeners[i].fn.apply(listeners[i].context, args2);
|
|
34665
|
+
}
|
|
34666
|
+
}
|
|
34667
|
+
}
|
|
34668
|
+
return true;
|
|
34669
|
+
};
|
|
34670
|
+
EventEmitter2.prototype.on = function on(event, fn, context) {
|
|
34671
|
+
return addListener(this, event, fn, context, false);
|
|
34672
|
+
};
|
|
34673
|
+
EventEmitter2.prototype.once = function once(event, fn, context) {
|
|
34674
|
+
return addListener(this, event, fn, context, true);
|
|
34675
|
+
};
|
|
34676
|
+
EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
34677
|
+
var evt = prefix ? prefix + event : event;
|
|
34678
|
+
if (!this._events[evt])
|
|
34679
|
+
return this;
|
|
34680
|
+
if (!fn) {
|
|
34681
|
+
clearEvent(this, evt);
|
|
34682
|
+
return this;
|
|
34683
|
+
}
|
|
34684
|
+
var listeners = this._events[evt];
|
|
34685
|
+
if (listeners.fn) {
|
|
34686
|
+
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
|
|
34687
|
+
clearEvent(this, evt);
|
|
34688
|
+
}
|
|
34689
|
+
} else {
|
|
34690
|
+
for (var i = 0, events = [], length = listeners.length;i < length; i++) {
|
|
34691
|
+
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
|
|
34692
|
+
events.push(listeners[i]);
|
|
34693
|
+
}
|
|
34694
|
+
}
|
|
34695
|
+
if (events.length)
|
|
34696
|
+
this._events[evt] = events.length === 1 ? events[0] : events;
|
|
34697
|
+
else
|
|
34698
|
+
clearEvent(this, evt);
|
|
34699
|
+
}
|
|
34700
|
+
return this;
|
|
34701
|
+
};
|
|
34702
|
+
EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
34703
|
+
var evt;
|
|
34704
|
+
if (event) {
|
|
34705
|
+
evt = prefix ? prefix + event : event;
|
|
34706
|
+
if (this._events[evt])
|
|
34707
|
+
clearEvent(this, evt);
|
|
34708
|
+
} else {
|
|
34709
|
+
this._events = new Events;
|
|
34710
|
+
this._eventsCount = 0;
|
|
34711
|
+
}
|
|
34712
|
+
return this;
|
|
34713
|
+
};
|
|
34714
|
+
EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
|
|
34715
|
+
EventEmitter2.prototype.addListener = EventEmitter2.prototype.on;
|
|
34716
|
+
EventEmitter2.prefixed = prefix;
|
|
34717
|
+
EventEmitter2.EventEmitter = EventEmitter2;
|
|
34718
|
+
{
|
|
34719
|
+
module.exports = EventEmitter2;
|
|
34720
|
+
}
|
|
34721
|
+
})(eventemitter32);
|
|
34722
|
+
return eventemitter32.exports;
|
|
34723
|
+
}
|
|
34724
|
+
var eventemitter3Exports2 = requireEventemitter32();
|
|
34725
|
+
var EventEmitter2 = /* @__PURE__ */ getDefaultExportFromCjs3(eventemitter3Exports2);
|
|
34726
|
+
var reRunFn2 = (promiseOpts) => {
|
|
34727
|
+
const timeout = promiseOpts.timeout || 5 * 60 * 1000;
|
|
34728
|
+
const interval = promiseOpts.interval || 1000;
|
|
34729
|
+
const checkSuccess = promiseOpts?.checkSuccess || (() => true);
|
|
34730
|
+
const signal = promiseOpts.signal;
|
|
34731
|
+
return new Promise(async (resolve, reject) => {
|
|
34732
|
+
let intervalId;
|
|
34733
|
+
let timeoutId = setTimeout(() => {
|
|
34734
|
+
clearTimeout(intervalId);
|
|
34735
|
+
resolve({
|
|
34736
|
+
code: 500,
|
|
34737
|
+
message: "timeout"
|
|
34738
|
+
});
|
|
34739
|
+
}, timeout);
|
|
34740
|
+
const fn = promiseOpts.fn || (() => true);
|
|
34741
|
+
const runFn = async () => {
|
|
34742
|
+
if (signal?.aborted) {
|
|
34743
|
+
clearInterval(intervalId);
|
|
34744
|
+
clearTimeout(timeoutId);
|
|
34745
|
+
return resolve({
|
|
34746
|
+
code: 499,
|
|
34747
|
+
message: "operation cancelled"
|
|
34748
|
+
});
|
|
34749
|
+
}
|
|
34750
|
+
const res = await fn();
|
|
34751
|
+
if (!!checkSuccess(res)) {
|
|
34752
|
+
clearInterval(intervalId);
|
|
34753
|
+
clearTimeout(timeoutId);
|
|
34754
|
+
resolve({
|
|
34755
|
+
code: 200,
|
|
34756
|
+
data: res
|
|
34757
|
+
});
|
|
34758
|
+
} else {
|
|
34759
|
+
setTimeout(() => {
|
|
34760
|
+
runFn();
|
|
34761
|
+
}, interval);
|
|
34762
|
+
}
|
|
34763
|
+
};
|
|
34764
|
+
if (signal) {
|
|
34765
|
+
signal.addEventListener("abort", () => {
|
|
34766
|
+
clearInterval(intervalId);
|
|
34767
|
+
clearTimeout(timeoutId);
|
|
34768
|
+
resolve({
|
|
34769
|
+
code: 499,
|
|
34770
|
+
message: "operation cancelled"
|
|
34771
|
+
});
|
|
34772
|
+
});
|
|
34773
|
+
}
|
|
34774
|
+
runFn();
|
|
34775
|
+
});
|
|
34776
|
+
};
|
|
34777
|
+
|
|
34778
|
+
class BaseLoad2 {
|
|
34779
|
+
modules = new Map;
|
|
34780
|
+
event;
|
|
34781
|
+
loading;
|
|
34782
|
+
static reRunFn = reRunFn2;
|
|
34783
|
+
timeout = 5 * 60 * 1000;
|
|
34784
|
+
constructor() {
|
|
34785
|
+
this.event = new EventEmitter2;
|
|
34786
|
+
this.loading = false;
|
|
34787
|
+
}
|
|
34788
|
+
listenKey(key, listenOpts) {
|
|
34789
|
+
const timeout = listenOpts?.timeout ?? this.timeout;
|
|
34790
|
+
return new Promise((resolve) => {
|
|
34791
|
+
const timeoutId = setTimeout(() => {
|
|
34792
|
+
this.event.removeListener(key, onEvent);
|
|
34793
|
+
resolve({
|
|
34794
|
+
code: 500,
|
|
34795
|
+
message: "timeout"
|
|
34796
|
+
});
|
|
34797
|
+
}, timeout);
|
|
34798
|
+
const onEvent = (error2) => {
|
|
34799
|
+
clearTimeout(timeoutId);
|
|
34800
|
+
if (error2) {
|
|
34801
|
+
return resolve({
|
|
34802
|
+
code: 500,
|
|
34803
|
+
message: error2
|
|
34804
|
+
});
|
|
34805
|
+
}
|
|
34806
|
+
const data = this.modules.get(key);
|
|
34807
|
+
if (data?.loadSuccessClear) {
|
|
34808
|
+
this.remove(key);
|
|
34809
|
+
}
|
|
34810
|
+
resolve({
|
|
34811
|
+
code: 200,
|
|
34812
|
+
data: data?.modules
|
|
34813
|
+
});
|
|
34814
|
+
};
|
|
34815
|
+
this.event.once(key, onEvent);
|
|
34816
|
+
});
|
|
34817
|
+
}
|
|
34818
|
+
async hasLoaded(key, hasLoadOpts) {
|
|
34819
|
+
if (!key) {
|
|
34820
|
+
return {
|
|
34821
|
+
code: 404,
|
|
34822
|
+
message: "key is required"
|
|
34823
|
+
};
|
|
34824
|
+
}
|
|
34825
|
+
const has = this.modules.has(key);
|
|
34826
|
+
if (!has) {
|
|
34827
|
+
const isExist = hasLoadOpts?.isExist ?? true;
|
|
34828
|
+
const timeout = hasLoadOpts?.timeout ?? this.timeout;
|
|
34829
|
+
if (isExist) {
|
|
34830
|
+
return await this.listenKey(key, { timeout });
|
|
34831
|
+
}
|
|
34832
|
+
return {
|
|
34833
|
+
code: 404
|
|
34834
|
+
};
|
|
34835
|
+
}
|
|
34836
|
+
const data = this.modules.get(key);
|
|
34837
|
+
if (data?.status === "loaded") {
|
|
34838
|
+
return {
|
|
34839
|
+
code: 200,
|
|
34840
|
+
data: data.modules
|
|
34841
|
+
};
|
|
34842
|
+
}
|
|
34843
|
+
if (data?.status === "loading") {
|
|
34844
|
+
return await this.listenKey(key, { timeout: hasLoadOpts?.timeout ?? this.timeout });
|
|
34845
|
+
}
|
|
34846
|
+
if (data?.status === "error") {
|
|
34847
|
+
return {
|
|
34848
|
+
code: 500,
|
|
34849
|
+
message: "load error"
|
|
34850
|
+
};
|
|
34851
|
+
}
|
|
34852
|
+
if (data?.status === "cancel") {
|
|
34853
|
+
return {
|
|
34854
|
+
code: 499,
|
|
34855
|
+
message: "operation cancelled"
|
|
34856
|
+
};
|
|
34857
|
+
}
|
|
34858
|
+
return {
|
|
34859
|
+
code: 404
|
|
34860
|
+
};
|
|
34861
|
+
}
|
|
34862
|
+
async loadFn(loadContent, opts) {
|
|
34863
|
+
const key = opts.key;
|
|
34864
|
+
if (!key) {
|
|
34865
|
+
return {
|
|
34866
|
+
code: 404,
|
|
34867
|
+
message: "key is required"
|
|
34868
|
+
};
|
|
34869
|
+
}
|
|
34870
|
+
const newModule = {
|
|
34871
|
+
key: opts.key,
|
|
34872
|
+
status: "loading",
|
|
34873
|
+
loading: true,
|
|
34874
|
+
loadSuccessClear: opts.loadSuccessClear ?? true
|
|
34875
|
+
};
|
|
34876
|
+
let errorMessage = "";
|
|
34877
|
+
try {
|
|
34878
|
+
const isReRun = opts.isReRun ?? false;
|
|
34879
|
+
let res;
|
|
34880
|
+
if (!isReRun) {
|
|
34881
|
+
this.modules.set(key, newModule);
|
|
34882
|
+
res = await loadContent();
|
|
34883
|
+
} else {
|
|
34884
|
+
newModule.controller = new AbortController;
|
|
34885
|
+
const signal = newModule.controller.signal;
|
|
34886
|
+
this.modules.set(key, newModule);
|
|
34887
|
+
const data = await reRunFn2({
|
|
34888
|
+
timeout: opts.timeout,
|
|
34889
|
+
interval: opts.interval,
|
|
34890
|
+
checkSuccess: opts.checkSuccess,
|
|
34891
|
+
fn: loadContent,
|
|
34892
|
+
signal
|
|
34893
|
+
});
|
|
34894
|
+
newModule.controller = null;
|
|
34895
|
+
if (data.code === 499) {
|
|
34896
|
+
newModule.status = "cancel";
|
|
34897
|
+
return {
|
|
34898
|
+
code: 499,
|
|
34899
|
+
message: "operation cancelled"
|
|
34900
|
+
};
|
|
34901
|
+
}
|
|
34902
|
+
if (data.code !== 200) {
|
|
34903
|
+
throw new Error(data.message);
|
|
34904
|
+
}
|
|
34905
|
+
res = data.data;
|
|
34906
|
+
}
|
|
34907
|
+
newModule.modules = res;
|
|
34908
|
+
newModule.status = "loaded";
|
|
34909
|
+
return {
|
|
34910
|
+
code: 200,
|
|
34911
|
+
data: res
|
|
34912
|
+
};
|
|
34913
|
+
} catch (error2) {
|
|
34914
|
+
errorMessage = error2.message;
|
|
34915
|
+
newModule.status = "error";
|
|
34916
|
+
return {
|
|
34917
|
+
code: 500,
|
|
34918
|
+
message: error2
|
|
34919
|
+
};
|
|
34920
|
+
} finally {
|
|
34921
|
+
newModule.loading = false;
|
|
34922
|
+
this.modules.set(opts.key, newModule);
|
|
34923
|
+
if (!errorMessage) {
|
|
34924
|
+
this.event.emit(opts.key);
|
|
34925
|
+
} else {
|
|
34926
|
+
this.event.emit(opts.key, errorMessage);
|
|
34927
|
+
}
|
|
34928
|
+
}
|
|
34929
|
+
}
|
|
34930
|
+
async load(loadContent, opts) {
|
|
34931
|
+
this.loading = true;
|
|
34932
|
+
const key = opts.key;
|
|
34933
|
+
if (!key) {
|
|
34934
|
+
return {
|
|
34935
|
+
code: 404,
|
|
34936
|
+
message: "key is required"
|
|
34937
|
+
};
|
|
34938
|
+
}
|
|
34939
|
+
if (opts?.force) {
|
|
34940
|
+
this.remove(key);
|
|
34941
|
+
}
|
|
34942
|
+
const has = this.modules.has(key);
|
|
34943
|
+
if (has) {
|
|
34944
|
+
return await this.hasLoaded(key);
|
|
34945
|
+
}
|
|
34946
|
+
if (typeof loadContent === "function") {
|
|
34947
|
+
return this.loadFn(loadContent, opts);
|
|
34948
|
+
}
|
|
34949
|
+
console.error("loadContent is not a function and not has loaded");
|
|
34950
|
+
}
|
|
34951
|
+
remove(key) {
|
|
34952
|
+
const has = this.modules.has(key);
|
|
34953
|
+
if (has) {
|
|
34954
|
+
this.checkRemoveController(key);
|
|
34955
|
+
this.modules.delete(key);
|
|
34956
|
+
}
|
|
34957
|
+
}
|
|
34958
|
+
emitLoaded(key) {
|
|
34959
|
+
this.checkRemoveController(key);
|
|
34960
|
+
this.event.emit(key);
|
|
34961
|
+
}
|
|
34962
|
+
setModule(key, data, loadData) {
|
|
34963
|
+
const newModule = {
|
|
34964
|
+
key,
|
|
34965
|
+
status: "loaded",
|
|
34966
|
+
loading: false,
|
|
34967
|
+
modules: data || {},
|
|
34968
|
+
...loadData
|
|
34969
|
+
};
|
|
34970
|
+
this.modules.set(key, newModule);
|
|
34971
|
+
this.emitLoaded(key);
|
|
34972
|
+
return newModule;
|
|
34973
|
+
}
|
|
34974
|
+
cancel(key) {
|
|
34975
|
+
this.checkRemoveController(key);
|
|
34976
|
+
}
|
|
34977
|
+
checkRemoveController(key) {
|
|
34978
|
+
const data = this.modules.get(key);
|
|
34979
|
+
if (data?.controller) {
|
|
34980
|
+
data.controller?.abort?.();
|
|
34981
|
+
delete data.controller;
|
|
34982
|
+
this.modules.set(key, data);
|
|
34983
|
+
}
|
|
34984
|
+
}
|
|
34985
|
+
}
|
|
34986
|
+
var gt2 = globalThis || window || self;
|
|
34987
|
+
var useEnv2 = (initEnv, initKey = "config", isOverwrite) => {
|
|
34988
|
+
const env2 = gt2[initKey];
|
|
34989
|
+
const _env = env2 || initEnv;
|
|
34990
|
+
if (!env2) {
|
|
34991
|
+
if (_env) {
|
|
34992
|
+
gt2[initKey] = _env;
|
|
34993
|
+
} else {
|
|
34994
|
+
gt2[initKey] = {};
|
|
34995
|
+
}
|
|
34996
|
+
} else if (isOverwrite) {
|
|
34997
|
+
gt2[initKey] = { ...env2, ...initEnv };
|
|
34998
|
+
}
|
|
34999
|
+
return gt2[initKey];
|
|
35000
|
+
};
|
|
35001
|
+
var useEnvKey2 = (key, init, initKey = "config") => {
|
|
35002
|
+
const _env = useEnv2({}, initKey);
|
|
35003
|
+
if (key && typeof _env[key] !== "undefined") {
|
|
35004
|
+
return _env[key];
|
|
35005
|
+
}
|
|
35006
|
+
if (key && init) {
|
|
35007
|
+
if (typeof init !== "function") {
|
|
35008
|
+
_env[key] = init;
|
|
35009
|
+
}
|
|
35010
|
+
if (typeof init === "function") {
|
|
35011
|
+
const result = init();
|
|
35012
|
+
if (result instanceof Promise) {
|
|
35013
|
+
return result.then((res) => {
|
|
35014
|
+
_env[key] = res;
|
|
35015
|
+
return res;
|
|
35016
|
+
});
|
|
35017
|
+
}
|
|
35018
|
+
_env[key] = result;
|
|
35019
|
+
}
|
|
35020
|
+
return _env[key];
|
|
35021
|
+
}
|
|
35022
|
+
if (key) {
|
|
35023
|
+
const baseLoad = new BaseLoad2;
|
|
35024
|
+
const voidFn = async () => {
|
|
35025
|
+
return _env[key];
|
|
35026
|
+
};
|
|
35027
|
+
const checkFn = async () => {
|
|
35028
|
+
const loadRes = await baseLoad.load(voidFn, {
|
|
35029
|
+
key,
|
|
35030
|
+
isReRun: true,
|
|
35031
|
+
checkSuccess: () => _env[key],
|
|
35032
|
+
timeout: 5 * 60 * 1000,
|
|
35033
|
+
interval: 1000
|
|
35034
|
+
});
|
|
35035
|
+
if (loadRes.code !== 200) {
|
|
35036
|
+
console.error("load key error");
|
|
35037
|
+
return null;
|
|
35038
|
+
}
|
|
35039
|
+
return _env[key];
|
|
35040
|
+
};
|
|
35041
|
+
return checkFn();
|
|
35042
|
+
}
|
|
35043
|
+
console.error("key is empty ");
|
|
35044
|
+
return null;
|
|
35045
|
+
};
|
|
35046
|
+
var useEnvKeyNew2 = (key, initKey = "config", opts) => {
|
|
35047
|
+
const _env = useEnv2({}, initKey);
|
|
35048
|
+
if (key) {
|
|
35049
|
+
delete _env[key];
|
|
35050
|
+
}
|
|
35051
|
+
if (opts?.getNew && opts.init) {
|
|
35052
|
+
return useEnvKey2(key, opts.init, initKey);
|
|
35053
|
+
} else if (opts?.getNew) {
|
|
35054
|
+
return useEnvKey2(key, null, initKey);
|
|
35055
|
+
}
|
|
35056
|
+
};
|
|
35057
|
+
var useContextKey2 = (key, init, isNew) => {
|
|
35058
|
+
if (isNew) {
|
|
35059
|
+
return useEnvKeyNew2(key, "context", { getNew: true, init });
|
|
35060
|
+
}
|
|
35061
|
+
return useEnvKey2(key, init, "context");
|
|
35062
|
+
};
|
|
35063
|
+
var use2 = useContextKey2;
|
|
35064
|
+
var useConfigKey2 = (key, init, isNew) => {
|
|
35065
|
+
if (isNew) {
|
|
35066
|
+
return useEnvKeyNew2(key, "config", { getNew: true, init });
|
|
35067
|
+
}
|
|
35068
|
+
return useEnvKey2(key, init, "config");
|
|
35069
|
+
};
|
|
35070
|
+
|
|
35071
|
+
class InitEnv2 {
|
|
35072
|
+
static isInit = false;
|
|
35073
|
+
static init(opts) {
|
|
35074
|
+
if (InitEnv2.isInit) {
|
|
35075
|
+
return;
|
|
35076
|
+
}
|
|
35077
|
+
const { load = true, page = false } = opts || {};
|
|
35078
|
+
InitEnv2.isInit = true;
|
|
35079
|
+
gt2.useConfigKey = useConfigKey2;
|
|
35080
|
+
gt2.useContextKey = useContextKey2;
|
|
35081
|
+
gt2.use = use2;
|
|
35082
|
+
gt2.webEnv = { useConfigKey: useConfigKey2, useContextKey: useContextKey2, use: use2 };
|
|
35083
|
+
load && (gt2.Load = BaseLoad2);
|
|
35084
|
+
}
|
|
35085
|
+
}
|
|
35086
|
+
InitEnv2.init();
|
|
35087
|
+
|
|
35088
|
+
// src/module/local-apps/src/modules/app-file.ts
|
|
35089
|
+
import path6 from "node:path";
|
|
35090
|
+
import fs6 from "node:fs";
|
|
35091
|
+
var getAppsPath2 = () => {
|
|
35092
|
+
const appsPath = process.env.APPS_PATH;
|
|
35093
|
+
if (appsPath) {
|
|
35094
|
+
const resolvePath = path6.resolve(appsPath);
|
|
35095
|
+
if (fileIsExist2(resolvePath)) {
|
|
35096
|
+
return resolvePath;
|
|
35097
|
+
} else {
|
|
35098
|
+
fs6.mkdirSync(resolvePath, { recursive: true });
|
|
35099
|
+
return resolvePath;
|
|
35100
|
+
}
|
|
35101
|
+
}
|
|
35102
|
+
return useFileStore2("apps", { needExists: true });
|
|
35103
|
+
};
|
|
35104
|
+
var loadAppInfo2 = async (appsPath = "apps", filename = "apps.config.json") => {
|
|
35105
|
+
let configFile = getConfigFile2({
|
|
35106
|
+
cwd: appsPath,
|
|
35107
|
+
fileName: filename
|
|
35108
|
+
});
|
|
35109
|
+
if (!configFile) {
|
|
35110
|
+
configFile = path6.join(appsPath, "..", filename);
|
|
35111
|
+
fs6.writeFileSync(configFile, JSON.stringify({ list: [] }));
|
|
35112
|
+
return { list: [] };
|
|
35113
|
+
}
|
|
35114
|
+
try {
|
|
35115
|
+
const config = fs6.readFileSync(configFile, "utf-8");
|
|
35116
|
+
const v = JSON.parse(config);
|
|
35117
|
+
if (!v.list) {
|
|
35118
|
+
v.list = [];
|
|
35119
|
+
}
|
|
35120
|
+
return v;
|
|
35121
|
+
} catch (e) {
|
|
35122
|
+
console.error("读取配置文件失败", e.message);
|
|
35123
|
+
return { list: [] };
|
|
35124
|
+
}
|
|
35125
|
+
};
|
|
35126
|
+
var saveAppInfo2 = async (data, appsPath, filename = "apps.config.json") => {
|
|
35127
|
+
const configFile = getConfigFile2({
|
|
35128
|
+
fileName: filename,
|
|
35129
|
+
cwd: appsPath
|
|
35130
|
+
});
|
|
35131
|
+
if (!configFile) {
|
|
35132
|
+
console.error("未找到配置文件");
|
|
35133
|
+
return;
|
|
35134
|
+
}
|
|
35135
|
+
fs6.writeFileSync(configFile, JSON.stringify(data, null, 2));
|
|
35136
|
+
};
|
|
35137
|
+
var deleteFileAppInfo2 = async (key, appsPath) => {
|
|
35138
|
+
const normalizedKey = key.replace(/\//g, path6.sep);
|
|
35139
|
+
const directory = path6.join(appsPath, normalizedKey);
|
|
35140
|
+
if (!fileIsExist2(directory)) {
|
|
35141
|
+
return;
|
|
35142
|
+
}
|
|
35143
|
+
fs6.rmSync(directory, { recursive: true });
|
|
35144
|
+
};
|
|
35145
|
+
|
|
35146
|
+
// src/module/local-apps/src/modules/manager.ts
|
|
35147
|
+
import { fork as fork2 } from "node:child_process";
|
|
35148
|
+
import path7 from "node:path";
|
|
35149
|
+
var import_fast_glob = __toESM(require_out4(), 1);
|
|
35150
|
+
import fs7 from "node:fs";
|
|
35151
|
+
|
|
35152
|
+
// src/module/local-apps/src/modules/pm2.ts
|
|
35153
|
+
import { spawn } from "node:child_process";
|
|
35154
|
+
import pm23 from "pm2";
|
|
35155
|
+
import { promisify as promisify3 } from "node:util";
|
|
35156
|
+
var normalizeScriptPath2 = (scriptPath) => {
|
|
35157
|
+
if (process.platform === "win32") {
|
|
35158
|
+
return scriptPath.replace(/\\/g, "/");
|
|
35159
|
+
}
|
|
35160
|
+
return scriptPath;
|
|
35161
|
+
};
|
|
35162
|
+
var connect2 = async (noDaemonMode = false) => {
|
|
35163
|
+
return new Promise((resolve, reject) => {
|
|
35164
|
+
pm23.connect(noDaemonMode, (err) => {
|
|
35165
|
+
if (err) {
|
|
35166
|
+
console.error("pm2 connect error", err);
|
|
35167
|
+
return reject(err);
|
|
35168
|
+
}
|
|
35169
|
+
resolve(true);
|
|
35170
|
+
});
|
|
35171
|
+
});
|
|
35172
|
+
};
|
|
35173
|
+
var disconnect2 = promisify3(pm23.disconnect).bind(pm23);
|
|
35174
|
+
var start3 = promisify3(pm23.start).bind(pm23);
|
|
35175
|
+
var stop3 = promisify3(pm23.stop).bind(pm23);
|
|
35176
|
+
var restart3 = promisify3(pm23.restart).bind(pm23);
|
|
35177
|
+
var reload2 = promisify3(pm23.reload).bind(pm23);
|
|
35178
|
+
var deleteProcess3 = promisify3(pm23.delete).bind(pm23);
|
|
35179
|
+
var list3 = promisify3(pm23.list).bind(pm23);
|
|
35180
|
+
var checkInstall = async (app) => {
|
|
35181
|
+
return new Promise((resolve, reject) => {
|
|
35182
|
+
const install = spawn("pnpm", ["install"], {
|
|
35183
|
+
cwd: app.path,
|
|
35184
|
+
stdio: "inherit"
|
|
35185
|
+
});
|
|
35186
|
+
install.on("close", (code) => {
|
|
35187
|
+
if (code !== 0) {
|
|
35188
|
+
console.log("install failed");
|
|
35189
|
+
return resolve(false);
|
|
35190
|
+
}
|
|
35191
|
+
console.log("install success");
|
|
35192
|
+
resolve(true);
|
|
35193
|
+
});
|
|
35194
|
+
});
|
|
35195
|
+
};
|
|
35196
|
+
|
|
35197
|
+
class Pm2Connect2 {
|
|
35198
|
+
needConnect = true;
|
|
35199
|
+
isConnected = false;
|
|
35200
|
+
constructor(needConnect = true) {
|
|
35201
|
+
this.needConnect = needConnect;
|
|
35202
|
+
}
|
|
35203
|
+
async sleep(ms) {
|
|
35204
|
+
return new Promise((resolve) => {
|
|
35205
|
+
setTimeout(resolve, ms);
|
|
35206
|
+
});
|
|
35207
|
+
}
|
|
35208
|
+
async checkConnect() {
|
|
35209
|
+
const that = this;
|
|
35210
|
+
try {
|
|
35211
|
+
if (this.needConnect && !this.isConnected) {
|
|
35212
|
+
const data = await connect2();
|
|
35213
|
+
that.isConnected = !!data;
|
|
35214
|
+
}
|
|
35215
|
+
} catch (e) {
|
|
35216
|
+
console.log("pm2 check connect error", e);
|
|
35217
|
+
}
|
|
35218
|
+
}
|
|
35219
|
+
async checkDisconnect(runOpts) {
|
|
35220
|
+
const needExit = runOpts?.needExit ?? true;
|
|
35221
|
+
if (this.needConnect && this.isConnected && needExit) {
|
|
35222
|
+
this.disconnect();
|
|
35223
|
+
}
|
|
35224
|
+
}
|
|
35225
|
+
async connect() {
|
|
35226
|
+
try {
|
|
35227
|
+
await connect2();
|
|
35228
|
+
this.isConnected = true;
|
|
35229
|
+
} catch (e) {
|
|
35230
|
+
console.log("pm2 connect error", e);
|
|
35231
|
+
}
|
|
35232
|
+
}
|
|
35233
|
+
async disconnect() {
|
|
35234
|
+
try {
|
|
35235
|
+
pm23.disconnect();
|
|
35236
|
+
await this.sleep(1000);
|
|
35237
|
+
} catch (e) {
|
|
35238
|
+
console.log("pm2 disconnect error", e);
|
|
35239
|
+
}
|
|
35240
|
+
this.isConnected = false;
|
|
35241
|
+
}
|
|
35242
|
+
}
|
|
35243
|
+
|
|
35244
|
+
class Pm2Manager2 {
|
|
35245
|
+
pm2Connect;
|
|
35246
|
+
appName;
|
|
35247
|
+
script;
|
|
35248
|
+
interpreter;
|
|
35249
|
+
needConnect = true;
|
|
35250
|
+
isConnect = false;
|
|
35251
|
+
env;
|
|
35252
|
+
constructor(opts) {
|
|
35253
|
+
this.appName = opts.appName;
|
|
35254
|
+
this.script = opts.script;
|
|
35255
|
+
this.interpreter = opts.interpreter;
|
|
35256
|
+
this.pm2Connect = opts.pm2Connect || new Pm2Connect2;
|
|
35257
|
+
this.env = opts.env || {};
|
|
35258
|
+
}
|
|
35259
|
+
async list(runOpts) {
|
|
35260
|
+
const _runOpts = { needExit: false, ...runOpts };
|
|
35261
|
+
try {
|
|
35262
|
+
await this.pm2Connect.checkConnect();
|
|
35263
|
+
const apps = await list3();
|
|
35264
|
+
return apps;
|
|
35265
|
+
} catch (e) {
|
|
35266
|
+
console.log("pm2 run error", e);
|
|
35267
|
+
return [];
|
|
35268
|
+
} finally {
|
|
35269
|
+
this.pm2Connect.checkDisconnect(_runOpts);
|
|
35270
|
+
}
|
|
35271
|
+
}
|
|
35272
|
+
async start(options, runOpts) {
|
|
35273
|
+
const { appName, script, env: env2, interpreter } = this;
|
|
35274
|
+
const needExit = runOpts?.needExit ?? true;
|
|
35275
|
+
if (!script) {
|
|
35276
|
+
console.error("script is required");
|
|
35277
|
+
return;
|
|
35278
|
+
}
|
|
35279
|
+
const normalizedScript = normalizeScriptPath2(script);
|
|
35280
|
+
const starter = {
|
|
35281
|
+
name: appName,
|
|
35282
|
+
script: normalizedScript,
|
|
35283
|
+
cwd: process.cwd(),
|
|
35284
|
+
interpreter,
|
|
35285
|
+
...options,
|
|
35286
|
+
env: {
|
|
35287
|
+
NODE_ENV: "production",
|
|
35288
|
+
...env2,
|
|
35289
|
+
...options?.env
|
|
35290
|
+
}
|
|
35291
|
+
};
|
|
35292
|
+
try {
|
|
35293
|
+
await this.pm2Connect.checkConnect();
|
|
35294
|
+
const apps = await this.list({ needExit: false });
|
|
35295
|
+
const app = apps.find((app2) => app2.name === appName);
|
|
35296
|
+
if (app && app.pid === 0) {
|
|
35297
|
+
await start3(starter);
|
|
35298
|
+
return;
|
|
35299
|
+
} else if (!app) {
|
|
35300
|
+
await start3(starter);
|
|
35301
|
+
} else {
|
|
35302
|
+
console.log(`pm2 app ${appName} is running`);
|
|
35303
|
+
}
|
|
35304
|
+
} catch (e) {
|
|
35305
|
+
console.error("error", e);
|
|
35306
|
+
} finally {
|
|
35307
|
+
this.pm2Connect.checkDisconnect({ needExit });
|
|
35308
|
+
}
|
|
35309
|
+
}
|
|
35310
|
+
async stop(runOpts) {
|
|
35311
|
+
try {
|
|
35312
|
+
await this.pm2Connect.checkConnect();
|
|
35313
|
+
const apps = await this.list({ needExit: false });
|
|
35314
|
+
const app = apps.find((app2) => app2.name === this.appName);
|
|
35315
|
+
if (app && app.pid !== 0) {
|
|
35316
|
+
await stop3(app.name);
|
|
35317
|
+
}
|
|
35318
|
+
} catch (e) {
|
|
35319
|
+
console.error("error", e);
|
|
35320
|
+
} finally {
|
|
35321
|
+
this.pm2Connect.checkDisconnect(runOpts);
|
|
35322
|
+
}
|
|
35323
|
+
}
|
|
35324
|
+
async restart(runOpts) {
|
|
35325
|
+
try {
|
|
35326
|
+
await this.pm2Connect.checkConnect();
|
|
35327
|
+
const apps = await this.list({ needExit: false });
|
|
35328
|
+
const app = apps.find((app2) => app2.name === this.appName);
|
|
35329
|
+
if (app) {
|
|
35330
|
+
await restart3(app.name);
|
|
35331
|
+
}
|
|
35332
|
+
} catch (e) {
|
|
35333
|
+
console.error("error", e);
|
|
35334
|
+
} finally {
|
|
35335
|
+
this.pm2Connect.checkDisconnect(runOpts);
|
|
35336
|
+
}
|
|
35337
|
+
}
|
|
35338
|
+
async remove(runOpts) {
|
|
35339
|
+
this.deleteProcess(runOpts);
|
|
35340
|
+
}
|
|
35341
|
+
async deleteProcess(runOpts) {
|
|
35342
|
+
try {
|
|
35343
|
+
await this.pm2Connect.checkConnect();
|
|
35344
|
+
const apps = await this.list({ needExit: false });
|
|
35345
|
+
const app = apps.find((app2) => app2.name === this.appName);
|
|
35346
|
+
if (app) {
|
|
35347
|
+
await deleteProcess3(app.name);
|
|
35348
|
+
}
|
|
35349
|
+
} catch (e) {
|
|
35350
|
+
console.error("error", e);
|
|
35351
|
+
} finally {
|
|
35352
|
+
this.pm2Connect.checkDisconnect(runOpts);
|
|
35353
|
+
}
|
|
35354
|
+
}
|
|
35355
|
+
}
|
|
34347
35356
|
|
|
34348
35357
|
// src/module/local-apps/src/modules/manager.ts
|
|
34349
35358
|
var onAppShowInfo2 = (app) => {
|
|
@@ -34620,12 +35629,12 @@ var LoadApp = async (app, opts) => {
|
|
|
34620
35629
|
if (app.status !== "running") {
|
|
34621
35630
|
return false;
|
|
34622
35631
|
}
|
|
34623
|
-
if (!
|
|
35632
|
+
if (!fileIsExist2(app.path)) {
|
|
34624
35633
|
console.error("app is not found");
|
|
34625
35634
|
return false;
|
|
34626
35635
|
}
|
|
34627
|
-
const pathEntry =
|
|
34628
|
-
if (!
|
|
35636
|
+
const pathEntry = path7.join(app.path, app.entry);
|
|
35637
|
+
if (!fileIsExist2(pathEntry)) {
|
|
34629
35638
|
console.error("file entry not found");
|
|
34630
35639
|
return false;
|
|
34631
35640
|
}
|
|
@@ -34644,7 +35653,7 @@ var LoadApp = async (app, opts) => {
|
|
|
34644
35653
|
});
|
|
34645
35654
|
app.process = childProcess;
|
|
34646
35655
|
} else if (app.type === "system-app" /* SystemApp */) {
|
|
34647
|
-
const pathEntryAndTimestamp =
|
|
35656
|
+
const pathEntryAndTimestamp = path7.join(app.path, entry2);
|
|
34648
35657
|
const importPath = process.platform === "win32" ? "file:///" + pathEntryAndTimestamp.replace(/\\/g, "/") : pathEntryAndTimestamp;
|
|
34649
35658
|
const module = await import(importPath);
|
|
34650
35659
|
if (module.loadApp && mainApp) {
|
|
@@ -34653,7 +35662,7 @@ var LoadApp = async (app, opts) => {
|
|
|
34653
35662
|
} else if (app.type === "gateway-app" /* GatewayApp */) {
|
|
34654
35663
|
console.log("gateway app not support");
|
|
34655
35664
|
} else if (app.type === "pm2-system-app" /* Pm2SystemApp */) {
|
|
34656
|
-
const pathEntry2 =
|
|
35665
|
+
const pathEntry2 = path7.join(app.path, app.entry);
|
|
34657
35666
|
const pm2Manager = new Pm2Manager2({
|
|
34658
35667
|
appName: app.key,
|
|
34659
35668
|
script: pathEntry2,
|
|
@@ -34671,7 +35680,7 @@ var LoadApp = async (app, opts) => {
|
|
|
34671
35680
|
pm2Options.interpreter = pm2Options.interpreter || app?.engine;
|
|
34672
35681
|
}
|
|
34673
35682
|
if (!pm2Options.cwd) {
|
|
34674
|
-
pm2Options.cwd =
|
|
35683
|
+
pm2Options.cwd = path7.join(app.path, "../..");
|
|
34675
35684
|
}
|
|
34676
35685
|
await pm2Manager.start(pm2Options);
|
|
34677
35686
|
} else if (app.type === "script-app" /* ScriptApp */) {
|
|
@@ -34706,30 +35715,30 @@ var StopApp = async (app, opts) => {
|
|
|
34706
35715
|
}
|
|
34707
35716
|
};
|
|
34708
35717
|
var installAppFromKey2 = async (key, _appPath) => {
|
|
34709
|
-
const normalizedKey = key.replace(/\//g,
|
|
34710
|
-
const directory =
|
|
34711
|
-
if (!
|
|
35718
|
+
const normalizedKey = key.replace(/\//g, path7.sep);
|
|
35719
|
+
const directory = path7.join(_appPath, normalizedKey);
|
|
35720
|
+
if (!fileIsExist2(directory)) {
|
|
34712
35721
|
console.error("App not found", directory);
|
|
34713
35722
|
throw new Error("App not found");
|
|
34714
35723
|
}
|
|
34715
|
-
const pkgs =
|
|
34716
|
-
if (!
|
|
35724
|
+
const pkgs = path7.join(directory, "package.json");
|
|
35725
|
+
if (!fileIsExist2(pkgs)) {
|
|
34717
35726
|
throw new Error("Invalid package.json, need package.json in app directory");
|
|
34718
35727
|
}
|
|
34719
|
-
const json =
|
|
35728
|
+
const json = fs7.readFileSync(pkgs, "utf-8");
|
|
34720
35729
|
const pkg = JSON.parse(json);
|
|
34721
35730
|
const { name, version, app } = pkg;
|
|
34722
35731
|
if (!name || !version || !app) {
|
|
34723
35732
|
console.error("need name, version and app in package.json");
|
|
34724
35733
|
throw new Error("Invalid package.json format, need name, version and app");
|
|
34725
35734
|
}
|
|
34726
|
-
const readmeFile =
|
|
34727
|
-
const readmeFile2 =
|
|
35735
|
+
const readmeFile = path7.join(directory, "README.md");
|
|
35736
|
+
const readmeFile2 = path7.join(directory, "readme.md");
|
|
34728
35737
|
let readmeDesc = "";
|
|
34729
|
-
if (
|
|
34730
|
-
readmeDesc =
|
|
34731
|
-
} else if (
|
|
34732
|
-
readmeDesc =
|
|
35738
|
+
if (fileIsExist2(readmeFile)) {
|
|
35739
|
+
readmeDesc = fs7.readFileSync(readmeFile, "utf-8");
|
|
35740
|
+
} else if (fileIsExist2(readmeFile2)) {
|
|
35741
|
+
readmeDesc = fs7.readFileSync(readmeFile2, "utf-8");
|
|
34733
35742
|
}
|
|
34734
35743
|
let showAppInfo = {
|
|
34735
35744
|
key,
|
|
@@ -34744,13 +35753,13 @@ var installAppFromKey2 = async (key, _appPath) => {
|
|
|
34744
35753
|
};
|
|
34745
35754
|
app.key = key;
|
|
34746
35755
|
if (app.type === "pm2-system-app") {
|
|
34747
|
-
const pm2Cwd =
|
|
35756
|
+
const pm2Cwd = path7.join(_appPath, "..");
|
|
34748
35757
|
showAppInfo.pm2Options = { cwd: pm2Cwd, ...app.pm2Options };
|
|
34749
35758
|
}
|
|
34750
35759
|
return { pkg, showAppInfo };
|
|
34751
35760
|
};
|
|
34752
35761
|
var getAppPathKeys2 = async (_appPath) => {
|
|
34753
|
-
const directory =
|
|
35762
|
+
const directory = path7.resolve(_appPath);
|
|
34754
35763
|
const root2 = directory;
|
|
34755
35764
|
const path1 = "*/package.json";
|
|
34756
35765
|
const path22 = "*/*/package.json";
|
|
@@ -34761,7 +35770,7 @@ var getAppPathKeys2 = async (_appPath) => {
|
|
|
34761
35770
|
ignore: ["**/node_modules/**"]
|
|
34762
35771
|
});
|
|
34763
35772
|
const appPathKeys = appsPackages.map((pkg) => {
|
|
34764
|
-
const dir =
|
|
35773
|
+
const dir = path7.dirname(pkg);
|
|
34765
35774
|
return dir.replace(/\\/g, "/");
|
|
34766
35775
|
});
|
|
34767
35776
|
return appPathKeys;
|
|
@@ -34769,8 +35778,8 @@ var getAppPathKeys2 = async (_appPath) => {
|
|
|
34769
35778
|
|
|
34770
35779
|
// src/module/assistant/local-app-manager/assistant-app.ts
|
|
34771
35780
|
var import_fast_glob3 = __toESM(require_out4(), 1);
|
|
34772
|
-
import
|
|
34773
|
-
import
|
|
35781
|
+
import path10 from "node:path";
|
|
35782
|
+
import fs12 from "node:fs";
|
|
34774
35783
|
|
|
34775
35784
|
// ../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
|
|
34776
35785
|
var import__2 = __toESM(require_eventemitter3(), 1);
|
|
@@ -34941,7 +35950,7 @@ var getEnvToken = () => {
|
|
|
34941
35950
|
return envTokne;
|
|
34942
35951
|
};
|
|
34943
35952
|
|
|
34944
|
-
// ../node_modules/.pnpm/@kevisual+query@0.0.
|
|
35953
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
|
|
34945
35954
|
var isTextForContentType = (contentType) => {
|
|
34946
35955
|
if (!contentType)
|
|
34947
35956
|
return false;
|
|
@@ -34973,11 +35982,15 @@ var adapter = async (opts = {}, overloadOpts) => {
|
|
|
34973
35982
|
url = new URL(opts.url, origin);
|
|
34974
35983
|
}
|
|
34975
35984
|
const isGet = method === "GET";
|
|
35985
|
+
const oldSearchParams = url.searchParams;
|
|
34976
35986
|
if (isGet) {
|
|
34977
|
-
let searchParams = new URLSearchParams(opts.body);
|
|
35987
|
+
let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
|
|
34978
35988
|
url.search = searchParams.toString();
|
|
34979
35989
|
} else {
|
|
34980
|
-
const params =
|
|
35990
|
+
const params = {
|
|
35991
|
+
...Object.fromEntries(oldSearchParams),
|
|
35992
|
+
...opts.params
|
|
35993
|
+
};
|
|
34981
35994
|
const searchParams = new URLSearchParams(params);
|
|
34982
35995
|
if (typeof opts.body === "object" && opts.body !== null) {
|
|
34983
35996
|
let body2 = opts.body || {};
|
|
@@ -35205,15 +36218,15 @@ import require$$4 from "node:tls";
|
|
|
35205
36218
|
import require$$0$22 from "node:stream";
|
|
35206
36219
|
import require$$02 from "node:zlib";
|
|
35207
36220
|
import require$$0$12 from "node:buffer";
|
|
35208
|
-
function
|
|
36221
|
+
function getDefaultExportFromCjs4(x) {
|
|
35209
36222
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
35210
36223
|
}
|
|
35211
|
-
var
|
|
35212
|
-
var
|
|
35213
|
-
function
|
|
35214
|
-
if (
|
|
35215
|
-
return
|
|
35216
|
-
|
|
36224
|
+
var eventemitter33 = { exports: {} };
|
|
36225
|
+
var hasRequiredEventemitter33;
|
|
36226
|
+
function requireEventemitter33() {
|
|
36227
|
+
if (hasRequiredEventemitter33)
|
|
36228
|
+
return eventemitter33.exports;
|
|
36229
|
+
hasRequiredEventemitter33 = 1;
|
|
35217
36230
|
(function(module) {
|
|
35218
36231
|
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
35219
36232
|
function Events() {}
|
|
@@ -35246,11 +36259,11 @@ function requireEventemitter32() {
|
|
|
35246
36259
|
else
|
|
35247
36260
|
delete emitter._events[evt];
|
|
35248
36261
|
}
|
|
35249
|
-
function
|
|
36262
|
+
function EventEmitter4() {
|
|
35250
36263
|
this._events = new Events;
|
|
35251
36264
|
this._eventsCount = 0;
|
|
35252
36265
|
}
|
|
35253
|
-
|
|
36266
|
+
EventEmitter4.prototype.eventNames = function eventNames() {
|
|
35254
36267
|
var names = [], events, name;
|
|
35255
36268
|
if (this._eventsCount === 0)
|
|
35256
36269
|
return names;
|
|
@@ -35263,7 +36276,7 @@ function requireEventemitter32() {
|
|
|
35263
36276
|
}
|
|
35264
36277
|
return names;
|
|
35265
36278
|
};
|
|
35266
|
-
|
|
36279
|
+
EventEmitter4.prototype.listeners = function listeners(event) {
|
|
35267
36280
|
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
35268
36281
|
if (!handlers)
|
|
35269
36282
|
return [];
|
|
@@ -35274,7 +36287,7 @@ function requireEventemitter32() {
|
|
|
35274
36287
|
}
|
|
35275
36288
|
return ee;
|
|
35276
36289
|
};
|
|
35277
|
-
|
|
36290
|
+
EventEmitter4.prototype.listenerCount = function listenerCount(event) {
|
|
35278
36291
|
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
35279
36292
|
if (!listeners)
|
|
35280
36293
|
return 0;
|
|
@@ -35282,7 +36295,7 @@ function requireEventemitter32() {
|
|
|
35282
36295
|
return 1;
|
|
35283
36296
|
return listeners.length;
|
|
35284
36297
|
};
|
|
35285
|
-
|
|
36298
|
+
EventEmitter4.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
35286
36299
|
var evt = prefix ? prefix + event : event;
|
|
35287
36300
|
if (!this._events[evt])
|
|
35288
36301
|
return false;
|
|
@@ -35337,13 +36350,13 @@ function requireEventemitter32() {
|
|
|
35337
36350
|
}
|
|
35338
36351
|
return true;
|
|
35339
36352
|
};
|
|
35340
|
-
|
|
36353
|
+
EventEmitter4.prototype.on = function on(event, fn, context) {
|
|
35341
36354
|
return addListener(this, event, fn, context, false);
|
|
35342
36355
|
};
|
|
35343
|
-
|
|
36356
|
+
EventEmitter4.prototype.once = function once(event, fn, context) {
|
|
35344
36357
|
return addListener(this, event, fn, context, true);
|
|
35345
36358
|
};
|
|
35346
|
-
|
|
36359
|
+
EventEmitter4.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
35347
36360
|
var evt = prefix ? prefix + event : event;
|
|
35348
36361
|
if (!this._events[evt])
|
|
35349
36362
|
return this;
|
|
@@ -35369,7 +36382,7 @@ function requireEventemitter32() {
|
|
|
35369
36382
|
}
|
|
35370
36383
|
return this;
|
|
35371
36384
|
};
|
|
35372
|
-
|
|
36385
|
+
EventEmitter4.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
35373
36386
|
var evt;
|
|
35374
36387
|
if (event) {
|
|
35375
36388
|
evt = prefix ? prefix + event : event;
|
|
@@ -35381,18 +36394,18 @@ function requireEventemitter32() {
|
|
|
35381
36394
|
}
|
|
35382
36395
|
return this;
|
|
35383
36396
|
};
|
|
35384
|
-
|
|
35385
|
-
|
|
35386
|
-
|
|
35387
|
-
|
|
36397
|
+
EventEmitter4.prototype.off = EventEmitter4.prototype.removeListener;
|
|
36398
|
+
EventEmitter4.prototype.addListener = EventEmitter4.prototype.on;
|
|
36399
|
+
EventEmitter4.prefixed = prefix;
|
|
36400
|
+
EventEmitter4.EventEmitter = EventEmitter4;
|
|
35388
36401
|
{
|
|
35389
|
-
module.exports =
|
|
36402
|
+
module.exports = EventEmitter4;
|
|
35390
36403
|
}
|
|
35391
|
-
})(
|
|
35392
|
-
return
|
|
36404
|
+
})(eventemitter33);
|
|
36405
|
+
return eventemitter33.exports;
|
|
35393
36406
|
}
|
|
35394
|
-
var
|
|
35395
|
-
var
|
|
36407
|
+
var eventemitter3Exports3 = requireEventemitter33();
|
|
36408
|
+
var EventEmitter4 = /* @__PURE__ */ getDefaultExportFromCjs4(eventemitter3Exports3);
|
|
35396
36409
|
var NEVER = Object.freeze({
|
|
35397
36410
|
status: "aborted"
|
|
35398
36411
|
});
|
|
@@ -35827,11 +36840,11 @@ function aborted(x, startIndex = 0) {
|
|
|
35827
36840
|
}
|
|
35828
36841
|
return false;
|
|
35829
36842
|
}
|
|
35830
|
-
function prefixIssues(
|
|
36843
|
+
function prefixIssues(path8, issues) {
|
|
35831
36844
|
return issues.map((iss) => {
|
|
35832
36845
|
var _a;
|
|
35833
36846
|
(_a = iss).path ?? (_a.path = []);
|
|
35834
|
-
iss.path.unshift(
|
|
36847
|
+
iss.path.unshift(path8);
|
|
35835
36848
|
return iss;
|
|
35836
36849
|
});
|
|
35837
36850
|
}
|
|
@@ -42141,7 +43154,7 @@ class ServerBase {
|
|
|
42141
43154
|
_callback;
|
|
42142
43155
|
cors;
|
|
42143
43156
|
listeners = [];
|
|
42144
|
-
emitter = new
|
|
43157
|
+
emitter = new EventEmitter4;
|
|
42145
43158
|
showConnected = true;
|
|
42146
43159
|
constructor(opts) {
|
|
42147
43160
|
this.path = opts?.path || "/api/router";
|
|
@@ -42171,7 +43184,7 @@ class ServerBase {
|
|
|
42171
43184
|
this.handle = handle;
|
|
42172
43185
|
}
|
|
42173
43186
|
createCallback() {
|
|
42174
|
-
const
|
|
43187
|
+
const path8 = this.path;
|
|
42175
43188
|
const handle = this.handle;
|
|
42176
43189
|
const cors = this.cors;
|
|
42177
43190
|
const that = this;
|
|
@@ -42189,7 +43202,7 @@ class ServerBase {
|
|
|
42189
43202
|
if (res.headersSent) {
|
|
42190
43203
|
return;
|
|
42191
43204
|
}
|
|
42192
|
-
if (!req.url.startsWith(
|
|
43205
|
+
if (!req.url.startsWith(path8)) {
|
|
42193
43206
|
return;
|
|
42194
43207
|
}
|
|
42195
43208
|
if (cors) {
|
|
@@ -42202,8 +43215,8 @@ class ServerBase {
|
|
|
42202
43215
|
}
|
|
42203
43216
|
}
|
|
42204
43217
|
const url2 = req.url;
|
|
42205
|
-
if (!url2.startsWith(
|
|
42206
|
-
res.end(resultError(`not path:[${
|
|
43218
|
+
if (!url2.startsWith(path8)) {
|
|
43219
|
+
res.end(resultError(`not path:[${path8}]`));
|
|
42207
43220
|
return;
|
|
42208
43221
|
}
|
|
42209
43222
|
const messages = await handleServer(req, res);
|
|
@@ -43984,7 +44997,7 @@ function requireWebsocket() {
|
|
|
43984
44997
|
if (hasRequiredWebsocket)
|
|
43985
44998
|
return websocket;
|
|
43986
44999
|
hasRequiredWebsocket = 1;
|
|
43987
|
-
const
|
|
45000
|
+
const EventEmitter5 = require$$0$32;
|
|
43988
45001
|
const https = require$$1$1;
|
|
43989
45002
|
const http = require$$2;
|
|
43990
45003
|
const net = require$$3;
|
|
@@ -44017,7 +45030,7 @@ function requireWebsocket() {
|
|
|
44017
45030
|
const readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
44018
45031
|
const subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
44019
45032
|
|
|
44020
|
-
class WebSocket2 extends
|
|
45033
|
+
class WebSocket2 extends EventEmitter5 {
|
|
44021
45034
|
constructor(address, protocols, options) {
|
|
44022
45035
|
super();
|
|
44023
45036
|
this._binaryType = BINARY_TYPES[0];
|
|
@@ -44907,7 +45920,7 @@ function requireWebsocketServer() {
|
|
|
44907
45920
|
if (hasRequiredWebsocketServer)
|
|
44908
45921
|
return websocketServer;
|
|
44909
45922
|
hasRequiredWebsocketServer = 1;
|
|
44910
|
-
const
|
|
45923
|
+
const EventEmitter5 = require$$0$32;
|
|
44911
45924
|
const http = require$$2;
|
|
44912
45925
|
const { Duplex } = require$$0$22;
|
|
44913
45926
|
const { createHash } = require$$1;
|
|
@@ -44921,7 +45934,7 @@ function requireWebsocketServer() {
|
|
|
44921
45934
|
const CLOSING = 1;
|
|
44922
45935
|
const CLOSED = 2;
|
|
44923
45936
|
|
|
44924
|
-
class WebSocketServer extends
|
|
45937
|
+
class WebSocketServer extends EventEmitter5 {
|
|
44925
45938
|
constructor(options, callback) {
|
|
44926
45939
|
super();
|
|
44927
45940
|
options = {
|
|
@@ -45449,8 +46462,8 @@ class Parser {
|
|
|
45449
46462
|
}
|
|
45450
46463
|
|
|
45451
46464
|
class Executor {
|
|
45452
|
-
getValueByPath(obj,
|
|
45453
|
-
return
|
|
46465
|
+
getValueByPath(obj, path8) {
|
|
46466
|
+
return path8.split(".").reduce((acc, part) => acc?.[part], obj);
|
|
45454
46467
|
}
|
|
45455
46468
|
likeToRegex(pattern2) {
|
|
45456
46469
|
let regex = "";
|
|
@@ -45598,17 +46611,270 @@ var initApi = async (opts) => {
|
|
|
45598
46611
|
message: "初始化路由成功"
|
|
45599
46612
|
};
|
|
45600
46613
|
};
|
|
46614
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.38/node_modules/@kevisual/query/dist/query-browser.js
|
|
46615
|
+
var isTextForContentType2 = (contentType) => {
|
|
46616
|
+
if (!contentType)
|
|
46617
|
+
return false;
|
|
46618
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
46619
|
+
return textTypes.some((type) => contentType.includes(type));
|
|
46620
|
+
};
|
|
46621
|
+
var adapter2 = async (opts = {}, overloadOpts) => {
|
|
46622
|
+
const controller = new AbortController;
|
|
46623
|
+
const signal = controller.signal;
|
|
46624
|
+
const isPostFile = opts.isPostFile || false;
|
|
46625
|
+
let responseType = opts.responseType || "json";
|
|
46626
|
+
if (opts.isBlob) {
|
|
46627
|
+
responseType = "blob";
|
|
46628
|
+
} else if (opts.isText) {
|
|
46629
|
+
responseType = "text";
|
|
46630
|
+
}
|
|
46631
|
+
const timeout = opts.timeout || 60000 * 3;
|
|
46632
|
+
const timer = setTimeout(() => {
|
|
46633
|
+
controller.abort();
|
|
46634
|
+
}, timeout);
|
|
46635
|
+
let method = overloadOpts?.method || opts?.method || "POST";
|
|
46636
|
+
let headers = { ...opts?.headers, ...overloadOpts?.headers };
|
|
46637
|
+
let origin = "";
|
|
46638
|
+
let url2;
|
|
46639
|
+
if (opts?.url?.startsWith("http")) {
|
|
46640
|
+
url2 = new URL(opts.url);
|
|
46641
|
+
} else {
|
|
46642
|
+
origin = window?.location?.origin || "http://localhost:51515";
|
|
46643
|
+
url2 = new URL(opts.url, origin);
|
|
46644
|
+
}
|
|
46645
|
+
const isGet = method === "GET";
|
|
46646
|
+
if (isGet) {
|
|
46647
|
+
let searchParams = new URLSearchParams(opts.body);
|
|
46648
|
+
url2.search = searchParams.toString();
|
|
46649
|
+
} else {
|
|
46650
|
+
const params = opts.params || {};
|
|
46651
|
+
const searchParams = new URLSearchParams(params);
|
|
46652
|
+
if (typeof opts.body === "object" && opts.body !== null) {
|
|
46653
|
+
let body2 = opts.body || {};
|
|
46654
|
+
if (!params.path && body2?.path) {
|
|
46655
|
+
searchParams.set("path", body2.path);
|
|
46656
|
+
if (body2?.key) {
|
|
46657
|
+
searchParams.set("key", body2.key);
|
|
46658
|
+
}
|
|
46659
|
+
}
|
|
46660
|
+
}
|
|
46661
|
+
url2.search = searchParams.toString();
|
|
46662
|
+
}
|
|
46663
|
+
let body = undefined;
|
|
46664
|
+
if (isGet) {
|
|
46665
|
+
body = undefined;
|
|
46666
|
+
} else if (isPostFile) {
|
|
46667
|
+
body = opts.body;
|
|
46668
|
+
} else {
|
|
46669
|
+
headers = {
|
|
46670
|
+
"Content-Type": "application/json",
|
|
46671
|
+
...headers
|
|
46672
|
+
};
|
|
46673
|
+
body = JSON.stringify(opts.body);
|
|
46674
|
+
}
|
|
46675
|
+
return fetch(url2, {
|
|
46676
|
+
method: method.toUpperCase(),
|
|
46677
|
+
signal,
|
|
46678
|
+
body,
|
|
46679
|
+
...overloadOpts,
|
|
46680
|
+
headers
|
|
46681
|
+
}).then(async (response) => {
|
|
46682
|
+
const contentType = response.headers.get("Content-Type");
|
|
46683
|
+
if (responseType === "blob") {
|
|
46684
|
+
return await response.blob();
|
|
46685
|
+
}
|
|
46686
|
+
const isText = responseType === "text";
|
|
46687
|
+
const isJson = contentType && contentType.includes("application/json");
|
|
46688
|
+
if (isJson && !isText) {
|
|
46689
|
+
return await response.json();
|
|
46690
|
+
} else if (isTextForContentType2(contentType)) {
|
|
46691
|
+
return {
|
|
46692
|
+
code: response.status,
|
|
46693
|
+
status: response.status,
|
|
46694
|
+
data: await response.text()
|
|
46695
|
+
};
|
|
46696
|
+
} else {
|
|
46697
|
+
return response;
|
|
46698
|
+
}
|
|
46699
|
+
}).catch((err) => {
|
|
46700
|
+
if (err.name === "AbortError") {
|
|
46701
|
+
return {
|
|
46702
|
+
code: 408,
|
|
46703
|
+
message: "请求超时"
|
|
46704
|
+
};
|
|
46705
|
+
}
|
|
46706
|
+
return {
|
|
46707
|
+
code: 500,
|
|
46708
|
+
message: err.message || "网络错误"
|
|
46709
|
+
};
|
|
46710
|
+
}).finally(() => {
|
|
46711
|
+
clearTimeout(timer);
|
|
46712
|
+
});
|
|
46713
|
+
};
|
|
46714
|
+
var wrapperError2 = ({ code, message }) => {
|
|
46715
|
+
const result = {
|
|
46716
|
+
code: code || 500,
|
|
46717
|
+
success: false,
|
|
46718
|
+
message: message || "api request error",
|
|
46719
|
+
showError: (fn) => {},
|
|
46720
|
+
noMsg: true
|
|
46721
|
+
};
|
|
46722
|
+
return result;
|
|
46723
|
+
};
|
|
46724
|
+
|
|
46725
|
+
class Query2 {
|
|
46726
|
+
adapter;
|
|
46727
|
+
url;
|
|
46728
|
+
beforeRequest;
|
|
46729
|
+
afterResponse;
|
|
46730
|
+
headers;
|
|
46731
|
+
timeout;
|
|
46732
|
+
stop;
|
|
46733
|
+
qws;
|
|
46734
|
+
isClient = false;
|
|
46735
|
+
constructor(opts) {
|
|
46736
|
+
this.adapter = opts?.adapter || adapter2;
|
|
46737
|
+
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
46738
|
+
this.url = opts?.url || defaultURL;
|
|
46739
|
+
this.headers = opts?.headers || {
|
|
46740
|
+
"Content-Type": "application/json"
|
|
46741
|
+
};
|
|
46742
|
+
this.timeout = opts?.timeout || 60000 * 3;
|
|
46743
|
+
if (opts.beforeRequest) {
|
|
46744
|
+
this.beforeRequest = opts.beforeRequest;
|
|
46745
|
+
} else {
|
|
46746
|
+
this.beforeRequest = async (opts2) => {
|
|
46747
|
+
const token = globalThis?.localStorage?.getItem("token");
|
|
46748
|
+
if (token) {
|
|
46749
|
+
opts2.headers = {
|
|
46750
|
+
...opts2.headers,
|
|
46751
|
+
Authorization: `Bearer ${token}`
|
|
46752
|
+
};
|
|
46753
|
+
}
|
|
46754
|
+
return opts2;
|
|
46755
|
+
};
|
|
46756
|
+
}
|
|
46757
|
+
}
|
|
46758
|
+
setQueryWs(qws) {
|
|
46759
|
+
this.qws = qws;
|
|
46760
|
+
}
|
|
46761
|
+
setStop(stop4) {
|
|
46762
|
+
this.stop = stop4;
|
|
46763
|
+
}
|
|
46764
|
+
async get(params, options) {
|
|
46765
|
+
return this.post(params, options);
|
|
46766
|
+
}
|
|
46767
|
+
async post(body, options) {
|
|
46768
|
+
const url2 = options?.url || this.url;
|
|
46769
|
+
const { headers, adapter: adapter3, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
46770
|
+
const _headers = { ...this.headers, ...headers };
|
|
46771
|
+
const _adapter = adapter3 || this.adapter;
|
|
46772
|
+
const _beforeRequest = beforeRequest || this.beforeRequest;
|
|
46773
|
+
const _afterResponse = afterResponse || this.afterResponse;
|
|
46774
|
+
const _timeout = timeout || this.timeout;
|
|
46775
|
+
const req = {
|
|
46776
|
+
url: url2,
|
|
46777
|
+
headers: _headers,
|
|
46778
|
+
body,
|
|
46779
|
+
timeout: _timeout,
|
|
46780
|
+
...rest
|
|
46781
|
+
};
|
|
46782
|
+
try {
|
|
46783
|
+
if (_beforeRequest) {
|
|
46784
|
+
const res = await _beforeRequest(req);
|
|
46785
|
+
if (res === false) {
|
|
46786
|
+
return wrapperError2({
|
|
46787
|
+
code: 500,
|
|
46788
|
+
message: "request is cancel",
|
|
46789
|
+
req
|
|
46790
|
+
});
|
|
46791
|
+
}
|
|
46792
|
+
}
|
|
46793
|
+
} catch (e) {
|
|
46794
|
+
console.error("request beforeFn error", e, req);
|
|
46795
|
+
return wrapperError2({
|
|
46796
|
+
code: 500,
|
|
46797
|
+
message: "api request beforeFn error"
|
|
46798
|
+
});
|
|
46799
|
+
}
|
|
46800
|
+
if (this.stop && !options?.noStop) {
|
|
46801
|
+
const that = this;
|
|
46802
|
+
await new Promise((resolve) => {
|
|
46803
|
+
let timer = 0;
|
|
46804
|
+
const detect = setInterval(() => {
|
|
46805
|
+
if (!that.stop) {
|
|
46806
|
+
clearInterval(detect);
|
|
46807
|
+
resolve(true);
|
|
46808
|
+
}
|
|
46809
|
+
timer++;
|
|
46810
|
+
if (timer > 30) {
|
|
46811
|
+
console.error("request stop: timeout", req.url, timer);
|
|
46812
|
+
}
|
|
46813
|
+
}, 1000);
|
|
46814
|
+
});
|
|
46815
|
+
}
|
|
46816
|
+
return _adapter(req).then(async (res) => {
|
|
46817
|
+
try {
|
|
46818
|
+
if (_afterResponse) {
|
|
46819
|
+
return await _afterResponse(res, {
|
|
46820
|
+
req,
|
|
46821
|
+
res,
|
|
46822
|
+
fetch: adapter3
|
|
46823
|
+
});
|
|
46824
|
+
}
|
|
46825
|
+
return res;
|
|
46826
|
+
} catch (e) {
|
|
46827
|
+
console.error("request afterFn error", e, req);
|
|
46828
|
+
return wrapperError2({
|
|
46829
|
+
code: 500,
|
|
46830
|
+
message: "api request afterFn error"
|
|
46831
|
+
});
|
|
46832
|
+
}
|
|
46833
|
+
});
|
|
46834
|
+
}
|
|
46835
|
+
before(fn) {
|
|
46836
|
+
this.beforeRequest = fn;
|
|
46837
|
+
}
|
|
46838
|
+
after(fn) {
|
|
46839
|
+
this.afterResponse = fn;
|
|
46840
|
+
}
|
|
46841
|
+
async fetchText(urlOrOptions, options) {
|
|
46842
|
+
let _options = { ...options };
|
|
46843
|
+
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
46844
|
+
_options.url = urlOrOptions;
|
|
46845
|
+
}
|
|
46846
|
+
if (typeof urlOrOptions === "object") {
|
|
46847
|
+
_options = { ...urlOrOptions, ..._options };
|
|
46848
|
+
}
|
|
46849
|
+
const res = await adapter2({
|
|
46850
|
+
method: "GET",
|
|
46851
|
+
..._options,
|
|
46852
|
+
headers: {
|
|
46853
|
+
...this.headers,
|
|
46854
|
+
..._options?.headers || {}
|
|
46855
|
+
}
|
|
46856
|
+
});
|
|
46857
|
+
if (res && !res.code) {
|
|
46858
|
+
return {
|
|
46859
|
+
code: 200,
|
|
46860
|
+
data: res
|
|
46861
|
+
};
|
|
46862
|
+
}
|
|
46863
|
+
return res;
|
|
46864
|
+
}
|
|
46865
|
+
}
|
|
46866
|
+
|
|
45601
46867
|
// src/module/light-code/index.ts
|
|
45602
46868
|
var import_fast_glob2 = __toESM(require_out4(), 1);
|
|
45603
|
-
import
|
|
45604
|
-
import
|
|
46869
|
+
import path8 from "node:path";
|
|
46870
|
+
import fs10 from "node:fs";
|
|
45605
46871
|
|
|
45606
46872
|
// src/module/light-code/run.ts
|
|
45607
46873
|
import { fork as fork3 } from "node:child_process";
|
|
45608
|
-
import
|
|
45609
|
-
var fileExists = (
|
|
46874
|
+
import fs8 from "fs";
|
|
46875
|
+
var fileExists = (path8) => {
|
|
45610
46876
|
try {
|
|
45611
|
-
|
|
46877
|
+
fs8.accessSync(path8, fs8.constants.F_OK);
|
|
45612
46878
|
return true;
|
|
45613
46879
|
} catch (e) {
|
|
45614
46880
|
return false;
|
|
@@ -45721,11 +46987,11 @@ var runCode = async (tsPath, params = {}, opts) => {
|
|
|
45721
46987
|
|
|
45722
46988
|
// src/module/file-hash.ts
|
|
45723
46989
|
import crypto2 from "node:crypto";
|
|
45724
|
-
import
|
|
46990
|
+
import fs9 from "node:fs";
|
|
45725
46991
|
var getHash = (file2) => {
|
|
45726
|
-
if (!
|
|
46992
|
+
if (!fs9.existsSync(file2))
|
|
45727
46993
|
return "";
|
|
45728
|
-
const buffer =
|
|
46994
|
+
const buffer = fs9.readFileSync(file2);
|
|
45729
46995
|
return crypto2.createHash("md5").update(buffer).digest("hex");
|
|
45730
46996
|
};
|
|
45731
46997
|
var getStringHash = (str) => {
|
|
@@ -45745,9 +47011,9 @@ var initLightCode = async (opts) => {
|
|
|
45745
47011
|
return;
|
|
45746
47012
|
}
|
|
45747
47013
|
const appDir = config2.configPath.appsDir;
|
|
45748
|
-
const lightcodeDir =
|
|
45749
|
-
if (!
|
|
45750
|
-
|
|
47014
|
+
const lightcodeDir = path8.join(appDir, "light-code", "code");
|
|
47015
|
+
if (!fs10.existsSync(lightcodeDir)) {
|
|
47016
|
+
fs10.mkdirSync(lightcodeDir, { recursive: true });
|
|
45751
47017
|
}
|
|
45752
47018
|
let diffList = [];
|
|
45753
47019
|
const codeFiles = import_fast_glob2.default.sync(["**/*.ts", "**/*.js"], {
|
|
@@ -45755,7 +47021,7 @@ var initLightCode = async (opts) => {
|
|
|
45755
47021
|
onlyFiles: true
|
|
45756
47022
|
}).map((file2) => {
|
|
45757
47023
|
return {
|
|
45758
|
-
filepath:
|
|
47024
|
+
filepath: path8.join(lightcodeDir, file2)
|
|
45759
47025
|
};
|
|
45760
47026
|
});
|
|
45761
47027
|
if (sync2) {
|
|
@@ -45768,7 +47034,7 @@ var initLightCode = async (opts) => {
|
|
|
45768
47034
|
const lightQueryList = queryRes.data?.list || [];
|
|
45769
47035
|
for (const item of lightQueryList) {
|
|
45770
47036
|
const codeHash = getStringHash(item.code || "");
|
|
45771
|
-
diffList.push({ id: item.id, code: item.code || "", hash: codeHash, filepath:
|
|
47037
|
+
diffList.push({ id: item.id, code: item.code || "", hash: codeHash, filepath: path8.join(lightcodeDir, `${item.id}.ts`) });
|
|
45772
47038
|
}
|
|
45773
47039
|
const codeFileSet = new Set(codeFiles.map((f) => f.filepath));
|
|
45774
47040
|
const toAdd = diffList.filter((d) => !codeFileSet.has(d.filepath));
|
|
@@ -45776,13 +47042,13 @@ var initLightCode = async (opts) => {
|
|
|
45776
47042
|
const toUpdate = diffList.filter((d) => codeFileSet.has(d.filepath) && d.hash !== getHash(d.filepath));
|
|
45777
47043
|
const unchanged = diffList.filter((d) => codeFileSet.has(d.filepath) && d.hash === getHash(d.filepath));
|
|
45778
47044
|
for (const item of toAdd) {
|
|
45779
|
-
|
|
47045
|
+
fs10.writeFileSync(item.filepath, item.code, "utf-8");
|
|
45780
47046
|
}
|
|
45781
47047
|
for (const filepath of toDelete) {
|
|
45782
|
-
|
|
47048
|
+
fs10.unlinkSync(filepath.filepath);
|
|
45783
47049
|
}
|
|
45784
47050
|
for (const item of toUpdate) {
|
|
45785
|
-
|
|
47051
|
+
fs10.writeFileSync(item.filepath, item.code, "utf-8");
|
|
45786
47052
|
}
|
|
45787
47053
|
} else {
|
|
45788
47054
|
console.error("light-code 同步失败", queryRes.message);
|
|
@@ -45840,8 +47106,8 @@ var initLightCode = async (opts) => {
|
|
|
45840
47106
|
};
|
|
45841
47107
|
|
|
45842
47108
|
// src/module/assistant/local-app-manager/assistant-app-resolve.ts
|
|
45843
|
-
import
|
|
45844
|
-
import
|
|
47109
|
+
import path9 from "node:path";
|
|
47110
|
+
import fs11 from "node:fs";
|
|
45845
47111
|
|
|
45846
47112
|
class ModuleResolver {
|
|
45847
47113
|
root;
|
|
@@ -45850,33 +47116,33 @@ class ModuleResolver {
|
|
|
45850
47116
|
this.root = root2;
|
|
45851
47117
|
}
|
|
45852
47118
|
resolve(routePath) {
|
|
45853
|
-
if (
|
|
47119
|
+
if (path9.isAbsolute(routePath)) {
|
|
45854
47120
|
return routePath;
|
|
45855
47121
|
}
|
|
45856
47122
|
if (routePath.startsWith("@")) {
|
|
45857
47123
|
return this.resolveScopedPackage(routePath);
|
|
45858
47124
|
}
|
|
45859
47125
|
if (!routePath.startsWith(".") && !routePath.startsWith("/")) {
|
|
45860
|
-
const pkgPath =
|
|
47126
|
+
const pkgPath = path9.join(this.root, "node_modules", routePath);
|
|
45861
47127
|
if (this.fileIsExists(pkgPath)) {
|
|
45862
47128
|
return pkgPath;
|
|
45863
47129
|
}
|
|
45864
47130
|
}
|
|
45865
|
-
const localFullPath =
|
|
47131
|
+
const localFullPath = path9.resolve(this.root, routePath);
|
|
45866
47132
|
return this.fileIsExists(localFullPath) ? localFullPath : routePath;
|
|
45867
47133
|
}
|
|
45868
47134
|
resolveScopedPackage(routePath) {
|
|
45869
47135
|
const parts = routePath.split("/");
|
|
45870
47136
|
const pkgName = parts.slice(0, 2).join("/");
|
|
45871
47137
|
const subPath = parts.slice(2).join("/");
|
|
45872
|
-
const pkgPath =
|
|
45873
|
-
const pkgJsonPath =
|
|
47138
|
+
const pkgPath = path9.join(this.root, "node_modules", pkgName);
|
|
47139
|
+
const pkgJsonPath = path9.join(pkgPath, "package.json");
|
|
45874
47140
|
const pkg = this.readPackageJson(pkgJsonPath);
|
|
45875
47141
|
if (!pkg) {
|
|
45876
47142
|
return routePath;
|
|
45877
47143
|
}
|
|
45878
47144
|
const entryPath = this.resolvePackageExport(pkg, subPath);
|
|
45879
|
-
return
|
|
47145
|
+
return path9.join(pkgPath, entryPath);
|
|
45880
47146
|
}
|
|
45881
47147
|
resolvePackageExport(pkg, subPath) {
|
|
45882
47148
|
const exportsField = pkg.exports;
|
|
@@ -45895,11 +47161,11 @@ class ModuleResolver {
|
|
|
45895
47161
|
readPackageJson(pkgJsonPath) {
|
|
45896
47162
|
try {
|
|
45897
47163
|
const cached2 = this.pkgCache.get(pkgJsonPath);
|
|
45898
|
-
const stats =
|
|
47164
|
+
const stats = fs11.statSync(pkgJsonPath);
|
|
45899
47165
|
if (cached2 && cached2.mtime === stats.mtimeMs) {
|
|
45900
47166
|
return cached2.pkg;
|
|
45901
47167
|
}
|
|
45902
|
-
const pkg = JSON.parse(
|
|
47168
|
+
const pkg = JSON.parse(fs11.readFileSync(pkgJsonPath, "utf-8"));
|
|
45903
47169
|
this.pkgCache.set(pkgJsonPath, { pkg, mtime: stats.mtimeMs });
|
|
45904
47170
|
return pkg;
|
|
45905
47171
|
} catch {
|
|
@@ -45908,7 +47174,7 @@ class ModuleResolver {
|
|
|
45908
47174
|
}
|
|
45909
47175
|
fileIsExists(filepath) {
|
|
45910
47176
|
try {
|
|
45911
|
-
|
|
47177
|
+
fs11.accessSync(filepath, fs11.constants.F_OK);
|
|
45912
47178
|
return true;
|
|
45913
47179
|
} catch {
|
|
45914
47180
|
return false;
|
|
@@ -45930,10 +47196,10 @@ class AssistantApp extends Manager2 {
|
|
|
45930
47196
|
resolver;
|
|
45931
47197
|
constructor(config2, mainApp) {
|
|
45932
47198
|
config2.checkMounted();
|
|
45933
|
-
const appsPath = config2?.configPath?.appsDir ||
|
|
45934
|
-
const pagesPath = config2?.configPath?.pagesDir ||
|
|
47199
|
+
const appsPath = config2?.configPath?.appsDir || path10.join(process.cwd(), "apps");
|
|
47200
|
+
const pagesPath = config2?.configPath?.pagesDir || path10.join(process.cwd(), "pages");
|
|
45935
47201
|
const appsConfigPath = config2.configPath?.appsConfigPath;
|
|
45936
|
-
const configFimename =
|
|
47202
|
+
const configFimename = path10.basename(appsConfigPath || "");
|
|
45937
47203
|
super({
|
|
45938
47204
|
appsPath,
|
|
45939
47205
|
configFilename: configFimename,
|
|
@@ -45950,7 +47216,7 @@ class AssistantApp extends Manager2 {
|
|
|
45950
47216
|
});
|
|
45951
47217
|
const pagesParse = pages.map((page) => {
|
|
45952
47218
|
const [user, app] = page.split("/");
|
|
45953
|
-
const contentStr =
|
|
47219
|
+
const contentStr = fs12.readFileSync(path10.join(this.pagesPath, page), "utf-8");
|
|
45954
47220
|
const content = parseIfJson(contentStr);
|
|
45955
47221
|
return {
|
|
45956
47222
|
user,
|
|
@@ -45973,7 +47239,7 @@ class AssistantApp extends Manager2 {
|
|
|
45973
47239
|
});
|
|
45974
47240
|
const pagesParse = pages.map((page) => {
|
|
45975
47241
|
const relativePath = page;
|
|
45976
|
-
const contentStr =
|
|
47242
|
+
const contentStr = fs12.readFileSync(path10.join(root2, page), "utf-8");
|
|
45977
47243
|
const content = parseIfJson(contentStr);
|
|
45978
47244
|
if (!content.appType) {
|
|
45979
47245
|
const isWeb = relativePath.startsWith("pages/");
|
|
@@ -46078,7 +47344,7 @@ class AssistantApp extends Manager2 {
|
|
|
46078
47344
|
console.warn("路由的api地址不能为空", proxyInfo.router);
|
|
46079
47345
|
continue;
|
|
46080
47346
|
}
|
|
46081
|
-
const query = new
|
|
47347
|
+
const query = new Query2({ url: url2 });
|
|
46082
47348
|
try {
|
|
46083
47349
|
initApi({
|
|
46084
47350
|
router: this.mainApp,
|
|
@@ -46134,13 +47400,13 @@ class AssistantApp extends Manager2 {
|
|
|
46134
47400
|
}
|
|
46135
47401
|
}
|
|
46136
47402
|
// ../node_modules/.pnpm/@kevisual+query@0.0.38/node_modules/@kevisual/query/dist/query.js
|
|
46137
|
-
var
|
|
47403
|
+
var isTextForContentType3 = (contentType) => {
|
|
46138
47404
|
if (!contentType)
|
|
46139
47405
|
return false;
|
|
46140
47406
|
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
46141
47407
|
return textTypes.some((type) => contentType.includes(type));
|
|
46142
47408
|
};
|
|
46143
|
-
var
|
|
47409
|
+
var adapter3 = async (opts = {}, overloadOpts) => {
|
|
46144
47410
|
const controller = new AbortController;
|
|
46145
47411
|
const signal = controller.signal;
|
|
46146
47412
|
const isPostFile = opts.isPostFile || false;
|
|
@@ -46209,7 +47475,7 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
46209
47475
|
const isJson = contentType && contentType.includes("application/json");
|
|
46210
47476
|
if (isJson && !isText) {
|
|
46211
47477
|
return await response.json();
|
|
46212
|
-
} else if (
|
|
47478
|
+
} else if (isTextForContentType3(contentType)) {
|
|
46213
47479
|
return {
|
|
46214
47480
|
code: response.status,
|
|
46215
47481
|
status: response.status,
|
|
@@ -46233,7 +47499,7 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
46233
47499
|
clearTimeout(timer);
|
|
46234
47500
|
});
|
|
46235
47501
|
};
|
|
46236
|
-
var
|
|
47502
|
+
var wrapperError3 = ({ code, message }) => {
|
|
46237
47503
|
const result = {
|
|
46238
47504
|
code: code || 500,
|
|
46239
47505
|
success: false,
|
|
@@ -46244,7 +47510,7 @@ var wrapperError2 = ({ code, message }) => {
|
|
|
46244
47510
|
return result;
|
|
46245
47511
|
};
|
|
46246
47512
|
|
|
46247
|
-
class
|
|
47513
|
+
class Query3 {
|
|
46248
47514
|
adapter;
|
|
46249
47515
|
url;
|
|
46250
47516
|
beforeRequest;
|
|
@@ -46255,7 +47521,7 @@ class Query2 {
|
|
|
46255
47521
|
qws;
|
|
46256
47522
|
isClient = false;
|
|
46257
47523
|
constructor(opts) {
|
|
46258
|
-
this.adapter = opts?.adapter ||
|
|
47524
|
+
this.adapter = opts?.adapter || adapter3;
|
|
46259
47525
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
46260
47526
|
this.url = opts?.url || defaultURL;
|
|
46261
47527
|
this.headers = opts?.headers || {
|
|
@@ -46288,9 +47554,9 @@ class Query2 {
|
|
|
46288
47554
|
}
|
|
46289
47555
|
async post(body, options) {
|
|
46290
47556
|
const url2 = options?.url || this.url;
|
|
46291
|
-
const { headers, adapter:
|
|
47557
|
+
const { headers, adapter: adapter4, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
46292
47558
|
const _headers = { ...this.headers, ...headers };
|
|
46293
|
-
const _adapter =
|
|
47559
|
+
const _adapter = adapter4 || this.adapter;
|
|
46294
47560
|
const _beforeRequest = beforeRequest || this.beforeRequest;
|
|
46295
47561
|
const _afterResponse = afterResponse || this.afterResponse;
|
|
46296
47562
|
const _timeout = timeout || this.timeout;
|
|
@@ -46305,7 +47571,7 @@ class Query2 {
|
|
|
46305
47571
|
if (_beforeRequest) {
|
|
46306
47572
|
const res = await _beforeRequest(req);
|
|
46307
47573
|
if (res === false) {
|
|
46308
|
-
return
|
|
47574
|
+
return wrapperError3({
|
|
46309
47575
|
code: 500,
|
|
46310
47576
|
message: "request is cancel",
|
|
46311
47577
|
req
|
|
@@ -46314,7 +47580,7 @@ class Query2 {
|
|
|
46314
47580
|
}
|
|
46315
47581
|
} catch (e) {
|
|
46316
47582
|
console.error("request beforeFn error", e, req);
|
|
46317
|
-
return
|
|
47583
|
+
return wrapperError3({
|
|
46318
47584
|
code: 500,
|
|
46319
47585
|
message: "api request beforeFn error"
|
|
46320
47586
|
});
|
|
@@ -46341,13 +47607,13 @@ class Query2 {
|
|
|
46341
47607
|
return await _afterResponse(res, {
|
|
46342
47608
|
req,
|
|
46343
47609
|
res,
|
|
46344
|
-
fetch:
|
|
47610
|
+
fetch: adapter4
|
|
46345
47611
|
});
|
|
46346
47612
|
}
|
|
46347
47613
|
return res;
|
|
46348
47614
|
} catch (e) {
|
|
46349
47615
|
console.error("request afterFn error", e, req);
|
|
46350
|
-
return
|
|
47616
|
+
return wrapperError3({
|
|
46351
47617
|
code: 500,
|
|
46352
47618
|
message: "api request afterFn error"
|
|
46353
47619
|
});
|
|
@@ -46368,7 +47634,7 @@ class Query2 {
|
|
|
46368
47634
|
if (typeof urlOrOptions === "object") {
|
|
46369
47635
|
_options = { ...urlOrOptions, ..._options };
|
|
46370
47636
|
}
|
|
46371
|
-
const res = await
|
|
47637
|
+
const res = await adapter3({
|
|
46372
47638
|
method: "GET",
|
|
46373
47639
|
..._options,
|
|
46374
47640
|
headers: {
|
|
@@ -46394,7 +47660,7 @@ var assistantConfig2 = new AssistantConfig({
|
|
|
46394
47660
|
});
|
|
46395
47661
|
|
|
46396
47662
|
// src/program.ts
|
|
46397
|
-
import
|
|
47663
|
+
import fs13 from "fs";
|
|
46398
47664
|
var version2 = "0.0.1";
|
|
46399
47665
|
try {
|
|
46400
47666
|
if ("0.0.8")
|
|
@@ -46403,7 +47669,7 @@ try {
|
|
|
46403
47669
|
program.name("asst").description("A CLI tool with envison").version(version2, "-v, --version", "output the current version");
|
|
46404
47670
|
var ls = new Command("ls").description("List files in the current directory").action(() => {
|
|
46405
47671
|
console.log("List files");
|
|
46406
|
-
console.log(
|
|
47672
|
+
console.log(fs13.readdirSync(process.cwd()));
|
|
46407
47673
|
});
|
|
46408
47674
|
program.addCommand(ls);
|
|
46409
47675
|
var runProgram = (args2) => {
|
|
@@ -46412,8 +47678,8 @@ var runProgram = (args2) => {
|
|
|
46412
47678
|
};
|
|
46413
47679
|
|
|
46414
47680
|
// src/services/init/index.ts
|
|
46415
|
-
import
|
|
46416
|
-
import
|
|
47681
|
+
import fs14 from "node:fs";
|
|
47682
|
+
import path11 from "node:path";
|
|
46417
47683
|
|
|
46418
47684
|
// ../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
46419
47685
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -47002,18 +48268,18 @@ class AssistantInit extends AssistantConfig {
|
|
|
47002
48268
|
return `${this.getConfig()?.app?.url || "https://kevisual.cn"}/api/router`;
|
|
47003
48269
|
}
|
|
47004
48270
|
setQuery(query2) {
|
|
47005
|
-
this.#query = query2 || new
|
|
48271
|
+
this.#query = query2 || new Query3({
|
|
47006
48272
|
url: `${this.getConfig()?.app?.url || "https://kevisual.cn"}/api/router`
|
|
47007
48273
|
});
|
|
47008
48274
|
}
|
|
47009
48275
|
checkConfigPath() {
|
|
47010
|
-
const assistantPath =
|
|
48276
|
+
const assistantPath = path11.join(this.configDir, "assistant-app", "assistant-config.json");
|
|
47011
48277
|
return checkFileExists(assistantPath);
|
|
47012
48278
|
}
|
|
47013
48279
|
createEnvConfig() {
|
|
47014
48280
|
const env3 = this.configPath?.envConfigPath;
|
|
47015
48281
|
if (!checkFileExists(env3, true)) {
|
|
47016
|
-
|
|
48282
|
+
fs14.writeFileSync(env3, `# 环境配置文件
|
|
47017
48283
|
`);
|
|
47018
48284
|
console.log(chalk2.green("助手环境配置.env文件创建成功"));
|
|
47019
48285
|
}
|
|
@@ -47021,7 +48287,7 @@ class AssistantInit extends AssistantConfig {
|
|
|
47021
48287
|
createOtherConfig() {
|
|
47022
48288
|
const appsConfig = this.configPath?.appsConfigPath;
|
|
47023
48289
|
if (!checkFileExists(appsConfig, true)) {
|
|
47024
|
-
|
|
48290
|
+
fs14.writeFileSync(appsConfig, JSON.stringify({ description: "apps manager.", list: [] }));
|
|
47025
48291
|
console.log(chalk2.green("助手应用配置文件 apps.json 创建成功"));
|
|
47026
48292
|
}
|
|
47027
48293
|
}
|
|
@@ -47043,20 +48309,20 @@ class AssistantInit extends AssistantConfig {
|
|
|
47043
48309
|
}
|
|
47044
48310
|
}
|
|
47045
48311
|
initPnpm() {
|
|
47046
|
-
const pnpmPath =
|
|
48312
|
+
const pnpmPath = path11.join(this.configDir, "assistant-app", "pnpm-workspace.yaml");
|
|
47047
48313
|
let create = false;
|
|
47048
48314
|
if (!checkFileExists(pnpmPath, true)) {
|
|
47049
48315
|
create = true;
|
|
47050
|
-
|
|
48316
|
+
fs14.writeFileSync(pnpmPath, `packages:
|
|
47051
48317
|
- 'apps/**/*'
|
|
47052
48318
|
- 'pages/**/*'
|
|
47053
48319
|
`);
|
|
47054
48320
|
console.log(chalk2.green("助手 pnpm-workspace.yaml 文件创建成功"));
|
|
47055
48321
|
}
|
|
47056
|
-
const packagePath =
|
|
48322
|
+
const packagePath = path11.join(this.configDir, "assistant-app", "package.json");
|
|
47057
48323
|
if (!checkFileExists(packagePath, true)) {
|
|
47058
48324
|
create = true;
|
|
47059
|
-
|
|
48325
|
+
fs14.writeFileSync(packagePath, `{
|
|
47060
48326
|
"name": "assistant-app",
|
|
47061
48327
|
"version": "1.0.0",
|
|
47062
48328
|
"description": "assistant-app package pnpm, node pkgs projects",
|
|
@@ -47098,7 +48364,7 @@ class AssistantInit extends AssistantConfig {
|
|
|
47098
48364
|
}
|
|
47099
48365
|
`);
|
|
47100
48366
|
console.log(chalk2.green("助手 package.json 文件创建成功, 正在安装依赖..."));
|
|
47101
|
-
installDeps({ appPath:
|
|
48367
|
+
installDeps({ appPath: path11.dirname(packagePath), isProduction: true }).then(() => {
|
|
47102
48368
|
console.log("------------------------------------------------");
|
|
47103
48369
|
console.log(chalk2.green("助手依赖安装完成"));
|
|
47104
48370
|
console.log("------------------------------------------------");
|
|
@@ -47109,10 +48375,10 @@ class AssistantInit extends AssistantConfig {
|
|
|
47109
48375
|
};
|
|
47110
48376
|
}
|
|
47111
48377
|
initIgnore() {
|
|
47112
|
-
const gitignorePath =
|
|
48378
|
+
const gitignorePath = path11.join(this.configDir, ".gitignore");
|
|
47113
48379
|
let content = "";
|
|
47114
48380
|
if (checkFileExists(gitignorePath, true)) {
|
|
47115
|
-
content =
|
|
48381
|
+
content = fs14.readFileSync(gitignorePath, "utf-8");
|
|
47116
48382
|
}
|
|
47117
48383
|
const ignoreLines = [
|
|
47118
48384
|
"node_modules",
|
|
@@ -47138,7 +48404,7 @@ ${line}`;
|
|
|
47138
48404
|
}
|
|
47139
48405
|
});
|
|
47140
48406
|
if (updated) {
|
|
47141
|
-
|
|
48407
|
+
fs14.writeFileSync(gitignorePath, content.trim() + `
|
|
47142
48408
|
`);
|
|
47143
48409
|
console.log(chalk2.green(".gitignore 文件更新成功"));
|
|
47144
48410
|
}
|
|
@@ -47163,8 +48429,8 @@ ${line}`;
|
|
|
47163
48429
|
}
|
|
47164
48430
|
|
|
47165
48431
|
// src/command/config-manager/index.ts
|
|
47166
|
-
import
|
|
47167
|
-
import
|
|
48432
|
+
import path12 from "node:path";
|
|
48433
|
+
import fs15 from "node:fs";
|
|
47168
48434
|
|
|
47169
48435
|
// ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.1.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
47170
48436
|
var isTabKey = (key) => key.name === "tab";
|
|
@@ -48616,9 +49882,9 @@ var dist_default2 = createPrompt((config3, done) => {
|
|
|
48616
49882
|
// src/command/config-manager/index.ts
|
|
48617
49883
|
var Init = new Command("init").description("初始化一个助手客户端,生成配置文件。").option("-w --workspace <workspace>", "助手路径,默认为执行命令的目录,如果助手路径不存在则创建。").action((opts) => {
|
|
48618
49884
|
if (opts.workspace && !opts.workspace.startsWith("/")) {
|
|
48619
|
-
opts.workspace =
|
|
49885
|
+
opts.workspace = path12.join(process.cwd(), opts.workspace);
|
|
48620
49886
|
} else if (opts.workspace) {
|
|
48621
|
-
opts.workspace =
|
|
49887
|
+
opts.workspace = path12.resolve(opts.workspace);
|
|
48622
49888
|
}
|
|
48623
49889
|
const configDir3 = AssistantInit.detectConfigDir(opts.workspace);
|
|
48624
49890
|
console.log("configDir", configDir3);
|
|
@@ -48630,20 +49896,20 @@ var Init = new Command("init").description("初始化一个助手客户端,生
|
|
|
48630
49896
|
program.addCommand(Init);
|
|
48631
49897
|
var removeCommand = new Command("remove").description("删除助手配置文件").option("-p --path <path>", "助手路径,默认为执行命令的目录,如果助手路径不存在则创建。").action((opts) => {
|
|
48632
49898
|
if (opts.path && !opts.path.startsWith("/")) {
|
|
48633
|
-
opts.path =
|
|
49899
|
+
opts.path = path12.join(process.cwd(), opts.path);
|
|
48634
49900
|
} else if (opts.path) {
|
|
48635
|
-
opts.path =
|
|
49901
|
+
opts.path = path12.resolve(opts.path);
|
|
48636
49902
|
}
|
|
48637
49903
|
const configDir3 = AssistantInit.detectConfigDir(opts.path);
|
|
48638
|
-
const assistantDir =
|
|
48639
|
-
if (
|
|
49904
|
+
const assistantDir = path12.join(configDir3, "assistant-app");
|
|
49905
|
+
if (fs15.existsSync(assistantDir)) {
|
|
48640
49906
|
dist_default2({
|
|
48641
49907
|
message: `确定要删除助手配置文件吗?
|
|
48642
49908
|
助手配置文件路径:${assistantDir}`,
|
|
48643
49909
|
default: false
|
|
48644
49910
|
}).then((confirmed) => {
|
|
48645
49911
|
if (confirmed) {
|
|
48646
|
-
|
|
49912
|
+
fs15.rmSync(assistantDir, { recursive: true, force: true });
|
|
48647
49913
|
console.log(source_default.green("助手配置文件已删除"));
|
|
48648
49914
|
} else {
|
|
48649
49915
|
console.log(source_default.blue("助手配置文件未删除"));
|
|
@@ -48656,9 +49922,9 @@ var removeCommand = new Command("remove").description("删除助手配置文件"
|
|
|
48656
49922
|
program.addCommand(removeCommand);
|
|
48657
49923
|
var npmCommand = new Command("pnpm").description("助手pnpm命令").option("-p --path <path>", "助手路径,默认为执行命令的目录,如果助手路径不存在则创建。").action((opts) => {
|
|
48658
49924
|
if (opts.path && !opts.path.startsWith("/")) {
|
|
48659
|
-
opts.path =
|
|
49925
|
+
opts.path = path12.join(process.cwd(), opts.path);
|
|
48660
49926
|
} else if (opts.path) {
|
|
48661
|
-
opts.path =
|
|
49927
|
+
opts.path = path12.resolve(opts.path);
|
|
48662
49928
|
}
|
|
48663
49929
|
const configDir3 = AssistantInit.detectConfigDir(opts.path);
|
|
48664
49930
|
console.log("configDir", configDir3);
|
|
@@ -48675,8 +49941,8 @@ var npmCommand = new Command("pnpm").description("助手pnpm命令").option("-p
|
|
|
48675
49941
|
Init.addCommand(npmCommand);
|
|
48676
49942
|
|
|
48677
49943
|
// src/services/app/index.ts
|
|
48678
|
-
import
|
|
48679
|
-
import
|
|
49944
|
+
import path13 from "path";
|
|
49945
|
+
import fs16 from "fs";
|
|
48680
49946
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
48681
49947
|
var runCommand = (command, args2) => {
|
|
48682
49948
|
const result = spawnSync2(command, args2, {
|
|
@@ -48717,7 +49983,7 @@ class AppDownload {
|
|
|
48717
49983
|
if (type === "web") {
|
|
48718
49984
|
args2.push("-o", pagesDir);
|
|
48719
49985
|
} else if (type === "app") {
|
|
48720
|
-
args2.push("-o",
|
|
49986
|
+
args2.push("-o", path13.join(appsDir));
|
|
48721
49987
|
} else {
|
|
48722
49988
|
throw new Error("应用类型错误,只能是 web 或 app");
|
|
48723
49989
|
}
|
|
@@ -48750,10 +50016,10 @@ class AppDownload {
|
|
|
48750
50016
|
let deletePath = "";
|
|
48751
50017
|
let isDelete = false;
|
|
48752
50018
|
if (type === "web") {
|
|
48753
|
-
const pagePath =
|
|
50019
|
+
const pagePath = path13.join(pagesDir, id);
|
|
48754
50020
|
deletePath = pagePath;
|
|
48755
50021
|
} else if (type === "app") {
|
|
48756
|
-
const appPath =
|
|
50022
|
+
const appPath = path13.join(appsDir, id);
|
|
48757
50023
|
deletePath = appPath;
|
|
48758
50024
|
}
|
|
48759
50025
|
if (deletePath && checkFileExists(deletePath)) {
|
|
@@ -48764,7 +50030,7 @@ class AppDownload {
|
|
|
48764
50030
|
return;
|
|
48765
50031
|
}
|
|
48766
50032
|
}
|
|
48767
|
-
|
|
50033
|
+
fs16.rmSync(deletePath, { recursive: true });
|
|
48768
50034
|
isDelete = true;
|
|
48769
50035
|
console.log(`删除应用成功: ${deletePath}`);
|
|
48770
50036
|
}
|
|
@@ -48981,8 +50247,8 @@ commdands.forEach((name) => {
|
|
|
48981
50247
|
});
|
|
48982
50248
|
|
|
48983
50249
|
// src/command/run-scripts/index.ts
|
|
48984
|
-
import
|
|
48985
|
-
import
|
|
50250
|
+
import path14 from "node:path";
|
|
50251
|
+
import fs17 from "node:fs";
|
|
48986
50252
|
var createRandomApp = (opts) => {
|
|
48987
50253
|
const { app, package: packageJson, pwd } = opts;
|
|
48988
50254
|
if (!app.status) {
|
|
@@ -49006,12 +50272,12 @@ var createRandomApp = (opts) => {
|
|
|
49006
50272
|
};
|
|
49007
50273
|
var start4 = new Command("start").description("获取package.json中app参数并启动对应的app").option("-s --save", "保存应用信息到assistant配置中", false).action(async (opts) => {
|
|
49008
50274
|
const pwd = process.cwd();
|
|
49009
|
-
const packageJsonPath =
|
|
50275
|
+
const packageJsonPath = path14.join(pwd, "package.json");
|
|
49010
50276
|
if (checkFileExists(packageJsonPath) === false) {
|
|
49011
50277
|
logger.error("package.json 在当前目录未找到,请在包含 package.json 的目录下运行此命令。");
|
|
49012
50278
|
return;
|
|
49013
50279
|
}
|
|
49014
|
-
const packageJson = JSON.parse(
|
|
50280
|
+
const packageJson = JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8"));
|
|
49015
50281
|
const appKey = packageJson.app;
|
|
49016
50282
|
if (!appKey) {
|
|
49017
50283
|
logger.error("package.json 中未找到 app 字段,请确保在 package.json 中正确配置 app 字段。");
|
|
@@ -49041,12 +50307,12 @@ var start4 = new Command("start").description("获取package.json中app参数并
|
|
|
49041
50307
|
program.addCommand(start4);
|
|
49042
50308
|
var stop5 = new Command("stop").description("获取package.json中app参数并停止对应的app").option("-t --todo <todo>", "停止应用,在pm2中如果为stop则停止,如果为remove则删除,默认为stop", "stop").option("-s --save", "保存应用信息到assistant配置中", false).action(async (opts) => {
|
|
49043
50309
|
const pwd = process.cwd();
|
|
49044
|
-
const packageJsonPath =
|
|
50310
|
+
const packageJsonPath = path14.join(pwd, "package.json");
|
|
49045
50311
|
if (checkFileExists(packageJsonPath) === false) {
|
|
49046
50312
|
logger.error("package.json 在当前目录未找到,请在包含 package.json 的目录下运行此命令。");
|
|
49047
50313
|
return;
|
|
49048
50314
|
}
|
|
49049
|
-
const packageJson = JSON.parse(
|
|
50315
|
+
const packageJson = JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8"));
|
|
49050
50316
|
const appKey = packageJson.app;
|
|
49051
50317
|
if (!appKey) {
|
|
49052
50318
|
logger.error("package.json 中未找到 app 字段,请确保在 package.json 中正确配置 app 字段。");
|
|
@@ -49064,18 +50330,18 @@ var stop5 = new Command("stop").description("获取package.json中app参数并
|
|
|
49064
50330
|
program.addCommand(stop5);
|
|
49065
50331
|
|
|
49066
50332
|
// ../node_modules/.pnpm/@kevisual+ai@0.0.24/node_modules/@kevisual/ai/dist/ai-provider-browser.js
|
|
49067
|
-
var
|
|
49068
|
-
var
|
|
49069
|
-
var
|
|
49070
|
-
var
|
|
50333
|
+
var __create4 = Object.create;
|
|
50334
|
+
var __getProtoOf4 = Object.getPrototypeOf;
|
|
50335
|
+
var __defProp4 = Object.defineProperty;
|
|
50336
|
+
var __getOwnPropNames4 = Object.getOwnPropertyNames;
|
|
49071
50337
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
49072
|
-
var
|
|
49073
|
-
var
|
|
49074
|
-
target = mod != null ?
|
|
49075
|
-
const to = isNodeMode || !mod || !mod.__esModule ?
|
|
49076
|
-
for (let key of
|
|
49077
|
-
if (!
|
|
49078
|
-
|
|
50338
|
+
var __hasOwnProp4 = Object.prototype.hasOwnProperty;
|
|
50339
|
+
var __toESM4 = (mod, isNodeMode, target) => {
|
|
50340
|
+
target = mod != null ? __create4(__getProtoOf4(mod)) : {};
|
|
50341
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp4(target, "default", { value: mod, enumerable: true }) : target;
|
|
50342
|
+
for (let key of __getOwnPropNames4(mod))
|
|
50343
|
+
if (!__hasOwnProp4.call(to, key))
|
|
50344
|
+
__defProp4(to, key, {
|
|
49079
50345
|
get: () => mod[key],
|
|
49080
50346
|
enumerable: true
|
|
49081
50347
|
});
|
|
@@ -49086,19 +50352,19 @@ var __toCommonJS2 = (from) => {
|
|
|
49086
50352
|
var entry2 = __moduleCache2.get(from), desc;
|
|
49087
50353
|
if (entry2)
|
|
49088
50354
|
return entry2;
|
|
49089
|
-
entry2 =
|
|
50355
|
+
entry2 = __defProp4({}, "__esModule", { value: true });
|
|
49090
50356
|
if (from && typeof from === "object" || typeof from === "function")
|
|
49091
|
-
|
|
50357
|
+
__getOwnPropNames4(from).map((key) => !__hasOwnProp4.call(entry2, key) && __defProp4(entry2, key, {
|
|
49092
50358
|
get: () => from[key],
|
|
49093
50359
|
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
49094
50360
|
}));
|
|
49095
50361
|
__moduleCache2.set(from, entry2);
|
|
49096
50362
|
return entry2;
|
|
49097
50363
|
};
|
|
49098
|
-
var
|
|
50364
|
+
var __commonJS4 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
49099
50365
|
var __export2 = (target, all) => {
|
|
49100
50366
|
for (var name in all)
|
|
49101
|
-
|
|
50367
|
+
__defProp4(target, name, {
|
|
49102
50368
|
get: all[name],
|
|
49103
50369
|
enumerable: true,
|
|
49104
50370
|
configurable: true,
|
|
@@ -50885,13 +52151,13 @@ __export2(exports_events, {
|
|
|
50885
52151
|
setMaxListeners: () => setMaxListeners2,
|
|
50886
52152
|
once: () => once2,
|
|
50887
52153
|
listenerCount: () => listenerCount2,
|
|
50888
|
-
init: () =>
|
|
52154
|
+
init: () => EventEmitter5,
|
|
50889
52155
|
getMaxListeners: () => getMaxListeners2,
|
|
50890
52156
|
getEventListeners: () => getEventListeners,
|
|
50891
52157
|
default: () => events_default,
|
|
50892
52158
|
captureRejectionSymbol: () => captureRejectionSymbol,
|
|
50893
52159
|
addAbortListener: () => addAbortListener,
|
|
50894
|
-
EventEmitter: () =>
|
|
52160
|
+
EventEmitter: () => EventEmitter5
|
|
50895
52161
|
});
|
|
50896
52162
|
function emitError(emitter, args2) {
|
|
50897
52163
|
var { _events: events } = emitter;
|
|
@@ -51039,7 +52305,7 @@ var kRejection;
|
|
|
51039
52305
|
var captureRejectionSymbol;
|
|
51040
52306
|
var ArrayPrototypeSlice;
|
|
51041
52307
|
var defaultMaxListeners = 10;
|
|
51042
|
-
var
|
|
52308
|
+
var EventEmitter5 = function(opts) {
|
|
51043
52309
|
if (this._events === undefined || this._events === this.__proto__._events)
|
|
51044
52310
|
this._events = { __proto__: null }, this._eventsCount = 0;
|
|
51045
52311
|
if (this._maxListeners ??= undefined, this[kCapture] = opts?.captureRejections ? Boolean(opts?.captureRejections) : EventEmitterPrototype[kCapture])
|
|
@@ -51123,14 +52389,14 @@ var init_events = __esm2(() => {
|
|
|
51123
52389
|
kRejection = SymbolFor("nodejs.rejection");
|
|
51124
52390
|
captureRejectionSymbol = SymbolFor("nodejs.rejection");
|
|
51125
52391
|
ArrayPrototypeSlice = Array.prototype.slice;
|
|
51126
|
-
EventEmitterPrototype =
|
|
52392
|
+
EventEmitterPrototype = EventEmitter5.prototype = {};
|
|
51127
52393
|
EventEmitterPrototype._events = undefined;
|
|
51128
52394
|
EventEmitterPrototype._eventsCount = 0;
|
|
51129
52395
|
EventEmitterPrototype._maxListeners = undefined;
|
|
51130
52396
|
EventEmitterPrototype.setMaxListeners = function(n) {
|
|
51131
52397
|
return validateNumber2(n, "setMaxListeners", 0), this._maxListeners = n, this;
|
|
51132
52398
|
};
|
|
51133
|
-
EventEmitterPrototype.constructor =
|
|
52399
|
+
EventEmitterPrototype.constructor = EventEmitter5;
|
|
51134
52400
|
EventEmitterPrototype.getMaxListeners = function() {
|
|
51135
52401
|
return this?._maxListeners ?? defaultMaxListeners;
|
|
51136
52402
|
};
|
|
@@ -51253,7 +52519,7 @@ var init_events = __esm2(() => {
|
|
|
51253
52519
|
this.code = "ABORT_ERR", this.name = "AbortError";
|
|
51254
52520
|
}
|
|
51255
52521
|
};
|
|
51256
|
-
Object.defineProperties(
|
|
52522
|
+
Object.defineProperties(EventEmitter5, { captureRejections: { get() {
|
|
51257
52523
|
return EventEmitterPrototype[kCapture];
|
|
51258
52524
|
}, set(value) {
|
|
51259
52525
|
validateBoolean(value, "EventEmitter.captureRejections"), EventEmitterPrototype[kCapture] = value;
|
|
@@ -51262,10 +52528,10 @@ var init_events = __esm2(() => {
|
|
|
51262
52528
|
}, set: (arg) => {
|
|
51263
52529
|
validateNumber2(arg, "defaultMaxListeners", 0), defaultMaxListeners = arg;
|
|
51264
52530
|
} }, kMaxEventTargetListeners: { value: kMaxEventTargetListeners, enumerable: false, configurable: false, writable: false }, kMaxEventTargetListenersWarned: { value: kMaxEventTargetListenersWarned, enumerable: false, configurable: false, writable: false } });
|
|
51265
|
-
Object.assign(
|
|
51266
|
-
events_default =
|
|
52531
|
+
Object.assign(EventEmitter5, { once: once2, getEventListeners, getMaxListeners: getMaxListeners2, setMaxListeners: setMaxListeners2, EventEmitter: EventEmitter5, usingDomains: false, captureRejectionSymbol, errorMonitor: kErrorMonitor, addAbortListener, init: EventEmitter5, listenerCount: listenerCount2 });
|
|
52532
|
+
events_default = EventEmitter5;
|
|
51267
52533
|
});
|
|
51268
|
-
var require_stream5 =
|
|
52534
|
+
var require_stream5 = __commonJS4((exports, module) => {
|
|
51269
52535
|
var __commonJS22 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
51270
52536
|
var require_primordials = __commonJS22((exports2, module2) => {
|
|
51271
52537
|
|
|
@@ -55314,7 +56580,7 @@ var require_pbkdf2;
|
|
|
55314
56580
|
var require_browserify_cipher;
|
|
55315
56581
|
var require_diffie_hellman;
|
|
55316
56582
|
var require_browserify_sign;
|
|
55317
|
-
var
|
|
56583
|
+
var require_package4;
|
|
55318
56584
|
var require_bn;
|
|
55319
56585
|
var require_minimalistic_assert;
|
|
55320
56586
|
var require_utils6;
|
|
@@ -56348,7 +57614,7 @@ var init_crypto = __esm2(() => {
|
|
|
56348
57614
|
exports.createVerify = crypto22.createVerify;
|
|
56349
57615
|
exports.Verify = crypto22.Verify;
|
|
56350
57616
|
});
|
|
56351
|
-
|
|
57617
|
+
require_package4 = __commonJS22((exports, module) => {
|
|
56352
57618
|
module.exports = { name: "elliptic", version: "6.6.1", description: "EC cryptography", main: "lib/elliptic.js", files: ["lib"], scripts: { lint: "eslint lib test", "lint:fix": "npm run lint -- --fix", unit: "istanbul test _mocha --reporter=spec test/index.js", test: "npm run lint && npm run unit", version: "grunt dist && git add dist/" }, repository: { type: "git", url: "git@github.com:indutny/elliptic" }, keywords: ["EC", "Elliptic", "curve", "Cryptography"], author: "Fedor Indutny <fedor@indutny.com>", license: "MIT", bugs: { url: "https://github.com/indutny/elliptic/issues" }, homepage: "https://github.com/indutny/elliptic", devDependencies: { brfs: "^2.0.2", coveralls: "^3.1.0", eslint: "^7.6.0", grunt: "^1.2.1", "grunt-browserify": "^5.3.0", "grunt-cli": "^1.3.2", "grunt-contrib-connect": "^3.0.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-uglify": "^5.0.0", "grunt-mocha-istanbul": "^5.0.2", "grunt-saucelabs": "^9.0.1", istanbul: "^0.4.5", mocha: "^8.0.1" }, dependencies: { "bn.js": "^4.11.9", brorand: "^1.1.0", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.1", inherits: "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" } };
|
|
56353
57619
|
});
|
|
56354
57620
|
require_bn = __commonJS22((exports, module) => {
|
|
@@ -60018,7 +61284,7 @@ var init_crypto = __esm2(() => {
|
|
|
60018
61284
|
});
|
|
60019
61285
|
require_elliptic = __commonJS22((exports) => {
|
|
60020
61286
|
var elliptic = exports;
|
|
60021
|
-
elliptic.version =
|
|
61287
|
+
elliptic.version = require_package4().version;
|
|
60022
61288
|
elliptic.utils = require_utils22();
|
|
60023
61289
|
elliptic.rand = require_brorand();
|
|
60024
61290
|
elliptic.curve = require_curve();
|
|
@@ -62988,8 +64254,8 @@ var init_crypto = __esm2(() => {
|
|
|
62988
64254
|
return result;
|
|
62989
64255
|
return { result: this.isError(result) ? null : result, errors: state.errors };
|
|
62990
64256
|
};
|
|
62991
|
-
function ReporterError(
|
|
62992
|
-
this.path =
|
|
64257
|
+
function ReporterError(path15, msg) {
|
|
64258
|
+
this.path = path15, this.rethrow(msg);
|
|
62993
64259
|
}
|
|
62994
64260
|
inherits2(ReporterError, Error);
|
|
62995
64261
|
ReporterError.prototype.rethrow = function(msg) {
|
|
@@ -67420,7 +68686,7 @@ https://github.com/browserify/crypto-browserify`);
|
|
|
67420
68686
|
webcrypto2 = crypto;
|
|
67421
68687
|
crypto_default = crypto;
|
|
67422
68688
|
});
|
|
67423
|
-
var require_core =
|
|
68689
|
+
var require_core = __commonJS4((exports, module) => {
|
|
67424
68690
|
(function(root2, factory) {
|
|
67425
68691
|
if (typeof exports === "object") {
|
|
67426
68692
|
module.exports = exports = factory();
|
|
@@ -67703,7 +68969,7 @@ var require_core = __commonJS3((exports, module) => {
|
|
|
67703
68969
|
return CryptoJS;
|
|
67704
68970
|
});
|
|
67705
68971
|
});
|
|
67706
|
-
var require_enc_base64 =
|
|
68972
|
+
var require_enc_base64 = __commonJS4((exports, module) => {
|
|
67707
68973
|
(function(root2, factory) {
|
|
67708
68974
|
if (typeof exports === "object") {
|
|
67709
68975
|
module.exports = exports = factory(require_core());
|
|
@@ -67781,7 +69047,7 @@ var require_enc_base64 = __commonJS3((exports, module) => {
|
|
|
67781
69047
|
return CryptoJS.enc.Base64;
|
|
67782
69048
|
});
|
|
67783
69049
|
});
|
|
67784
|
-
var require_md52 =
|
|
69050
|
+
var require_md52 = __commonJS4((exports, module) => {
|
|
67785
69051
|
(function(root2, factory) {
|
|
67786
69052
|
if (typeof exports === "object") {
|
|
67787
69053
|
module.exports = exports = factory(require_core());
|
|
@@ -67956,7 +69222,7 @@ var require_md52 = __commonJS3((exports, module) => {
|
|
|
67956
69222
|
return CryptoJS.MD5;
|
|
67957
69223
|
});
|
|
67958
69224
|
});
|
|
67959
|
-
var require_sha1 =
|
|
69225
|
+
var require_sha1 = __commonJS4((exports, module) => {
|
|
67960
69226
|
(function(root2, factory) {
|
|
67961
69227
|
if (typeof exports === "object") {
|
|
67962
69228
|
module.exports = exports = factory(require_core());
|
|
@@ -68043,7 +69309,7 @@ var require_sha1 = __commonJS3((exports, module) => {
|
|
|
68043
69309
|
return CryptoJS.SHA1;
|
|
68044
69310
|
});
|
|
68045
69311
|
});
|
|
68046
|
-
var require_hmac2 =
|
|
69312
|
+
var require_hmac2 = __commonJS4((exports, module) => {
|
|
68047
69313
|
(function(root2, factory) {
|
|
68048
69314
|
if (typeof exports === "object") {
|
|
68049
69315
|
module.exports = exports = factory(require_core());
|
|
@@ -68103,7 +69369,7 @@ var require_hmac2 = __commonJS3((exports, module) => {
|
|
|
68103
69369
|
})();
|
|
68104
69370
|
});
|
|
68105
69371
|
});
|
|
68106
|
-
var require_evpkdf =
|
|
69372
|
+
var require_evpkdf = __commonJS4((exports, module) => {
|
|
68107
69373
|
(function(root2, factory, undef) {
|
|
68108
69374
|
if (typeof exports === "object") {
|
|
68109
69375
|
module.exports = exports = factory(require_core(), require_sha1(), require_hmac2());
|
|
@@ -68160,7 +69426,7 @@ var require_evpkdf = __commonJS3((exports, module) => {
|
|
|
68160
69426
|
return CryptoJS.EvpKDF;
|
|
68161
69427
|
});
|
|
68162
69428
|
});
|
|
68163
|
-
var require_cipher_core =
|
|
69429
|
+
var require_cipher_core = __commonJS4((exports, module) => {
|
|
68164
69430
|
(function(root2, factory, undef) {
|
|
68165
69431
|
if (typeof exports === "object") {
|
|
68166
69432
|
module.exports = exports = factory(require_core(), require_evpkdf());
|
|
@@ -68456,7 +69722,7 @@ var require_cipher_core = __commonJS3((exports, module) => {
|
|
|
68456
69722
|
}();
|
|
68457
69723
|
});
|
|
68458
69724
|
});
|
|
68459
|
-
var require_aes =
|
|
69725
|
+
var require_aes = __commonJS4((exports, module) => {
|
|
68460
69726
|
(function(root2, factory, undef) {
|
|
68461
69727
|
if (typeof exports === "object") {
|
|
68462
69728
|
module.exports = exports = factory(require_core(), require_enc_base64(), require_md52(), require_evpkdf(), require_cipher_core());
|
|
@@ -68606,7 +69872,7 @@ var require_aes = __commonJS3((exports, module) => {
|
|
|
68606
69872
|
return CryptoJS.AES;
|
|
68607
69873
|
});
|
|
68608
69874
|
});
|
|
68609
|
-
var require_enc_utf8 =
|
|
69875
|
+
var require_enc_utf8 = __commonJS4((exports, module) => {
|
|
68610
69876
|
(function(root2, factory) {
|
|
68611
69877
|
if (typeof exports === "object") {
|
|
68612
69878
|
module.exports = exports = factory(require_core());
|
|
@@ -69038,8 +70304,8 @@ class ProviderManager {
|
|
|
69038
70304
|
return this.provider.chat(messages);
|
|
69039
70305
|
}
|
|
69040
70306
|
}
|
|
69041
|
-
var import_aes =
|
|
69042
|
-
var import_enc_utf8 =
|
|
70307
|
+
var import_aes = __toESM4(require_aes(), 1);
|
|
70308
|
+
var import_enc_utf8 = __toESM4(require_enc_utf8(), 1);
|
|
69043
70309
|
var CryptoJS = { AES: import_aes.default, enc: { Utf8: import_enc_utf8.default } };
|
|
69044
70310
|
|
|
69045
70311
|
// src/command/ai/index.ts
|