Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix missing file issues when running solo from npm install -g #736

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@hashgraph/solo",
"version": "0.31.1",
"description": "An opinionated CLI tool to deploy and manage private Hedera Networks.",
"main": "dist/index.js",
"main": "dist/src/index.js",
"type": "module",
"bin": {
"solo": "dist/solo.js"
Expand Down
18 changes: 17 additions & 1 deletion resources/post-build-script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
'use strict'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import {fileURLToPath} from 'node:url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

//! Target directory
const distDir = path.resolve(__dirname, '../dist')
const srcPackageJsonFilePath = path.resolve(__dirname, '../package.json')
const targetPackageJsonFilePath = path.join(distDir, 'src', 'package.json')
const srcResourcesDir = path.join(__dirname, '../resources')
const targetResourcesDir = path.join(distDir, 'resources')

/** @param {string} filePath */
function replaceTsWithJs(filePath) {
Expand All @@ -33,6 +37,18 @@ function traverseDirectory(dir) {
}
}

function copyPackageJson(srcPackageJsonFilePath, targetPackageJsonFilePath) {
fs.copyFileSync(srcPackageJsonFilePath, targetPackageJsonFilePath)
}

function copyResources(srcDir, targetDir) {
fs.cpSync(srcDir, targetDir, {recursive: true})
}

console.time('Copy package.json')
copyPackageJson(srcPackageJsonFilePath, targetPackageJsonFilePath)
console.time('Copy resources')
copyResources(srcResourcesDir, targetResourcesDir)
console.time('Successfully replaced .ts extensions with .js')
traverseDirectory(distDir)
console.timeEnd('Successfully replaced .ts extensions with .js')
13 changes: 7 additions & 6 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { AccountId, FileId } from '@hashgraph/sdk'
import { color, type ListrLogger, PRESET_TIMER } from 'listr2'
import path, { normalize } from 'path'

export const ROOT_DIR = process.cwd()
export const ROOT_DIR = path.join(dirname(fileURLToPath(import.meta.url)), '..', '..')

// -------------------- solo related constants ---------------------------------------------------------------------
export const SOLO_HOME_DIR = process.env.SOLO_HOME || path.join(process.env.HOME as string, '.solo')
Expand Down Expand Up @@ -59,9 +59,9 @@ export const MIRROR_NODE_CHART_URL = 'https://hashgraph.github.io/hedera-mirror-
export const MIRROR_NODE_CHART = 'hedera-mirror'

export const DEFAULT_CHART_REPO: Map<string, string> = new Map()
.set(SOLO_TESTING_CHART, SOLO_TESTING_CHART_URL)
.set(JSON_RPC_RELAY_CHART, JSON_RPC_RELAY_CHART_URL)
.set(MIRROR_NODE_CHART, MIRROR_NODE_CHART_URL)
.set(SOLO_TESTING_CHART, SOLO_TESTING_CHART_URL)
.set(JSON_RPC_RELAY_CHART, JSON_RPC_RELAY_CHART_URL)
.set(MIRROR_NODE_CHART, MIRROR_NODE_CHART_URL)

// ------------------- Hedera Account related ---------------------------------------------------------------------------------
export const OPERATOR_ID = process.env.SOLO_OPERATOR_ID || '0.0.2'
Expand Down Expand Up @@ -105,10 +105,11 @@ export const LISTR_DEFAULT_RENDERER_OPTION = {
timer: LISTR_DEFAULT_RENDERER_TIMER_OPTION
} as {
collapseSubtasks: boolean
timer: { condition: (duration: number) => boolean
timer: {
condition: (duration: number) => boolean
format: (duration: number) => any
field: string | ((args_0: number) => string)
args?: [ number ]
args?: [number]
},
logger: ListrLogger
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import { type NodeAlias, type NodeAliases, type PodName } from '../types/aliases
import { type NodeDeleteConfigClass } from '../commands/node/configs.ts'
import { type CommandFlag } from '../types/index.ts'
import { type V1Pod } from '@kubernetes/client-node'
import { type SoloLogger } from './logging.js'
import { type NodeCommandHandlers } from '../commands/node/handlers.js'
import { type SoloLogger } from './logging.ts'
import { type NodeCommandHandlers } from '../commands/node/handlers.ts'

export function sleep (ms: number) {
return new Promise<void>((resolve) => {
Expand Down
Loading