@bashlife/boxbox-beta 69.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bashlife/boxbox-beta",
3
- "version": "69.0.0",
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
  }
@@ -0,0 +1,49 @@
1
+ import fs from "fs";
2
+
3
+ export default async function(args) {
4
+ let decode = false;
5
+ let inputFile = null;
6
+ let outputFile = null;
7
+
8
+ for (let i = 0; i < args.length; i++) {
9
+ const arg = args[i];
10
+
11
+ if (arg === "-d" || arg === "--decode") {
12
+ decode = true;
13
+ } else if (arg === "-i" || arg === "--input") {
14
+ inputFile = args[++i];
15
+ } else if (arg === "-o" || arg === "--output") {
16
+ outputFile = args[++i];
17
+ }
18
+ }
19
+
20
+ try {
21
+ let input;
22
+
23
+ if (inputFile) {
24
+ input = fs.readFileSync(inputFile);
25
+ } else {
26
+ input = Buffer.from(
27
+ args.filter(a => !a.startsWith("-")).join(" "),
28
+ "utf8"
29
+ );
30
+ }
31
+
32
+ let result;
33
+
34
+ if (decode) {
35
+ result = Buffer.from(input.toString(), "base64");
36
+ } else {
37
+ result = Buffer.from(input).toString("base64");
38
+ }
39
+
40
+ if (outputFile) {
41
+ fs.writeFileSync(outputFile, result);
42
+ } else {
43
+ console.log(result.toString());
44
+ }
45
+
46
+ } catch (err) {
47
+ console.error(`base64: ${err.message}`);
48
+ }
49
+ }
File without changes
@@ -1,47 +1,17 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { fileURLToPath } from "url";
3
4
 
4
- export default function info() {
5
- const root = process.cwd();
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
6
7
 
7
- const packagePath = path.join(
8
- root,
9
- "package.json"
10
- );
8
+ export default async function() {
9
+ const commandsDir = __dirname;
11
10
 
12
- const commandsDir = path.join(
13
- root,
14
- "src",
15
- "commands"
16
- );
11
+ const commands = fs.readdirSync(commandsDir);
17
12
 
18
- let version = "unknown";
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: ${commandCount}`);
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,8 @@ const args = process.argv.slice(2);
6
6
  const command = args[0];
7
7
 
8
8
  const commands = {
9
+ install: "./commands/install.js",
10
+ base64: "./commands/base64.js",
9
11
  rmdir: "./commands/rmdir.js",
10
12
  javascript: "./commands/JavaScriptRun/index.js",
11
13
  printf: "./commands/printf.js",
@@ -160,6 +162,9 @@ Commands:
160
162
  printf Format and print text
161
163
  javascript Run JavaScript projects with jsRun
162
164
  rmdir Remove empty directories
165
+ nano create files write them edit them
166
+ base64 Encode or decode data using Base64
167
+ install - Copy files and set file permissions
163
168
  `);
164
169
 
165
170
  process.exit(0);
@@ -172,7 +177,7 @@ if (commands[command]) {
172
177
  if (file.endsWith(".sh")) {
173
178
  execFile("sh", [file, ...args.slice(1)], (err, stdout, stderr) => {
174
179
  if (err) {
175
- console.log(`boxbox error: ${err.message}`);
180
+ console.log(`boxbox Error: ${err.message}`);
176
181
  return;
177
182
  }
178
183
 
@@ -185,10 +190,10 @@ if (commands[command]) {
185
190
  }
186
191
 
187
192
  } catch (err) {
188
- console.log(`boxbox error: ${err.message}`);
193
+ console.log(`boxbox Error: ${err.message}`);
189
194
  }
190
195
 
191
196
  } else {
192
197
  console.log(`boxbox: unknown command '${command}'`);
193
- console.log("Run 'boxbox help' for available commands.");
198
+ console.log("Run 'boxbox' for available commands.");
194
199
  }