@moltium/world-cli 0.1.15 → 0.1.16
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/dist/index.js +57 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,7 +40,10 @@ function generateWorldConfig(options) {
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
...options.persistenceType === "postgres" && options.dbConfig && {
|
|
43
|
-
postgres: {
|
|
43
|
+
postgres: options.dbConfig.connectionString ? {
|
|
44
|
+
connectionString: options.dbConfig.connectionString,
|
|
45
|
+
ssl: true
|
|
46
|
+
} : {
|
|
44
47
|
host: options.dbConfig.host,
|
|
45
48
|
port: options.dbConfig.port,
|
|
46
49
|
database: options.dbConfig.database,
|
|
@@ -115,7 +118,13 @@ ${options.tokenType === "custom" ? "WORLD_TOKEN_ADDRESS=\n" : ""}
|
|
|
115
118
|
# MONAD_ETHERSCAN_KEY=
|
|
116
119
|
`;
|
|
117
120
|
if (options.persistenceType === "postgres") {
|
|
118
|
-
|
|
121
|
+
if (options.dbConfig?.connectionString) {
|
|
122
|
+
env += `
|
|
123
|
+
# PostgreSQL Configuration (Connection URL)
|
|
124
|
+
DATABASE_URL=${options.dbConfig.connectionString}
|
|
125
|
+
`;
|
|
126
|
+
} else {
|
|
127
|
+
env += `
|
|
119
128
|
# PostgreSQL Configuration
|
|
120
129
|
DB_HOST=${options.dbConfig?.host || "localhost"}
|
|
121
130
|
DB_PORT=${options.dbConfig?.port || "5432"}
|
|
@@ -124,6 +133,7 @@ DB_USER=${options.dbConfig?.user || "postgres"}
|
|
|
124
133
|
DB_PASSWORD=${options.dbConfig?.password || ""}
|
|
125
134
|
DB_SSL=${options.dbConfig?.ssl ? "true" : "false"}
|
|
126
135
|
`;
|
|
136
|
+
}
|
|
127
137
|
} else if (options.persistenceType === "redis") {
|
|
128
138
|
env += `
|
|
129
139
|
# Redis Configuration
|
|
@@ -173,13 +183,22 @@ async function main() {
|
|
|
173
183
|
|
|
174
184
|
if (config.persistence) {
|
|
175
185
|
if (config.persistence.type === 'postgres') {
|
|
176
|
-
if (!config.persistence.postgres) config.persistence.postgres = {
|
|
177
|
-
if (process.env.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
if (!config.persistence.postgres) config.persistence.postgres = {};
|
|
187
|
+
if (process.env.DATABASE_URL) {
|
|
188
|
+
config.persistence.postgres.connectionString = process.env.DATABASE_URL;
|
|
189
|
+
config.persistence.postgres.ssl = true;
|
|
190
|
+
} else {
|
|
191
|
+
if (!config.persistence.postgres.host) config.persistence.postgres.host = 'localhost';
|
|
192
|
+
if (!config.persistence.postgres.database) config.persistence.postgres.database = 'moltium_world';
|
|
193
|
+
if (!config.persistence.postgres.user) config.persistence.postgres.user = 'postgres';
|
|
194
|
+
if (!config.persistence.postgres.password) config.persistence.postgres.password = '';
|
|
195
|
+
if (process.env.DB_HOST) config.persistence.postgres.host = process.env.DB_HOST;
|
|
196
|
+
if (process.env.DB_PORT) config.persistence.postgres.port = parseInt(process.env.DB_PORT);
|
|
197
|
+
if (process.env.DB_NAME) config.persistence.postgres.database = process.env.DB_NAME;
|
|
198
|
+
if (process.env.DB_USER) config.persistence.postgres.user = process.env.DB_USER;
|
|
199
|
+
if (process.env.DB_PASSWORD) config.persistence.postgres.password = process.env.DB_PASSWORD;
|
|
200
|
+
if (process.env.DB_SSL === 'true') config.persistence.postgres.ssl = true;
|
|
201
|
+
}
|
|
183
202
|
} else if (config.persistence.type === 'redis') {
|
|
184
203
|
if (!config.persistence.redis) config.persistence.redis = { host: 'localhost', port: 6379 };
|
|
185
204
|
if (process.env.DB_HOST) config.persistence.redis.host = process.env.DB_HOST;
|
|
@@ -433,15 +452,34 @@ var initCommand = new Command("init").description("Initialize a new world projec
|
|
|
433
452
|
]);
|
|
434
453
|
let dbConfig = {};
|
|
435
454
|
if (persistenceAnswers.persistenceType === "postgres") {
|
|
436
|
-
|
|
437
|
-
{
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
455
|
+
const pgMethod = await inquirer.prompt([
|
|
456
|
+
{
|
|
457
|
+
type: "list",
|
|
458
|
+
name: "method",
|
|
459
|
+
message: "PostgreSQL connection method:",
|
|
460
|
+
choices: [
|
|
461
|
+
{ name: "Connection URL (Neon, Supabase, Railway, etc.)", value: "url" },
|
|
462
|
+
{ name: "Individual fields (host, port, user, password)", value: "fields" }
|
|
463
|
+
],
|
|
464
|
+
default: "url"
|
|
465
|
+
}
|
|
443
466
|
]);
|
|
444
|
-
|
|
467
|
+
if (pgMethod.method === "url") {
|
|
468
|
+
dbConfig = await inquirer.prompt([
|
|
469
|
+
{ type: "input", name: "connectionString", message: "PostgreSQL connection URL:", validate: (v) => v.startsWith("postgresql://") || v.startsWith("postgres://") || "Must be a postgresql:// or postgres:// URL" }
|
|
470
|
+
]);
|
|
471
|
+
dbConfig.ssl = true;
|
|
472
|
+
} else {
|
|
473
|
+
dbConfig = await inquirer.prompt([
|
|
474
|
+
{ type: "input", name: "host", message: "PostgreSQL host:", default: "localhost" },
|
|
475
|
+
{ type: "input", name: "port", message: "PostgreSQL port:", default: "5432", validate: (v) => !isNaN(Number(v)) || "Must be a number" },
|
|
476
|
+
{ type: "input", name: "database", message: "Database name:", default: "moltium_world" },
|
|
477
|
+
{ type: "input", name: "user", message: "Database user:", default: "postgres" },
|
|
478
|
+
{ type: "password", name: "password", message: "Database password:", mask: "*" },
|
|
479
|
+
{ type: "confirm", name: "ssl", message: "Enable SSL? (required for Neon, Supabase, etc.):", default: (answers2) => answers2.host !== "localhost" && answers2.host !== "127.0.0.1" }
|
|
480
|
+
]);
|
|
481
|
+
dbConfig.port = parseInt(dbConfig.port);
|
|
482
|
+
}
|
|
445
483
|
} else if (persistenceAnswers.persistenceType === "redis") {
|
|
446
484
|
dbConfig = await inquirer.prompt([
|
|
447
485
|
{ type: "input", name: "host", message: "Redis host:", default: "localhost" },
|
|
@@ -526,7 +564,7 @@ var initCommand = new Command("init").description("Initialize a new world projec
|
|
|
526
564
|
"deploy:contracts": "moltium-world deploy"
|
|
527
565
|
},
|
|
528
566
|
dependencies: {
|
|
529
|
-
"@moltium/world-core": "^0.1.
|
|
567
|
+
"@moltium/world-core": "^0.1.16",
|
|
530
568
|
dotenv: "^16.4.0",
|
|
531
569
|
...persistenceAnswers.persistenceType === "sqlite" ? { "better-sqlite3": "^11.0.0" } : {},
|
|
532
570
|
...persistenceAnswers.persistenceType === "redis" ? { "ioredis": "^5.3.0" } : {},
|
|
@@ -945,7 +983,7 @@ var deployCommand = new Command4("deploy").description("Deploy smart contracts t
|
|
|
945
983
|
|
|
946
984
|
// src/index.ts
|
|
947
985
|
var program = new Command5();
|
|
948
|
-
program.name("moltium-world").description("CLI tool for creating and managing Moltium World SDK projects").version("0.1.
|
|
986
|
+
program.name("moltium-world").description("CLI tool for creating and managing Moltium World SDK projects").version("0.1.16");
|
|
949
987
|
program.addCommand(initCommand);
|
|
950
988
|
program.addCommand(tokenCommand);
|
|
951
989
|
program.addCommand(startCommand);
|