@ruan-cat/utils 4.16.0 → 4.17.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/dist/index.d.ts +14 -1
- package/dist/index.js +2632 -0
- package/dist/index.js.map +1 -1
- package/dist/node-cjs/index.cjs +2633 -0
- package/dist/node-cjs/index.cjs.map +1 -1
- package/dist/node-cjs/index.d.cts +14 -1
- package/dist/node-esm/index.js +57 -49
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +9 -8
- package/src/index.ts +1 -0
- package/src/monorepo.ts +70 -0
package/dist/node-esm/index.js
CHANGED
|
@@ -84,39 +84,12 @@ function generateSpawnSync(spawnSyncSimpleParams) {
|
|
|
84
84
|
import { isPlainObject, isArray } from "lodash-es";
|
|
85
85
|
import consola2 from "consola";
|
|
86
86
|
|
|
87
|
-
// src/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"yarn.lock",
|
|
92
|
-
"pnpm-lock.yaml",
|
|
93
|
-
"package-lock.json",
|
|
94
|
-
// 项目常见文件
|
|
95
|
-
"dist",
|
|
96
|
-
//
|
|
97
|
-
".turbo",
|
|
98
|
-
".vercel",
|
|
99
|
-
// vuepress
|
|
100
|
-
".cache",
|
|
101
|
-
".temp"
|
|
102
|
-
];
|
|
103
|
-
async function clean(targets) {
|
|
104
|
-
const cleanTargets = targets ?? defaultCleanTargets;
|
|
105
|
-
const glob = `**/{${cleanTargets.join()}}`;
|
|
106
|
-
console.log(" \u5F53\u524D\u8FD0\u884C\u5730\u5740 process.cwd() ", process.cwd());
|
|
107
|
-
const doClean = generateSpawnSync({
|
|
108
|
-
command: "rimraf",
|
|
109
|
-
parameters: ["-g", glob]
|
|
110
|
-
});
|
|
111
|
-
await doClean();
|
|
112
|
-
}
|
|
87
|
+
// src/monorepo.ts
|
|
88
|
+
import { join } from "path";
|
|
89
|
+
import * as fs from "fs";
|
|
90
|
+
import { sync } from "glob";
|
|
113
91
|
|
|
114
|
-
//
|
|
115
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
116
|
-
import { consola as consola3 } from "consola";
|
|
117
|
-
import { isUndefined } from "lodash-es";
|
|
118
|
-
|
|
119
|
-
// ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
|
|
92
|
+
// ../../node_modules/.pnpm/js-yaml@4.1.1/node_modules/js-yaml/dist/js-yaml.mjs
|
|
120
93
|
function isNothing(subject) {
|
|
121
94
|
return typeof subject === "undefined" || subject === null;
|
|
122
95
|
}
|
|
@@ -980,6 +953,18 @@ function charFromCodepoint(c) {
|
|
|
980
953
|
(c - 65536 & 1023) + 56320
|
|
981
954
|
);
|
|
982
955
|
}
|
|
956
|
+
function setProperty(object, key, value) {
|
|
957
|
+
if (key === "__proto__") {
|
|
958
|
+
Object.defineProperty(object, key, {
|
|
959
|
+
configurable: true,
|
|
960
|
+
enumerable: true,
|
|
961
|
+
writable: true,
|
|
962
|
+
value
|
|
963
|
+
});
|
|
964
|
+
} else {
|
|
965
|
+
object[key] = value;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
983
968
|
var simpleEscapeCheck = new Array(256);
|
|
984
969
|
var simpleEscapeMap = new Array(256);
|
|
985
970
|
for (i = 0; i < 256; i++) {
|
|
@@ -1099,7 +1084,7 @@ function mergeMappings(state, destination, source, overridableKeys) {
|
|
|
1099
1084
|
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1100
1085
|
key = sourceKeys[index];
|
|
1101
1086
|
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1102
|
-
destination
|
|
1087
|
+
setProperty(destination, key, source[key]);
|
|
1103
1088
|
overridableKeys[key] = true;
|
|
1104
1089
|
}
|
|
1105
1090
|
}
|
|
@@ -1139,16 +1124,7 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu
|
|
|
1139
1124
|
state.position = startPos || state.position;
|
|
1140
1125
|
throwError(state, "duplicated mapping key");
|
|
1141
1126
|
}
|
|
1142
|
-
|
|
1143
|
-
Object.defineProperty(_result, keyNode, {
|
|
1144
|
-
configurable: true,
|
|
1145
|
-
enumerable: true,
|
|
1146
|
-
writable: true,
|
|
1147
|
-
value: valueNode
|
|
1148
|
-
});
|
|
1149
|
-
} else {
|
|
1150
|
-
_result[keyNode] = valueNode;
|
|
1151
|
-
}
|
|
1127
|
+
setProperty(_result, keyNode, valueNode);
|
|
1152
1128
|
delete overridableKeys[keyNode];
|
|
1153
1129
|
}
|
|
1154
1130
|
return _result;
|
|
@@ -2736,24 +2712,56 @@ var jsYaml = {
|
|
|
2736
2712
|
safeLoadAll,
|
|
2737
2713
|
safeDump
|
|
2738
2714
|
};
|
|
2739
|
-
|
|
2715
|
+
|
|
2716
|
+
// src/monorepo.ts
|
|
2717
|
+
import { isUndefined } from "lodash-es";
|
|
2718
|
+
|
|
2719
|
+
// src/node-esm/scripts/clean.ts
|
|
2720
|
+
var defaultCleanTargets = [
|
|
2721
|
+
// node常见文件
|
|
2722
|
+
"node_modules",
|
|
2723
|
+
"yarn.lock",
|
|
2724
|
+
"pnpm-lock.yaml",
|
|
2725
|
+
"package-lock.json",
|
|
2726
|
+
// 项目常见文件
|
|
2727
|
+
"dist",
|
|
2728
|
+
//
|
|
2729
|
+
".turbo",
|
|
2730
|
+
".vercel",
|
|
2731
|
+
// vuepress
|
|
2732
|
+
".cache",
|
|
2733
|
+
".temp"
|
|
2734
|
+
];
|
|
2735
|
+
async function clean(targets) {
|
|
2736
|
+
const cleanTargets = targets ?? defaultCleanTargets;
|
|
2737
|
+
const glob = `**/{${cleanTargets.join()}}`;
|
|
2738
|
+
console.log(" \u5F53\u524D\u8FD0\u884C\u5730\u5740 process.cwd() ", process.cwd());
|
|
2739
|
+
const doClean = generateSpawnSync({
|
|
2740
|
+
command: "rimraf",
|
|
2741
|
+
parameters: ["-g", glob]
|
|
2742
|
+
});
|
|
2743
|
+
await doClean();
|
|
2744
|
+
}
|
|
2740
2745
|
|
|
2741
2746
|
// src/node-esm/yaml-to-md.ts
|
|
2747
|
+
import { readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
2748
|
+
import { consola as consola3 } from "consola";
|
|
2749
|
+
import { isUndefined as isUndefined2 } from "lodash-es";
|
|
2742
2750
|
function writeYaml2md(params) {
|
|
2743
2751
|
consola3.info(` \u5F53\u524D\u8FD0\u884C\u7684\u5730\u5740\u4E3A\uFF1A ${process.cwd()} `);
|
|
2744
2752
|
const { mdPath, data } = params;
|
|
2745
|
-
if (
|
|
2753
|
+
if (isUndefined2(mdPath)) {
|
|
2746
2754
|
consola3.error(" \u8BF7\u63D0\u4F9Bmd\u6587\u4EF6\u7684\u5730\u5740 ");
|
|
2747
2755
|
process.exit(1);
|
|
2748
2756
|
}
|
|
2749
2757
|
try {
|
|
2750
|
-
|
|
2758
|
+
readFileSync2(mdPath, "utf-8");
|
|
2751
2759
|
} catch (error) {
|
|
2752
2760
|
consola3.error(` \u6587\u4EF6 ${mdPath} \u4E0D\u5B58\u5728 `);
|
|
2753
2761
|
process.exit(1);
|
|
2754
2762
|
}
|
|
2755
|
-
const mdContent =
|
|
2756
|
-
const yamlContent =
|
|
2763
|
+
const mdContent = readFileSync2(mdPath, "utf-8");
|
|
2764
|
+
const yamlContent = jsYaml.dump(data);
|
|
2757
2765
|
const newContent = `---
|
|
2758
2766
|
${yamlContent}---
|
|
2759
2767
|
|
|
@@ -2770,6 +2778,6 @@ export {
|
|
|
2770
2778
|
/*! Bundled license information:
|
|
2771
2779
|
|
|
2772
2780
|
js-yaml/dist/js-yaml.mjs:
|
|
2773
|
-
(*! js-yaml 4.1.
|
|
2781
|
+
(*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
2774
2782
|
*/
|
|
2775
2783
|
//# sourceMappingURL=index.js.map
|