webide-cli 0.0.1-alpha.4 → 0.0.1-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 IFTC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  QQ群:1050254184
3
3
 
4
4
  # 安装
5
- 1. 安装NodeJS和NPM
5
+ 1. 安装NodeJS和NPM:(如已安装,则跳过此步骤)
6
6
  ```bash
7
7
  apk add nodejs
8
8
  apk add npm
@@ -22,3 +22,4 @@ webide -v
22
22
  ```bash
23
23
  webide -h
24
24
  ```
25
+ > 安装过程如有问题,请加Q群反馈
package/index.js CHANGED
@@ -1,6 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  const { program } = require('commander');
3
3
  const { version } = require('./package.json');
4
+ const { createClient } = require('@supabase/supabase-js');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ const SUPABASE_URL = "https://dbmp-xbgmorqeur6oh81z.database.nocode.cn";
9
+ const SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzQ2OTc5MjAwLCJleHAiOjE5MDQ3NDU2MDB9.11QbQ5OW_m10vblDXAlw1Qq7Dve5Swzn12ILo7-9IXY";
10
+ const FILE_BUCKET = "jslib";
11
+
12
+ const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
13
+ const bucket = supabase.storage.from(FILE_BUCKET);
14
+
15
+ const workdir = process.cwd();
4
16
 
5
17
  program
6
18
  .name('webide')
@@ -15,4 +27,111 @@ program
15
27
  });
16
28
 
17
29
  program
18
- .parse(process.argv);
30
+ .command('workdir')
31
+ .description('Show current working directory.')
32
+ .action(() => {
33
+ console.log("Current working directory:", process.cwd());
34
+ });
35
+
36
+ program
37
+ .command('add <name>')
38
+ .description('Add a new library.')
39
+ .action(async (libname) => {
40
+ fs.access(workdir + "/webapp.json", fs.constants.F_OK, (err) => {
41
+ if (err) {
42
+ console.error("webapp.json not found in current directory. Please make sure you are in a WebIDE project directory.");
43
+ process.exit(114514);
44
+ }
45
+ });
46
+ fs.mkdirSync(path.join(workdir, 'libs', libname), { recursive: true });
47
+ try {
48
+ const load = loading(`Checking if library "${libname}" exists...`);
49
+ if (await checkFileExists(libname + "/lib.json")) {
50
+ load();
51
+ console.log(`Library "${libname}" already exists.`);
52
+ console.log(`Start downloading...`);
53
+ const downloadingTip = `Downloading library "${libname}" ...`;
54
+ let load2 = loading(downloadingTip);
55
+ const libJsonData = await getFile(libname + "/lib.json");
56
+ const libJson = JSON.parse(await libJsonData.text());
57
+ const { name, author, description, version } = libJson;
58
+ load2();
59
+ console.log(`Library info: `);
60
+ console.log(` Name: ${name}`);
61
+ console.log(` Version: ${version}`);
62
+ console.log(` Author: ${author || 'Unknown'}`);
63
+ console.log(` Description: ${description || 'No description'}`);
64
+ load2 = loading(downloadingTip);
65
+ await download(libname, path.join(workdir, 'libs', libname));
66
+ load2();
67
+ console.log(`Library "${libname}" downloaded successfully.`);
68
+ } else {
69
+ load();
70
+ console.error(`Library "${libname}" does not exist in the database.`);
71
+ process.exit(114514);
72
+ }
73
+ } catch (error) {
74
+ fs.rmSync(path.join(workdir, 'libs', libname), { recursive: true, force: true });
75
+ console.error("\r\nAn error occurred:", error.stack);
76
+ process.exit(114514);
77
+ }
78
+ });
79
+
80
+ program
81
+ .command('remove <name>')
82
+ .description('Remove a library')
83
+ .action(function (libname) {
84
+ const libPath = path.join(workdir, 'libs', libname);
85
+ if (fs.existsSync(libPath)) {
86
+ fs.rmSync(libPath, { recursive: true, force: true });
87
+ console.log(`Library "${libname}" removed.`);
88
+ } else {
89
+ console.error(`Library "${libname}" does not exist.`);
90
+ }
91
+ });
92
+
93
+ program
94
+ .parse(process.argv);
95
+
96
+ async function checkFileExists(path) {
97
+ const { data } = await bucket.exists(path);
98
+ return data;
99
+ }
100
+
101
+ async function getFile(path) {
102
+ const { data, error } = await bucket.download(path);
103
+ return data;
104
+ }
105
+
106
+ function loading(msg) {
107
+ const spinnerChars = ['⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
108
+ let i = 0;
109
+ const interval = setInterval(() => {
110
+ process.stdout.write(`\r${spinnerChars[i++]} ${msg}`);
111
+ i = i % spinnerChars.length;
112
+ }, 50);
113
+ return () => {
114
+ clearInterval(interval);
115
+ process.stdout.write('\r\x1b[K');
116
+ }
117
+ }
118
+
119
+ async function download(path, savepath) {
120
+ const { data, error } = await bucket.list(path);
121
+ if (error) throw error;
122
+ for (const file of data) {
123
+ const remotePath = path ? `${path}/${file.name}` : file.name;
124
+ if (!file.metadata) {
125
+ const localDirPath = require("path").join(savepath, file.name);
126
+ fs.mkdirSync(localDirPath, { recursive: true });
127
+ await download(remotePath, localDirPath);
128
+ continue;
129
+ }
130
+ const { data: fileData, error: downloadError } = await bucket.download(remotePath);
131
+ if (downloadError) throw downloadError;
132
+ const filepath = require("path").join(savepath, file.name);
133
+ fs.mkdirSync(require("path").dirname(filepath), { recursive: true });
134
+ const bufferData = Buffer.from(await fileData.arrayBuffer());
135
+ fs.writeFileSync(filepath, bufferData);
136
+ }
137
+ }
package/init.js CHANGED
@@ -6,7 +6,6 @@ const arch = os.arch();
6
6
  const workdir = process.cwd();
7
7
  const bindir = "/usr/bin/";
8
8
 
9
- // console.log(workdir);
10
9
  if (platform === "linux" && arch === "arm64") {
11
10
  fs.writeFile(bindir + "webide", `#!/bin/bash
12
11
  node ${workdir}/index.js "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webide-cli",
3
- "version": "0.0.1-alpha.4",
3
+ "version": "0.0.1-alpha.6",
4
4
  "description": "A CLI for NEW WebIDE",
5
5
  "keywords": [
6
6
  "WebIDE",
@@ -21,6 +21,7 @@
21
21
  "postinstall": "node init"
22
22
  },
23
23
  "dependencies": {
24
+ "@supabase/supabase-js": "^2.90.1",
24
25
  "commander": "^14.0.2"
25
26
  }
26
27
  }
package/webapp.json ADDED
File without changes