@bashlife/boxbox-beta 70.0.0 → 73.0.0
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 +5 -2
- package/src/commands/cd.sh +0 -0
- package/src/commands/info.js +8 -38
- package/src/commands/install.js +35 -0
- package/src/index.js +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bashlife/boxbox-beta",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "73.0.0",
|
|
4
4
|
"description": "A modern BusyBox-style CLI toolkit with custom commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "bashlife",
|
|
@@ -16,5 +16,8 @@
|
|
|
16
16
|
"bash",
|
|
17
17
|
"boxbox"
|
|
18
18
|
],
|
|
19
|
-
"license": "UNLICENSED"
|
|
19
|
+
"license": "UNLICENSED",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"boxbox-unfinished": "^65.0.2"
|
|
22
|
+
}
|
|
20
23
|
}
|
package/src/commands/cd.sh
CHANGED
|
File without changes
|
package/src/commands/info.js
CHANGED
|
@@ -1,47 +1,17 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"package.json"
|
|
10
|
-
);
|
|
8
|
+
export default async function() {
|
|
9
|
+
const commandsDir = __dirname;
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
root,
|
|
14
|
-
"src",
|
|
15
|
-
"commands"
|
|
16
|
-
);
|
|
11
|
+
const commands = fs.readdirSync(commandsDir);
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
let commandCount = 0;
|
|
20
|
-
|
|
21
|
-
// Read version from package.json
|
|
22
|
-
if (fs.existsSync(packagePath)) {
|
|
23
|
-
try {
|
|
24
|
-
const pkg = JSON.parse(
|
|
25
|
-
fs.readFileSync(packagePath, "utf8")
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
version = pkg.version || "unknown";
|
|
29
|
-
} catch {
|
|
30
|
-
version = "unknown";
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Count commands (files + folders)
|
|
35
|
-
if (fs.existsSync(commandsDir)) {
|
|
36
|
-
const entries = fs.readdirSync(commandsDir);
|
|
37
|
-
|
|
38
|
-
commandCount = entries.filter((entry) => {
|
|
39
|
-
return !entry.startsWith(".");
|
|
40
|
-
}).length;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log(`BoxBox ${version}`);
|
|
13
|
+
console.log("BoxBox v73.0.0");
|
|
44
14
|
console.log("Runtime: Node.js");
|
|
45
15
|
console.log(`Platform: ${process.platform}`);
|
|
46
|
-
console.log(`Commands: ${
|
|
16
|
+
console.log(`Commands: ${commands.length}`);
|
|
47
17
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export default async function(args) {
|
|
5
|
+
if (args.length < 2) {
|
|
6
|
+
console.log("Usage: install <source> <destination>");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const source = args[0];
|
|
11
|
+
const destination = args[1];
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
if (!fs.existsSync(source)) {
|
|
15
|
+
console.error(`install: ${source}: No such file`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let target = destination;
|
|
20
|
+
|
|
21
|
+
// If destination is a directory, keep the filename
|
|
22
|
+
if (fs.existsSync(destination) && fs.statSync(destination).isDirectory()) {
|
|
23
|
+
target = path.join(destination, path.basename(source));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fs.copyFileSync(source, target);
|
|
27
|
+
|
|
28
|
+
// Default install behavior: executable permissions
|
|
29
|
+
fs.chmodSync(target, 0o755);
|
|
30
|
+
|
|
31
|
+
console.log(`installed ${source} -> ${target}`);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(`install: ${err.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const args = process.argv.slice(2);
|
|
|
6
6
|
const command = args[0];
|
|
7
7
|
|
|
8
8
|
const commands = {
|
|
9
|
+
install: "./commands/install.js",
|
|
9
10
|
base64: "./commands/base64.js",
|
|
10
11
|
rmdir: "./commands/rmdir.js",
|
|
11
12
|
javascript: "./commands/JavaScriptRun/index.js",
|
|
@@ -163,6 +164,7 @@ Commands:
|
|
|
163
164
|
rmdir Remove empty directories
|
|
164
165
|
nano create files write them edit them
|
|
165
166
|
base64 Encode or decode data using Base64
|
|
167
|
+
install - Copy files and set file permissions
|
|
166
168
|
`);
|
|
167
169
|
|
|
168
170
|
process.exit(0);
|
|
@@ -175,7 +177,7 @@ if (commands[command]) {
|
|
|
175
177
|
if (file.endsWith(".sh")) {
|
|
176
178
|
execFile("sh", [file, ...args.slice(1)], (err, stdout, stderr) => {
|
|
177
179
|
if (err) {
|
|
178
|
-
console.log(`boxbox
|
|
180
|
+
console.log(`boxbox Error: ${err.message}`);
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
181
183
|
|
|
@@ -188,10 +190,10 @@ if (commands[command]) {
|
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
} catch (err) {
|
|
191
|
-
console.log(`boxbox
|
|
193
|
+
console.log(`boxbox Error: ${err.message}`);
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
} else {
|
|
195
197
|
console.log(`boxbox: unknown command '${command}'`);
|
|
196
|
-
console.log("Run 'boxbox
|
|
198
|
+
console.log("Run 'boxbox' for available commands.");
|
|
197
199
|
}
|