oipage 1.5.0-alpha.3 → 1.6.0-alpha.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/CHANGELOG CHANGED
@@ -98,7 +98,7 @@ v1.4.1:
98
98
  - 修复bug
99
99
  1、修复开发服务器大文件丢失文件大小问题
100
100
  v1.5.0:
101
- date:
101
+ date:2025-11-13
102
102
  changes:
103
103
  - 修复bug
104
104
  1、修复404网站在手机浏览器显示高问题
@@ -111,4 +111,16 @@ v1.5.0:
111
111
  1、开发服务器 / 应用市场
112
112
  * 聊天工具
113
113
  * 图片编辑器
114
- * 图片转PDF
114
+ * 图片转PDF
115
+ 2、API功能(Node.js)
116
+ * disk 磁盘相关操作
117
+ (包括:moveDisk、listDisk)
118
+ v1.6.0:
119
+ date:
120
+ changes:
121
+ - 新增功能
122
+ 1、命令(oipage-cli)
123
+ * disk --link 创建磁盘链接
124
+ 2、API功能(Node.js)
125
+ * disk 磁盘相关操作
126
+ (包括:linkDisk)
package/bin/disk.js CHANGED
@@ -1,4 +1,4 @@
1
- const { deleteDisk, copyDisk } = require("../nodejs/disk");
1
+ const { deleteDisk, copyDisk, moveDisk, linkDisk } = require("../nodejs/disk");
2
2
 
3
3
  module.exports = function (config) {
4
4
  let isForce = false;
@@ -20,13 +20,17 @@ module.exports = function (config) {
20
20
 
21
21
  // 移动文件或文件夹
22
22
  else if (config.value[i].name === "--move") {
23
- copyDisk(config.value[i].value[0], config.value[i].value[1], isForce);
24
- deleteDisk(config.value[i].value[0]);
23
+ moveDisk(config.value[i].value[0], config.value[i].value[1], isForce);
25
24
  }
26
25
 
27
26
  // 复制文件或文件夹
28
27
  else if (config.value[i].name === "--copy") {
29
28
  copyDisk(config.value[i].value[0], config.value[i].value[1], isForce);
30
29
  }
30
+
31
+ // 创建磁盘链接
32
+ else if (config.value[i].name === "--link") {
33
+ linkDisk(config.value[i].value[0], config.value[i].value[1], isForce);
34
+ }
31
35
  }
32
36
  };
package/bin/help.js CHANGED
@@ -15,8 +15,9 @@ OIPage@v${packageValue.version}
15
15
  【2】oipage-cli disk 磁盘操作
16
16
  --force|-f 强制执行
17
17
  --delete|-d 删除文件或文件夹
18
- --move|m 移动文件或文件夹
18
+ --move|-m 移动文件或文件夹
19
19
  --copy|-c 复制文件或文件夹
20
+ --linkDisk|-l 创建磁盘链接
20
21
 
21
22
  【3】oipage-cli run "任务一" "任务二" ... 运行多命令
22
23
 
package/bin/run CHANGED
@@ -56,7 +56,8 @@ else if (process.argv[2] === "disk") {
56
56
  "-f": "--force",
57
57
  "-d": "--delete",
58
58
  "-m": "--move",
59
- "-c": "--copy"
59
+ "-c": "--copy",
60
+ "-l": "--link"
60
61
  }, true);
61
62
 
62
63
  require("./disk.js")(argvObj);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.5.0-alpha.3
2
+ * animation of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * cmdlog of OIPage v1.5.0-alpha.3
2
+ * cmdlog of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -14,4 +14,35 @@ export interface copyDiskType {
14
14
  (sourcePath: string, targetPath: string, isForce?: boolean): void
15
15
  }
16
16
 
