uniky 1.0.19 → 1.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniky",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "uni-app 开发工具库,包含 hooks、http 请求和 vite 插件",
5
5
  "type": "module",
6
6
  "main": "./src/lib/index.ts",
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { copyFileSync, mkdirSync, existsSync, writeFileSync } from 'fs';
2
+ import { copyFileSync, mkdirSync, existsSync, writeFileSync, readdirSync, statSync } from 'fs';
3
3
  import { join, dirname } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
 
@@ -28,6 +28,30 @@ function findProjectRoot() {
28
28
  return process.cwd();
29
29
  }
30
30
 
31
+ function copyDirectoryRecursive(source, target) {
32
+ if (!existsSync(target)) {
33
+ mkdirSync(target, { recursive: true });
34
+ }
35
+
36
+ const files = readdirSync(source);
37
+ let count = 0;
38
+
39
+ files.forEach(file => {
40
+ const sourcePath = join(source, file);
41
+ const targetPath = join(target, file);
42
+ const stat = statSync(sourcePath);
43
+
44
+ if (stat.isDirectory()) {
45
+ count += copyDirectoryRecursive(sourcePath, targetPath);
46
+ } else {
47
+ copyFileSync(sourcePath, targetPath);
48
+ count++;
49
+ }
50
+ });
51
+
52
+ return count;
53
+ }
54
+
31
55
  function installPluginFiles() {
32
56
  try {
33
57
  const projectRoot = findProjectRoot();
@@ -38,28 +62,8 @@ function installPluginFiles() {
38
62
  mkdirSync(unikyDir, { recursive: true });
39
63
  }
40
64
 
41
- if (!existsSync(pluginDir)) {
42
- mkdirSync(pluginDir, { recursive: true });
43
- }
44
-
45
65
  const sourceDir = join(__dirname, '..', 'src', 'plugin');
46
- const filesToCopy = [
47
- 'pages.defined.ts',
48
- 'global.defined.ts',
49
- 'lib.defined.ts',
50
- 'index.ts'
51
- ];
52
-
53
- let copiedCount = 0;
54
- filesToCopy.forEach(file => {
55
- const sourcePath = join(sourceDir, file);
56
- const targetPath = join(pluginDir, file);
57
-
58
- if (existsSync(sourcePath)) {
59
- copyFileSync(sourcePath, targetPath);
60
- copiedCount++;
61
- }
62
- });
66
+ const copiedCount = copyDirectoryRecursive(sourceDir, pluginDir);
63
67
 
64
68
  const indexContent = `// created by zhuxietong on 2026-01-30 16:37
65
69
  export * from './plugin/index.js';