@guanghechen/config 1.0.0-alpha.8 → 1.0.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/CHANGELOG.md +97 -20
- package/lib/cjs/index.cjs +38 -32
- package/lib/esm/index.mjs +34 -28
- package/lib/types/index.d.ts +8 -4
- package/package.json +10 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,80 +1,157 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
3
|
+
All notable changes to this project will be documented in this file. See
|
|
4
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## 1.0.0-alpha.18 (2024-09-18)
|
|
7
|
+
|
|
8
|
+
- :rotating_light: improve: fix lint ([3083212](https://github.com/guanghechen/sora/commit/3083212))
|
|
9
|
+
- :wrench: chore: upgrade devDependencies and fix configs
|
|
10
|
+
([230fb63](https://github.com/guanghechen/sora/commit/230fb63))
|
|
11
|
+
|
|
12
|
+
# Change Log
|
|
13
|
+
|
|
14
|
+
All notable changes to this project will be documented in this file. See
|
|
15
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
16
|
|
|
17
|
+
# [1.0.0-alpha.17](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.16...@guanghechen/config@1.0.0-alpha.17) (2024-03-10)
|
|
8
18
|
|
|
9
19
|
### Performance Improvements
|
|
10
20
|
|
|
11
|
-
|
|
21
|
+
- :art: format codes
|
|
22
|
+
([177eb54](https://github.com/guanghechen/sora/commit/177eb5407fe9209269541a327d42084901a63090))
|
|
12
23
|
|
|
24
|
+
# Change Log
|
|
13
25
|
|
|
26
|
+
All notable changes to this project will be documented in this file. See
|
|
27
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
14
28
|
|
|
29
|
+
# [1.0.0-alpha.16](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.15...@guanghechen/config@1.0.0-alpha.16) (2024-03-09)
|
|
15
30
|
|
|
31
|
+
### Performance Improvements
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
- 🔧 fix config
|
|
34
|
+
([214a842](https://github.com/guanghechen/sora/commit/214a84231af7614dc46990b01ee8cfff44c6f20c))
|
|
18
35
|
|
|
19
|
-
|
|
36
|
+
# Change Log
|
|
20
37
|
|
|
38
|
+
All notable changes to this project will be documented in this file. See
|
|
39
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
21
40
|
|
|
41
|
+
# [1.0.0-alpha.15](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.14...@guanghechen/config@1.0.0-alpha.15) (2024-02-03)
|
|
22
42
|
|
|
43
|
+
### Performance Improvements
|
|
23
44
|
|
|
45
|
+
- 🔧 fix nx scripts
|
|
46
|
+
([47bc4e6](https://github.com/guanghechen/sora/commit/47bc4e66df825cb37127219bccf60dc81d6a9b48))
|
|
47
|
+
- 🔧 update tsconfig
|
|
48
|
+
([98855bc](https://github.com/guanghechen/sora/commit/98855bcc245d98c61217c5bafc6a1b2506b7824d))
|
|
24
49
|
|
|
25
|
-
#
|
|
50
|
+
# Change Log
|
|
26
51
|
|
|
52
|
+
All notable changes to this project will be documented in this file. See
|
|
53
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
27
54
|
|
|
28
|
-
|
|
55
|
+
# [1.0.0-alpha.14](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.13...@guanghechen/config@1.0.0-alpha.14) (2024-01-21)
|
|
29
56
|
|
|
30
|
-
|
|
57
|
+
### Performance Improvements
|
|
31
58
|
|
|
59
|
+
- 💄 fix lint
|
|
60
|
+
([2d5bb6f](https://github.com/guanghechen/sora/commit/2d5bb6f03d0312a42c1117d95181df8b69de827a))
|
|
61
|
+
- 🎨 remove @guanghechen/mac
|
|
62
|
+
([5bde7d0](https://github.com/guanghechen/sora/commit/5bde7d0aa38fa648518804c1c30662fe4bbfa6ac))
|
|
32
63
|
|
|
64
|
+
# Change Log
|
|
33
65
|
|
|
66
|
+
All notable changes to this project will be documented in this file. See
|
|
67
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
34
68
|
|
|
69
|
+
# [1.0.0-alpha.13](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.12...@guanghechen/config@1.0.0-alpha.13) (2024-01-20)
|
|
35
70
|
|
|
36
|
-
|
|
71
|
+
### Features
|
|
37
72
|
|
|
73
|
+
- 🎨 add MemoTextResource & rename TextFileResource to FileTextResource
|
|
74
|
+
([fa9bb9c](https://github.com/guanghechen/sora/commit/fa9bb9c9d927a644dc1127ee48914f813a5611ab))
|
|
38
75
|
|
|
39
76
|
### Performance Improvements
|
|
40
77
|
|
|
41
|
-
|
|
42
|
-
|
|
78
|
+
- ⬆️ fix dependencies & fix lint
|
|
79
|
+
([b94c1da](https://github.com/guanghechen/sora/commit/b94c1dab2352201f11022e7aa5820c9da149cbb7))
|
|
80
|
+
- ⬆️ upgrade dependencies
|
|
81
|
+
([1039cb9](https://github.com/guanghechen/sora/commit/1039cb979b9b760ffb02e3620b05a4320d0bd107))
|
|
43
82
|
|
|
83
|
+
# [1.0.0-alpha.12](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.11...@guanghechen/config@1.0.0-alpha.12) (2024-01-13)
|
|
44
84
|
|
|
85
|
+
### Features
|
|
45
86
|
|
|
87
|
+
- 🎨 add 'parse' method to parse config content
|
|
88
|
+
([9fbc4f0](https://github.com/guanghechen/sora/commit/9fbc4f090398c1a59894f81aa3facd1bc10aa60c))
|
|
46
89
|
|
|
47
|
-
# [1.0.0-alpha.
|
|
90
|
+
# [1.0.0-alpha.11](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.10...@guanghechen/config@1.0.0-alpha.11) (2024-01-02)
|
|
48
91
|
|
|
49
92
|
**Note:** Version bump only for package @guanghechen/config
|
|
50
93
|
|
|
94
|
+
# [1.0.0-alpha.10](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.9...@guanghechen/config@1.0.0-alpha.10) (2023-12-08)
|
|
51
95
|
|
|
96
|
+
### Performance Improvements
|
|
52
97
|
|
|
98
|
+
- 🔧 update description
|
|
99
|
+
([83ce262](https://github.com/guanghechen/sora/commit/83ce26221ae681837c03eec4259c5b9bd07faffb))
|
|
53
100
|
|
|
101
|
+
# [1.0.0-alpha.9](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.8...@guanghechen/config@1.0.0-alpha.9) (2023-12-04)
|
|
54
102
|
|
|
55
|
-
|
|
103
|
+
### Performance Improvements
|
|
56
104
|
|
|
57
|
-
|
|
105
|
+
- 🔧 fix circular dependencies
|
|
106
|
+
([fc2a82d](https://github.com/guanghechen/sora/commit/fc2a82d6e5376c722f347f6765cc8df7ff6fd31f))
|
|
107
|
+
- 💄 fix lint
|
|
108
|
+
([ad8c6ed](https://github.com/guanghechen/sora/commit/ad8c6edbcb04a5db1740bfeb64ef2173abf06311))
|
|
58
109
|
|
|
110
|
+
# [1.0.0-alpha.8](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.7...@guanghechen/config@1.0.0-alpha.8) (2023-12-03)
|
|
59
111
|
|
|
112
|
+
### Performance Improvements
|
|
60
113
|
|
|
114
|
+
- 🔧 fix lint
|
|
115
|
+
([4bc57d2](https://github.com/guanghechen/sora/commit/4bc57d2deabf2a4f144c7af46d45582387825ecb))
|
|
61
116
|
|
|
117
|
+
# [1.0.0-alpha.7](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.6...@guanghechen/config@1.0.0-alpha.7) (2023-12-02)
|
|
62
118
|
|
|
63
|
-
|
|
119
|
+
**Note:** Version bump only for package @guanghechen/config
|
|
64
120
|
|
|
121
|
+
# [1.0.0-alpha.6](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.5...@guanghechen/config@1.0.0-alpha.6) (2023-11-29)
|
|
65
122
|
|
|
66
123
|
### Performance Improvements
|
|
67
124
|
|
|
68
|
-
|
|
69
|
-
|
|
125
|
+
- 🔧 no longer to require node engine version in packages
|
|
126
|
+
([6dc2014](https://github.com/guanghechen/sora/commit/6dc2014122dd44bcadc893e2ee98697265e7d61e))
|
|
70
127
|
|
|
128
|
+
# [1.0.0-alpha.5](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.4...@guanghechen/config@1.0.0-alpha.5) (2023-11-25)
|
|
71
129
|
|
|
130
|
+
### Performance Improvements
|
|
72
131
|
|
|
132
|
+
- ⬆️ upgrade devDependencies
|
|
133
|
+
([85c97b7](https://github.com/guanghechen/sora/commit/85c97b734e30a44a5016f117862ec0ba1084a054))
|
|
73
134
|
|
|
135
|
+
# [1.0.0-alpha.4](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.3...@guanghechen/config@1.0.0-alpha.4) (2023-11-18)
|
|
74
136
|
|
|
75
|
-
|
|
137
|
+
**Note:** Version bump only for package @guanghechen/config
|
|
138
|
+
|
|
139
|
+
# [1.0.0-alpha.3](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.2...@guanghechen/config@1.0.0-alpha.3) (2023-11-18)
|
|
76
140
|
|
|
141
|
+
**Note:** Version bump only for package @guanghechen/config
|
|
142
|
+
|
|
143
|
+
# [1.0.0-alpha.2](https://github.com/guanghechen/sora/compare/@guanghechen/config@1.0.0-alpha.1...@guanghechen/config@1.0.0-alpha.2) (2023-11-18)
|
|
144
|
+
|
|
145
|
+
### Performance Improvements
|
|
146
|
+
|
|
147
|
+
- chore: upgrade dependencies
|
|
148
|
+
([46cb847](https://github.com/guanghechen/sora/commit/46cb8470de325045eaa1737b096aa2cc100bd430))
|
|
149
|
+
- 🔧 upgrade engine version requirement from '>= 16.0.0' to '>= 18.0.0'
|
|
150
|
+
([ddb9521](https://github.com/guanghechen/sora/commit/ddb9521b529b2ca838554794339b9e27ac80b8aa))
|
|
151
|
+
|
|
152
|
+
# 1.0.0-alpha.1 (2023-11-07)
|
|
77
153
|
|
|
78
154
|
### Features
|
|
79
155
|
|
|
80
|
-
|
|
156
|
+
- ✨ add @guanghechen/config
|
|
157
|
+
([f982c65](https://github.com/guanghechen/sora/commit/f982c650b09cafe19311ba24bdd6a31af30b2fe2))
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var byte = require('@guanghechen/byte');
|
|
4
|
-
require('
|
|
5
|
-
require('
|
|
6
|
-
require('node:
|
|
7
|
-
var mac = require('@guanghechen/mac');
|
|
8
|
-
var semver = require('semver');
|
|
4
|
+
var invariant = require('@guanghechen/invariant');
|
|
5
|
+
var satisfies = require('semver/functions/satisfies');
|
|
6
|
+
var node_crypto = require('node:crypto');
|
|
9
7
|
var config_types = require('@guanghechen/config.types');
|
|
10
8
|
|
|
11
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
10
|
|
|
13
|
-
var
|
|
11
|
+
var satisfies__default = /*#__PURE__*/_interopDefault(satisfies);
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
throw new Error(prefix);
|
|
22
|
-
if (message == null)
|
|
23
|
-
throw new Error(prefix + ': ');
|
|
24
|
-
throw new Error(prefix + ': ' + (message instanceof Function ? message() : message));
|
|
13
|
+
function calcMac(chunks, algorithm) {
|
|
14
|
+
const hash = node_crypto.createHash(algorithm);
|
|
15
|
+
for (const chunk of chunks)
|
|
16
|
+
hash.update(chunk);
|
|
17
|
+
const mac = hash.digest();
|
|
18
|
+
return Uint8Array.from(mac);
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
const clazz = 'BaseConfigKeeper';
|
|
@@ -42,33 +36,35 @@ class BaseConfigKeeper {
|
|
|
42
36
|
return this._instance;
|
|
43
37
|
}
|
|
44
38
|
compatible(version) {
|
|
45
|
-
return
|
|
39
|
+
return satisfies__default.default(version, this.__compatible_version__, {
|
|
46
40
|
loose: false,
|
|
47
41
|
includePrerelease: true,
|
|
48
42
|
});
|
|
49
43
|
}
|
|
50
|
-
async
|
|
51
|
-
this.
|
|
44
|
+
async destroy() {
|
|
45
|
+
await this._resource.destroy();
|
|
46
|
+
this._instance = undefined;
|
|
52
47
|
}
|
|
53
48
|
async load(resource = this._resource) {
|
|
54
49
|
const configContent = await resource.load();
|
|
55
|
-
invariant(configContent !== undefined, `[${clazz}.load] Failed to load config.`);
|
|
50
|
+
invariant.invariant(configContent !== undefined, `[${clazz}.load] Failed to load config.`);
|
|
56
51
|
const config = await this.decode(configContent);
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
invariant(this.compatible(__version__), `[${clazz}.load] Version not compatible. expect(${this.__compatible_version__}), received(${__version__})`);
|
|
60
|
-
const content = this.stringify(data);
|
|
61
|
-
const mac$1 = byte.bytes2text(mac.calcMac([byte.text2bytes(content, 'utf8')], this.hashAlgorithm), 'hex');
|
|
62
|
-
invariant(mac$1 === config.__mac__, () => `[${clazz}.load] Bad config, mac is not matched.`);
|
|
63
|
-
const instance = await this.deserialize(data);
|
|
52
|
+
const { __nonce__ } = config ?? {};
|
|
53
|
+
const instance = await this._parseFromConfig(config);
|
|
64
54
|
this._instance = instance;
|
|
65
55
|
this._nonce = __nonce__;
|
|
56
|
+
return instance;
|
|
57
|
+
}
|
|
58
|
+
async parse(configContent) {
|
|
59
|
+
const config = await this.decode(configContent);
|
|
60
|
+
const instance = await this._parseFromConfig(config);
|
|
61
|
+
return instance;
|
|
66
62
|
}
|
|
67
63
|
async save(resource = this._resource) {
|
|
68
|
-
invariant(this._instance !== undefined, `[${clazz}.save] No valid data holding.`);
|
|
64
|
+
invariant.invariant(this._instance !== undefined, `[${clazz}.save] No valid data holding.`);
|
|
69
65
|
const data = await this.serialize(this._instance);
|
|
70
66
|
const content = this.stringify(data);
|
|
71
|
-
const __mac__ = byte.bytes2text(
|
|
67
|
+
const __mac__ = byte.bytes2text(calcMac([byte.text2bytes(content, 'utf8')], this.hashAlgorithm), 'hex');
|
|
72
68
|
const __nonce__ = this.nonce(this._nonce);
|
|
73
69
|
const config = {
|
|
74
70
|
__version__: this.__version__,
|
|
@@ -79,9 +75,18 @@ class BaseConfigKeeper {
|
|
|
79
75
|
const stringifiedConfig = await this.encode(config);
|
|
80
76
|
await resource.save(stringifiedConfig);
|
|
81
77
|
}
|
|
82
|
-
async
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
async update(instance) {
|
|
79
|
+
this._instance = instance;
|
|
80
|
+
}
|
|
81
|
+
async _parseFromConfig(config) {
|
|
82
|
+
const { __version__, __mac__, data } = config ?? {};
|
|
83
|
+
invariant.invariant(typeof __version__ === 'string' && typeof __mac__ === 'string', () => `[${clazz}.load] Bad config, invalid fields. (${JSON.stringify(config)})`);
|
|
84
|
+
invariant.invariant(this.compatible(__version__), `[${clazz}.load] Version not compatible. expect(${this.__compatible_version__}), received(${__version__})`);
|
|
85
|
+
const content = this.stringify(data);
|
|
86
|
+
const mac = byte.bytes2text(calcMac([byte.text2bytes(content, 'utf8')], this.hashAlgorithm), 'hex');
|
|
87
|
+
invariant.invariant(mac === config.__mac__, () => `[${clazz}.load] Bad config, mac is not matched.`);
|
|
88
|
+
const instance = await this.deserialize(data);
|
|
89
|
+
return instance;
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
|
|
@@ -116,3 +121,4 @@ Object.keys(config_types).forEach(function (k) {
|
|
|
116
121
|
get: function () { return config_types[k]; }
|
|
117
122
|
});
|
|
118
123
|
});
|
|
124
|
+
//# sourceMappingURL=index.cjs.map
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { bytes2text, randomBytes, text2bytes } from '@guanghechen/byte';
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
import 'node:
|
|
5
|
-
import { calcMac } from '@guanghechen/mac';
|
|
6
|
-
import semver from 'semver';
|
|
2
|
+
import { invariant } from '@guanghechen/invariant';
|
|
3
|
+
import satisfies from 'semver/functions/satisfies.js';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
7
5
|
export * from '@guanghechen/config.types';
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error(prefix);
|
|
16
|
-
if (message == null)
|
|
17
|
-
throw new Error(prefix + ': ');
|
|
18
|
-
throw new Error(prefix + ': ' + (message instanceof Function ? message() : message));
|
|
7
|
+
function calcMac(chunks, algorithm) {
|
|
8
|
+
const hash = createHash(algorithm);
|
|
9
|
+
for (const chunk of chunks)
|
|
10
|
+
hash.update(chunk);
|
|
11
|
+
const mac = hash.digest();
|
|
12
|
+
return Uint8Array.from(mac);
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
const clazz = 'BaseConfigKeeper';
|
|
@@ -36,27 +30,29 @@ class BaseConfigKeeper {
|
|
|
36
30
|
return this._instance;
|
|
37
31
|
}
|
|
38
32
|
compatible(version) {
|
|
39
|
-
return
|
|
33
|
+
return satisfies(version, this.__compatible_version__, {
|
|
40
34
|
loose: false,
|
|
41
35
|
includePrerelease: true,
|
|
42
36
|
});
|
|
43
37
|
}
|
|
44
|
-
async
|
|
45
|
-
this.
|
|
38
|
+
async destroy() {
|
|
39
|
+
await this._resource.destroy();
|
|
40
|
+
this._instance = undefined;
|
|
46
41
|
}
|
|
47
42
|
async load(resource = this._resource) {
|
|
48
43
|
const configContent = await resource.load();
|
|
49
44
|
invariant(configContent !== undefined, `[${clazz}.load] Failed to load config.`);
|
|
50
45
|
const config = await this.decode(configContent);
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
invariant(this.compatible(__version__), `[${clazz}.load] Version not compatible. expect(${this.__compatible_version__}), received(${__version__})`);
|
|
54
|
-
const content = this.stringify(data);
|
|
55
|
-
const mac = bytes2text(calcMac([text2bytes(content, 'utf8')], this.hashAlgorithm), 'hex');
|
|
56
|
-
invariant(mac === config.__mac__, () => `[${clazz}.load] Bad config, mac is not matched.`);
|
|
57
|
-
const instance = await this.deserialize(data);
|
|
46
|
+
const { __nonce__ } = config ?? {};
|
|
47
|
+
const instance = await this._parseFromConfig(config);
|
|
58
48
|
this._instance = instance;
|
|
59
49
|
this._nonce = __nonce__;
|
|
50
|
+
return instance;
|
|
51
|
+
}
|
|
52
|
+
async parse(configContent) {
|
|
53
|
+
const config = await this.decode(configContent);
|
|
54
|
+
const instance = await this._parseFromConfig(config);
|
|
55
|
+
return instance;
|
|
60
56
|
}
|
|
61
57
|
async save(resource = this._resource) {
|
|
62
58
|
invariant(this._instance !== undefined, `[${clazz}.save] No valid data holding.`);
|
|
@@ -73,9 +69,18 @@ class BaseConfigKeeper {
|
|
|
73
69
|
const stringifiedConfig = await this.encode(config);
|
|
74
70
|
await resource.save(stringifiedConfig);
|
|
75
71
|
}
|
|
76
|
-
async
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
async update(instance) {
|
|
73
|
+
this._instance = instance;
|
|
74
|
+
}
|
|
75
|
+
async _parseFromConfig(config) {
|
|
76
|
+
const { __version__, __mac__, data } = config ?? {};
|
|
77
|
+
invariant(typeof __version__ === 'string' && typeof __mac__ === 'string', () => `[${clazz}.load] Bad config, invalid fields. (${JSON.stringify(config)})`);
|
|
78
|
+
invariant(this.compatible(__version__), `[${clazz}.load] Version not compatible. expect(${this.__compatible_version__}), received(${__version__})`);
|
|
79
|
+
const content = this.stringify(data);
|
|
80
|
+
const mac = bytes2text(calcMac([text2bytes(content, 'utf8')], this.hashAlgorithm), 'hex');
|
|
81
|
+
invariant(mac === config.__mac__, () => `[${clazz}.load] Bad config, mac is not matched.`);
|
|
82
|
+
const instance = await this.deserialize(data);
|
|
83
|
+
return instance;
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
|
|
@@ -102,3 +107,4 @@ class PlainJsonConfigKeeper extends JsonConfigKeeper {
|
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
export { BaseConfigKeeper, JsonConfigKeeper, PlainJsonConfigKeeper };
|
|
110
|
+
//# sourceMappingURL=index.mjs.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IConfigKeeper, IConfig } from '@guanghechen/config.types';
|
|
2
2
|
export * from '@guanghechen/config.types';
|
|
3
|
-
import { IHashAlgorithm } from '@guanghechen/mac';
|
|
4
3
|
import { ITextResource } from '@guanghechen/resource.types';
|
|
5
4
|
|
|
5
|
+
type IHashAlgorithm = 'md5' | 'sha1' | 'sha256' | 'sha512';
|
|
6
|
+
|
|
6
7
|
interface IBaseConfigKeeperProps {
|
|
7
8
|
/**
|
|
8
9
|
* The resource which hold the config data.
|
|
@@ -30,10 +31,12 @@ declare abstract class BaseConfigKeeper<Instance, Data> implements IConfigKeeper
|
|
|
30
31
|
protected nonce(oldNonce: string | undefined): string | undefined;
|
|
31
32
|
get data(): Readonly<Instance> | undefined;
|
|
32
33
|
compatible(version: string): boolean;
|
|
33
|
-
update(instance: Instance): Promise<void>;
|
|
34
|
-
load(resource?: ITextResource): Promise<void>;
|
|
35
|
-
save(resource?: ITextResource): Promise<void>;
|
|
36
34
|
destroy(): Promise<void>;
|
|
35
|
+
load(resource?: ITextResource): Promise<Instance>;
|
|
36
|
+
parse(configContent: string): Promise<Instance | never>;
|
|
37
|
+
save(resource?: ITextResource): Promise<void>;
|
|
38
|
+
update(instance: Instance): Promise<void>;
|
|
39
|
+
private _parseFromConfig;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
interface IJsonConfigKeeperProps extends IBaseConfigKeeperProps {
|
|
@@ -51,3 +54,4 @@ declare class PlainJsonConfigKeeper<Data> extends JsonConfigKeeper<Data, Data> i
|
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export { BaseConfigKeeper, type IBaseConfigKeeperProps, type IJsonConfigKeeperProps, JsonConfigKeeper, PlainJsonConfigKeeper };
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/config",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
7
7
|
},
|
|
8
|
+
"description": "Utilities for defining config followed by semantic version.",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/config@1.0.0-alpha.
|
|
11
|
+
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/config@1.0.0-alpha.18",
|
|
11
12
|
"directory": "packages/config"
|
|
12
13
|
},
|
|
13
|
-
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/config@1.0.0-alpha.
|
|
14
|
+
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/config@1.0.0-alpha.18/packages/config#readme",
|
|
14
15
|
"type": "module",
|
|
15
16
|
"exports": {
|
|
16
17
|
".": {
|
|
@@ -33,20 +34,12 @@
|
|
|
33
34
|
"LICENSE",
|
|
34
35
|
"README.md"
|
|
35
36
|
],
|
|
36
|
-
"scripts": {
|
|
37
|
-
"build": "../../node_modules/.bin/rimraf lib/ && ../../node_modules/.bin/cross-env NODE_ENV=production ../../node_modules/.bin/rollup -c ../../rollup.config.mjs",
|
|
38
|
-
"prepublishOnly": "yarn build",
|
|
39
|
-
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest --config ../../jest.config.mjs --rootDir ."
|
|
40
|
-
},
|
|
41
37
|
"dependencies": {
|
|
42
|
-
"@guanghechen/byte": "^1.0.0
|
|
43
|
-
"@guanghechen/config.types": "^1.0.0
|
|
44
|
-
"@guanghechen/
|
|
45
|
-
"@guanghechen/resource.types": "^1.0.0
|
|
46
|
-
"semver": "^7.
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@guanghechen/internal": "^1.0.0-alpha.0"
|
|
38
|
+
"@guanghechen/byte": "^1.0.0",
|
|
39
|
+
"@guanghechen/config.types": "^1.0.0",
|
|
40
|
+
"@guanghechen/invariant": "^6.0.1",
|
|
41
|
+
"@guanghechen/resource.types": "^1.0.0",
|
|
42
|
+
"semver": "^7.6.3"
|
|
50
43
|
},
|
|
51
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "2723aaa31e8ac85afed5b25760875db429d88563"
|
|
52
45
|
}
|