@koishijs/loader
Advanced tools
Comparing version 4.5.5 to 4.5.6
@@ -78,3 +78,3 @@ var __create = Object.create; | ||
let addDep = function(name) { | ||
manifest.dependencies[name] = deps[name]; | ||
meta.dependencies[name] = deps[name]; | ||
isDirty = true; | ||
@@ -84,7 +84,16 @@ }; | ||
let isDirty = false; | ||
const manifest = JSON.parse(await import_fs.promises.readFile("package.json", "utf8")); | ||
const meta = JSON.parse(await import_fs.promises.readFile("package.json", "utf8")); | ||
const require2 = (0, import_module.createRequire)(__filename); | ||
const deps = require2("koishi/package.json").dependencies; | ||
if (!manifest.dependencies["@koishijs/plugin-proxy-agent"]) { | ||
if (!meta.dependencies["@koishijs/plugin-http"]) { | ||
const { request = {} } = this.config; | ||
delete this.config["request"]; | ||
this.config.plugins = { | ||
http: request, | ||
...this.config.plugins | ||
}; | ||
addDep("@koishijs/plugin-http"); | ||
} | ||
if (!meta.dependencies["@koishijs/plugin-proxy-agent"]) { | ||
this.config.plugins = { | ||
"proxy-agent": {}, | ||
@@ -108,4 +117,4 @@ ...this.config.plugins | ||
if (isDirty) { | ||
manifest.dependencies = Object.fromEntries(Object.entries(manifest.dependencies).sort(([a], [b]) => a.localeCompare(b))); | ||
await import_fs.promises.writeFile("package.json", JSON.stringify(manifest, null, 2) + "\n"); | ||
meta.dependencies = Object.fromEntries(Object.entries(meta.dependencies).sort(([a], [b]) => a.localeCompare(b))); | ||
await import_fs.promises.writeFile("package.json", JSON.stringify(meta, null, 2) + "\n"); | ||
} | ||
@@ -112,0 +121,0 @@ } catch (error) { |
{ | ||
"name": "@koishijs/loader", | ||
"description": "Config Loader for Koishi", | ||
"version": "4.5.5", | ||
"version": "4.5.6", | ||
"main": "lib/index.js", | ||
@@ -48,6 +48,6 @@ "module": "lib/index.mjs", | ||
"peerDependencies": { | ||
"@koishijs/core": "4.17.5" | ||
"@koishijs/core": "4.17.6" | ||
}, | ||
"devDependencies": { | ||
"@koishijs/core": "4.17.5", | ||
"@koishijs/core": "4.17.6", | ||
"@types/js-yaml": "^4.0.9" | ||
@@ -54,0 +54,0 @@ }, |
@@ -48,12 +48,22 @@ import { Dict, Logger } from '@koishijs/core' | ||
let isDirty = false | ||
const manifest = JSON.parse(await fs.readFile('package.json', 'utf8')) | ||
const meta = JSON.parse(await fs.readFile('package.json', 'utf8')) | ||
const require = createRequire(__filename) | ||
const deps = require('koishi/package.json').dependencies | ||
function addDep(name: string) { | ||
manifest.dependencies[name] = deps[name] | ||
meta.dependencies[name] = deps[name] | ||
isDirty = true | ||
} | ||
if (!manifest.dependencies['@koishijs/plugin-proxy-agent']) { | ||
if (!meta.dependencies['@koishijs/plugin-http']) { | ||
const { request = {} } = this.config as any | ||
delete this.config['request'] | ||
this.config.plugins = { | ||
http: request, | ||
...this.config.plugins, | ||
} | ||
addDep('@koishijs/plugin-http') | ||
} | ||
if (!meta.dependencies['@koishijs/plugin-proxy-agent']) { | ||
this.config.plugins = { | ||
'proxy-agent': {}, | ||
@@ -79,4 +89,4 @@ ...this.config.plugins, | ||
if (isDirty) { | ||
manifest.dependencies = Object.fromEntries(Object.entries(manifest.dependencies).sort(([a], [b]) => a.localeCompare(b))) | ||
await fs.writeFile('package.json', JSON.stringify(manifest, null, 2) + '\n') | ||
meta.dependencies = Object.fromEntries(Object.entries(meta.dependencies).sort(([a], [b]) => a.localeCompare(b))) | ||
await fs.writeFile('package.json', JSON.stringify(meta, null, 2) + '\n') | ||
} | ||
@@ -83,0 +93,0 @@ } catch (error) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
84428
1782