@tgrv/void-cli 1.0.0 → 1.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/bin/void.js CHANGED
@@ -8,7 +8,9 @@ import readline from "readline";
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = path.dirname(__filename);
11
- const workspaceDir = path.resolve(__dirname, "../../..");
11
+ const cliRoot = path.resolve(__dirname, "..");
12
+ const isLocalDev = fs.existsSync(path.join(cliRoot, "../../packages/void-runtime"));
13
+ const workspaceDir = isLocalDev ? path.resolve(cliRoot, "../..") : process.cwd();
12
14
 
13
15
  // ANSI Color formatting codes
14
16
  const colors = {
@@ -88,7 +90,7 @@ const command = args[0];
88
90
 
89
91
  if (!command) {
90
92
  console.log(`
91
- ${colors.bold}${colors.cyan}Void CLI V2 - WASM Plugin Manager${colors.reset}
93
+ ${colors.bold}${colors.cyan}Void CLI - WASM Plugin Manager${colors.reset}
92
94
 
93
95
  ${colors.bold}Usage:${colors.reset}
94
96
  ${colors.green}void init [path]${colors.reset} - Initialize a new application project at path (default: .)
@@ -196,6 +198,9 @@ function runBuild(pluginPathArg) {
196
198
  dependencies: {
197
199
  "@tgrv/void-runtime": "^1.0.0",
198
200
  },
201
+ publishConfig: {
202
+ access: "public"
203
+ }
199
204
  };
200
205
  fs.writeFileSync(path.join(buildOutputDir, "package.json"), JSON.stringify(pkgJson, null, 2));
201
206
 
@@ -310,7 +315,7 @@ try {
310
315
 
311
316
  console.log(`${info} Creating Rust plugin template at ${colors.bold}${targetDir}${colors.reset}...`);
312
317
  ensureDir(targetDir);
313
- const templateSrc = path.join(workspaceDir, "templates", "rust");
318
+ const templateSrc = path.join(cliRoot, "templates", "rust");
314
319
  copyFolderRecursive(templateSrc, targetDir, {
315
320
  "\\{\\{name\\}\\}": folderName,
316
321
  "\\{\\{type\\}\\}": "rust",
@@ -327,7 +332,7 @@ try {
327
332
 
328
333
  console.log(`${info} Creating Go plugin template at ${colors.bold}${targetDir}${colors.reset}...`);
329
334
  ensureDir(targetDir);
330
- const templateSrc = path.join(workspaceDir, "templates", "go");
335
+ const templateSrc = path.join(cliRoot, "templates", "go");
331
336
  copyFolderRecursive(templateSrc, targetDir, {
332
337
  "\\{\\{name\\}\\}": folderName,
333
338
  "\\{\\{type\\}\\}": "go",
@@ -335,7 +340,8 @@ try {
335
340
  });
336
341
  }
337
342
 
338
- console.log(`${tick} ${colors.green}Plugin created successfully under '${pluginPathArg}'!${colors.reset}\n`);
343
+ console.log(`${tick} ${colors.green}Plugin created successfully under '${pluginPathArg}'!${colors.reset}`);
344
+ console.log(`${info} ${colors.yellow}Reminder: Make sure to include build directories in your main .gitignore to avoid committing builds (e.g., add **/@void/ and **/@tgrv/).${colors.reset}\n`);
339
345
  break;
340
346
  }
341
347
 
@@ -350,9 +356,9 @@ try {
350
356
  // 1. Run build
351
357
  const buildOutputDir = runBuild(pluginPathArg);
352
358
 
353
- // 2. Call npm publish inside the output build folder
354
- console.log(`\n${info} Running 'npm publish' inside: ${colors.bold}${buildOutputDir}${colors.reset}`);
355
- const publishSuccess = runCommand("npm publish", { cwd: buildOutputDir });
359
+ // 2. Call npm publish --access public inside the output build folder
360
+ console.log(`\n${info} Running 'npm publish --access public' inside: ${colors.bold}${buildOutputDir}${colors.reset}`);
361
+ const publishSuccess = runCommand("npm publish --access public", { cwd: buildOutputDir });
356
362
  if (!publishSuccess) {
357
363
  console.log(`\n${warning} ${colors.yellow}NPM publish failed or completed as dry run (check NPM login credentials).${colors.reset}`);
358
364
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tgrv/void-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "void": "./bin/void.js"
@@ -0,0 +1,5 @@
1
+ module {{name}}
2
+
3
+ go 1.26
4
+
5
+ require github.com/shoya-129/Void/sdk/void-sdk-go v1.0.0
@@ -0,0 +1,19 @@
1
+ package main
2
+
3
+ import (
4
+ "encoding/json"
5
+ "fmt"
6
+ "github.com/tgrv/void-sdk-go"
7
+ )
8
+
9
+ func Hello(args map[string]json.RawMessage) (any, error) {
10
+ name, err := void.GetString(args, "name")
11
+ if err != nil {
12
+ name = "World"
13
+ }
14
+ return fmt.Sprintf("Hello, %s!", name), nil
15
+ }
16
+
17
+ func main() {
18
+ void.Register("hello", Hello)
19
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@void/{{name}}",
3
+ "type": "go",
4
+ "buildDir": "@void/{{name}}"
5
+ }
@@ -0,0 +1,12 @@
1
+ [package]
2
+ name = "{{name}}"
3
+ version = "1.0.0"
4
+ edition = "2021"
5
+
6
+ [lib]
7
+ crate-type = ["cdylib"]
8
+
9
+ [dependencies]
10
+ void-sdk-rust = "1.0.0"
11
+ serde = { version = "1.0", features = ["derive"] }
12
+ serde_json = "1.0"
@@ -0,0 +1,14 @@
1
+ use std::collections::HashMap;
2
+ use void_sdk_rust::{register, void_plugin, get_string, Value};
3
+
4
+ fn hello(args: HashMap<String, Value>) -> Result<Value, String> {
5
+ let name = get_string(&args, "name").unwrap_or_else(|_| "World".to_string());
6
+ Ok(Value::String(format!("Hello, {}!", name)))
7
+ }
8
+
9
+ fn setup() {
10
+ register("hello", hello);
11
+ }
12
+
13
+ // Export FFI functions and call setup on init
14
+ void_plugin!(setup);
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@void/{{name}}",
3
+ "type": "rust",
4
+ "buildDir": "@void/{{name}}"
5
+ }