@fxri/swagger2api 1.0.15 → 1.1.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.
@@ -1,21 +0,0 @@
1
- /**
2
- * 获取参数
3
- * @param name 参数名称
4
- * @param next true取索引值,false取索引键
5
- * @param use 配置已使用
6
- * @return 选中的参数
7
- */
8
- export declare function getParam(name: string | string[], next?: boolean, use?: boolean): string | boolean;
9
- /**
10
- * 获取参数列表
11
- * @param used 是否已使用
12
- * @return 参数数组
13
- */
14
- export declare function getParamList(used?: boolean): string[];
15
- /**
16
- * 保存文件
17
- * @param file 文件地址
18
- * @param data 数据
19
- * @return 无返回数据
20
- */
21
- export declare function saveFile(file: any, data: any): void;
@@ -1,75 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- /** 数据集合 */
4
- const datas = {
5
- /** 参数 */
6
- param: process.argv.filter((_item, index) => index > 1),
7
- /** 已使用 */
8
- used: {}
9
- };
10
- /**
11
- * 获取参数
12
- * @param name 参数名称
13
- * @param next true取索引值,false取索引键
14
- * @param use 配置已使用
15
- * @return 选中的参数
16
- */
17
- export function getParam(name, next = true, use = true) {
18
- // 处理名称
19
- if (!Array.isArray(name))
20
- name = [name];
21
- // 配置数据
22
- let data;
23
- // 查询参数
24
- datas.param.forEach((item, index) => {
25
- // 查询索引
26
- if (!name.includes(item)) {
27
- // 空值
28
- return;
29
- }
30
- else if (next) {
31
- // 取索引值
32
- data = datas.param[index + 1];
33
- // 配置已使用
34
- use && Object.assign(datas.used, { [index + 1]: true });
35
- }
36
- else if (["true", "false"].includes(datas.param[index + 1])) {
37
- // 取索引键,但存在索引值的话,则取索引值
38
- data = datas.param[index + 1].toLowerCase() == "true";
39
- // 配置已使用
40
- use && Object.assign(datas.used, { [index + 1]: true });
41
- }
42
- else {
43
- // 取索引键
44
- data = true;
45
- }
46
- // 配置已使用
47
- use && Object.assign(datas.used, { [index]: true });
48
- });
49
- // 返回参数
50
- return data;
51
- }
52
- /**
53
- * 获取参数列表
54
- * @param used 是否已使用
55
- * @return 参数数组
56
- */
57
- export function getParamList(used) {
58
- return typeof used == "boolean" ? datas.param.filter((_item, index) => (used ? datas.used[index] : !datas.used[index])) : datas.param;
59
- }
60
- /**
61
- * 保存文件
62
- * @param file 文件地址
63
- * @param data 数据
64
- * @return 无返回数据
65
- */
66
- export function saveFile(file, data) {
67
- // 获取目录
68
- const dir = path.dirname(file);
69
- // 创建目录
70
- if (!fs.existsSync(dir)) {
71
- fs.mkdirSync(dir, { recursive: true });
72
- }
73
- // 写入文件
74
- fs.writeFileSync(file, data);
75
- }
@@ -1,2 +0,0 @@
1
- export * from "./method.js";
2
- export * from "./common.js";
@@ -1,4 +0,0 @@
1
- // 基础函数
2
- export * from "./method.js";
3
- // 公共方法
4
- export * from "./common.js";
@@ -1,2 +0,0 @@
1
- /** 校验URL */
2
- export declare const isUrl: (data: any) => boolean;
@@ -1,7 +0,0 @@
1
- // +----------------------------------------------------------------------
2
- // | Author 唐启云 <tqy@fxri.net>
3
- // +----------------------------------------------------------------------
4
- // | Category 方弦研究所
5
- // +----------------------------------------------------------------------
6
- /** 校验URL */
7
- export const isUrl = (data) => /^(https?:\/\/|:?\/\/)/.test(data);