@jayfong/x-server 2.21.7 → 2.21.9
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/lib/_cjs/cli/env_util.js +4 -1
- package/lib/_cjs/services/sms.js +24 -8
- package/lib/cli/env_util.d.ts +1 -0
- package/lib/cli/env_util.js +5 -2
- package/lib/services/sms.js +24 -8
- package/package.json +2 -2
package/lib/cli/env_util.d.ts
CHANGED
package/lib/cli/env_util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { dedent, devOrProd, escapeRegExp, isNumeric } from 'vtils';
|
|
3
|
+
import { dedent, devOrProd, escapeRegExp, isNumeric, isPlainObject } from 'vtils';
|
|
4
4
|
import { parse as yamlParse } from 'yaml';
|
|
5
5
|
export class EnvUtil {
|
|
6
6
|
static normalizeValue(value) {
|
|
@@ -143,7 +143,7 @@ export class EnvUtil {
|
|
|
143
143
|
${env.comment.split(/[\r\n]+/g).map(line => `* ${line.trim()}`).join('\n*\n')}
|
|
144
144
|
*/
|
|
145
145
|
` : ''}
|
|
146
|
-
${env.key}: ${
|
|
146
|
+
${env.key}: ${EnvUtil.getTypesFromValue(env.value)};
|
|
147
147
|
`).join('\n')}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -155,6 +155,9 @@ export class EnvUtil {
|
|
|
155
155
|
const types = EnvUtil.makeTypes(envs);
|
|
156
156
|
await fs.outputFile(outFile, types);
|
|
157
157
|
}
|
|
158
|
+
static getTypesFromValue(value) {
|
|
159
|
+
return Array.isArray(value) ? `Array<${value[0] ? EnvUtil.getTypesFromValue(value[0]) : 'any'}>` : isPlainObject(value) ? Object.keys(value).length ? `Record<any, ${EnvUtil.getTypesFromValue(value[Object.keys(value)[0]])}>` : `Record<any, any>` : typeof value;
|
|
160
|
+
}
|
|
158
161
|
}
|
|
159
162
|
EnvUtil.NEWLINE = '\n';
|
|
160
163
|
EnvUtil.RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*(.*)?\s*$/;
|