Skip to content
Permalink
Browse files

bunch of updates (#315)

* refact: remove useless deps

- lerna
- slugify
- ramda
- markdown-table
- json-stringify-pretty-compact
- git-url-parse
- glob

* chore: bunch of updates

- set default block commit_timeout to 1s
- fix get starter process bug
- fix start output in `single chain` mode
- better read config exception handle

* feat: ignore fetch remote releases error when list local releases #299

* chore: remove non-root doc if run with root user #279

* breaking change: change account/blocklet/chain/contract/install/tx subcommands

1. deprecate outdated alias
1. unify `*:list` to `*:ls`

Related issue: #300

* bump version
  • Loading branch information
polunzh committed Oct 30, 2019
1 parent c587b6e commit 2a7d34eae5c241ec86aab41c416638ab13348ceb

This file was deleted.

@@ -1,3 +1,11 @@
## 0.39.27 (October 30, 2019)

- breaking change: change account/blocklet/chain/contract/install/tx subcommands #300
- chore: remove non-root doc if run with root user #279
- feat: ignore fetch remote releases error when list local releases #299
- chore: bunch of updates
- refact: remove useless deps

## 0.39.26 (October 30, 2019)

- fix: cache failed
@@ -1,6 +1,6 @@
{
"name": "@arcblock/forge-cli",
"version": "0.39.26",
"version": "0.39.27",
"description": "a general set of CLI for arcblock Forge framework",
"license": "Apache-2.0",
"main": "src/index.js",
@@ -90,18 +90,14 @@
"fuzzy": "^0.1.3",
"get-port": "^5.0.0",
"getos": "^3.1.1",
"git-url-parse": "^11.1.2",
"glob": "^7.1.2",
"inquirer": "^5.2.0",
"inquirer-autocomplete-prompt": "^0.12.2",
"internal-ip": "^4.3.0",
"is-elevated": "^3.0.0",
"is-ip": "^3.1.0",
"json-stringify-pretty-compact": "^1.2.0",
"leven": "^3.1.0",
"lodash": "4.17.14",
"log-symbols": "^2.2.0",
"markdown-table": "^1.1.2",
"moment": "^2.22.2",
"mustache": "^2.3.0",
"numeral": "^2.0.6",
@@ -112,14 +108,12 @@
"pretty-ms": "^4.0.0",
"prettyjson": "^1.2.1",
"progress": "^2.0.3",
"ramda": "^0.25.0",
"rc": "^1.2.8",
"rcfile": "^1.0.3",
"registry-url": "^5.1.0",
"safe-eval": "^0.4.1",
"semver": "^5.6.0",
"shelljs": "^0.8.1",
"slugify": "^1.3.0",
"tar": "^4.4.10",
"yaml": "^1.3.2"
},
@@ -132,7 +126,6 @@
"eslint-plugin-prettier": "latest",
"husky": "^2.3.0",
"jest": "^24.7.1",
"lerna": "^3.3.2",
"lint-staged": "^7.2.2",
"prettier": "^1.6.1",
"rewire": "^4.0.1"
@@ -4,7 +4,7 @@ const { getTopRunningChains } = require('core/forge-process');
const { execute, run } = require('./list');

cli(
'account:list [role]',
'account:ls [role]',
'List all accounts stored in this node',
input => action(execute, run, input),
{
@@ -15,8 +15,5 @@ cli(
currentChainRunning: true,
chainName: getTopRunningChains,
},
options: [
// ['--some-option [value]', 'some test option'],
],
}
);
@@ -6,7 +6,6 @@ const { print } = require('core/util');
const { execute, run } = require('./use');

cli('blocklet:use', 'Download and install a blocklet', input => action(execute, run, input), {
alias: 'project:create',
requirements: {
forgeRelease: false,
runningNode: false,
@@ -208,7 +208,7 @@ async function readUserConfigs(
type: 'number',
name: 'blockTime',
message: 'Please input block time (in seconds):',
default: parseInt(defaults.tendermint.timeout_commit, 10),
default: 1,
validate: getNumberValidator('block time'),
},
{
@@ -8,7 +8,6 @@ cli(
'Create a new chain instance',
input => action(execute, run, input),
{
alias: 'create-chain',
parseArgs: chainName => ({
chainName,
}),
@@ -3,7 +3,6 @@ const { cli, action } = require('core/cli');
const { execute, run } = require('./list');

cli('chain:ls', 'List all chains', input => action(execute, run, input), {
alias: 'chains',
requirements: {
forgeRelease: false,
rpcClient: false,
@@ -11,7 +11,6 @@ cli(
'Download and setup forge release on this machine',
input => action(execute, run, input),
{
alias: 'init',
requirements: {
forgeRelease: false,
rpcClient: false,
@@ -32,20 +32,20 @@ async function main({
}

async function start(chainName, dryRun = false, allowMultiChain) {
if (await isForgeStarted(chainName)) {
printInfo(`Chain ${chalk.cyan(chalk.cyan(chainName))} is already started!`);
return true;
}

if (allowMultiChain === false) {
const runningChains = await getAllRunningProcesses();
if (runningChains.length > 0) {
printInfo(`Chain ${chalk.cyan(chalk.cyan(chainName))} is already started!`);
printError('Forge CLI is configured to work with single chain only, abort!');
await printAllProcesses();
return true;
return false;
}
}

if (await isForgeStarted(chainName)) {
printInfo(`Chain ${chalk.cyan(chalk.cyan(chainName))} is already started!`);
return true;
}

const { starterBinPath, forgeBinPath, forgeConfigPath } = config.get('cli');

const { shell: envShell, homedir } = getOSUserInfo();
@@ -3,7 +3,7 @@ const { cli, action } = require('core/cli');
const { getTopRunningChains } = require('core/forge-process');
const { execute, run } = require('./list');

cli('tx:list', 'List latest transactions', input => action(execute, run, input), {
cli('tx:ls', 'List latest transactions', input => action(execute, run, input), {
requirements: {
forgeRelease: true,
runningNode: true,
@@ -358,18 +358,12 @@ function findReleaseVersion(releaseDir) {
async function ensureNonRoot() {
try {
if (await isElevated()) {
shell.echo(
`${symbols.error} ${chalk.red('Error: forge cannot be started with root permission')}`
);
shell.echo(
`${symbols.info} Checkout the following guide on how to run forge as non-root user`
);
shell.echo('https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md');
printError(`${chalk.red('Error: forge cannot be started with root permission')}`);
process.exit(77);
}
} catch (err) {
debug.error(err);
shell.echo(`${symbols.error} cannot get current username`);
printError('Cannot get current username');
}
}

@@ -14,6 +14,7 @@ const {
chainSortHandler,
fetchReleaseAssetsInfo,
getPlatform,
logError,
print,
printWarning,
printInfo,
@@ -43,14 +44,21 @@ const readChainConfigFromEnv = () => {
};

const readChainConfig = (chainName, key, defaultValue = '') => {
const configPath = getChainReleaseFilePath(chainName);
const config = TOML.parse(fs.readFileSync(configPath).toString());
let configPath = '';

if (!key) {
return config;
}
try {
configPath = getChainReleaseFilePath(chainName);
const config = TOML.parse(fs.readFileSync(configPath).toString());

if (!key) {
return config;
}

return get(config, key, defaultValue);
return get(config, key, defaultValue);
} catch (error) {
logError(error);
throw new Error(`read ${chainName} config ${configPath} failed: ${error.message}`);
}
};

function clearDataDirectories(chainName = process.env.FORGE_CURRENT_CHAIN, keepConfig = false) {
@@ -110,17 +118,32 @@ async function getLocalReleases() {

async function listReleases() {
const platform = await getPlatform();
const remoteReleasesInfo = (await fetchReleaseAssetsInfo(platform)) || [];
let remoteReleasesInfo = [];
try {
remoteReleasesInfo = await fetchReleaseAssetsInfo(platform);
} catch (error) {
debug('fetch remote releases information failed:', error.message);
logError(error);
}

const versionAssetsMap = await getLocalReleases();

const result = [];
let result = Object.keys(versionAssetsMap)
.map(version => {
if (versionAssetsMap[version]) {
return { version, assets: versionAssetsMap[version] };
}

Object.keys(versionAssetsMap).forEach(version => {
const tmp = remoteReleasesInfo.find(x => semver.eq(x.version, version));
if (versionAssetsMap[version] && isEqual(versionAssetsMap[version], tmp.assets)) {
result.push({ version, assets: versionAssetsMap[version] });
}
});
return null;
})
.filter(Boolean);

if (remoteReleasesInfo.length > 0) {
result = result.filter(({ version, assets }) => {
const tmp = remoteReleasesInfo.find(x => semver.eq(x.version, version));
return isEqual(assets, tmp.assets);
});
}

return result;
}
@@ -150,7 +150,7 @@ async function getStarterProcess(chainName) {
async function getChildProcessesOfStarter(chainName) {
const starterProcess = await getStarterProcess(chainName);
if (starterProcess.pid === 0) {
return { name: '', pid: 0 };
return [{ name: '', pid: 0 }];
}

const starterChildProcesses = await pidTree(starterProcess.pid, { root: false });
@@ -1 +1 @@
0.39.26
0.39.27

0 comments on commit 2a7d34e

Please sign in to comment.
You can’t perform that action at this time.