@jayfong/x-utils 1.0.0-202407020954 → 1.0.0-202407021055

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/_cjs/env.js CHANGED
@@ -37,20 +37,22 @@ var import_fs = require("./fs.js");
37
37
  var import_path = require("./path.js");
38
38
  var import_yaml = require("./yaml.js");
39
39
  class XEnv {
40
- static getEnvVarsFromFile = (0, import_vtils.memoize)(async () => {
41
- const envYmlFile = import_path.XPath.join(process.cwd(), ".env.yml");
40
+ static getEnvVarsFromFile = (0, import_vtils.memoize)(async function get(local = true) {
41
+ const baseName = local ? ".env.local" : ".env";
42
+ const envYmlFile = import_path.XPath.join(process.cwd(), `${baseName}.yml`);
42
43
  if (await import_fs.XFs.pathExists(envYmlFile)) {
43
44
  return import_yaml.XYaml.read(envYmlFile);
44
45
  }
45
- const envYamlFile = import_path.XPath.join(process.cwd(), ".env.yaml");
46
+ const envYamlFile = import_path.XPath.join(process.cwd(), `${baseName}.yaml`);
46
47
  if (await import_fs.XFs.pathExists(envYamlFile)) {
47
48
  return import_yaml.XYaml.read(envYamlFile);
48
49
  }
49
- const dotenvFile = import_path.XPath.join(process.cwd(), ".env");
50
+ const dotenvFile = import_path.XPath.join(process.cwd(), baseName);
50
51
  if (await import_fs.XFs.pathExists(dotenvFile)) {
51
52
  const dotenvContent = await import_fs.XFs.readFile(dotenvFile, "utf-8");
52
53
  return import_dotenv.default.parse(dotenvContent);
53
54
  }
55
+ if (local) return get(false);
54
56
  });
55
57
  static async getEnvVar(name) {
56
58
  if (process.env[name] != null) {
package/_cjs/ksb.js CHANGED
@@ -23,9 +23,10 @@ __export(ksb_exports, {
23
23
  module.exports = __toCommonJS(ksb_exports);
24
24
  var import_x_request = require("@jayfong/x-request");
25
25
  var import_vtils = require("vtils");
26
+ var import_env = require("./env.js");
26
27
  class XKsb {
27
- static request(url, data) {
28
- const token = "%22ZpWKMcjeUIsZMwZIMUdkhEfAq93e3dPsQyWxAtkRNbc=%22";
28
+ static async request(url, data) {
29
+ const token = await import_env.XEnv.getEnvVar("X_KSB_USER_TOKEN");
29
30
  const key = "12b6bb84e093532fb72b4d65fec3f00b";
30
31
  const clientId = "ca37dd67-f885-4678-91a7-6531bb153ef2";
31
32
  const ts = (/* @__PURE__ */ new Date()).getTime();
package/env.js CHANGED
@@ -4,20 +4,22 @@ import { XFs } from "./fs.js";
4
4
  import { XPath } from "./path.js";
5
5
  import { XYaml } from "./yaml.js";
6
6
  class XEnv {
7
- static getEnvVarsFromFile = memoize(async () => {
8
- const envYmlFile = XPath.join(process.cwd(), ".env.yml");
7
+ static getEnvVarsFromFile = memoize(async function get(local = true) {
8
+ const baseName = local ? ".env.local" : ".env";
9
+ const envYmlFile = XPath.join(process.cwd(), `${baseName}.yml`);
9
10
  if (await XFs.pathExists(envYmlFile)) {
10
11
  return XYaml.read(envYmlFile);
11
12
  }
12
- const envYamlFile = XPath.join(process.cwd(), ".env.yaml");
13
+ const envYamlFile = XPath.join(process.cwd(), `${baseName}.yaml`);
13
14
  if (await XFs.pathExists(envYamlFile)) {
14
15
  return XYaml.read(envYamlFile);
15
16
  }
16
- const dotenvFile = XPath.join(process.cwd(), ".env");
17
+ const dotenvFile = XPath.join(process.cwd(), baseName);
17
18
  if (await XFs.pathExists(dotenvFile)) {
18
19
  const dotenvContent = await XFs.readFile(dotenvFile, "utf-8");
19
20
  return dotenv.parse(dotenvContent);
20
21
  }
22
+ if (local) return get(false);
21
23
  });
22
24
  static async getEnvVar(name) {
23
25
  if (process.env[name] != null) {
package/ksb.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  /// <reference types="lodash" />
2
+ /**
3
+ * 环境变量:
4
+ *
5
+ * `X_KSB_USER_TOKEN`: 用户令牌
6
+ */
2
7
  export declare class XKsb {
3
8
  static request<T>(url: string, data?: any): Promise<T>;
4
9
  static desensitize(text: string): string;
package/ksb.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { xr } from "@jayfong/x-request";
2
2
  import { castArray, md5, memoize } from "vtils";
3
+ import { XEnv } from "./env.js";
3
4
  class XKsb {
4
- static request(url, data) {
5
- const token = "%22ZpWKMcjeUIsZMwZIMUdkhEfAq93e3dPsQyWxAtkRNbc=%22";
5
+ static async request(url, data) {
6
+ const token = await XEnv.getEnvVar("X_KSB_USER_TOKEN");
6
7
  const key = "12b6bb84e093532fb72b4d65fec3f00b";
7
8
  const clientId = "ca37dd67-f885-4678-91a7-6531bb153ef2";
8
9
  const ts = (/* @__PURE__ */ new Date()).getTime();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jayfong/x-utils",
3
3
  "description": "123456",
4
- "version": "1.0.0-202407020954",
4
+ "version": "1.0.0-202407021055",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "vtils": "^4.115.0",
@@ -22,13 +22,15 @@
22
22
  "nzh": "^1.0.12",
23
23
  "pathe": "^1.1.2",
24
24
  "pinyin-pro": "^3.19.4",
25
- "puppeteer": "^22.3.0",
26
25
  "consola": "^3.2.3",
27
26
  "html-entities": "^2.5.2",
28
27
  "file-type": "^19.0.0",
29
28
  "sharp": "^0.32.5",
30
29
  "yaml": "^2.3.4"
31
30
  },
31
+ "peerDependencies": {
32
+ "puppeteer": "^22.3.0"
33
+ },
32
34
  "exports": {
33
35
  "./package.json": "./package.json",
34
36
  "./ai": {