node-karin 1.15.4 → 1.15.5

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/dist/index.d.ts CHANGED
@@ -8,7 +8,8 @@ import { Job } from 'node-schedule';
8
8
  import fs$1, { WriteStream } from 'node:fs';
9
9
  import { Readable } from 'node:stream';
10
10
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
11
- import YAML from 'yaml';
11
+ import * as _yaml from 'yaml';
12
+ import { Document, parse, stringify, parseDocument, YAMLSeq, YAMLMap } from 'yaml';
12
13
  import { FSWatcher } from 'chokidar';
13
14
  import { ExecException as ExecException$1, exec as exec$2 } from 'node:child_process';
14
15
  import { Request as Request$1, Router, Response, RequestHandler, Express } from 'express';
@@ -8158,8 +8159,8 @@ type Save = {
8158
8159
  /** YAML 编辑器 */
8159
8160
  declare class YamlEditor {
8160
8161
  filePath: string;
8161
- doc: YAML.Document;
8162
- document: YAML.Document;
8162
+ doc: Document;
8163
+ document: Document;
8163
8164
  constructor(file: string);
8164
8165
  /**
8165
8166
  * 获取指定路径的值
@@ -8312,7 +8313,16 @@ declare const comment: (filePath: string, commentConfig: string | YamlComment) =
8312
8313
  */
8313
8314
  declare const applyComments: (editor: YamlEditor, comments: YamlComment) => void;
8314
8315
  /** YAML 工具 */
8315
- declare const yaml: typeof YAML & {
8316
+ declare const yaml: {
8317
+ parse: typeof parse;
8318
+ stringify: typeof stringify;
8319
+ parseDocument: typeof parseDocument;
8320
+ Document: typeof Document;
8321
+ YAMLSeq: typeof YAMLSeq;
8322
+ YAMLMap: typeof YAMLMap;
8323
+ isMap: <K = unknown, V = unknown>(node: any) => node is YAMLMap<K, V>;
8324
+ isSeq: <T = unknown>(node: any) => node is YAMLSeq<T>;
8325
+ isPair: <K = unknown, V = unknown>(node: any) => node is _yaml.Pair<K, V>;
8316
8326
  /** 读取并解析 YAML 文件 */
8317
8327
  read: ReadFunction;
8318
8328
  /** 保存数据并写入注释 */
package/dist/index.mjs CHANGED
@@ -4,7 +4,8 @@ import require$$2 from 'os';
4
4
  import require$$3 from 'crypto';
5
5
  import { fileURLToPath } from 'url';
6
6
  import fs5, { promises, existsSync as existsSync$1 } from 'node:fs';
7
- import YAML, { isMap, isSeq, isPair } from 'yaml';
7
+ import * as yaml2 from 'yaml';
8
+ import { parseDocument, YAMLSeq, YAMLMap, isMap, isSeq, isPair, parse, stringify, Document } from 'yaml';
8
9
  import { spawn, execSync, exec as exec$2 } from 'node:child_process';
9
10
  import path4, { join } from 'node:path';
10
11
  import chokidar from 'chokidar';
@@ -81,7 +82,7 @@ function requireMain() {
81
82
  const packageJson = require$$4;
82
83
  const version2 = packageJson.version;
83
84
  const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
84
- function parse2(src) {
85
+ function parse5(src) {
85
86
  const obj = {};
86
87
  let lines = src.toString();
87
88
  lines = lines.replace(/\r\n?/mg, "\n");
@@ -324,7 +325,7 @@ function requireMain() {
324
325
  _parseVault: _parseVault2,
325
326
  config: config3,
326
327
  decrypt: decrypt2,
327
- parse: parse2,
328
+ parse: parse5,
328
329
  populate: populate2
329
330
  };
330
331
  main$1.exports.configDotenv = DotenvModule.configDotenv;
@@ -504,7 +505,7 @@ var init_env = __esm({
504
505
  isWorkspace = () => {
505
506
  const workspace = fs5.existsSync(`${process.cwd()}/pnpm-workspace.yaml`);
506
507
  if (!workspace) return false;
507
- const data = YAML.parse(fs5.readFileSync(`${process.cwd()}/pnpm-workspace.yaml`, "utf-8"));
508
+ const data = yaml2.parse(fs5.readFileSync(`${process.cwd()}/pnpm-workspace.yaml`, "utf-8"));
508
509
  return Array.isArray(data.packages) && data.packages.length > 0;
509
510
  };
510
511
  setProcessEnv = (key, value) => {
@@ -624,10 +625,10 @@ var init_require = __esm({
624
625
  if (parser2) return parser2(content);
625
626
  if (type) {
626
627
  if (type === "json") return JSON.parse(content);
627
- if (type === "yaml" || type === "yml") return YAML.parse(content);
628
+ if (type === "yaml" || type === "yml") return yaml2.parse(content);
628
629
  }
629
630
  if (absPath2.endsWith(".json")) return JSON.parse(content);
630
- if (absPath2.endsWith(".yaml") || absPath2.endsWith(".yml")) return YAML.parse(content);
631
+ if (absPath2.endsWith(".yaml") || absPath2.endsWith(".yml")) return yaml2.parse(content);
631
632
  return content;
632
633
  };
633
634
  setInterval(() => {
@@ -1524,7 +1525,7 @@ var init_yaml = __esm({
1524
1525
  document;
1525
1526
  constructor(file2) {
1526
1527
  this.filePath = file2;
1527
- const data = YAML.parseDocument(fs5.existsSync(file2) ? fs5.readFileSync(file2, "utf8") : file2);
1528
+ const data = parseDocument(fs5.existsSync(file2) ? fs5.readFileSync(file2, "utf8") : file2);
1528
1529
  this.doc = data;
1529
1530
  this.document = data;
1530
1531
  }
@@ -1602,9 +1603,9 @@ var init_yaml = __esm({
1602
1603
  const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
1603
1604
  let current = this.document.getIn(_path);
1604
1605
  if (!current) {
1605
- current = new YAML.YAMLSeq();
1606
+ current = new YAMLSeq();
1606
1607
  this.document.setIn(_path, current);
1607
- } else if (!(current instanceof YAML.YAMLSeq)) {
1608
+ } else if (!(current instanceof YAMLSeq)) {
1608
1609
  logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u662F\u6570\u7EC4");
1609
1610
  return false;
1610
1611
  } else {
@@ -1631,7 +1632,7 @@ var init_yaml = __esm({
1631
1632
  logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u5B58\u5728");
1632
1633
  return false;
1633
1634
  }
1634
- if (!(current instanceof YAML.YAMLSeq)) {
1635
+ if (!(current instanceof YAMLSeq)) {
1635
1636
  logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u662F\u6570\u7EC4");
1636
1637
  return false;
1637
1638
  }
@@ -1673,9 +1674,9 @@ var init_yaml = __esm({
1673
1674
  const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
1674
1675
  const current = this.document.getIn(_path);
1675
1676
  if (!current) return false;
1676
- if (current instanceof YAML.YAMLSeq) {
1677
+ if (current instanceof YAMLSeq) {
1677
1678
  return current.items.some((item) => lodash3.isEqual(item.toJSON(), value));
1678
- } else if (current instanceof YAML.YAMLMap) {
1679
+ } else if (current instanceof YAMLMap) {
1679
1680
  return Array.from(current.values()).some((v) => lodash3.isEqual(v.toJSON(), value));
1680
1681
  } else {
1681
1682
  return lodash3.isEqual(current, value);
@@ -1700,8 +1701,8 @@ var init_yaml = __esm({
1700
1701
  */
1701
1702
  pusharr(value) {
1702
1703
  try {
1703
- if (!(this.document.contents instanceof YAML.YAMLSeq)) {
1704
- this.document.contents = new YAML.YAMLSeq();
1704
+ if (!(this.document.contents instanceof YAMLSeq)) {
1705
+ this.document.contents = new YAMLSeq();
1705
1706
  logger.debug("[YamlEditor] \u6839\u8282\u70B9\u5DF2\u8F6C\u6362\u4E3A\u6570\u7EC4");
1706
1707
  }
1707
1708
  this.document.contents.add(value);
@@ -1718,7 +1719,7 @@ var init_yaml = __esm({
1718
1719
  */
1719
1720
  delarr(index4) {
1720
1721
  try {
1721
- if (!(this.document.contents instanceof YAML.YAMLSeq)) {
1722
+ if (!(this.document.contents instanceof YAMLSeq)) {
1722
1723
  throw new Error("[YamlEditor] \u6839\u8282\u70B9\u4E0D\u662F\u6570\u7EC4");
1723
1724
  }
1724
1725
  if (index4 < 0 || index4 >= this.document.contents.items.length) {
@@ -1827,7 +1828,7 @@ var init_yaml = __esm({
1827
1828
  }
1828
1829
  };
1829
1830
  read = (path36) => {
1830
- const data = YAML.parse(fs5.readFileSync(path36, "utf-8"));
1831
+ const data = parse(fs5.readFileSync(path36, "utf-8"));
1831
1832
  read.save = (options) => {
1832
1833
  try {
1833
1834
  save(path36, data, typeof options === "string" ? JSON.parse(options) : options);
@@ -1842,7 +1843,7 @@ var init_yaml = __esm({
1842
1843
  };
1843
1844
  write = (path36, value) => {
1844
1845
  try {
1845
- fs5.writeFileSync(path36, YAML.stringify(value));
1846
+ fs5.writeFileSync(path36, stringify(value));
1846
1847
  return true;
1847
1848
  } catch {
1848
1849
  return false;
@@ -1850,10 +1851,10 @@ var init_yaml = __esm({
1850
1851
  };
1851
1852
  save = (path36, value, options) => {
1852
1853
  if (!options) {
1853
- fs5.writeFileSync(path36, YAML.stringify(value));
1854
+ fs5.writeFileSync(path36, stringify(value));
1854
1855
  return;
1855
1856
  }
1856
- const editor = new YamlEditor(YAML.stringify(value));
1857
+ const editor = new YamlEditor(stringify(value));
1857
1858
  const comment2 = typeof options === "string" ? JSON.parse(fs5.readFileSync(options, "utf8")) : options;
1858
1859
  applyComments(editor, comment2);
1859
1860
  fs5.writeFileSync(path36, editor.document.toString());
@@ -1876,7 +1877,16 @@ var init_yaml = __esm({
1876
1877
  }
1877
1878
  }
1878
1879
  };
1879
- yaml3 = Object.assign(YAML, {
1880
+ yaml3 = {
1881
+ parse: parse,
1882
+ stringify,
1883
+ parseDocument,
1884
+ Document,
1885
+ YAMLSeq,
1886
+ YAMLMap,
1887
+ isMap,
1888
+ isSeq,
1889
+ isPair,
1880
1890
  /** 读取并解析 YAML 文件 */
1881
1891
  read,
1882
1892
  /** 保存数据并写入注释 */
@@ -1885,7 +1895,7 @@ var init_yaml = __esm({
1885
1895
  comment,
1886
1896
  /** 批量添加注释 */
1887
1897
  applyComments
1888
- });
1898
+ };
1889
1899
  }
1890
1900
  });
1891
1901
  var fnStore, lockMethod, unlockMethod, lockProp, lock;
@@ -7907,12 +7917,18 @@ var init_update = __esm({
7907
7917
  }
7908
7918
  };
7909
7919
  getPkgVersion = async (name) => {
7920
+ let pkg2;
7921
+ try {
7922
+ pkg2 = await getPkg();
7923
+ } catch {
7924
+ pkg2 = void 0;
7925
+ }
7926
+ if (pkg2?.name === name) {
7927
+ return pkg2?.version || "";
7928
+ }
7910
7929
  const { stdout, error } = await exec(`npm list ${name} --depth=0`);
7911
7930
  if (stdout) {
7912
7931
  const data = stdout.toString();
7913
- if (data.includes("empty") || data.includes("extraneous")) {
7914
- throw new Error(`\u83B7\u53D6\u5931\u8D25\uFF0C${name} \u672A\u5B89\u88C5`);
7915
- }
7916
7932
  const esc = escapeRegex2(name);
7917
7933
  const reg = new RegExp(`${esc}@([0-9A-Za-z-.+]+)`, "gm");
7918
7934
  const match = reg.exec(data);
@@ -7920,17 +7936,18 @@ var init_update = __esm({
7920
7936
  return match[1].trim();
7921
7937
  }
7922
7938
  }
7939
+ const spec = pkg2?.dependencies?.[name] || pkg2?.devDependencies?.[name] || pkg2?.peerDependencies?.[name];
7940
+ if (spec) {
7941
+ return extractSemver(spec) || spec;
7942
+ }
7923
7943
  if (error) {
7924
7944
  const stack = error?.stack?.toString() || "";
7925
- if (stack.includes("empty") || stack.includes("extraneous")) {
7945
+ if (stack.includes("empty")) {
7926
7946
  throw new Error(`\u83B7\u53D6\u5931\u8D25\uFF0C${name} \u672A\u5B89\u88C5`);
7927
7947
  }
7928
7948
  throw error;
7929
7949
  }
7930
- const pkg2 = await getPkg();
7931
- const spec = pkg2?.dependencies?.[name] || pkg2?.devDependencies?.[name] || pkg2?.peerDependencies?.[name];
7932
- if (!spec) return "";
7933
- return extractSemver(spec) || spec;
7950
+ return "";
7934
7951
  };
7935
7952
  getRemotePkgVersion = async (name, tag = "latest") => {
7936
7953
  const cmd = tag === "latest" ? `npm show ${name} version` : `npm show ${name} dist-tags.${tag}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.15.4",
3
+ "version": "1.15.5",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",