cc1-ui 0.0.3 → 0.0.5

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 CHANGED
@@ -12,8 +12,8 @@ export {}
12
12
  /* prettier-ignore */
13
13
  declare module 'vue' {
14
14
  export interface GlobalComponents {
15
- VButton:typeof import('./components/Button/index.vue')['default']
16
15
  VCircle:typeof import('./components/Circle/index.vue')['default']
16
+ VButton:typeof import('./components/Button/index.vue')['default']
17
17
  VIcon:typeof import('./components/Icon/index.vue')['default']
18
18
  VMask:typeof import('./components/Mask/index.vue')['default']
19
19
  VSIcon:typeof import('./components/SIcon/index.vue')['default']
package/dist/util.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare const readDir: (dirurl: string, filecallback: Function) => Promise<boolean>;
2
+ export declare const readFile: (filename: string) => Promise<string>;
3
+ export declare const writeFile: (filename: string, content: string) => Promise<boolean>;
4
+ export declare const copyDirOrFile: (sourcePath: string, destinationPath: string) => Promise<void>;
5
+ export declare const deleteDirOrFile: (dirOrFilePath: string) => Promise<void>;
package/dist/util.js ADDED
@@ -0,0 +1,72 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ export const readDir = async (dirurl, filecallback) => {
4
+ const dirInfo = fs.readdirSync(dirurl);
5
+ for (let i = 0; i < dirInfo.length; i++) {
6
+ const item = dirInfo[i];
7
+ const location = path.join(dirurl, item);
8
+ const info = fs.statSync(location);
9
+ if (info.isDirectory()) {
10
+ if ((await readDir(location, filecallback)) === true)
11
+ return true;
12
+ }
13
+ else {
14
+ if ((await filecallback(location)) === true)
15
+ return true;
16
+ }
17
+ }
18
+ };
19
+ export const readFile = async (filename) => {
20
+ try {
21
+ return fs.readFileSync(filename).toString();
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ };
27
+ export const writeFile = async (filename, content) => {
28
+ try {
29
+ fs.mkdirSync(path.dirname(filename), {
30
+ recursive: true
31
+ });
32
+ fs.writeFileSync(filename, content);
33
+ return true;
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ };
39
+ export const copyDirOrFile = async (sourcePath, destinationPath) => {
40
+ const stats = fs.statSync(sourcePath);
41
+ if (stats.isDirectory()) {
42
+ if (!fs.existsSync(destinationPath)) {
43
+ fs.mkdirSync(destinationPath, { recursive: true });
44
+ }
45
+ const files = fs.readdirSync(sourcePath);
46
+ for (const file of files) {
47
+ const sourceFile = path.join(sourcePath, file);
48
+ const destinationFile = path.join(destinationPath, file);
49
+ await copyDirOrFile(sourceFile, destinationFile);
50
+ }
51
+ }
52
+ else {
53
+ fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
54
+ fs.copyFileSync(sourcePath, destinationPath);
55
+ }
56
+ };
57
+ export const deleteDirOrFile = async (dirOrFilePath) => {
58
+ if (fs.existsSync(dirOrFilePath)) {
59
+ const stat = fs.lstatSync(dirOrFilePath);
60
+ if (stat.isDirectory()) {
61
+ const files = fs.readdirSync(dirOrFilePath);
62
+ for (const file of files) {
63
+ const curPath = path.join(dirOrFilePath, file);
64
+ await deleteDirOrFile(curPath);
65
+ }
66
+ fs.rmdirSync(dirOrFilePath);
67
+ }
68
+ else {
69
+ fs.unlinkSync(dirOrFilePath);
70
+ }
71
+ }
72
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc1-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "我来助你-Vue3UI库",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,6 +26,11 @@
26
26
  "import": "./dist/autoimport.js",
27
27
  "require": "./dist/autoimport.js"
28
28
  },
29
+ "./dist/util": {
30
+ "types": "./dist/util.d.ts",
31
+ "import": "./dist/util.js",
32
+ "require": "./dist/util.js"
33
+ },
29
34
  "./index.css": "./dist/index.css"
30
35
  },
31
36
  "scripts": {