@moltium/world-cli 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +58 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- #!/usr/bin/env node
3
2
 
4
3
  // src/index.ts
5
4
  import { Command as Command5 } from "commander";
@@ -89,7 +88,7 @@ ${options.tokenType === "custom" ? "WORLD_TOKEN_ADDRESS=\n" : ""}
89
88
  }
90
89
 
91
90
  // src/templates/world-template.ts
92
- function generateWorldTemplate(config) {
91
+ function generateWorldTemplate(config3) {
93
92
  const files = {};
94
93
  files["src/index.ts"] = `import { World } from '@moltium/world-core';
95
94
  import { loadWorldConfig } from '@moltium/world-core/config';
@@ -111,7 +110,7 @@ async function main() {
111
110
  // Start HTTP server
112
111
  await startWorldServer(world);
113
112
 
114
- console.log(\`\u{1F30D} ${config.name} is running!\`);
113
+ console.log(\`\u{1F30D} ${config3.name} is running!\`);
115
114
  console.log(\` Server: http://\${config.server.host}:\${config.server.port}\`);
116
115
  console.log(\` Agents: \${world.getAgents().length}/\${config.admission.maxAgents}\`);
117
116
 
@@ -128,9 +127,9 @@ main().catch((error) => {
128
127
  process.exit(1);
129
128
  });
130
129
  `;
131
- if (config.worldType === "game") {
130
+ if (config3.worldType === "game") {
132
131
  files["src/game-logic.ts"] = generateGameLogic();
133
- } else if (config.worldType === "marketplace") {
132
+ } else if (config3.worldType === "marketplace") {
134
133
  files["src/marketplace-logic.ts"] = generateMarketplaceLogic();
135
134
  }
136
135
  return files;
@@ -453,10 +452,10 @@ var initCommand = new Command("init").description("Initialize a new world projec
453
452
  process.exit(1);
454
453
  }
455
454
  });
456
- function generateReadme(config) {
457
- return `# ${config.name}
455
+ function generateReadme(config3) {
456
+ return `# ${config3.name}
458
457
 
459
- ${config.description}
458
+ ${config3.description}
460
459
 
461
460
  ## Getting Started
462
461
 
@@ -464,7 +463,7 @@ ${config.description}
464
463
  # Install dependencies
465
464
  npm install
466
465
 
467
- ${config.hasCustomToken ? "# Deploy custom token\nnpm run token:deploy\n" : ""}# Deploy smart contracts
466
+ ${config3.hasCustomToken ? "# Deploy custom token\nnpm run token:deploy\n" : ""}# Deploy smart contracts
468
467
  npm run deploy:contracts
469
468
 
470
469
  # Start world server
@@ -474,11 +473,11 @@ npm run dev
474
473
  ## Configuration
475
474
 
476
475
  - **World config:** \`world.config.json\`
477
- ${config.hasCustomToken ? "- **Token config:** `token.config.json`\n" : ""}- **Environment:** \`.env\`
476
+ ${config3.hasCustomToken ? "- **Token config:** `token.config.json`\n" : ""}- **Environment:** \`.env\`
478
477
 
479
478
  ## Token Type
480
479
 
481
- ${config.tokenType === "native" ? "**Native (MON)** - This world uses Monad's native currency for transactions." : "**Custom ERC20** - This world has its own custom token. Deploy it using `npm run token:deploy`."}
480
+ ${config3.tokenType === "native" ? "**Native (MON)** - This world uses Monad's native currency for transactions." : "**Custom ERC20** - This world has its own custom token. Deploy it using `npm run token:deploy`."}
482
481
 
483
482
  ## Commands
484
483
 
@@ -486,7 +485,7 @@ ${config.tokenType === "native" ? "**Native (MON)** - This world uses Monad's na
486
485
  - \`npm run build\` - Build for production
487
486
  - \`npm run start\` - Start production server
488
487
  - \`npm run deploy:contracts\` - Deploy smart contracts to Monad
489
- ${config.hasCustomToken ? "- `npm run token:deploy` - Deploy custom token\n- `npm run token:verify` - Verify token contract\n" : ""}
488
+ ${config3.hasCustomToken ? "- `npm run token:deploy` - Deploy custom token\n- `npm run token:verify` - Verify token contract\n" : ""}
490
489
  ## Documentation
491
490
 
492
491
  For more information, visit: https://moltium.world/docs
@@ -500,6 +499,7 @@ import ora2 from "ora";
500
499
  import fs3 from "fs/promises";
501
500
  import path3 from "path";
502
501
  import { execSync } from "child_process";
502
+ import { config } from "dotenv";
503
503
 
504
504
  // src/lib/config-loader.ts
505
505
  import fs2 from "fs/promises";
@@ -550,6 +550,7 @@ var tokenCommand = new Command2("token").description("Manage world token deploym
550
550
  tokenCommand.command("deploy").description("Deploy custom ERC20 token").option("-c, --config <path>", "Token config file", "./token.config.json").option("-r, --rpc-url <url>", "RPC URL (overrides .env)").option("-s, --silent", "No interactive prompts").action(async (options) => {
551
551
  console.log(chalk2.bold.cyan("\n\u{1FA99} Deploying Custom Token\n"));
552
552
  try {
553
+ config({ path: path3.join(process.cwd(), ".env") });
553
554
  const spinner = ora2("Loading configuration...").start();
554
555
  const tokenConfig = await loadTokenConfig(options.config);
555
556
  spinner.text = "Checking environment...";
@@ -594,7 +595,26 @@ tokenCommand.command("deploy").description("Deploy custom ERC20 token").option("
594
595
  TOKEN_MAX_SUPPLY: tokenConfig.maxSupply?.toString() || "0",
595
596
  TOKEN_DECIMALS: tokenConfig.decimals?.toString() || "18"
596
597
  };
597
- const worldCorePath = path3.join(process.cwd(), "../world-core");
598
+ const worldCorePath = path3.join(process.cwd(), "node_modules", "@moltium", "world-core");
599
+ const libPath = path3.join(worldCorePath, "lib");
600
+ try {
601
+ await fs3.access(libPath);
602
+ } catch {
603
+ deploySpinner.text = "Installing Foundry dependencies...";
604
+ try {
605
+ execSync("forge install --no-commit", {
606
+ cwd: worldCorePath,
607
+ stdio: "pipe"
608
+ });
609
+ deploySpinner.text = "Deploying token contract...";
610
+ } catch (error) {
611
+ deploySpinner.fail();
612
+ console.error(chalk2.red("\\n\u274C Failed to install Foundry dependencies"));
613
+ console.log(chalk2.yellow("\\nPlease ensure Foundry is installed: https://getfoundry.sh/"));
614
+ console.log(chalk2.gray(`\\nThen run manually: cd ${worldCorePath} && forge install\\n`));
615
+ process.exit(1);
616
+ }
617
+ }
598
618
  const command = `forge script script/DeployToken.s.sol:DeployTokenScript --rpc-url monad --broadcast -vvv`;
599
619
  const output = execSync(command, {
600
620
  cwd: worldCorePath,
@@ -662,7 +682,7 @@ tokenCommand.command("verify").description("Verify token contract on Sourcify").
662
682
  console.log(` ${chalk2.gray("Contract:")} ${tokenAddress}\\n`);
663
683
  const spinner = ora2("Verifying on Sourcify...").start();
664
684
  try {
665
- const worldCorePath = path3.join(process.cwd(), "../world-core");
685
+ const worldCorePath = path3.join(process.cwd(), "node_modules", "@moltium", "world-core");
666
686
  const command = `MONAD_ETHERSCAN_KEY="" forge verify-contract ${tokenAddress} contracts/WorldToken.sol:WorldToken --chain 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org/`;
667
687
  execSync(command, {
668
688
  cwd: worldCorePath,
@@ -714,9 +734,11 @@ import chalk4 from "chalk";
714
734
  import ora4 from "ora";
715
735
  import { execSync as execSync3 } from "child_process";
716
736
  import path4 from "path";
737
+ import { config as config2 } from "dotenv";
717
738
  var deployCommand = new Command4("deploy").description("Deploy smart contracts to Monad").option("-r, --rpc-url <url>", "RPC URL (overrides .env)").action(async (options) => {
718
739
  console.log(chalk4.bold.cyan("\\n\u{1F680} Deploying Smart Contracts\\n"));
719
740
  try {
741
+ config2({ path: path4.join(process.cwd(), ".env") });
720
742
  const spinner = ora4("Checking environment...").start();
721
743
  const privateKey = process.env.DEPLOYER_PRIVATE_KEY;
722
744
  if (!privateKey) {
@@ -736,7 +758,27 @@ var deployCommand = new Command4("deploy").description("Deploy smart contracts t
736
758
  console.log(` ${chalk4.gray("RPC URL:")} ${rpcUrl}\\n`);
737
759
  const deploySpinner = ora4("Deploying AgentRegistry...").start();
738
760
  try {
739
- const worldCorePath = path4.join(process.cwd(), "../world-core");
761
+ const worldCorePath = path4.join(process.cwd(), "node_modules", "@moltium", "world-core");
762
+ const libPath = path4.join(worldCorePath, "lib");
763
+ const fs4 = await import("fs/promises");
764
+ try {
765
+ await fs4.access(libPath);
766
+ } catch {
767
+ deploySpinner.text = "Installing Foundry dependencies...";
768
+ try {
769
+ execSync3("forge install --no-commit", {
770
+ cwd: worldCorePath,
771
+ stdio: "pipe"
772
+ });
773
+ deploySpinner.text = "Deploying AgentRegistry...";
774
+ } catch (error) {
775
+ deploySpinner.fail();
776
+ console.error(chalk4.red("\\n\u274C Failed to install Foundry dependencies"));
777
+ console.log(chalk4.yellow("\\nPlease ensure Foundry is installed: https://getfoundry.sh/"));
778
+ console.log(chalk4.gray(`\\nThen run manually: cd ${worldCorePath} && forge install\\n`));
779
+ process.exit(1);
780
+ }
781
+ }
740
782
  const env = {
741
783
  ...process.env,
742
784
  MONAD_RPC_URL: rpcUrl,
@@ -762,7 +804,6 @@ var deployCommand = new Command4("deploy").description("Deploy smart contracts t
762
804
  console.log(` ${chalk4.gray("AgentRegistry:")} ${chalk4.green(agentRegistryAddress)}`);
763
805
  console.log(` ${chalk4.gray("WorldMembership:")} ${chalk4.green(membershipAddress)}`);
764
806
  const updateSpinner = ora4("\\nUpdating world.config.json...").start();
765
- const fs4 = await import("fs/promises");
766
807
  worldConfig.blockchain = worldConfig.blockchain || {};
767
808
  worldConfig.blockchain.agentRegistryAddress = agentRegistryAddress;
768
809
  worldConfig.blockchain.membershipContractAddress = membershipAddress;
@@ -789,7 +830,7 @@ var deployCommand = new Command4("deploy").description("Deploy smart contracts t
789
830
 
790
831
  // src/index.ts
791
832
  var program = new Command5();
792
- program.name("moltium-world").description("CLI tool for creating and managing Moltium World SDK projects").version("0.1.0");
833
+ program.name("moltium-world").description("CLI tool for creating and managing Moltium World SDK projects").version("0.1.2");
793
834
  program.addCommand(initCommand);
794
835
  program.addCommand(tokenCommand);
795
836
  program.addCommand(startCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltium/world-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "CLI tool for creating and managing Moltium World SDK projects",
5
5
  "license": "MIT",
6
6
  "keywords": [