@ruan-cat/utils 4.19.0 → 4.21.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/README.md +26 -0
- package/dist/index.d.ts +5 -16
- package/dist/node-cjs/index.cjs +18 -2
- package/dist/node-cjs/index.cjs.map +1 -1
- package/dist/node-cjs/index.d.cts +15 -17
- package/dist/node-esm/index.d.ts +88 -1
- package/dist/node-esm/index.js +199 -12
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +19 -15
- package/src/monorepo/index.ts +28 -1
- package/src/node-esm/index.ts +1 -0
- package/src/node-esm/scripts/move-vercel-output-to-root/index.test.ts +151 -0
- package/src/node-esm/scripts/move-vercel-output-to-root/index.ts +286 -0
- package/src/types/pnpm-workspace.yaml.shim.ts +5 -17
package/README.md
CHANGED
|
@@ -14,3 +14,29 @@ dir:
|
|
|
14
14
|
<!-- /automd -->
|
|
15
15
|
|
|
16
16
|
这是阮喵喵开发的工具包,提供了一些工具函数。
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
<!-- automd:pm-install name="@ruan-cat/utils" -->
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
# ✨ Auto-detect
|
|
24
|
+
npx nypm install @ruan-cat/utils
|
|
25
|
+
|
|
26
|
+
# npm
|
|
27
|
+
npm install @ruan-cat/utils
|
|
28
|
+
|
|
29
|
+
# yarn
|
|
30
|
+
yarn add @ruan-cat/utils
|
|
31
|
+
|
|
32
|
+
# pnpm
|
|
33
|
+
pnpm add @ruan-cat/utils
|
|
34
|
+
|
|
35
|
+
# bun
|
|
36
|
+
bun install @ruan-cat/utils
|
|
37
|
+
|
|
38
|
+
# deno
|
|
39
|
+
deno install npm:@ruan-cat/utils
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
<!-- /automd -->
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PnpmWorkspaceYamlSchema } from 'pnpm-workspace-yaml';
|
|
2
|
+
|
|
1
3
|
type Condition = (...args: unknown[]) => boolean;
|
|
2
4
|
/** @deprecated 没必要 */
|
|
3
5
|
type Conditions = Condition[];
|
|
@@ -96,24 +98,11 @@ lastParams?: any): Promise<any>;
|
|
|
96
98
|
/**
|
|
97
99
|
* pnpm-workspace.yaml 文件的类型声明
|
|
98
100
|
* @description
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* 主要是为了让该文件被解析后,能够有一个基础的类型声明
|
|
101
|
+
* 现在是 pnpm-workspace-yaml 提供的 `PnpmWorkspaceYamlSchema` 类型
|
|
102
102
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* 未来应该找到这样的类型声明库,直接复用别人的就好了,不要自己写了。
|
|
103
|
+
* @see https://github.com/antfu/pnpm-workspace-utils/blob/main/packages/pnpm-workspace-yaml/src/index.ts#L4
|
|
106
104
|
*/
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* 包的匹配语法字符串
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ["packages/**", "demos/**", "utils"]
|
|
113
|
-
*/
|
|
114
|
-
packages?: string[];
|
|
115
|
-
catalog?: string[];
|
|
116
|
-
}
|
|
105
|
+
type PnpmWorkspace = PnpmWorkspaceYamlSchema;
|
|
117
106
|
|
|
118
107
|
/**
|
|
119
108
|
* `Prettify` 帮助程序是一种实用程序类型,它采用对象类型并使悬停叠加更具可读性。
|
package/dist/node-cjs/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
defPrintCurrentCommand: () => defPrintCurrentCommand,
|
|
34
34
|
definePromiseTasks: () => definePromiseTasks,
|
|
35
35
|
executePromiseTasks: () => executePromiseTasks,
|
|
36
|
+
findMonorepoRoot: () => findMonorepoRoot,
|
|
36
37
|
generateSimpleAsyncTask: () => generateSimpleAsyncTask,
|
|
37
38
|
generateSpawnSync: () => generateSpawnSync,
|
|
38
39
|
initFlag: () => initFlag,
|
|
@@ -54,8 +55,8 @@ var import_node_child_process = require("child_process");
|
|
|
54
55
|
// src/simple-promise-tools.ts
|
|
55
56
|
function generateSimpleAsyncTask(func) {
|
|
56
57
|
return function(...args) {
|
|
57
|
-
return new Promise((
|
|
58
|
-
|
|
58
|
+
return new Promise((resolve2, reject) => {
|
|
59
|
+
resolve2(func(...args));
|
|
59
60
|
});
|
|
60
61
|
};
|
|
61
62
|
}
|
|
@@ -2787,6 +2788,20 @@ var import_lodash_es2 = require("lodash-es");
|
|
|
2787
2788
|
function pathChange2(path) {
|
|
2788
2789
|
return path.replace(/\\/g, "/");
|
|
2789
2790
|
}
|
|
2791
|
+
function findMonorepoRoot(startDir = process.cwd()) {
|
|
2792
|
+
let currentDir = (0, import_node_path.resolve)(startDir);
|
|
2793
|
+
const fileSystemRoot = (0, import_node_path.parse)(currentDir).root;
|
|
2794
|
+
while (true) {
|
|
2795
|
+
const workspaceConfigPath = (0, import_node_path.join)(currentDir, "pnpm-workspace.yaml");
|
|
2796
|
+
if (fs.existsSync(workspaceConfigPath)) {
|
|
2797
|
+
return currentDir;
|
|
2798
|
+
}
|
|
2799
|
+
if (currentDir === fileSystemRoot) {
|
|
2800
|
+
return null;
|
|
2801
|
+
}
|
|
2802
|
+
currentDir = (0, import_node_path.dirname)(currentDir);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2790
2805
|
function isMonorepoProject() {
|
|
2791
2806
|
const workspaceConfigPath = (0, import_node_path.join)(process.cwd(), "pnpm-workspace.yaml");
|
|
2792
2807
|
if (!fs.existsSync(workspaceConfigPath)) {
|
|
@@ -2821,6 +2836,7 @@ function isMonorepoProject() {
|
|
|
2821
2836
|
defPrintCurrentCommand,
|
|
2822
2837
|
definePromiseTasks,
|
|
2823
2838
|
executePromiseTasks,
|
|
2839
|
+
findMonorepoRoot,
|
|
2824
2840
|
generateSimpleAsyncTask,
|
|
2825
2841
|
generateSpawnSync,
|
|
2826
2842
|
initFlag,
|