Skip to content

Commit ebbe79d

Browse files
committed
fix missing file issues when running solo from npm install -g
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 3ed4120 commit ebbe79d

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@hashgraph/solo",
33
"version": "0.31.2",
44
"description": "An opinionated CLI tool to deploy and manage private Hedera Networks.",
5-
"main": "dist/index.js",
5+
"main": "dist/src/index.js",
66
"type": "module",
77
"bin": {
88
"solo": "dist/solo.js"

resources/post-build-script.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
'use strict'
22
import fs from 'node:fs'
33
import path from 'node:path'
4-
import { fileURLToPath } from 'node:url'
4+
import {fileURLToPath} from 'node:url'
55

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

88
//! Target directory
99
const distDir = path.resolve(__dirname, '../dist')
10+
const srcPackageJsonFilePath = path.resolve(__dirname, '../package.json')
11+
const targetPackageJsonFilePath = path.join(distDir, 'src', 'package.json')
12+
const srcResourcesDir = path.join(__dirname, '../resources')
13+
const targetResourcesDir = path.join(distDir, 'resources')
1014

1115
/** @param {string} filePath */
1216
function replaceTsWithJs(filePath) {
@@ -33,6 +37,18 @@ function traverseDirectory(dir) {
3337
}
3438
}
3539

40+
function copyPackageJson(srcPackageJsonFilePath, targetPackageJsonFilePath) {
41+
fs.copyFileSync(srcPackageJsonFilePath, targetPackageJsonFilePath)
42+
}
43+
44+
function copyResources(srcDir, targetDir) {
45+
fs.cpSync(srcDir, targetDir, {recursive: true})
46+
}
47+
48+
console.time('Copy package.json')
49+
copyPackageJson(srcPackageJsonFilePath, targetPackageJsonFilePath)
50+
console.time('Copy resources')
51+
copyResources(srcResourcesDir, targetResourcesDir)
3652
console.time('Successfully replaced .ts extensions with .js')
3753
traverseDirectory(distDir)
3854
console.timeEnd('Successfully replaced .ts extensions with .js')

src/core/constants.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ import { color, type ListrLogger, PRESET_TIMER } from 'listr2'
2020
import path, { dirname, normalize } from 'path'
2121
import { fileURLToPath } from 'url'
2222

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

2525
// -------------------- solo related constants ---------------------------------------------------------------------
26-
export const CUR_FILE_DIR = dirname(fileURLToPath(import.meta.url))
2726
export const SOLO_HOME_DIR = process.env.SOLO_HOME || path.join(process.env.HOME as string, '.solo')
2827
export const SOLO_LOGS_DIR = path.join(SOLO_HOME_DIR, 'logs')
2928
export const SOLO_CACHE_DIR = path.join(SOLO_HOME_DIR, 'cache')
@@ -63,9 +62,9 @@ export const MIRROR_NODE_CHART_URL = 'https://hashgraph.github.io/hedera-mirror-
6362
export const MIRROR_NODE_CHART = 'hedera-mirror'
6463

6564
export const DEFAULT_CHART_REPO: Map<string, string> = new Map()
66-
.set(SOLO_TESTING_CHART, SOLO_TESTING_CHART_URL)
67-
.set(JSON_RPC_RELAY_CHART, JSON_RPC_RELAY_CHART_URL)
68-
.set(MIRROR_NODE_CHART, MIRROR_NODE_CHART_URL)
65+
.set(SOLO_TESTING_CHART, SOLO_TESTING_CHART_URL)
66+
.set(JSON_RPC_RELAY_CHART, JSON_RPC_RELAY_CHART_URL)
67+
.set(MIRROR_NODE_CHART, MIRROR_NODE_CHART_URL)
6968

7069
// ------------------- Hedera Account related ---------------------------------------------------------------------------------
7170
export const OPERATOR_ID = process.env.SOLO_OPERATOR_ID || '0.0.2'
@@ -115,10 +114,11 @@ export const LISTR_DEFAULT_RENDERER_OPTION = {
115114
timer: LISTR_DEFAULT_RENDERER_TIMER_OPTION
116115
} as {
117116
collapseSubtasks: boolean
118-
timer: { condition: (duration: number) => boolean
117+
timer: {
118+
condition: (duration: number) => boolean
119119
format: (duration: number) => any
120120
field: string | ((args_0: number) => string)
121-
args?: [ number ]
121+
args?: [number]
122122
},
123123
logger: ListrLogger
124124
}

src/core/helpers.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
*/
1717
import fs from 'fs'
1818
import os from 'os'
19-
import path, * as paths from 'path'
19+
import path from 'path'
2020
import util from 'util'
2121
import { SoloError } from './errors.ts'
22-
import { fileURLToPath } from 'url'
2322
import * as semver from 'semver'
2423
import { Templates } from './templates.ts'
2524
import { HEDERA_HAPI_PATH, ROOT_CONTAINER, SOLO_LOGS_DIR } from './constants.ts'
@@ -33,9 +32,6 @@ import { type NodeAlias, type NodeAliases, type PodName } from '../types/aliases
3332
import { type NodeDeleteConfigClass } from '../commands/node.ts'
3433
import { type CommandFlag } from '../types/index.js'
3534

36-
// cache current directory
37-
const CUR_FILE_DIR = paths.dirname(fileURLToPath(import.meta.url))
38-
3935
export function sleep (ms: number) {
4036
return new Promise<void>((resolve) => {
4137
setTimeout(resolve, ms)

0 commit comments

Comments
 (0)