cc1-ui 0.0.5 → 0.0.6

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,4 +1,7 @@
1
1
  import { Plugin } from 'vite';
2
+ export declare const readDir: (dirurl: string, filecallback: Function) => Promise<boolean>;
3
+ export declare const readFile: (filename: string) => Promise<string>;
4
+ export declare const writeFile: (filename: string, content: string) => Promise<boolean>;
2
5
  /**
3
6
  * 按需导入组件
4
7
  * @param config
@@ -1,5 +1,41 @@
1
1
  import * as path from 'path';
2
- import { readDir, readFile } from './util';
2
+ import * as fs from 'fs';
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
+ };
3
39
  let btime = new Date().getTime();
4
40
  const log = (str, time = false) => {
5
41
  console.log('');
@@ -113,11 +149,10 @@ export function UIAuto(config) {
113
149
  }
114
150
  }
115
151
  }
116
- log(`🥰🥰【${getName()}】一顿操作终于编译完成啦`);
117
152
  return res.join('\n');
118
153
  }
119
154
  else if (comImport.indexOf('cc1-ui#dist#index.css') != -1) {
120
- return conf.use.map((v) => `@import url('./components/${v.toLowerCase().substring(1)}/style.css');`).join('\n');
155
+ return conf.use.map((v) => `@import url('./components/${v.substring(1)}/style.css');`).join('\n');
121
156
  }
122
157
  }
123
158
  };
package/dist/index.d.ts CHANGED
@@ -12,10 +12,10 @@ export {}
12
12
  /* prettier-ignore */
13
13
  declare module 'vue' {
14
14
  export interface GlobalComponents {
15
- VCircle:typeof import('./components/Circle/index.vue')['default']
16
15
  VButton:typeof import('./components/Button/index.vue')['default']
17
- VIcon:typeof import('./components/Icon/index.vue')['default']
16
+ VCircle:typeof import('./components/Circle/index.vue')['default']
18
17
  VMask:typeof import('./components/Mask/index.vue')['default']
18
+ VIcon:typeof import('./components/Icon/index.vue')['default']
19
19
  VSIcon:typeof import('./components/SIcon/index.vue')['default']
20
20
  VScale:typeof import('./components/Scale/index.vue')['default']
21
21
  VSelect:typeof import('./components/Select/index.vue')['default']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc1-ui",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "我来助你-Vue3UI库",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,11 +26,6 @@
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
- },
34
29
  "./index.css": "./dist/index.css"
35
30
  },
36
31
  "scripts": {
package/dist/util.d.ts DELETED
@@ -1,5 +0,0 @@
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 DELETED
@@ -1,72 +0,0 @@
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
- };