@moltium/world-cli 0.1.14 → 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 +60 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,12 +40,16 @@ 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,
|
|
47
50
|
user: options.dbConfig.user,
|
|
48
|
-
password: options.dbConfig.password
|
|
51
|
+
password: options.dbConfig.password,
|
|
52
|
+
...options.dbConfig.ssl && { ssl: true }
|
|
49
53
|
}
|
|
50
54
|
},
|
|
51
55
|
...options.persistenceType === "redis" && options.dbConfig && {
|
|
@@ -114,14 +118,22 @@ ${options.tokenType === "custom" ? "WORLD_TOKEN_ADDRESS=\n" : ""}
|
|
|
114
118
|
# MONAD_ETHERSCAN_KEY=
|
|
115
119
|
`;
|
|
116
120
|
if (options.persistenceType === "postgres") {
|
|
117
|
-
|
|
121
|
+
if (options.dbConfig?.connectionString) {
|
|
122
|
+
env += `
|
|
123
|
+
# PostgreSQL Configuration (Connection URL)
|
|
124
|
+
DATABASE_URL=${options.dbConfig.connectionString}
|
|
125
|
+
`;
|
|
126
|
+
} else {
|
|
127
|
+
env += `
|
|
118
128
|
# PostgreSQL Configuration
|
|
119
129
|
DB_HOST=${options.dbConfig?.host || "localhost"}
|
|
120
130
|
DB_PORT=${options.dbConfig?.port || "5432"}
|
|
121
131
|
DB_NAME=${options.dbConfig?.database || "moltium_world"}
|
|
122
132
|
DB_USER=${options.dbConfig?.user || "postgres"}
|
|
123
133
|
DB_PASSWORD=${options.dbConfig?.password || ""}
|
|
134
|
+
DB_SSL=${options.dbConfig?.ssl ? "true" : "false"}
|
|
124
135
|
`;
|
|
136
|
+
}
|
|
125
137
|
} else if (options.persistenceType === "redis") {
|
|
126
138
|
env += `
|
|
127
139
|
# Redis Configuration
|
|
@@ -171,12 +183,22 @@ async function main() {
|
|
|
171
183
|
|
|
172
184
|
if (config.persistence) {
|
|
173
185
|
if (config.persistence.type === 'postgres') {
|
|
174
|
-
if (!config.persistence.postgres) config.persistence.postgres = {
|
|
175
|
-
if (process.env.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
+
}
|
|
180
202
|
} else if (config.persistence.type === 'redis') {
|
|
181
203
|
if (!config.persistence.redis) config.persistence.redis = { host: 'localhost', port: 6379 };
|
|
182
204
|
if (process.env.DB_HOST) config.persistence.redis.host = process.env.DB_HOST;
|
|
@@ -430,14 +452,34 @@ var initCommand = new Command("init").description("Initialize a new world projec
|
|
|
430
452
|
]);
|
|
431
453
|
let dbConfig = {};
|
|
432
454
|
if (persistenceAnswers.persistenceType === "postgres") {
|
|
433
|
-
|
|
434
|
-
{
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
+
}
|
|
439
466
|
]);
|
|
440
|
-
|
|
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
|
+
}
|
|
441
483
|
} else if (persistenceAnswers.persistenceType === "redis") {
|
|
442
484
|
dbConfig = await inquirer.prompt([
|
|
443
485
|
{ type: "input", name: "host", message: "Redis host:", default: "localhost" },
|
|
@@ -522,7 +564,7 @@ var initCommand = new Command("init").description("Initialize a new world projec
|
|
|
522
564
|
"deploy:contracts": "moltium-world deploy"
|
|
523
565
|
},
|
|
524
566
|
dependencies: {
|
|
525
|
-
"@moltium/world-core": "^0.1.
|
|
567
|
+
"@moltium/world-core": "^0.1.16",
|
|
526
568
|
dotenv: "^16.4.0",
|
|
527
569
|
...persistenceAnswers.persistenceType === "sqlite" ? { "better-sqlite3": "^11.0.0" } : {},
|
|
528
570
|
...persistenceAnswers.persistenceType === "redis" ? { "ioredis": "^5.3.0" } : {},
|
|
@@ -941,7 +983,7 @@ var deployCommand = new Command4("deploy").description("Deploy smart contracts t
|
|
|
941
983
|
|
|
942
984
|
// src/index.ts
|
|
943
985
|
var program = new Command5();
|
|
944
|
-
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");
|
|
945
987
|
program.addCommand(initCommand);
|
|
946
988
|
program.addCommand(tokenCommand);
|
|
947
989
|
program.addCommand(startCommand);
|