Skip to content

Commit

Permalink
add command to print the json schema of the config (#361)
Browse files Browse the repository at this point in the history
* add command to print the json schema of the config

* paima-utils: export BaseConfigWithoutDefaults
  • Loading branch information
ecioppettini authored May 8, 2024
1 parent b5f79ba commit 9ee0fe3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/engine/paima-standalone/src/utils/input.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FunnelFactory } from '@paima/funnel';
import paimaRuntime, { registerDocs, registerValidationErrorHandler } from '@paima/runtime';
import { ENV, GlobalConfig, doLog } from '@paima/utils';
import { ENV, GlobalConfig, doLog, BaseConfigWithoutDefaults } from '@paima/utils';
import { exec } from 'child_process';
import { createInterface } from 'readline';
import { gameSM } from '../sm.js';
Expand Down Expand Up @@ -64,6 +64,10 @@ export const argumentRouter = async (): Promise<void> => {
batcherCommand();
break;

case 'gen-config-json-schema':
genConfigSchemaCommand();
break;

default:
helpCommand();
}
Expand Down Expand Up @@ -167,13 +171,18 @@ export const helpCommand = (): void => {
doLog(` help Shows list of commands currently available.`);
doLog(` version Shows the version of used paima-engine.`);
doLog(` batcher Saves the bundled batcher project to your local filesystem.`);
doLog(` gen-config-json-schema Prints the JSON Schema for the engine configuration.`);
};

// Batcher command logic
export const batcherCommand = (): void => {
prepareBatcher();
};

export const configJsonSchema = (): void => {
genConfigSchemaCommand();
};

// Build middleware for specific .env file and launch webserver:
const startWebServer = (): Promise<void> =>
new Promise((resolve, reject) => {
Expand Down Expand Up @@ -249,3 +258,7 @@ const pickGameTemplate = async (templateArg: string): Promise<Template> => {
doLog(`Unknown selection, ${defaultTemplate} will be used.`);
return defaultTemplate;
};

function genConfigSchemaCommand() {
doLog(JSON.stringify(BaseConfigWithoutDefaults));
}
2 changes: 2 additions & 0 deletions packages/paima-sdk/paima-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
defaultEvmMainNetworkName,
defaultCardanoNetworkName,
defaultMinaNetworkName,
BaseConfigWithoutDefaults,
} from './config/loading.js';

export * from './config.js';
Expand All @@ -41,6 +42,7 @@ export {
defaultEvmMainNetworkName,
defaultCardanoNetworkName,
defaultMinaNetworkName,
BaseConfigWithoutDefaults,
};

export const DEFAULT_GAS_PRICE = '61000000000' as const;
Expand Down

0 comments on commit 9ee0fe3

Please sign in to comment.