@yongdall/configuration 0.4.0 → 0.5.2
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/index.d.mts +5 -3
- package/index.mjs +7 -3
- package/index.mjs.map +1 -1
- package/package.json +5 -5
package/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Realm } from "@yongdall/types";
|
|
2
2
|
import { assetsRoot, configRoot, projectRoot } from "@yongdall/root";
|
|
3
3
|
|
|
4
4
|
//#region cli/configuration/index.d.mts
|
|
@@ -16,7 +16,9 @@ declare function loadCfgWithPath<T extends object>(name: string): Promise<[strin
|
|
|
16
16
|
* @returns {Promise<T | null>}
|
|
17
17
|
*/
|
|
18
18
|
declare function loadCfg<T extends object>(name: string): Promise<T | null>;
|
|
19
|
-
declare function
|
|
19
|
+
declare function loadRealm(): Promise<Omit<Realm, "id">>;
|
|
20
|
+
/** @deprecated */
|
|
21
|
+
declare function loadTenant(): Promise<Omit<Realm, "id">>;
|
|
20
22
|
declare function loadBoot(): Promise<object>;
|
|
21
23
|
type Configuration = {
|
|
22
24
|
/**
|
|
@@ -41,4 +43,4 @@ type Configuration = {
|
|
|
41
43
|
plugins?: Record<string, string | boolean> | undefined;
|
|
42
44
|
};
|
|
43
45
|
//#endregion
|
|
44
|
-
export { Configuration, assetsRoot, configRoot, loadBoot, loadCfg, loadCfgWithPath, loadProjectConfiguration, loadProjectConfigurationPath, loadTenant, projectRoot };
|
|
46
|
+
export { Configuration, assetsRoot, configRoot, loadBoot, loadCfg, loadCfgWithPath, loadProjectConfiguration, loadProjectConfigurationPath, loadRealm, loadTenant, projectRoot };
|
package/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { assetsRoot, configRoot, configRoot as configRoot$1, configurationPath,
|
|
|
4
4
|
import loadConfiguration, { loadConfigurationWithPath } from "@yongdall/load-configuration";
|
|
5
5
|
|
|
6
6
|
//#region cli/configuration/index.mjs
|
|
7
|
-
/** @import {
|
|
7
|
+
/** @import { Realm } from '@yongdall/types' */
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {object} Configuration
|
|
10
10
|
* @prop {string} [bootModule] 启动模块
|
|
@@ -39,7 +39,7 @@ async function loadCfgWithPath(name) {
|
|
|
39
39
|
async function loadCfg(name) {
|
|
40
40
|
return loadConfiguration(pathFn.resolve(configRoot$1, name));
|
|
41
41
|
}
|
|
42
|
-
async function
|
|
42
|
+
async function loadRealm() {
|
|
43
43
|
const configuration = await loadProjectConfiguration();
|
|
44
44
|
return {
|
|
45
45
|
label: configuration.title || "拥道YongDall",
|
|
@@ -48,8 +48,12 @@ async function loadTenant() {
|
|
|
48
48
|
salt: await fsPromises.readFile(pathFn.resolve(configRoot$1, "salt"))
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
+
/** @deprecated */
|
|
52
|
+
function loadTenant() {
|
|
53
|
+
return loadRealm();
|
|
54
|
+
}
|
|
51
55
|
const loadBoot = async () => await loadCfg("boot") || {};
|
|
52
56
|
|
|
53
57
|
//#endregion
|
|
54
|
-
export { assetsRoot, configRoot, loadBoot, loadCfg, loadCfgWithPath, loadProjectConfiguration, loadProjectConfigurationPath, loadTenant, projectRoot };
|
|
58
|
+
export { assetsRoot, configRoot, loadBoot, loadCfg, loadCfgWithPath, loadProjectConfiguration, loadProjectConfigurationPath, loadRealm, loadTenant, projectRoot };
|
|
55
59
|
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["linkPath","configRoot"],"sources":["../../cli/configuration/index.mjs"],"sourcesContent":["import * as pathFn from 'node:path';\nimport * as fsPromises from 'node:fs/promises';\nimport loadConfiguration, { loadConfigurationWithPath } from '@yongdall/load-configuration';\nexport { projectRoot, configRoot, assetsRoot } from '@yongdall/root';\nimport { configurationPath as linkPath, configRoot } from '@yongdall/root';\n/** @import {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["linkPath","configRoot"],"sources":["../../cli/configuration/index.mjs"],"sourcesContent":["import * as pathFn from 'node:path';\nimport * as fsPromises from 'node:fs/promises';\nimport loadConfiguration, { loadConfigurationWithPath } from '@yongdall/load-configuration';\nexport { projectRoot, configRoot, assetsRoot } from '@yongdall/root';\nimport { configurationPath as linkPath, configRoot } from '@yongdall/root';\n/** @import { Realm } from '@yongdall/types' */\n\n/**\n * @typedef {object} Configuration\n * @prop {string} [bootModule] 启动模块\n * @prop {string} [bootName] 启动模块配置名称\n * @prop {string} [title] 网站名称\n * @prop {boolean} [single] 单用户模式\n * @prop {Record<string, string | boolean>} [plugins] 插件\n */\n\n/** @type {Promise<[string, object | null]?>?} */\nlet projectConfigurationPromise = null;\nexport async function loadProjectConfiguration() {\n\tprojectConfigurationPromise ||= loadConfigurationWithPath(linkPath).catch(() => null);\n\treturn projectConfigurationPromise.then(r => /** @type {Configuration} */(r?.[1] || {}));\n}\nexport async function loadProjectConfigurationPath() {\n\tprojectConfigurationPromise ||= loadConfigurationWithPath(linkPath).catch(() => null);\n\treturn projectConfigurationPromise.then(r => r?.[0] || linkPath);\n}\n\n/**\n * @template {object} T\n * @param {string} name \n * @returns {Promise<[string, T | null] | null>}\n */\nexport async function loadCfgWithPath(name) {\n\tlet path = pathFn.resolve(configRoot, name);\n\treturn loadConfigurationWithPath(path);\n}\n\n\n/**\n * @template {object} T\n * @param {string} name \n * @returns {Promise<T | null>}\n */\nexport async function loadCfg(name) {\n\tlet path = pathFn.resolve(configRoot, name);\n\treturn loadConfiguration(path);\n}\n\nexport async function loadRealm() {\n\tconst configuration = await loadProjectConfiguration();\n\t/** @type {Omit<Realm, 'id'>} */\n\tconst realm = {\n\t\tlabel: configuration.title || '拥道YongDall',\n\t\tsingle: Boolean(configuration.single),\n\t\tproviders: await loadCfg('providers').catch(() => { }).then(v => /** @type {Record<string, string>} */(v || {})),\n\t\tsalt: await fsPromises.readFile(pathFn.resolve(configRoot, 'salt'))\n\t};\n\treturn realm;\n}\n/** @deprecated */\nexport function loadTenant() { return loadRealm(); }\n\nexport const loadBoot = async () => await loadCfg('boot') || {};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAI,8BAA8B;AAClC,eAAsB,2BAA2B;AAChD,iCAAgC,0BAA0BA,kBAAS,CAAC,YAAY,KAAK;AACrF,QAAO,4BAA4B,MAAK,MAAkC,IAAI,MAAM,EAAE,CAAE;;AAEzF,eAAsB,+BAA+B;AACpD,iCAAgC,0BAA0BA,kBAAS,CAAC,YAAY,KAAK;AACrF,QAAO,4BAA4B,MAAK,MAAK,IAAI,MAAMA,kBAAS;;;;;;;AAQjE,eAAsB,gBAAgB,MAAM;AAE3C,QAAO,0BADI,OAAO,QAAQC,cAAY,KAAK,CACL;;;;;;;AASvC,eAAsB,QAAQ,MAAM;AAEnC,QAAO,kBADI,OAAO,QAAQA,cAAY,KAAK,CACb;;AAG/B,eAAsB,YAAY;CACjC,MAAM,gBAAgB,MAAM,0BAA0B;AAQtD,QANc;EACb,OAAO,cAAc,SAAS;EAC9B,QAAQ,QAAQ,cAAc,OAAO;EACrC,WAAW,MAAM,QAAQ,YAAY,CAAC,YAAY,GAAI,CAAC,MAAK,MAA2C,KAAK,EAAE,CAAE;EAChH,MAAM,MAAM,WAAW,SAAS,OAAO,QAAQA,cAAY,OAAO,CAAC;EACnE;;;AAIF,SAAgB,aAAa;AAAE,QAAO,WAAW;;AAEjD,MAAa,WAAW,YAAY,MAAM,QAAQ,OAAO,IAAI,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yongdall/configuration",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"configuration.yongdall": "./bin.mjs",
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"#index": "./index.mjs"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@yongdall/load-configuration": "^0.
|
|
16
|
-
"@yongdall/root": "^0.
|
|
15
|
+
"@yongdall/load-configuration": "^0.5.0",
|
|
16
|
+
"@yongdall/root": "^0.5.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@yongdall/cli-parse": "^0.
|
|
20
|
-
"@yongdall/types": "^0.
|
|
19
|
+
"@yongdall/cli-parse": "^0.5.0",
|
|
20
|
+
"@yongdall/types": "^0.5.2"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
".": "./index.mjs"
|