mirror of
https://github.com/EvernodeXRPL/hp-devkit.git
synced 2026-04-29 15:37:58 +00:00
Resolved bug in hpdevkit clean command. (#18)
This commit is contained in:
committed by
GitHub
parent
01ff8a3c59
commit
d60bc7989e
@@ -1,12 +1,7 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
const { program } = require('commander');
|
||||
const { version, codeGen, bundle, deploy, clean, logs, start, stop, update, uninstall } = require('./lib/command-handler');
|
||||
|
||||
program
|
||||
.command('bundle <node-public-key> <contract-path>')
|
||||
.description('hpdevkit bundle <node-public-key> <contract-path>')
|
||||
.action(bundle);
|
||||
const { version, codeGen, deploy, clean, logs, start, stop, update, uninstall } = require('./lib/command-handler');
|
||||
|
||||
program
|
||||
.command('version')
|
||||
|
||||
@@ -74,82 +74,6 @@ function deploy(contractPath) {
|
||||
}
|
||||
}
|
||||
|
||||
function bundle(nodePublicKey, contractDirectoryPath) {
|
||||
info(`command: bundle`);
|
||||
|
||||
try {
|
||||
|
||||
contractDirectoryPath = path.normalize(contractDirectoryPath);
|
||||
let stats = fs.statSync(contractDirectoryPath);
|
||||
|
||||
if (!stats.isDirectory())
|
||||
throw 'You are supposed to provide a path of the contract directory.';
|
||||
|
||||
const overrideConfigPath = path.resolve(contractDirectoryPath, CONSTANTS.confOverrideFile);
|
||||
const contractConfigPath = path.resolve(contractDirectoryPath, CONSTANTS.contractCfgFile);
|
||||
const prerequisiteInstaller = path.resolve(contractDirectoryPath, CONSTANTS.prerequisiteInstaller);
|
||||
const overrideConfig = JSON.parse(fs.readFileSync(overrideConfigPath).toString());
|
||||
|
||||
const contractConfigs = {
|
||||
"version": "2.0",
|
||||
"unl": [
|
||||
`${nodePublicKey}`
|
||||
],
|
||||
"bin_path": `${overrideConfig?.contract.bin_path}`,
|
||||
"bin_args": `${overrideConfig?.contract.bin_args}`,
|
||||
"environment": {},
|
||||
"max_input_ledger_offset": 10,
|
||||
"consensus": {
|
||||
"mode": "private",
|
||||
"roundtime": 8000,
|
||||
"stage_slice": 25,
|
||||
"threshold": 50
|
||||
},
|
||||
"npl": {
|
||||
"mode": "private"
|
||||
},
|
||||
"appbill": {
|
||||
"mode": "",
|
||||
"bin_args": ""
|
||||
},
|
||||
"round_limits": {
|
||||
"user_input_bytes": 0,
|
||||
"user_output_bytes": 0,
|
||||
"npl_output_bytes": 0,
|
||||
"proc_cpu_seconds": 0,
|
||||
"proc_mem_bytes": 0,
|
||||
"proc_ofd_count": 0
|
||||
}
|
||||
}
|
||||
|
||||
// Write contract.config file content.
|
||||
fs.writeFileSync(contractConfigPath, JSON.stringify(contractConfigs, null, 4));
|
||||
info(`Prepared ${CONSTANTS.contractCfgFile} file.`);
|
||||
|
||||
// Add prerequisite install script.
|
||||
fs.writeFileSync(prerequisiteInstaller,
|
||||
`#!/bin/bash\n` +
|
||||
`echo "Prerequisite installer script"\n` +
|
||||
`exit 0`, null);
|
||||
|
||||
// Change permission pre-requisite installer.
|
||||
fs.chmodSync(prerequisiteInstaller, 0o755);
|
||||
info("Added prerequisite installer script.");
|
||||
|
||||
const bundleTargetPath = path.normalize(`${contractDirectoryPath}/../bundle`);
|
||||
|
||||
if (!fs.existsSync(bundleTargetPath)) {
|
||||
fs.mkdirSync(bundleTargetPath);
|
||||
}
|
||||
|
||||
archiveDirectory(contractDirectoryPath, bundleTargetPath);
|
||||
|
||||
} catch (e) {
|
||||
error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function clean() {
|
||||
info(`command: clean (cluster: ${appenv.cluster})`);
|
||||
|
||||
|
||||
@@ -101,8 +101,10 @@ function initializeDeploymentCluster() {
|
||||
}
|
||||
|
||||
function teardownDeploymentCluster() {
|
||||
exec(`docker stop ${CONSTANTS.deploymentContainerName}`);
|
||||
exec(`docker rm ${CONSTANTS.deploymentContainerName}`);
|
||||
if (isExists(CONSTANTS.deploymentContainerName)) {
|
||||
exec(`docker stop ${CONSTANTS.deploymentContainerName}`);
|
||||
exec(`docker rm ${CONSTANTS.deploymentContainerName}`);
|
||||
}
|
||||
runOnContainer(null, null, true, true, null, "cluster stop ; cluster destroy", null, false);
|
||||
}
|
||||
|
||||
|
||||
4
npm/package-lock.json
generated
4
npm/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "hpdevkit",
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hpdevkit",
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hpdevkit",
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"description": "Developer toolkit for HotPocket smart contract development",
|
||||
"scripts": {
|
||||
"install": "node scripts/install.js"
|
||||
|
||||
Reference in New Issue
Block a user