genlayer 0.9.0 → 0.10.0-beta.0

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/.env.example CHANGED
@@ -69,7 +69,7 @@ VALIDATORS_CONFIG_JSON=''
69
69
 
70
70
 
71
71
  VSCODEDEBUG="false"
72
- LOCALNETVERSION="latest"
72
+ LOCALNETVERSION="v0.29.0"
73
73
 
74
74
  FRONTEND_BUILD_TARGET = 'final' # change to 'dev' to run in dev mode
75
75
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
 
2
2
 
3
+ ## 0.10.0-beta.0 (2024-12-13)
4
+
5
+
6
+ ### Features
7
+
8
+ * new global var to deal with compatible version ([33a4c02](https://github.com/yeagerai/genlayer-cli/commit/33a4c02f091e87faf1b884177ee854fe1b66f52b))
9
+
10
+ ## 0.9.1 (2024-12-13)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * removing volumes to stop error when running node without nvm ([#156](https://github.com/yeagerai/genlayer-cli/issues/156)) ([189c759](https://github.com/yeagerai/genlayer-cli/commit/189c7592fedb6373e3603f1bdb4366c79f289160))
16
+
3
17
  ## 0.9.0 (2024-12-13)
4
18
 
5
19
 
package/dist/index.js CHANGED
@@ -58904,7 +58904,7 @@ var {
58904
58904
  } = import_index.default;
58905
58905
 
58906
58906
  // package.json
58907
- var version = "0.9.0";
58907
+ var version = "0.10.0-beta.0";
58908
58908
  var package_default = {
58909
58909
  name: "genlayer",
58910
58910
  version,
@@ -59040,12 +59040,14 @@ function v4(options, buf, offset) {
59040
59040
  var v4_default = v4;
59041
59041
 
59042
59042
  // src/lib/config/simulator.ts
59043
+ var localnetCompatibleVersion = "v0.29.0";
59043
59044
  var DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
59044
- var DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX = "/genlayer-cli-";
59045
+ var CONTAINERS_NAME_PREFIX = "/genlayer-";
59046
+ var IMAGES_NAME_PREFIX = "yeagerai";
59045
59047
  var DEFAULT_RUN_SIMULATOR_COMMAND = (location, options) => ({
59046
- darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose up ${options}"'`,
59047
- win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose up && pause ${options}"`,
59048
- linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose up -d ${options}'`
59048
+ darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose -p genlayer up ${options}"'`,
59049
+ win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose -p genlayer up ${options} && pause"`,
59050
+ linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose -p genlayer up ${options} -d '`
59049
59051
  });
59050
59052
  var DEFAULT_RUN_DOCKER_COMMAND = {
59051
59053
  darwin: "open -a Docker",
@@ -59637,7 +59639,6 @@ var SimulatorService = class {
59637
59639
  }
59638
59640
  addConfigToEnvFile(newConfig) {
59639
59641
  const envFilePath = path2.join(this.location, ".env");
59640
- fs5.writeFileSync(`${envFilePath}.bak`, fs5.readFileSync(envFilePath));
59641
59642
  const envConfig = dotenv.parse(fs5.readFileSync(envFilePath, "utf8"));
59642
59643
  Object.keys(newConfig).forEach((key) => {
59643
59644
  envConfig[key] = newConfig[key];
@@ -59793,7 +59794,7 @@ Run npm install -g genlayer to update
59793
59794
  const containers = await this.docker.listContainers({ all: true });
59794
59795
  const genlayerContainers = containers.filter(
59795
59796
  (container) => container.Names.some(
59796
- (name) => name.startsWith(DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX)
59797
+ (name) => name.startsWith(CONTAINERS_NAME_PREFIX)
59797
59798
  )
59798
59799
  );
59799
59800
  for (const containerInfo of genlayerContainers) {
@@ -59808,7 +59809,7 @@ Run npm install -g genlayer to update
59808
59809
  async resetDockerImages() {
59809
59810
  const images = await this.docker.listImages();
59810
59811
  const genlayerImages = images.filter(
59811
- (image) => image.RepoTags?.some((tag) => tag.startsWith(DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX))
59812
+ (image) => image.RepoTags?.some((tag) => tag.startsWith(IMAGES_NAME_PREFIX))
59812
59813
  );
59813
59814
  for (const imageInfo of genlayerImages) {
59814
59815
  const image = this.docker.getImage(imageInfo.Id);
@@ -62670,7 +62671,7 @@ async function startAction(options, simulatorService) {
62670
62671
 
62671
62672
  // src/commands/general/index.ts
62672
62673
  function initializeGeneralCommands(program2) {
62673
- program2.command("init").description("Initialize the GenLayer Environment").option("--numValidators <numValidators>", "Number of validators", "5").option("--headless", "Headless mode", false).option("--reset-db", "Reset Database", false).option("--localnet-version <localnetVersion>", "Select a specific localnet version", "latest").action((options) => initAction(options, simulator_default));
62674
+ program2.command("init").description("Initialize the GenLayer Environment").option("--numValidators <numValidators>", "Number of validators", "5").option("--headless", "Headless mode", false).option("--reset-db", "Reset Database", false).option("--localnet-version <localnetVersion>", "Select a specific localnet version", localnetCompatibleVersion).action((options) => initAction(options, simulator_default));
62674
62675
  program2.command("up").description("Starts GenLayer's simulator").option("--reset-validators", "Remove all current validators and create new random ones", false).option("--numValidators <numValidators>", "Number of validators", "5").option("--headless", "Headless mode", false).option("--reset-db", "Reset Database", false).action((options) => startAction(options, simulator_default));
62675
62676
  return program2;
62676
62677
  }
@@ -7,8 +7,8 @@ services:
7
7
  - "${FRONTEND_PORT:-8080}:8080"
8
8
  environment:
9
9
  - VITE_*
10
- volumes:
11
- - ./.env:/app/.env
10
+ env_file:
11
+ - ./.env
12
12
  depends_on:
13
13
  jsonrpc:
14
14
  condition: service_healthy
@@ -36,8 +36,8 @@ services:
36
36
  ports:
37
37
  - "${RPCPORT:-5000}:${RPCPORT:-5000}"
38
38
  - "${RPCDEBUGPORT:-5001}:${RPCDEBUGPORT:-5001}"
39
- volumes:
40
- - ./.env:/app/.env
39
+ env_file:
40
+ - ./.env
41
41
  healthcheck:
42
42
  test: [ "CMD", "python", "backend/healthcheck.py", "--port", "${RPCPORT}" ]
43
43
  interval: 30s
@@ -75,8 +75,8 @@ services:
75
75
  expose:
76
76
  - "${WEBREQUESTPORT:-5002}:${WEBREQUESTPORT:-5002}"
77
77
  - "${WEBREQUESTSELENIUMPORT:-4444}:${WEBREQUESTSELENIUMPORT:-4444}"
78
- volumes:
79
- - ./.env:/app/webrequest/.env
78
+ env_file:
79
+ - ./.env
80
80
  depends_on:
81
81
  ollama:
82
82
  condition: service_started
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genlayer",
3
- "version": "0.9.0",
3
+ "version": "0.10.0-beta.0",
4
4
  "description": "GenLayer Command Line Tool",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
@@ -1,7 +1,9 @@
1
1
  import { Command } from "commander";
2
+
2
3
  import simulatorService from "../../lib/services/simulator";
3
4
  import { initAction, InitActionOptions } from "./init";
4
5
  import { startAction, StartActionOptions } from "./start";
6
+ import {localnetCompatibleVersion} from "../../lib/config/simulator";
5
7
 
6
8
  export function initializeGeneralCommands(program: Command) {
7
9
  program
@@ -10,7 +12,7 @@ export function initializeGeneralCommands(program: Command) {
10
12
  .option("--numValidators <numValidators>", "Number of validators", "5")
11
13
  .option("--headless", "Headless mode", false)
12
14
  .option("--reset-db", "Reset Database", false)
13
- .option("--localnet-version <localnetVersion>", "Select a specific localnet version", "latest")
15
+ .option("--localnet-version <localnetVersion>", "Select a specific localnet version", localnetCompatibleVersion)
14
16
  .action((options: InitActionOptions) => initAction(options, simulatorService));
15
17
 
16
18
  program
@@ -147,7 +147,6 @@ export async function initAction(options: InitActionOptions, simulatorService: I
147
147
  simulatorService.addConfigToEnvFile(aiProvidersEnvVars);
148
148
  simulatorService.addConfigToEnvFile({LOCALNETVERSION: localnetVersion});
149
149
 
150
-
151
150
  // Run the GenLayer Simulator
152
151
  console.log("Running the GenLayer Simulator...");
153
152
  try {
@@ -1,9 +1,11 @@
1
+ export const localnetCompatibleVersion = "v0.29.0";
1
2
  export const DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
2
- export const DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX = "/genlayer-cli-";
3
+ export const CONTAINERS_NAME_PREFIX = "/genlayer-";
4
+ export const IMAGES_NAME_PREFIX = "yeagerai";
3
5
  export const DEFAULT_RUN_SIMULATOR_COMMAND = (location: string, options: string) => ({
4
- darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose up ${options}"'`,
5
- win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose up && pause ${options}"`,
6
- linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose up -d ${options}'`,
6
+ darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose -p genlayer up ${options}"'`,
7
+ win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose -p genlayer up ${options} && pause"`,
8
+ linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose -p genlayer up ${options} -d '`,
7
9
  });
8
10
  export const DEFAULT_RUN_DOCKER_COMMAND = {
9
11
  darwin: "open -a Docker",
@@ -8,7 +8,6 @@ import pkg from '../../../package.json'
8
8
 
9
9
  import {rpcClient} from "../clients/jsonRpcClient";
10
10
  import {
11
- DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX,
12
11
  DEFAULT_RUN_SIMULATOR_COMMAND,
13
12
  DEFAULT_RUN_DOCKER_COMMAND,
14
13
  STARTING_TIMEOUT_WAIT_CYLCE,
@@ -16,6 +15,8 @@ import {
16
15
  AI_PROVIDERS_CONFIG,
17
16
  AiProviders,
18
17
  VERSION_REQUIREMENTS,
18
+ CONTAINERS_NAME_PREFIX,
19
+ IMAGES_NAME_PREFIX
19
20
  } from "../config/simulator";
20
21
  import {
21
22
  checkCommand,
@@ -50,9 +51,6 @@ export class SimulatorService implements ISimulatorService {
50
51
  public addConfigToEnvFile(newConfig: Record<string, string>): void {
51
52
  const envFilePath = path.join(this.location, ".env");
52
53
 
53
- // Create a backup of the original .env file
54
- fs.writeFileSync(`${envFilePath}.bak`, fs.readFileSync(envFilePath));
55
-
56
54
  // Transform the config string to object
57
55
  const envConfig = dotenv.parse(fs.readFileSync(envFilePath, "utf8"));
58
56
  Object.keys(newConfig).forEach(key => {
@@ -257,7 +255,7 @@ export class SimulatorService implements ISimulatorService {
257
255
  const containers = await this.docker.listContainers({ all: true });
258
256
  const genlayerContainers = containers.filter(container =>
259
257
  container.Names.some(name =>
260
- name.startsWith(DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX)
258
+ name.startsWith(CONTAINERS_NAME_PREFIX)
261
259
  )
262
260
  );
263
261
 
@@ -274,7 +272,7 @@ export class SimulatorService implements ISimulatorService {
274
272
  public async resetDockerImages(): Promise<boolean> {
275
273
  const images = await this.docker.listImages();
276
274
  const genlayerImages = images.filter(image =>
277
- image.RepoTags?.some(tag => tag.startsWith(DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX))
275
+ image.RepoTags?.some(tag => tag.startsWith(IMAGES_NAME_PREFIX))
278
276
  );
279
277
 
280
278
  for (const imageInfo of genlayerImages) {
@@ -7,6 +7,7 @@ import {mkdtempSync} from "fs";
7
7
  import {join} from "path";
8
8
  import fs from "fs";
9
9
  import * as dotenv from "dotenv";
10
+ import {localnetCompatibleVersion} from "../../src/lib/config/simulator";
10
11
 
11
12
 
12
13
  vi.mock("fs");
@@ -14,7 +15,7 @@ vi.mock("dotenv");
14
15
 
15
16
 
16
17
  const tempDir = mkdtempSync(join(tmpdir(), "test-initAction-"));
17
- const defaultActionOptions = { numValidators: 5, branch: "main", location: tempDir, headless: false, resetDb: false, localnetVersion: 'latest' };
18
+ const defaultActionOptions = { numValidators: 5, branch: "main", location: tempDir, headless: false, resetDb: false, localnetVersion: localnetCompatibleVersion };
18
19
 
19
20
  describe("init action", () => {
20
21
  let error: ReturnType<any>;
@@ -3,13 +3,14 @@ import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
3
3
  import { initializeGeneralCommands } from "../../src/commands/general";
4
4
  import { getCommand, getCommandOption } from "../utils";
5
5
  import simulatorService from '../../src/lib/services/simulator'
6
+ import {localnetCompatibleVersion} from "../../src/lib/config/simulator";
6
7
 
7
8
  const openFrontendSpy = vi.spyOn(simulatorService, "openFrontend");
8
9
  const defaultOptions = {
9
10
  numValidators: "5",
10
11
  headless: false,
11
12
  resetDb: false,
12
- localnetVersion: 'latest'
13
+ localnetVersion: localnetCompatibleVersion
13
14
  }
14
15
 
15
16
  vi.mock("inquirer", () => ({
@@ -10,10 +10,10 @@ import {
10
10
  checkCommand,
11
11
  } from "../../src/lib/clients/system";
12
12
  import {
13
- DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX,
13
+ CONTAINERS_NAME_PREFIX,
14
14
  VERSION_REQUIREMENTS,
15
15
  STARTING_TIMEOUT_ATTEMPTS,
16
- DEFAULT_RUN_SIMULATOR_COMMAND,
16
+ DEFAULT_RUN_SIMULATOR_COMMAND, localnetCompatibleVersion, IMAGES_NAME_PREFIX,
17
17
  } from "../../src/lib/config/simulator";
18
18
  import { rpcClient } from "../../src/lib/clients/jsonRpcClient";
19
19
  import * as semver from "semver";
@@ -173,7 +173,6 @@ describe("SimulatorService - Basic Tests", () => {
173
173
 
174
174
  simulatorService.addConfigToEnvFile(newConfig);
175
175
 
176
- expect(writeFileSyncMock).toHaveBeenCalledWith(`${envFilePath}.bak`, "");
177
176
  const expectedUpdatedContent = `NEW_KEY=newValue`;
178
177
  expect(writeFileSyncMock).toHaveBeenCalledWith(envFilePath, expectedUpdatedContent);
179
178
  });
@@ -376,12 +375,12 @@ describe("SimulatorService - Docker Tests", () => {
376
375
  const mockContainers = [
377
376
  {
378
377
  Id: "container1",
379
- Names: [`${DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX}container1`],
378
+ Names: [`${CONTAINERS_NAME_PREFIX}container1`],
380
379
  State: "running",
381
380
  },
382
381
  {
383
382
  Id: "container2",
384
- Names: [`${DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX}container2`],
383
+ Names: [`${CONTAINERS_NAME_PREFIX}container2`],
385
384
  State: "exited",
386
385
  },
387
386
  {
@@ -418,11 +417,11 @@ describe("SimulatorService - Docker Tests", () => {
418
417
  const mockImages = [
419
418
  {
420
419
  Id: "image1",
421
- RepoTags: [`${DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX}image1:latest`],
420
+ RepoTags: [`${IMAGES_NAME_PREFIX}image1:${localnetCompatibleVersion}`],
422
421
  },
423
422
  {
424
423
  Id: "image2",
425
- RepoTags: [`${DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX}image2:latest`],
424
+ RepoTags: [`${IMAGES_NAME_PREFIX}image2:${localnetCompatibleVersion}`],
426
425
  },
427
426
  {
428
427
  Id: "image3",