17
- export let copyDisk: copyDiskType
17
+ export let copyDisk: copyDiskType
18
+
19
+ /**
20
+ * 移动文件或文件夹
21
+ */
22
+ export interface moveDiskType {
23
+ (sourcePath: string, targetPath: string, isForce?: boolean): void
24
+ }
25
+
26
+ export let moveDisk: moveDiskType
27
+
28
+ /**
29
+ * 遍历当前文件或文件夹中所有文件
30
+ */
31
+ export interface listDiskType {
32
+ (sourcePath: string, callback: (fileInfo: {
33
+ name: string
34
+ path: string
35
+ folder: string
36
+ }) => void): void
37
+ }
38
+
39
+ export let listDisk: listDiskType
40
+
41
+ /**
42
+ * 创建文件或文件夹的链接
43
+ */
44
+ export interface linkDiskType {
45
+ (sourcePath: string, targetPath: string): void
46
+ }
47
+
48
+ export let linkDisk: linkDiskType
@@ -1,10 +1,11 @@
1
1
  /*!
2
- * disk of OIPage v1.5.0-alpha.3
2
+ * disk of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
6
  const { join } = require("path");
7
- const { existsSync, readdirSync, lstatSync, unlinkSync, rmdirSync, mkdirSync, copyFileSync } = require("fs");
7
+ const { existsSync, readdirSync, lstatSync, unlinkSync, rmdirSync, mkdirSync, copyFileSync, symlinkSync } = require("fs");
8
+ const { execSync } = require("child_process");
8
9
 
9
10
  /**
10
11
  * 删除文件或文件夹
@@ -49,7 +50,7 @@ function copyDisk(sourcePath, targetPath, isForce) {
49
50
  throw new Error("OIPage: The source path does not exist.");
50
51
  }
51
52
 
52
- // 如果模板文件已经存在
53
+ // 如果目标文件已经存在
53
54
  if (existsSync(targetPath)) {
54
55
  if (isForce) {
55
56
  deleteDisk(targetPath);
@@ -80,6 +81,95 @@ function copyDisk(sourcePath, targetPath, isForce) {
80
81
 
81
82
  }
82
83
  })(sourcePath, targetPath);
84
+ }
85
+
86
+ /**
87
+ * 移动文件或文件夹
88
+ * @param {string} sourcePath
89
+ * @param {string} targetPath
90
+ * @param {boolean} isForce 可选,是否强制执行
91
+ */
92
+ function moveDisk(sourcePath, targetPath, isForce) {
93
+
94
+ // 如果源文件不存在
95
+ if (!existsSync(sourcePath)) {
96
+ console.log("\x1b[0m\x1b[31m" + sourcePath + "\x1b[0m");
97
+ throw new Error("OIPage: The source path does not exist.");
98
+ }
99
+
100
+ // 如果目标文件已经存在
101
+ if (existsSync(targetPath)) {
102
+ if (isForce) {
103
+ deleteDisk(targetPath);
104
+ } else {
105
+ console.log("\x1b[0m\x1b[31m" + targetPath + "\x1b[0m");
106
+ throw new Error("OIPage: The target path already exists.");
107
+ }
108
+ }
109
+
110
+ // 如果是文件,直接剪切即可
111
+ if (!lstatSync(sourcePath).isDirectory()) {
112
+ copyFileSync(sourcePath, targetPath);
113
+ unlinkSync(sourcePath);
114
+ } else {
115
+
116
+ // 读取子文件
117
+ const subFiles = readdirSync(sourcePath);
118
+
119
+ // 如果文件夹不存在,创建
120
+ if (!existsSync(targetPath)) {
121
+ mkdirSync(targetPath, { recursive: true });
122
+ }
123
+
124
+ // 移动子文件或文件夹
125
+ subFiles.forEach(function (file) {
126
+ moveDisk(join(sourcePath, "./" + file), join(targetPath, "./" + file));
127
+ });
128
+
129
+ // 移动完子文件或文件夹以后(移动完毕也意味着子文件或文件夹被删除了)
130
+ rmdirSync(sourcePath);
131
+ }
132
+ }
133
+
134
+ /**
135
+ * 遍历当前文件或文件夹中所有文件
136
+ * @param {string} sourcePath
137
+ * @param {function} callback
138
+ */
139
+ function listDisk(sourcePath, callback) {
140
+ // 文件夹
141
+ if (lstatSync(sourcePath).isDirectory()) {
142
+
143
+ // 读取子文件
144
+ const subFiles = readdirSync(sourcePath);
145
+ subFiles.forEach(function (file) {
146
+ listDisk(join(sourcePath, "./" + file), callback);
147
+ });
148
+ }
149
+
150
+ // 文件
151
+ else {
152
+ let folder = join(sourcePath, "../");
153
+
154
+ callback({
155
+ "name": sourcePath.replace(folder, ""),
156
+ "path": sourcePath,
157
+ "folder": folder
158
+ });
159
+ }
160
+ }
161
+
162
+ /**
163
+ * 软链接文件或文件夹
164
+ * @param {*} sourcePath
165
+ * @param {*} targetPath
166
+ */
167
+ function linkDisk(sourcePath, targetPath) {
168
+ const type = lstatSync(sourcePath).isDirectory() ? 'junction' : 'file';
169
+ symlinkSync(sourcePath, targetPath, type);
83
170
  }
84
171
  exports.deleteDisk = deleteDisk;
85
172
  exports.copyDisk = copyDisk;
173
+ exports.moveDisk = moveDisk;
174
+ exports.listDisk = listDisk;
175
+ exports.linkDisk = linkDisk;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * format of OIPage v1.5.0-alpha.3
2
+ * format of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * json of OIPage v1.5.0-alpha.3
2
+ * json of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {reader} = require("../reader/index.js");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * logform of OIPage v1.5.0-alpha.3
2
+ * logform of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {linelog} = require("../cmdlog/index.js");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * reader of OIPage v1.5.0-alpha.3
2
+ * reader of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.5.0-alpha.3
2
+ * throttle of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oipage",
3
- "version": "1.5.0-alpha.3",
3
+ "version": "1.6.0-alpha.0",
4
4
  "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * XMLHttpRequest of OIPage v1.5.0-alpha.3
2
+ * XMLHttpRequest of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.5.0-alpha.3
2
+ * animation of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * format of OIPage v1.5.0-alpha.3
2
+ * format of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/web/json/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * json of OIPage v1.5.0-alpha.3
2
+ * json of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  import {reader} from "../reader/index.js";
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * onReady of OIPage v1.5.0-alpha.3
2
+ * onReady of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * performChunk of OIPage v1.5.0-alpha.3
2
+ * performChunk of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * reader of OIPage v1.5.0-alpha.3
2
+ * reader of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * style of OIPage v1.5.0-alpha.3
2
+ * style of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.5.0-alpha.3
2
+ * throttle of OIPage v1.6.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5