vvvfs 0.0.1-alpha.2 → 0.0.2

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/esbuild.config.js CHANGED
@@ -1,13 +1,18 @@
1
- const esbuild = require('esbuild');
1
+ import { build } from 'esbuild';
2
+ import fs from 'fs';
2
3
 
3
- esbuild.build({
4
- entryPoints: ['index.js'],
4
+ const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
5
+
6
+ build({
7
+ entryPoints: ['index.ts'],
5
8
  bundle: true,
6
9
  outfile: 'dist/vvvfs.min.js',
7
- format: 'cjs',
10
+ format: 'iife',
11
+ define: {
12
+ 'process.env.PACKAGE_VERSION': JSON.stringify(pkg.version), // 注入版本号
13
+ },
8
14
  minify: true,
9
15
  platform: 'browser',
10
16
  target: ["chrome80", "firefox70", "safari13", "edge80"],
11
17
  logLevel: 'info',
12
- // external: ['dexie']
13
- });
18
+ }).catch(() => process.exit(1));
package/index.html CHANGED
@@ -4,37 +4,29 @@
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Document</title>
8
- <script src="dist/vvfs.min.js"></script>
7
+ <title>Example</title>
8
+ <script src="dist/vvvfs.min.js"></script>
9
9
  </head>
10
10
 
11
11
  <body>
12
12
  <script>
13
13
  (async () => {
14
- const vvfs = new VVFS();
15
- await vvfs.reset();
16
- console.log(vvfs);
17
- if (!vvfs.exists('/home/root/')) {
18
- console.log('Creating directory /home/root/');
19
- await vvfs.mkdirs('/home/root/');
14
+ try {
15
+ globalThis.vvvfs = new VVVFS();
16
+ await vvvfs.reset();
17
+ console.log(vvvfs);
18
+ console.log("创建文件", await vvvfs.createFile("/test.txt"));
19
+ console.log("写入文件", await vvvfs.writeText("/test.txt", "Hello World"));
20
+ console.log("文件是否存在", await vvvfs.exists("/test.txt"));
21
+ console.log("文件是否存在", await vvvfs.exists("/test2.txt"));
22
+ console.log("读取文件", await vvvfs.readText("/test.txt"));
23
+ console.log("复制文件", await vvvfs.copy("/test.txt", "/test2.txt"));
24
+ console.log("搜索文件", await vvvfs.search("test"));
25
+ console.log("移动文件", await vvvfs.move("/test2.txt", "/test3.txt"));
26
+ console.log("删除文件", await vvvfs.delete("/test.txt"));
27
+ } catch (error) {
28
+ console.error(error);
20
29
  }
21
- await vvfs.write('/home/root/test.txt', new File(['test content'], 'test.txt'));
22
- await vvfs.write('/home/root/hello.txt', new File(['Hello, World!'], 'hello.txt'));
23
- await vvfs.chmod('/home/root/test.txt', 0o644);
24
- console.log('Changed permissions of /home/root/test.txt to 644');
25
- await vvfs.chmod('/home/root/hello.txt', 0o644);
26
- console.log('Changed permissions of /home/root/hello.txt to 644');
27
- await vvfs.rename('/home/root/test.txt', '/home/root/test-renamed.txt');
28
- console.log('Renamed /home/root/test.txt to /home/root/test-renamed.txt');
29
- const content = await vvfs.read('/home/root/test.txt');
30
- console.log('Content of /home/root/test.txt:', content);
31
- const hello = await vvfs.read('/home/root/hello.txt');
32
- console.log('Content of /home/root/hello.txt:', hello);
33
- // await vvfs.delete('/home/root/test.txt');
34
- // await vvfs.delete('/home/root/hello.txt');
35
- console.log('Deleted /home/root/test.txt and /home/root/hello.txt');
36
- console.log('Listing directory /home/root/:', await vvfs.list('/home/root/'));
37
- console.log('Listing directory /home/:', await vvfs.list('/home/'));
38
30
  })();
39
31
  </script>
40
32
  </body>