@ruan-cat/utils 4.10.0 → 4.11.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 +15 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/node-cjs/index.cjs +9 -0
- package/dist/node-cjs/index.cjs.map +1 -1
- package/dist/node-cjs/index.d.cts +15 -1
- package/dist/node-esm/index.js +12 -11
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +6 -6
- package/src/.vitepress/config.mts +2 -2
- package/src/print.ts +27 -0
- package/tsconfig.json +6 -12
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,20 @@ declare function isConditionsSome(conditions: Condition[]): boolean;
|
|
|
26
26
|
* 主要用于测试框架打印完整的内容
|
|
27
27
|
*/
|
|
28
28
|
declare function printFormat(params: any): any;
|
|
29
|
+
interface PrintListParams {
|
|
30
|
+
/** 标题,可以是字符串或根据列表生成标题的函数 */
|
|
31
|
+
title: ((stringList: string[]) => string) | string;
|
|
32
|
+
/** 要显示的字符串列表 */
|
|
33
|
+
stringList: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 输出字符串列表
|
|
37
|
+
* @description
|
|
38
|
+
* 1. 生成编号列表文本
|
|
39
|
+
* 2. 生成标题文本
|
|
40
|
+
* 3. 输出标题和列表
|
|
41
|
+
*/
|
|
42
|
+
declare function printList({ title, stringList }: PrintListParams): void;
|
|
29
43
|
|
|
30
44
|
/** 创建简单的异步任务 */
|
|
31
45
|
declare function generateSimpleAsyncTask<T extends (...args: any) => any>(func: T): (...args: any) => Promise<ReturnType<T>>;
|
|
@@ -116,4 +130,4 @@ type Prettify<T> = {
|
|
|
116
130
|
*/
|
|
117
131
|
type ToNumberLike<T extends number> = T | `${T}`;
|
|
118
132
|
|
|
119
|
-
export { type BaseTask, type Condition, type Conditions, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, type SimpleAsyncTask, type SingleTasks, type Task, type TaskType, type TasksConfig, type ToNumberLike, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, initFlag, isConditionsEvery, isConditionsSome, printFormat, runPromiseByConcurrency, runPromiseByQueue, taskTypes };
|
|
133
|
+
export { type BaseTask, type Condition, type Conditions, type ParallelTasks, type PnpmWorkspace, type Prettify, type PrintListParams, type PromiseTasksConfig, type QueueTasks, type SimpleAsyncTask, type SingleTasks, type Task, type TaskType, type TasksConfig, type ToNumberLike, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, initFlag, isConditionsEvery, isConditionsSome, printFormat, printList, runPromiseByConcurrency, runPromiseByQueue, taskTypes };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ function isConditionsSome(conditions) {
|
|
|
8
8
|
|
|
9
9
|
// src/print.ts
|
|
10
10
|
import { isPlainObject, isArray } from "lodash-es";
|
|
11
|
+
import consola from "consola";
|
|
11
12
|
function printFormat(params) {
|
|
12
13
|
const boolRes = isConditionsSome([
|
|
13
14
|
// 是不是纯对象?
|
|
@@ -18,6 +19,12 @@ function printFormat(params) {
|
|
|
18
19
|
const res = boolRes ? JSON.stringify(params, null, 2) : params;
|
|
19
20
|
return res;
|
|
20
21
|
}
|
|
22
|
+
function printList({ title, stringList }) {
|
|
23
|
+
const listText = stringList.map((item, index) => `${index + 1}. ${item}`).join("\n");
|
|
24
|
+
const titleText = typeof title === "function" ? title(stringList) : title;
|
|
25
|
+
consola.info(titleText);
|
|
26
|
+
consola.box(listText);
|
|
27
|
+
}
|
|
21
28
|
|
|
22
29
|
// src/define-promise-tasks.ts
|
|
23
30
|
var taskTypes = ["single", "parallel", "queue"];
|
|
@@ -94,6 +101,7 @@ export {
|
|
|
94
101
|
isConditionsEvery,
|
|
95
102
|
isConditionsSome,
|
|
96
103
|
printFormat,
|
|
104
|
+
printList,
|
|
97
105
|
runPromiseByConcurrency,
|
|
98
106
|
runPromiseByQueue,
|
|
99
107
|
taskTypes
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/conditions.ts","../src/print.ts","../src/define-promise-tasks.ts","../src/simple-promise-tools.ts"],"sourcesContent":["export type Condition = (...args: unknown[]) => boolean;\n\n/** @deprecated 没必要 */\nexport type Conditions = Condition[];\n\n/**\n * 是否每一个条件函数都满足?\n * @description\n * ### 设计理由\n * 旨在于封装这样的代码段\n * ```js\n * const conditions = [\n * \t() => !isEqual(nAssetRecord, oAssetRecord),\n * \t() => !isEqual(nAssetRecord, defPropsAssets),\n * \t() => isEdit.value || isInfo.value,\n * ];\n * conditions.every((condition) => condition())\n * ```\n */\nexport function isConditionsEvery(conditions: Condition[]) {\n\treturn conditions.every((condition) => condition());\n}\n\nexport function isConditionsSome(conditions: Condition[]) {\n\treturn conditions.some((condition) => condition());\n}\n","import { isPlainObject, isArray } from \"lodash-es\";\nimport { isConditionsSome } from \"./conditions\";\n\n/**\n * 一个简单的格式化函数\n * @description\n * 用于将复杂对象变成纯文本 打印出来\n *\n * 主要用于测试框架打印完整的内容\n */\nexport function printFormat(params: any) {\n\tconst boolRes = isConditionsSome([\n\t\t// 是不是纯对象?\n\t\t() => isPlainObject(params),\n\t\t// 或者是不是单纯的数组?\n\t\t() => isArray(params),\n\t]);\n\n\t// 如果是纯对象或者数组,则使用 JSON.stringify 格式化输出 否则原样返回\n\tconst res = boolRes ? JSON.stringify(params, null, 2) : params;\n\n\treturn res;\n}\n","import { type SimpleAsyncTask } from \"./simple-promise-tools\";\n\nexport const taskTypes = <const>[\"single\", \"parallel\", \"queue\"];\n\nexport type TaskType = (typeof taskTypes)[number];\n\nexport interface BaseTask {\n\t/** 任务类型 */\n\ttype: TaskType;\n}\n\nexport type Task = SimpleAsyncTask | TasksConfig;\n\nexport interface SingleTasks extends BaseTask {\n\ttype: \"single\";\n\ttasks: Task;\n}\n\nexport interface ParallelTasks extends BaseTask {\n\ttype: \"parallel\";\n\ttasks: Task[];\n}\n\nexport interface QueueTasks extends BaseTask {\n\ttype: \"queue\";\n\ttasks: Task[];\n}\n\nexport type TasksConfig = SingleTasks | ParallelTasks | QueueTasks;\n\nexport type PromiseTasksConfig = TasksConfig;\n\nfunction isSingleTasks(config: TasksConfig): config is SingleTasks {\n\treturn config.type === \"single\";\n}\n\nfunction isParallelTasks(config: TasksConfig): config is ParallelTasks {\n\treturn config.type === \"parallel\";\n}\n\nfunction isQueueTasks(config: TasksConfig): config is QueueTasks {\n\treturn config.type === \"queue\";\n}\n\nfunction isSimpleAsyncTask(config: Task): config is SimpleAsyncTask {\n\treturn typeof config === \"function\";\n}\n\nfunction isTasksConfig(config: Task): config is TasksConfig {\n\treturn typeof config === \"object\";\n}\n\n/**\n * 定义异步任务对象\n * @description\n * 这个对象是一揽子异步任务的配置\n */\nexport function definePromiseTasks(config: TasksConfig) {\n\treturn config;\n}\n\n/**\n * @private 一个工具函数 用于生成异步函数数组\n * @deprecated 在处理串行任务时 疑似有故障\n */\nfunction getPromises(tasks: Task[]): ((...args: any) => Promise<any>)[] {\n\treturn tasks.map((task) => {\n\t\treturn async function (...args: any) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\treturn await task(...args);\n\t\t\t} else {\n\t\t\t\treturn await executePromiseTasks(task);\n\t\t\t}\n\t\t};\n\t});\n}\n\n/**\n * 执行异步函数对象\n */\nexport async function executePromiseTasks(\n\tconfig: TasksConfig,\n\t/**\n\t * 上一次递归执行时提供的参数\n\t * @description\n\t * 考虑到递归函数 这里提供了一个参数 用于传递上一次递归执行的结果\n\t */\n\tlastParams: any = null,\n): Promise<any> {\n\tif (isSingleTasks(config)) {\n\t\tif (isSimpleAsyncTask(config.tasks)) {\n\t\t\t// 实际执行的 tasks 往往是无参函数 这里为了保险,故主动传递参数\n\t\t\treturn await config.tasks(lastParams);\n\t\t}\n\n\t\treturn await executePromiseTasks(config.tasks, lastParams);\n\t}\n\n\tif (isParallelTasks(config)) {\n\t\treturn await Promise.all(\n\t\t\tconfig.tasks.map((task) => {\n\t\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t\t// console.log(` 并行任务遇到单独的异步函数 `);\n\t\t\t\t\treturn task(lastParams);\n\t\t\t\t}\n\n\t\t\t\t// console.log(` 并行任务遇到嵌套结构 `);\n\t\t\t\treturn executePromiseTasks(task, lastParams);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (isQueueTasks(config)) {\n\t\tlet res: Awaited<any>;\n\t\tfor await (const task of config.tasks) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t// console.log(` 串行任务遇到单独的异步函数 `);\n\n\t\t\t\tres = await task(lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 单独 res `, res);\n\t\t\t} else {\n\t\t\t\tres = await executePromiseTasks(task, lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 配置 res `, res);\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n}\n","// import { uniqueId } from \"lodash-es\";\n// const getCounter = () => uniqueId();\n\n/** 创建简单的异步任务 */\nexport function generateSimpleAsyncTask<T extends (...args: any) => any>(func: T) {\n\t// const taskId = getCounter();\n\n\treturn function (...args: any) {\n\t\t// consola.info(` 这是第 ${taskId} 个异步任务 `);\n\t\t// consola.start(\" 这里是新创建的异步函数 检查参数: \", ...args);\n\n\t\treturn new Promise<ReturnType<T>>((resolve, reject) => {\n\t\t\t// consola.start(\" 内部promise 检查参数: \", ...args);\n\t\t\tresolve(func(...args));\n\t\t});\n\t};\n}\n\nexport type SimpleAsyncTask = ReturnType<typeof generateSimpleAsyncTask>;\n\nexport const initFlag = <const>\"initFlag\";\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @see https://github.com/ascoders/weekly/blob/master/前沿技术/77.精读《用%20Reduce%20实现%20Promise%20串行执行》.md\n * @version 1\n */\nasync function runPromiseByQueueV1<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tpromises.reduce(\n\t\tasync function (previousPromise, nextPromise, currentIndex) {\n\t\t\tconst response = await previousPromise;\n\t\t\t// consola.log(` reduce串行函数 currentIndex= ${currentIndex} res =`, response);\n\t\t\treturn await nextPromise(response);\n\t\t},\n\t\tPromise.resolve(initFlag) as Promise<any>,\n\t);\n}\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @version 2\n */\nexport async function runPromiseByQueue<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tlet response: typeof initFlag | Awaited<T> = initFlag;\n\tfor await (const promise of promises) {\n\t\tresponse = await promise(response);\n\t}\n}\n\n/**\n * 以并行的形式 并发运行异步函数\n */\nexport async function runPromiseByConcurrency<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tawait Promise.all(promises.map((promise) => promise()));\n}\n"],"mappings":";AAmBO,SAAS,kBAAkB,YAAyB;AAC1D,SAAO,WAAW,MAAM,CAAC,cAAc,UAAU,CAAC;AACnD;AAEO,SAAS,iBAAiB,YAAyB;AACzD,SAAO,WAAW,KAAK,CAAC,cAAc,UAAU,CAAC;AAClD;;;ACzBA,SAAS,eAAe,eAAe;
|
|
1
|
+
{"version":3,"sources":["../src/conditions.ts","../src/print.ts","../src/define-promise-tasks.ts","../src/simple-promise-tools.ts"],"sourcesContent":["export type Condition = (...args: unknown[]) => boolean;\n\n/** @deprecated 没必要 */\nexport type Conditions = Condition[];\n\n/**\n * 是否每一个条件函数都满足?\n * @description\n * ### 设计理由\n * 旨在于封装这样的代码段\n * ```js\n * const conditions = [\n * \t() => !isEqual(nAssetRecord, oAssetRecord),\n * \t() => !isEqual(nAssetRecord, defPropsAssets),\n * \t() => isEdit.value || isInfo.value,\n * ];\n * conditions.every((condition) => condition())\n * ```\n */\nexport function isConditionsEvery(conditions: Condition[]) {\n\treturn conditions.every((condition) => condition());\n}\n\nexport function isConditionsSome(conditions: Condition[]) {\n\treturn conditions.some((condition) => condition());\n}\n","import { isPlainObject, isArray } from \"lodash-es\";\nimport { isConditionsSome } from \"./conditions\";\nimport consola from \"consola\";\n\n/**\n * 一个简单的格式化函数\n * @description\n * 用于将复杂对象变成纯文本 打印出来\n *\n * 主要用于测试框架打印完整的内容\n */\nexport function printFormat(params: any) {\n\tconst boolRes = isConditionsSome([\n\t\t// 是不是纯对象?\n\t\t() => isPlainObject(params),\n\t\t// 或者是不是单纯的数组?\n\t\t() => isArray(params),\n\t]);\n\n\t// 如果是纯对象或者数组,则使用 JSON.stringify 格式化输出 否则原样返回\n\tconst res = boolRes ? JSON.stringify(params, null, 2) : params;\n\n\treturn res;\n}\n\nexport interface PrintListParams {\n\t/** 标题,可以是字符串或根据列表生成标题的函数 */\n\ttitle: ((stringList: string[]) => string) | string;\n\t/** 要显示的字符串列表 */\n\tstringList: string[];\n}\n\n/**\n * 输出字符串列表\n * @description\n * 1. 生成编号列表文本\n * 2. 生成标题文本\n * 3. 输出标题和列表\n */\nexport function printList({ title, stringList }: PrintListParams): void {\n\t// 生成编号列表文本\n\tconst listText = stringList.map((item, index) => `${index + 1}. ${item}`).join(\"\\n\");\n\n\t// 生成标题文本\n\tconst titleText = typeof title === \"function\" ? title(stringList) : title;\n\n\t// 输出标题和列表\n\tconsola.info(titleText);\n\tconsola.box(listText);\n}\n","import { type SimpleAsyncTask } from \"./simple-promise-tools\";\n\nexport const taskTypes = <const>[\"single\", \"parallel\", \"queue\"];\n\nexport type TaskType = (typeof taskTypes)[number];\n\nexport interface BaseTask {\n\t/** 任务类型 */\n\ttype: TaskType;\n}\n\nexport type Task = SimpleAsyncTask | TasksConfig;\n\nexport interface SingleTasks extends BaseTask {\n\ttype: \"single\";\n\ttasks: Task;\n}\n\nexport interface ParallelTasks extends BaseTask {\n\ttype: \"parallel\";\n\ttasks: Task[];\n}\n\nexport interface QueueTasks extends BaseTask {\n\ttype: \"queue\";\n\ttasks: Task[];\n}\n\nexport type TasksConfig = SingleTasks | ParallelTasks | QueueTasks;\n\nexport type PromiseTasksConfig = TasksConfig;\n\nfunction isSingleTasks(config: TasksConfig): config is SingleTasks {\n\treturn config.type === \"single\";\n}\n\nfunction isParallelTasks(config: TasksConfig): config is ParallelTasks {\n\treturn config.type === \"parallel\";\n}\n\nfunction isQueueTasks(config: TasksConfig): config is QueueTasks {\n\treturn config.type === \"queue\";\n}\n\nfunction isSimpleAsyncTask(config: Task): config is SimpleAsyncTask {\n\treturn typeof config === \"function\";\n}\n\nfunction isTasksConfig(config: Task): config is TasksConfig {\n\treturn typeof config === \"object\";\n}\n\n/**\n * 定义异步任务对象\n * @description\n * 这个对象是一揽子异步任务的配置\n */\nexport function definePromiseTasks(config: TasksConfig) {\n\treturn config;\n}\n\n/**\n * @private 一个工具函数 用于生成异步函数数组\n * @deprecated 在处理串行任务时 疑似有故障\n */\nfunction getPromises(tasks: Task[]): ((...args: any) => Promise<any>)[] {\n\treturn tasks.map((task) => {\n\t\treturn async function (...args: any) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\treturn await task(...args);\n\t\t\t} else {\n\t\t\t\treturn await executePromiseTasks(task);\n\t\t\t}\n\t\t};\n\t});\n}\n\n/**\n * 执行异步函数对象\n */\nexport async function executePromiseTasks(\n\tconfig: TasksConfig,\n\t/**\n\t * 上一次递归执行时提供的参数\n\t * @description\n\t * 考虑到递归函数 这里提供了一个参数 用于传递上一次递归执行的结果\n\t */\n\tlastParams: any = null,\n): Promise<any> {\n\tif (isSingleTasks(config)) {\n\t\tif (isSimpleAsyncTask(config.tasks)) {\n\t\t\t// 实际执行的 tasks 往往是无参函数 这里为了保险,故主动传递参数\n\t\t\treturn await config.tasks(lastParams);\n\t\t}\n\n\t\treturn await executePromiseTasks(config.tasks, lastParams);\n\t}\n\n\tif (isParallelTasks(config)) {\n\t\treturn await Promise.all(\n\t\t\tconfig.tasks.map((task) => {\n\t\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t\t// console.log(` 并行任务遇到单独的异步函数 `);\n\t\t\t\t\treturn task(lastParams);\n\t\t\t\t}\n\n\t\t\t\t// console.log(` 并行任务遇到嵌套结构 `);\n\t\t\t\treturn executePromiseTasks(task, lastParams);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (isQueueTasks(config)) {\n\t\tlet res: Awaited<any>;\n\t\tfor await (const task of config.tasks) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t// console.log(` 串行任务遇到单独的异步函数 `);\n\n\t\t\t\tres = await task(lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 单独 res `, res);\n\t\t\t} else {\n\t\t\t\tres = await executePromiseTasks(task, lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 配置 res `, res);\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n}\n","// import { uniqueId } from \"lodash-es\";\n// const getCounter = () => uniqueId();\n\n/** 创建简单的异步任务 */\nexport function generateSimpleAsyncTask<T extends (...args: any) => any>(func: T) {\n\t// const taskId = getCounter();\n\n\treturn function (...args: any) {\n\t\t// consola.info(` 这是第 ${taskId} 个异步任务 `);\n\t\t// consola.start(\" 这里是新创建的异步函数 检查参数: \", ...args);\n\n\t\treturn new Promise<ReturnType<T>>((resolve, reject) => {\n\t\t\t// consola.start(\" 内部promise 检查参数: \", ...args);\n\t\t\tresolve(func(...args));\n\t\t});\n\t};\n}\n\nexport type SimpleAsyncTask = ReturnType<typeof generateSimpleAsyncTask>;\n\nexport const initFlag = <const>\"initFlag\";\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @see https://github.com/ascoders/weekly/blob/master/前沿技术/77.精读《用%20Reduce%20实现%20Promise%20串行执行》.md\n * @version 1\n */\nasync function runPromiseByQueueV1<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tpromises.reduce(\n\t\tasync function (previousPromise, nextPromise, currentIndex) {\n\t\t\tconst response = await previousPromise;\n\t\t\t// consola.log(` reduce串行函数 currentIndex= ${currentIndex} res =`, response);\n\t\t\treturn await nextPromise(response);\n\t\t},\n\t\tPromise.resolve(initFlag) as Promise<any>,\n\t);\n}\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @version 2\n */\nexport async function runPromiseByQueue<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tlet response: typeof initFlag | Awaited<T> = initFlag;\n\tfor await (const promise of promises) {\n\t\tresponse = await promise(response);\n\t}\n}\n\n/**\n * 以并行的形式 并发运行异步函数\n */\nexport async function runPromiseByConcurrency<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tawait Promise.all(promises.map((promise) => promise()));\n}\n"],"mappings":";AAmBO,SAAS,kBAAkB,YAAyB;AAC1D,SAAO,WAAW,MAAM,CAAC,cAAc,UAAU,CAAC;AACnD;AAEO,SAAS,iBAAiB,YAAyB;AACzD,SAAO,WAAW,KAAK,CAAC,cAAc,UAAU,CAAC;AAClD;;;ACzBA,SAAS,eAAe,eAAe;AAEvC,OAAO,aAAa;AASb,SAAS,YAAY,QAAa;AACxC,QAAM,UAAU,iBAAiB;AAAA;AAAA,IAEhC,MAAM,cAAc,MAAM;AAAA;AAAA,IAE1B,MAAM,QAAQ,MAAM;AAAA,EACrB,CAAC;AAGD,QAAM,MAAM,UAAU,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI;AAExD,SAAO;AACR;AAgBO,SAAS,UAAU,EAAE,OAAO,WAAW,GAA0B;AAEvE,QAAM,WAAW,WAAW,IAAI,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,IAAI;AAGnF,QAAM,YAAY,OAAO,UAAU,aAAa,MAAM,UAAU,IAAI;AAGpE,UAAQ,KAAK,SAAS;AACtB,UAAQ,IAAI,QAAQ;AACrB;;;AC/CO,IAAM,YAAmB,CAAC,UAAU,YAAY,OAAO;AA8B9D,SAAS,cAAc,QAA4C;AAClE,SAAO,OAAO,SAAS;AACxB;AAEA,SAAS,gBAAgB,QAA8C;AACtE,SAAO,OAAO,SAAS;AACxB;AAEA,SAAS,aAAa,QAA2C;AAChE,SAAO,OAAO,SAAS;AACxB;AAEA,SAAS,kBAAk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CAAC;AACvD;","names":[]}
|
package/dist/node-cjs/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
isConditionsSome: () => isConditionsSome,
|
|
41
41
|
pathChange: () => pathChange,
|
|
42
42
|
printFormat: () => printFormat,
|
|
43
|
+
printList: () => printList,
|
|
43
44
|
runPromiseByConcurrency: () => runPromiseByConcurrency,
|
|
44
45
|
runPromiseByQueue: () => runPromiseByQueue,
|
|
45
46
|
taskTypes: () => taskTypes
|
|
@@ -122,6 +123,7 @@ function isConditionsSome(conditions) {
|
|
|
122
123
|
|
|
123
124
|
// src/print.ts
|
|
124
125
|
var import_lodash_es = require("lodash-es");
|
|
126
|
+
var import_consola2 = __toESM(require("consola"), 1);
|
|
125
127
|
function printFormat(params) {
|
|
126
128
|
const boolRes = isConditionsSome([
|
|
127
129
|
// 是不是纯对象?
|
|
@@ -132,6 +134,12 @@ function printFormat(params) {
|
|
|
132
134
|
const res = boolRes ? JSON.stringify(params, null, 2) : params;
|
|
133
135
|
return res;
|
|
134
136
|
}
|
|
137
|
+
function printList({ title, stringList }) {
|
|
138
|
+
const listText = stringList.map((item, index) => `${index + 1}. ${item}`).join("\n");
|
|
139
|
+
const titleText = typeof title === "function" ? title(stringList) : title;
|
|
140
|
+
import_consola2.default.info(titleText);
|
|
141
|
+
import_consola2.default.box(listText);
|
|
142
|
+
}
|
|
135
143
|
|
|
136
144
|
// src/define-promise-tasks.ts
|
|
137
145
|
var taskTypes = ["single", "parallel", "queue"];
|
|
@@ -193,6 +201,7 @@ async function executePromiseTasks(config, lastParams = null) {
|
|
|
193
201
|
isConditionsSome,
|
|
194
202
|
pathChange,
|
|
195
203
|
printFormat,
|
|
204
|
+
printList,
|
|
196
205
|
runPromiseByConcurrency,
|
|
197
206
|
runPromiseByQueue,
|
|
198
207
|
taskTypes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node-cjs/index.ts","../../src/node-cjs/tools.ts","../../src/simple-promise-tools.ts","../../src/conditions.ts","../../src/print.ts","../../src/define-promise-tasks.ts"],"sourcesContent":["export * from \"./tools\";\n\n// 将绝大多数的工具函数 以cjs的方式导出\nexport * from \"../index\";\n","/**\n * 一些node环境下的工具函数\n */\n\nimport { normalize } from \"node:path\";\nimport { spawnSync, type SpawnOptions } from \"node:child_process\";\n\nimport { generateSimpleAsyncTask } from \"../simple-promise-tools\";\nimport consola from \"consola\";\n// import { normalizePath } from \"vite\";\n\n/**\n * 路径转换工具\n */\nexport function pathChange(path: string) {\n\treturn path.replace(/\\\\/g, \"/\");\n\t// FIXME: 无法有效地实现解析路径 测试用例不通过\n\t// return normalize(path);\n\t// FIXME: tsup打包时,无法处理好vite的依赖 会导致打包失败 不知道怎么单独使用并打包该函数\n\t// return normalizePath(path);\n}\n\nexport interface SpawnSyncSimpleParams {\n\tcommand: string;\n\tparameters: string[];\n\t/**\n\t * 是否流式输出内容\n\t * @description 默认输出的命令数据全部以流式的方式输出\n\t * @default true\n\t */\n\tisFlow?: boolean;\n\n\t/**\n\t * 是否显示命令?\n\t * @description\n\t * 是否打印目前正在执行的命令?\n\t * @default true\n\t */\n\tisShowCommand?: boolean;\n\tspawnOptions?: SpawnOptions;\n\n\t/** 打印当前运行的命令 */\n\tprintCurrentCommand?: (params: Pick<SpawnSyncSimpleParams, \"command\" | \"parameters\">) => void;\n}\n\n/**\n * 默认的打印当前运行命令 函数\n */\nexport const defPrintCurrentCommand: SpawnSyncSimpleParams[\"printCurrentCommand\"] = function (params) {\n\tconst { command, parameters } = params;\n\tconsola.info(` 当前运行的命令为: ${command} ${parameters.join(\" \")} \\n`);\n};\n\n/**\n * 生成简单的执行命令函数\n * @description\n * 对 spawnSync 做简单的包装\n *\n * 之前封装的是 execa 函数\n * @version 2\n */\nexport function generateSpawnSync(spawnSyncSimpleParams: SpawnSyncSimpleParams) {\n\tconst {\n\t\tcommand,\n\t\tparameters,\n\t\tisFlow = true,\n\t\tisShowCommand = true,\n\t\tspawnOptions = {},\n\t\tprintCurrentCommand = defPrintCurrentCommand,\n\t} = spawnSyncSimpleParams;\n\n\tif (isShowCommand) {\n\t\tprintCurrentCommand?.({ command, parameters });\n\t}\n\n\treturn generateSimpleAsyncTask(() => {\n\t\tconst result = spawnSync(command, parameters, {\n\t\t\t/**\n\t\t\t * 是否流式输出?\n\t\t\t * 是流式输出就是继承父进程的流式输出\n\t\t\t * 否则就使用默认值\n\t\t\t * @see https://nodejs.org/api/child_process.html#optionsstdio\n\t\t\t */\n\t\t\tstdio: isFlow ? \"inherit\" : \"pipe\",\n\t\t\tshell: true,\n\t\t\t...spawnOptions,\n\t\t});\n\n\t\t// 如果不是流式输出 就直接返回返回值即可\n\t\tif (!isFlow) {\n\t\t\treturn result;\n\t\t}\n\n\t\tif (result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\n\t\treturn result;\n\t});\n}\n","// import { uniqueId } from \"lodash-es\";\n// const getCounter = () => uniqueId();\n\n/** 创建简单的异步任务 */\nexport function generateSimpleAsyncTask<T extends (...args: any) => any>(func: T) {\n\t// const taskId = getCounter();\n\n\treturn function (...args: any) {\n\t\t// consola.info(` 这是第 ${taskId} 个异步任务 `);\n\t\t// consola.start(\" 这里是新创建的异步函数 检查参数: \", ...args);\n\n\t\treturn new Promise<ReturnType<T>>((resolve, reject) => {\n\t\t\t// consola.start(\" 内部promise 检查参数: \", ...args);\n\t\t\tresolve(func(...args));\n\t\t});\n\t};\n}\n\nexport type SimpleAsyncTask = ReturnType<typeof generateSimpleAsyncTask>;\n\nexport const initFlag = <const>\"initFlag\";\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @see https://github.com/ascoders/weekly/blob/master/前沿技术/77.精读《用%20Reduce%20实现%20Promise%20串行执行》.md\n * @version 1\n */\nasync function runPromiseByQueueV1<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tpromises.reduce(\n\t\tasync function (previousPromise, nextPromise, currentIndex) {\n\t\t\tconst response = await previousPromise;\n\t\t\t// consola.log(` reduce串行函数 currentIndex= ${currentIndex} res =`, response);\n\t\t\treturn await nextPromise(response);\n\t\t},\n\t\tPromise.resolve(initFlag) as Promise<any>,\n\t);\n}\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @version 2\n */\nexport async function runPromiseByQueue<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tlet response: typeof initFlag | Awaited<T> = initFlag;\n\tfor await (const promise of promises) {\n\t\tresponse = await promise(response);\n\t}\n}\n\n/**\n * 以并行的形式 并发运行异步函数\n */\nexport async function runPromiseByConcurrency<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tawait Promise.all(promises.map((promise) => promise()));\n}\n","export type Condition = (...args: unknown[]) => boolean;\n\n/** @deprecated 没必要 */\nexport type Conditions = Condition[];\n\n/**\n * 是否每一个条件函数都满足?\n * @description\n * ### 设计理由\n * 旨在于封装这样的代码段\n * ```js\n * const conditions = [\n * \t() => !isEqual(nAssetRecord, oAssetRecord),\n * \t() => !isEqual(nAssetRecord, defPropsAssets),\n * \t() => isEdit.value || isInfo.value,\n * ];\n * conditions.every((condition) => condition())\n * ```\n */\nexport function isConditionsEvery(conditions: Condition[]) {\n\treturn conditions.every((condition) => condition());\n}\n\nexport function isConditionsSome(conditions: Condition[]) {\n\treturn conditions.some((condition) => condition());\n}\n","import { isPlainObject, isArray } from \"lodash-es\";\nimport { isConditionsSome } from \"./conditions\";\n\n/**\n * 一个简单的格式化函数\n * @description\n * 用于将复杂对象变成纯文本 打印出来\n *\n * 主要用于测试框架打印完整的内容\n */\nexport function printFormat(params: any) {\n\tconst boolRes = isConditionsSome([\n\t\t// 是不是纯对象?\n\t\t() => isPlainObject(params),\n\t\t// 或者是不是单纯的数组?\n\t\t() => isArray(params),\n\t]);\n\n\t// 如果是纯对象或者数组,则使用 JSON.stringify 格式化输出 否则原样返回\n\tconst res = boolRes ? JSON.stringify(params, null, 2) : params;\n\n\treturn res;\n}\n","import { type SimpleAsyncTask } from \"./simple-promise-tools\";\n\nexport const taskTypes = <const>[\"single\", \"parallel\", \"queue\"];\n\nexport type TaskType = (typeof taskTypes)[number];\n\nexport interface BaseTask {\n\t/** 任务类型 */\n\ttype: TaskType;\n}\n\nexport type Task = SimpleAsyncTask | TasksConfig;\n\nexport interface SingleTasks extends BaseTask {\n\ttype: \"single\";\n\ttasks: Task;\n}\n\nexport interface ParallelTasks extends BaseTask {\n\ttype: \"parallel\";\n\ttasks: Task[];\n}\n\nexport interface QueueTasks extends BaseTask {\n\ttype: \"queue\";\n\ttasks: Task[];\n}\n\nexport type TasksConfig = SingleTasks | ParallelTasks | QueueTasks;\n\nexport type PromiseTasksConfig = TasksConfig;\n\nfunction isSingleTasks(config: TasksConfig): config is SingleTasks {\n\treturn config.type === \"single\";\n}\n\nfunction isParallelTasks(config: TasksConfig): config is ParallelTasks {\n\treturn config.type === \"parallel\";\n}\n\nfunction isQueueTasks(config: TasksConfig): config is QueueTasks {\n\treturn config.type === \"queue\";\n}\n\nfunction isSimpleAsyncTask(config: Task): config is SimpleAsyncTask {\n\treturn typeof config === \"function\";\n}\n\nfunction isTasksConfig(config: Task): config is TasksConfig {\n\treturn typeof config === \"object\";\n}\n\n/**\n * 定义异步任务对象\n * @description\n * 这个对象是一揽子异步任务的配置\n */\nexport function definePromiseTasks(config: TasksConfig) {\n\treturn config;\n}\n\n/**\n * @private 一个工具函数 用于生成异步函数数组\n * @deprecated 在处理串行任务时 疑似有故障\n */\nfunction getPromises(tasks: Task[]): ((...args: any) => Promise<any>)[] {\n\treturn tasks.map((task) => {\n\t\treturn async function (...args: any) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\treturn await task(...args);\n\t\t\t} else {\n\t\t\t\treturn await executePromiseTasks(task);\n\t\t\t}\n\t\t};\n\t});\n}\n\n/**\n * 执行异步函数对象\n */\nexport async function executePromiseTasks(\n\tconfig: TasksConfig,\n\t/**\n\t * 上一次递归执行时提供的参数\n\t * @description\n\t * 考虑到递归函数 这里提供了一个参数 用于传递上一次递归执行的结果\n\t */\n\tlastParams: any = null,\n): Promise<any> {\n\tif (isSingleTasks(config)) {\n\t\tif (isSimpleAsyncTask(config.tasks)) {\n\t\t\t// 实际执行的 tasks 往往是无参函数 这里为了保险,故主动传递参数\n\t\t\treturn await config.tasks(lastParams);\n\t\t}\n\n\t\treturn await executePromiseTasks(config.tasks, lastParams);\n\t}\n\n\tif (isParallelTasks(config)) {\n\t\treturn await Promise.all(\n\t\t\tconfig.tasks.map((task) => {\n\t\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t\t// console.log(` 并行任务遇到单独的异步函数 `);\n\t\t\t\t\treturn task(lastParams);\n\t\t\t\t}\n\n\t\t\t\t// console.log(` 并行任务遇到嵌套结构 `);\n\t\t\t\treturn executePromiseTasks(task, lastParams);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (isQueueTasks(config)) {\n\t\tlet res: Awaited<any>;\n\t\tfor await (const task of config.tasks) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t// console.log(` 串行任务遇到单独的异步函数 `);\n\n\t\t\t\tres = await task(lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 单独 res `, res);\n\t\t\t} else {\n\t\t\t\tres = await executePromiseTasks(task, lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 配置 res `, res);\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,gCAA6C;;;ACDtC,SAAS,wBAAyD,MAAS;AAGjF,SAAO,YAAa,MAAW;AAI9B,WAAO,IAAI,QAAuB,CAAC,SAAS,WAAW;AAEtD,cAAQ,KAAK,GAAG,IAAI,CAAC;AAAA,IACtB,CAAC;AAAA,EACF;AACD;AAIO,IAAM,WAAkB;AAsB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IACD;AAEA,WAAO;AAAA,EACR;AACD;","names":["consola"]}
|
|
1
|
+
{"version":3,"sources":["../../src/node-cjs/index.ts","../../src/node-cjs/tools.ts","../../src/simple-promise-tools.ts","../../src/conditions.ts","../../src/print.ts","../../src/define-promise-tasks.ts"],"sourcesContent":["export * from \"./tools\";\n\n// 将绝大多数的工具函数 以cjs的方式导出\nexport * from \"../index\";\n","/**\n * 一些node环境下的工具函数\n */\n\nimport { normalize } from \"node:path\";\nimport { spawnSync, type SpawnOptions } from \"node:child_process\";\n\nimport { generateSimpleAsyncTask } from \"../simple-promise-tools\";\nimport consola from \"consola\";\n// import { normalizePath } from \"vite\";\n\n/**\n * 路径转换工具\n */\nexport function pathChange(path: string) {\n\treturn path.replace(/\\\\/g, \"/\");\n\t// FIXME: 无法有效地实现解析路径 测试用例不通过\n\t// return normalize(path);\n\t// FIXME: tsup打包时,无法处理好vite的依赖 会导致打包失败 不知道怎么单独使用并打包该函数\n\t// return normalizePath(path);\n}\n\nexport interface SpawnSyncSimpleParams {\n\tcommand: string;\n\tparameters: string[];\n\t/**\n\t * 是否流式输出内容\n\t * @description 默认输出的命令数据全部以流式的方式输出\n\t * @default true\n\t */\n\tisFlow?: boolean;\n\n\t/**\n\t * 是否显示命令?\n\t * @description\n\t * 是否打印目前正在执行的命令?\n\t * @default true\n\t */\n\tisShowCommand?: boolean;\n\tspawnOptions?: SpawnOptions;\n\n\t/** 打印当前运行的命令 */\n\tprintCurrentCommand?: (params: Pick<SpawnSyncSimpleParams, \"command\" | \"parameters\">) => void;\n}\n\n/**\n * 默认的打印当前运行命令 函数\n */\nexport const defPrintCurrentCommand: SpawnSyncSimpleParams[\"printCurrentCommand\"] = function (params) {\n\tconst { command, parameters } = params;\n\tconsola.info(` 当前运行的命令为: ${command} ${parameters.join(\" \")} \\n`);\n};\n\n/**\n * 生成简单的执行命令函数\n * @description\n * 对 spawnSync 做简单的包装\n *\n * 之前封装的是 execa 函数\n * @version 2\n */\nexport function generateSpawnSync(spawnSyncSimpleParams: SpawnSyncSimpleParams) {\n\tconst {\n\t\tcommand,\n\t\tparameters,\n\t\tisFlow = true,\n\t\tisShowCommand = true,\n\t\tspawnOptions = {},\n\t\tprintCurrentCommand = defPrintCurrentCommand,\n\t} = spawnSyncSimpleParams;\n\n\tif (isShowCommand) {\n\t\tprintCurrentCommand?.({ command, parameters });\n\t}\n\n\treturn generateSimpleAsyncTask(() => {\n\t\tconst result = spawnSync(command, parameters, {\n\t\t\t/**\n\t\t\t * 是否流式输出?\n\t\t\t * 是流式输出就是继承父进程的流式输出\n\t\t\t * 否则就使用默认值\n\t\t\t * @see https://nodejs.org/api/child_process.html#optionsstdio\n\t\t\t */\n\t\t\tstdio: isFlow ? \"inherit\" : \"pipe\",\n\t\t\tshell: true,\n\t\t\t...spawnOptions,\n\t\t});\n\n\t\t// 如果不是流式输出 就直接返回返回值即可\n\t\tif (!isFlow) {\n\t\t\treturn result;\n\t\t}\n\n\t\tif (result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\n\t\treturn result;\n\t});\n}\n","// import { uniqueId } from \"lodash-es\";\n// const getCounter = () => uniqueId();\n\n/** 创建简单的异步任务 */\nexport function generateSimpleAsyncTask<T extends (...args: any) => any>(func: T) {\n\t// const taskId = getCounter();\n\n\treturn function (...args: any) {\n\t\t// consola.info(` 这是第 ${taskId} 个异步任务 `);\n\t\t// consola.start(\" 这里是新创建的异步函数 检查参数: \", ...args);\n\n\t\treturn new Promise<ReturnType<T>>((resolve, reject) => {\n\t\t\t// consola.start(\" 内部promise 检查参数: \", ...args);\n\t\t\tresolve(func(...args));\n\t\t});\n\t};\n}\n\nexport type SimpleAsyncTask = ReturnType<typeof generateSimpleAsyncTask>;\n\nexport const initFlag = <const>\"initFlag\";\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @see https://github.com/ascoders/weekly/blob/master/前沿技术/77.精读《用%20Reduce%20实现%20Promise%20串行执行》.md\n * @version 1\n */\nasync function runPromiseByQueueV1<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tpromises.reduce(\n\t\tasync function (previousPromise, nextPromise, currentIndex) {\n\t\t\tconst response = await previousPromise;\n\t\t\t// consola.log(` reduce串行函数 currentIndex= ${currentIndex} res =`, response);\n\t\t\treturn await nextPromise(response);\n\t\t},\n\t\tPromise.resolve(initFlag) as Promise<any>,\n\t);\n}\n\n/**\n * 以队列串行的形式 串行运行异步函数\n * @version 2\n */\nexport async function runPromiseByQueue<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tlet response: typeof initFlag | Awaited<T> = initFlag;\n\tfor await (const promise of promises) {\n\t\tresponse = await promise(response);\n\t}\n}\n\n/**\n * 以并行的形式 并发运行异步函数\n */\nexport async function runPromiseByConcurrency<T>(promises: ((...args: any) => Promise<T>)[]) {\n\tawait Promise.all(promises.map((promise) => promise()));\n}\n","export type Condition = (...args: unknown[]) => boolean;\n\n/** @deprecated 没必要 */\nexport type Conditions = Condition[];\n\n/**\n * 是否每一个条件函数都满足?\n * @description\n * ### 设计理由\n * 旨在于封装这样的代码段\n * ```js\n * const conditions = [\n * \t() => !isEqual(nAssetRecord, oAssetRecord),\n * \t() => !isEqual(nAssetRecord, defPropsAssets),\n * \t() => isEdit.value || isInfo.value,\n * ];\n * conditions.every((condition) => condition())\n * ```\n */\nexport function isConditionsEvery(conditions: Condition[]) {\n\treturn conditions.every((condition) => condition());\n}\n\nexport function isConditionsSome(conditions: Condition[]) {\n\treturn conditions.some((condition) => condition());\n}\n","import { isPlainObject, isArray } from \"lodash-es\";\nimport { isConditionsSome } from \"./conditions\";\nimport consola from \"consola\";\n\n/**\n * 一个简单的格式化函数\n * @description\n * 用于将复杂对象变成纯文本 打印出来\n *\n * 主要用于测试框架打印完整的内容\n */\nexport function printFormat(params: any) {\n\tconst boolRes = isConditionsSome([\n\t\t// 是不是纯对象?\n\t\t() => isPlainObject(params),\n\t\t// 或者是不是单纯的数组?\n\t\t() => isArray(params),\n\t]);\n\n\t// 如果是纯对象或者数组,则使用 JSON.stringify 格式化输出 否则原样返回\n\tconst res = boolRes ? JSON.stringify(params, null, 2) : params;\n\n\treturn res;\n}\n\nexport interface PrintListParams {\n\t/** 标题,可以是字符串或根据列表生成标题的函数 */\n\ttitle: ((stringList: string[]) => string) | string;\n\t/** 要显示的字符串列表 */\n\tstringList: string[];\n}\n\n/**\n * 输出字符串列表\n * @description\n * 1. 生成编号列表文本\n * 2. 生成标题文本\n * 3. 输出标题和列表\n */\nexport function printList({ title, stringList }: PrintListParams): void {\n\t// 生成编号列表文本\n\tconst listText = stringList.map((item, index) => `${index + 1}. ${item}`).join(\"\\n\");\n\n\t// 生成标题文本\n\tconst titleText = typeof title === \"function\" ? title(stringList) : title;\n\n\t// 输出标题和列表\n\tconsola.info(titleText);\n\tconsola.box(listText);\n}\n","import { type SimpleAsyncTask } from \"./simple-promise-tools\";\n\nexport const taskTypes = <const>[\"single\", \"parallel\", \"queue\"];\n\nexport type TaskType = (typeof taskTypes)[number];\n\nexport interface BaseTask {\n\t/** 任务类型 */\n\ttype: TaskType;\n}\n\nexport type Task = SimpleAsyncTask | TasksConfig;\n\nexport interface SingleTasks extends BaseTask {\n\ttype: \"single\";\n\ttasks: Task;\n}\n\nexport interface ParallelTasks extends BaseTask {\n\ttype: \"parallel\";\n\ttasks: Task[];\n}\n\nexport interface QueueTasks extends BaseTask {\n\ttype: \"queue\";\n\ttasks: Task[];\n}\n\nexport type TasksConfig = SingleTasks | ParallelTasks | QueueTasks;\n\nexport type PromiseTasksConfig = TasksConfig;\n\nfunction isSingleTasks(config: TasksConfig): config is SingleTasks {\n\treturn config.type === \"single\";\n}\n\nfunction isParallelTasks(config: TasksConfig): config is ParallelTasks {\n\treturn config.type === \"parallel\";\n}\n\nfunction isQueueTasks(config: TasksConfig): config is QueueTasks {\n\treturn config.type === \"queue\";\n}\n\nfunction isSimpleAsyncTask(config: Task): config is SimpleAsyncTask {\n\treturn typeof config === \"function\";\n}\n\nfunction isTasksConfig(config: Task): config is TasksConfig {\n\treturn typeof config === \"object\";\n}\n\n/**\n * 定义异步任务对象\n * @description\n * 这个对象是一揽子异步任务的配置\n */\nexport function definePromiseTasks(config: TasksConfig) {\n\treturn config;\n}\n\n/**\n * @private 一个工具函数 用于生成异步函数数组\n * @deprecated 在处理串行任务时 疑似有故障\n */\nfunction getPromises(tasks: Task[]): ((...args: any) => Promise<any>)[] {\n\treturn tasks.map((task) => {\n\t\treturn async function (...args: any) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\treturn await task(...args);\n\t\t\t} else {\n\t\t\t\treturn await executePromiseTasks(task);\n\t\t\t}\n\t\t};\n\t});\n}\n\n/**\n * 执行异步函数对象\n */\nexport async function executePromiseTasks(\n\tconfig: TasksConfig,\n\t/**\n\t * 上一次递归执行时提供的参数\n\t * @description\n\t * 考虑到递归函数 这里提供了一个参数 用于传递上一次递归执行的结果\n\t */\n\tlastParams: any = null,\n): Promise<any> {\n\tif (isSingleTasks(config)) {\n\t\tif (isSimpleAsyncTask(config.tasks)) {\n\t\t\t// 实际执行的 tasks 往往是无参函数 这里为了保险,故主动传递参数\n\t\t\treturn await config.tasks(lastParams);\n\t\t}\n\n\t\treturn await executePromiseTasks(config.tasks, lastParams);\n\t}\n\n\tif (isParallelTasks(config)) {\n\t\treturn await Promise.all(\n\t\t\tconfig.tasks.map((task) => {\n\t\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t\t// console.log(` 并行任务遇到单独的异步函数 `);\n\t\t\t\t\treturn task(lastParams);\n\t\t\t\t}\n\n\t\t\t\t// console.log(` 并行任务遇到嵌套结构 `);\n\t\t\t\treturn executePromiseTasks(task, lastParams);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (isQueueTasks(config)) {\n\t\tlet res: Awaited<any>;\n\t\tfor await (const task of config.tasks) {\n\t\t\tif (isSimpleAsyncTask(task)) {\n\t\t\t\t// console.log(` 串行任务遇到单独的异步函数 `);\n\n\t\t\t\tres = await task(lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 单独 res `, res);\n\t\t\t} else {\n\t\t\t\tres = await executePromiseTasks(task, lastParams);\n\t\t\t\tlastParams = res;\n\t\t\t\t// console.log(` 串行任务 配置 res `, res);\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,gCAA6C;;;ACDtC,SAAS,wBAAyD,MAAS;AAGjF,SAAO,YAAa,MAAW;AAI9B,WAAO,IAAI,QAAuB,CAAC,SAAS,WAAW;AAEtD,cAAQ,KAAK,GAAG,IAAI,CAAC;AAAA,IACtB,CAAC;AAAA,EACF;AACD;AAIO,IAAM,WAAkB;AAsB/B,eAAsB,kBAAqB,UAA4C;AACtF,MAAI,WAAyC;AAC7C,mBAAiB,WAAW,UAAU;AACrC,eAAW,MAAM,QAAQ,QAAQ;AAAA,EAClC;AACD;AAKA,eAAsB,wBAA2B,UAA4C;AAC5F,QAAM,QAAQ,IAAI,SAAS,IAAI,CAAC,YAAY,QAAQ,CAAC,CAAC;AACvD;;;AD9CA,qBAAoB;AAMb,SAAS,WAAW,MAAc;AACxC,SAAO,KAAK,QAAQ,OAAO,GAAG;AAK/B;AA4BO,IAAM,yBAAuE,SAAU,QAAQ;AACrG,QAAM,EAAE,SAAS,WAAW,IAAI;AAChC,iBAAAA,QAAQ,KAAK,2DAAc,OAAO,IAAI,WAAW,KAAK,GAAG,CAAC;AAAA,CAAK;AAChE;AAUO,SAAS,kBAAkB,uBAA8C;AAC/E,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,eAAe,CAAC;AAAA,IAChB,sBAAsB;AAAA,EACvB,IAAI;AAEJ,MAAI,eAAe;AAClB,0BAAsB,EAAE,SAAS,WAAW,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,QAA2C;AAChE,SAAO,OAAO,SAAS;AACxB;AAEA,SAAS,kBAAkB,QAAyC;AACnE,SAAO,OAAO,WAAW;AAC1B;AAWO,SAAS,mBAAmB,QAAqB;AACvD,SAAO;AACR;AAqBA,eAAsB,oBACrB,QAMA,aAAkB,MACH;AACf,MAAI,cAAc,MAAM,GAAG;AAC1B,QAAI,kBAAkB,OAAO,KAAK,GAAG;AAEpC,aAAO,MAAM,OAAO,MAAM,UAAU;AAAA,IACrC;AAEA,WAAO,MAAM,oBAAoB,OAAO,OAAO,UAAU;AAAA,EAC1D;AAEA,MAAI,gBAAgB,MAAM,GAAG;AAC5B,WAAO,MAAM,QAAQ;AAAA,MACpB,OAAO,MAAM,IAAI,CAAC,SAAS;AAC1B,YAAI,kBAAkB,IAAI,GAAG;AAE5B,iBAAO,KAAK,UAAU;AAAA,QACvB;AAGA,eAAO,oBAAoB,MAAM,UAAU;AAAA,MAC5C,CAAC;AAAA,IACF;AAAA,EACD;AAEA,MAAI,aAAa,MAAM,GAAG;AACzB,QAAI;AACJ,qBAAiB,QAAQ,OAAO,OAAO;AACtC,UAAI,kBAAkB,IAAI,GAAG;AAG5B,cAAM,MAAM,KAAK,UAAU;AAC3B,qBAAa;AAAA,MAEd,OAAO;AACN,cAAM,MAAM,oBAAoB,MAAM,UAAU;AAChD,qBAAa;AAAA,MAEd;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;","names":["consola","import_consola","consola"]}
|
|
@@ -67,6 +67,20 @@ declare function isConditionsSome(conditions: Condition[]): boolean;
|
|
|
67
67
|
* 主要用于测试框架打印完整的内容
|
|
68
68
|
*/
|
|
69
69
|
declare function printFormat(params: any): any;
|
|
70
|
+
interface PrintListParams {
|
|
71
|
+
/** 标题,可以是字符串或根据列表生成标题的函数 */
|
|
72
|
+
title: ((stringList: string[]) => string) | string;
|
|
73
|
+
/** 要显示的字符串列表 */
|
|
74
|
+
stringList: string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 输出字符串列表
|
|
78
|
+
* @description
|
|
79
|
+
* 1. 生成编号列表文本
|
|
80
|
+
* 2. 生成标题文本
|
|
81
|
+
* 3. 输出标题和列表
|
|
82
|
+
*/
|
|
83
|
+
declare function printList({ title, stringList }: PrintListParams): void;
|
|
70
84
|
|
|
71
85
|
/** 创建简单的异步任务 */
|
|
72
86
|
declare function generateSimpleAsyncTask<T extends (...args: any) => any>(func: T): (...args: any) => Promise<ReturnType<T>>;
|
|
@@ -157,4 +171,4 @@ type Prettify<T> = {
|
|
|
157
171
|
*/
|
|
158
172
|
type ToNumberLike<T extends number> = T | `${T}`;
|
|
159
173
|
|
|
160
|
-
export { type BaseTask, type Condition, type Conditions, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, type SimpleAsyncTask, type SingleTasks, type SpawnSyncSimpleParams, type Task, type TaskType, type TasksConfig, type ToNumberLike, defPrintCurrentCommand, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, generateSpawnSync, initFlag, isConditionsEvery, isConditionsSome, pathChange, printFormat, runPromiseByConcurrency, runPromiseByQueue, taskTypes };
|
|
174
|
+
export { type BaseTask, type Condition, type Conditions, type ParallelTasks, type PnpmWorkspace, type Prettify, type PrintListParams, type PromiseTasksConfig, type QueueTasks, type SimpleAsyncTask, type SingleTasks, type SpawnSyncSimpleParams, type Task, type TaskType, type TasksConfig, type ToNumberLike, defPrintCurrentCommand, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, generateSpawnSync, initFlag, isConditionsEvery, isConditionsSome, pathChange, printFormat, printList, runPromiseByConcurrency, runPromiseByQueue, taskTypes };
|
package/dist/node-esm/index.js
CHANGED
|
@@ -87,6 +87,7 @@ function isConditionsSome(conditions) {
|
|
|
87
87
|
|
|
88
88
|
// src/print.ts
|
|
89
89
|
import { isPlainObject, isArray } from "lodash-es";
|
|
90
|
+
import consola2 from "consola";
|
|
90
91
|
|
|
91
92
|
// src/node-esm/scripts/clean.ts
|
|
92
93
|
var defaultCleanTargets = [
|
|
@@ -118,12 +119,12 @@ async function clean(targets) {
|
|
|
118
119
|
// src/node-esm/scripts/copy-changelog.ts
|
|
119
120
|
import fs from "fs";
|
|
120
121
|
import path from "path";
|
|
121
|
-
import
|
|
122
|
+
import consola3 from "consola";
|
|
122
123
|
function hasChangelogMd() {
|
|
123
124
|
const res = fs.existsSync(path.resolve(process.cwd(), "CHANGELOG.md"));
|
|
124
125
|
if (!res) {
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
consola3.log("\u5F53\u524D\u9879\u76EE\u6839\u76EE\u5F55\u4E3A\uFF1A", process.cwd());
|
|
127
|
+
consola3.warn("\u5F53\u524D\u9879\u76EE\u6839\u76EE\u5F55\u4E0D\u5B58\u5728 CHANGELOG.md \u6587\u4EF6");
|
|
127
128
|
}
|
|
128
129
|
return res;
|
|
129
130
|
}
|
|
@@ -139,20 +140,20 @@ function copyChangelogMd(target) {
|
|
|
139
140
|
// src/node-esm/scripts/copy-readme.ts
|
|
140
141
|
import fs2 from "fs";
|
|
141
142
|
import path2 from "path";
|
|
142
|
-
import
|
|
143
|
+
import consola4 from "consola";
|
|
143
144
|
var capitalReadmeMd = "README.md";
|
|
144
145
|
var lowerCaseReadmeMd = "readme.md";
|
|
145
146
|
function hasCapitalReadmeMd() {
|
|
146
147
|
const res = fs2.existsSync(path2.resolve(process.cwd(), capitalReadmeMd));
|
|
147
148
|
if (!res) {
|
|
148
|
-
|
|
149
|
+
consola4.warn(`\u5F53\u524D\u9879\u76EE\u6839\u76EE\u5F55\u4E0D\u5B58\u5728 ${capitalReadmeMd} \u6587\u4EF6`);
|
|
149
150
|
}
|
|
150
151
|
return res;
|
|
151
152
|
}
|
|
152
153
|
function hasLowerCaseReadmeMd() {
|
|
153
154
|
const res = fs2.existsSync(path2.resolve(process.cwd(), lowerCaseReadmeMd));
|
|
154
155
|
if (!res) {
|
|
155
|
-
|
|
156
|
+
consola4.log(`\u5F53\u524D\u9879\u76EE\u6839\u76EE\u5F55\u4E0D\u5B58\u5728 ${lowerCaseReadmeMd} \u6587\u4EF6`);
|
|
156
157
|
}
|
|
157
158
|
return res;
|
|
158
159
|
}
|
|
@@ -177,7 +178,7 @@ function copyReadmeMd(target) {
|
|
|
177
178
|
|
|
178
179
|
// src/node-esm/scripts/yaml-to-md.ts
|
|
179
180
|
import { readFileSync, writeFileSync } from "fs";
|
|
180
|
-
import { consola as
|
|
181
|
+
import { consola as consola5 } from "consola";
|
|
181
182
|
import { isUndefined } from "lodash-es";
|
|
182
183
|
|
|
183
184
|
// ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
|
|
@@ -2804,16 +2805,16 @@ var js_yaml_default = jsYaml;
|
|
|
2804
2805
|
|
|
2805
2806
|
// src/node-esm/scripts/yaml-to-md.ts
|
|
2806
2807
|
function writeYaml2md(params) {
|
|
2807
|
-
|
|
2808
|
+
consola5.info(` \u5F53\u524D\u8FD0\u884C\u7684\u5730\u5740\u4E3A\uFF1A ${process.cwd()} `);
|
|
2808
2809
|
const { mdPath, data } = params;
|
|
2809
2810
|
if (isUndefined(mdPath)) {
|
|
2810
|
-
|
|
2811
|
+
consola5.error(" \u8BF7\u63D0\u4F9Bmd\u6587\u4EF6\u7684\u5730\u5740 ");
|
|
2811
2812
|
process.exit(1);
|
|
2812
2813
|
}
|
|
2813
2814
|
try {
|
|
2814
2815
|
readFileSync(mdPath, "utf-8");
|
|
2815
2816
|
} catch (error) {
|
|
2816
|
-
|
|
2817
|
+
consola5.error(` \u6587\u4EF6 ${mdPath} \u4E0D\u5B58\u5728 `);
|
|
2817
2818
|
process.exit(1);
|
|
2818
2819
|
}
|
|
2819
2820
|
const mdContent = readFileSync(mdPath, "utf-8");
|
|
@@ -2823,7 +2824,7 @@ ${yamlContent}---
|
|
|
2823
2824
|
|
|
2824
2825
|
${mdContent}`;
|
|
2825
2826
|
writeFileSync(mdPath, newContent, "utf-8");
|
|
2826
|
-
|
|
2827
|
+
consola5.success(` \u5DF2\u5C06YAML\u6570\u636E\u5199\u5165\u5230 ${mdPath} `);
|
|
2827
2828
|
}
|
|
2828
2829
|
|
|
2829
2830
|
// src/node-esm/scripts/add-changelog-to-doc.ts
|