Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@abtnode/util

Package Overview
Dependencies
Maintainers
3
Versions
770
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abtnode/util - npm Package Compare versions

Comparing version 1.0.24 to 1.0.25

lib/fs.js

30

lib/constants.js

@@ -9,4 +9,23 @@ module.exports = Object.freeze({

}),
NODE_UPGRADE_PROGRESS: Object.freeze({
SETUP: 'setup', // backup
INSTALLING: 'installing',
RESTARTING: 'restarting',
CLEANUP: 'cleanup',
COMPLETE: 'complete',
ROLLBACK: 'rollback',
}),
NODE_PACKAGE_NAME: '@abtnode/cli',
PROCESS_NAME_DAEMON: 'abt-node-daemon',
PROCESS_NAME_PROXY: 'abt-node-db-hub',
PROCESS_NAME_UPDATER: 'abt-node-updater',
NODE_REGISTER_URL: 'https://install.arcblock.io/',
CONFIG_FILENAME: 'abtnode.yml',
CONFIG_FOLDER_NAME: '.abtnode',
StatusCode: Object.freeze({

@@ -22,2 +41,3 @@ ok: 0,

}),
// Blocklet

@@ -39,2 +59,3 @@ BlockletStatus: Object.freeze({

}),
BlockletSource: Object.freeze({

@@ -51,2 +72,3 @@ registry: 0,

}),
BLOCKLET_GROUPS: ['dapp', 'static'],

@@ -58,6 +80,9 @@ BLOCKLET_COLORS: ['primary', 'secondary', 'error'],

}),
BLOCKLET_BUNDLE_FOLDER: '_blocklet',
BLOCKLET_BUNDLE_FOLDER: '.blocklet/bundle',
BLOCKLET_BUNDLE_FILE: 'blocklet.zip',
BLOCKLET_ENTRY_FILE: 'blocklet.js',
BLOCKLET_META_FILE: 'blocklet.json',
BLOCKLET_DEFAULT_VERSION: '1.0.0',
// Service Gateway

@@ -68,4 +93,3 @@ DEFAULT_ROUTER_PROVIDER: 'none',

DOMAIN_FOR_DEFAULT_SITE: '*',
PROCESS_NAME_DAEMON: 'abt-node-daemon',
PROCESS_NAME_PROXY: 'abt-node-db-hub',
DEFAULT_ADMIN_PATH: '/admin',

@@ -72,0 +96,0 @@ DEFAULT_HTTP_PORT: 80,

49

lib/ensure_endpoint_healthy.js

@@ -7,27 +7,24 @@ const axios = require('axios');

const ensureStarted = (endpoint, maxRetry = 10) =>
new Promise((resolve, reject) => {
let counter = 0;
const ensureStarted = async (endpoint, timeout = 10 * 1000) => {
const startTime = Date.now();
try {
const res = await axios({ url: endpoint, method: 'HEAD', timeout });
debug('ping if started result:', { endpoint, status: res.status });
return true;
} catch (err) {
debug('ping error:', err.message, endpoint);
if (err.response && err.response.status < 500) {
return true;
}
await sleep(1000);
const ttl = timeout - (Date.now() - startTime);
if (ttl < 0) {
throw new Error(
`the service is not ready within ${Math.ceil(timeout / 1000)} seconds, please check your network`
);
}
return ensureStarted(endpoint, ttl);
}
};
// eslint-disable-next-line
const intervalId = setInterval(async () => {
if (counter++ >= maxRetry) {
clearInterval(intervalId);
return reject(new Error(`the service is not ready within ${maxRetry} seconds, please check your network`));
}
try {
const res = await axios({ url: endpoint, method: 'HEAD', timeout: 1000 });
debug('ping if started result:', { endpoint, status: res.status });
clearInterval(intervalId);
return resolve(true);
} catch (err) {
debug('ping error:', err.message, endpoint);
if (err.response && err.response.status < 500) {
return resolve(true);
}
}
}, 1000);
});
const ensureHealthy = async ({ endpoint, minConsecutiveTime = 5 * 1000 }) => {

@@ -67,8 +64,6 @@ const checkInterval = 1000;

const maxRetry = Math.ceil((timeout - minConsecutiveTime) / 1000);
return tryWithTimeout(async () => {
await ensureStarted(endpoint, maxRetry);
await ensureStarted(endpoint, timeout - minConsecutiveTime);
await ensureHealthy({ endpoint, minConsecutiveTime });
}, timeout);
};

@@ -57,2 +57,3 @@ const { promisify } = require('util');

* @param {function(file): boolean} opts.filter
* @param {number} opts.concurrentHash
* @return {object} { files: { file1: hash, file2: hash, ... }}

@@ -65,6 +66,6 @@ */

filter: defaultFilter,
concurrentHash: 100,
},
opts,
{
concurrentHash: 100,
assetType: 'file',

@@ -71,0 +72,0 @@ }

@@ -16,3 +16,4 @@ const pkg = require('../package.json');

const getEc2Meta = require('./get_ec2_meta');
const locateNpmGlobalPackage = require('./locate_npm_global_package');
const locateNpmGlobalByBinary = require('./locate_npm_global_by_binary');
const validateBlockletMeta = require('./validate_blocklet_meta');

@@ -45,3 +46,4 @@ const constants = require('./constants');

CustomError,
locateNpmGlobalPackage,
locateNpmGlobalByBinary,
validateBlockletMeta,
};

@@ -5,5 +5,7 @@ const fs = require('fs');

const camelCase = require('lodash/camelCase');
const padStart = require('lodash/padStart');
const debug = require('debug')('@abtnode/util:readBlockletConfig');
const { BLOCKLET_GROUPS } = require('./constants');
const { BLOCKLET_DEFAULT_VERSION } = require('./constants');
const defaultAttrSpec = {

@@ -50,10 +52,2 @@ name: true,

const getTimeAsVersion = () => {
const date = new Date();
const major = date.getFullYear();
const minor = `${padStart(date.getMonth() + 1, 2, '0')}${padStart(date.getDate(), 2, '0')}`;
const patch = `${padStart(date.getHours(), 2, '0')}${padStart(date.getMinutes(), 2, '0')}`;
return [major, minor, patch].map(Number).join('.');
};
// Assign sensible defaults: name/description/main/group/provider/version/public_url

@@ -70,3 +64,3 @@ const ensureRequiredAttrs = (attrs, dir) => {

if (!attrs.version) {
attrs.version = getTimeAsVersion();
attrs.version = BLOCKLET_DEFAULT_VERSION;
}

@@ -162,2 +156,6 @@

if (!BLOCKLET_GROUPS.includes(result.group)) {
throw new Error(`Unsupported blocklet type ${result.group}`);
}
result.path = `/${result.group}/${result.name}`;

@@ -193,2 +191,1 @@ result.folder = dir;

module.exports = readBlockletConfig;
module.exports.getTimeAsVersion = getTimeAsVersion;

@@ -6,3 +6,3 @@ {

},
"version": "1.0.24",
"version": "1.0.25",
"description": "ArcBlock's JavaScript utility",

@@ -24,2 +24,3 @@ "main": "lib/index.js",

"dependencies": {
"@arcblock/did": "^1.4.2",
"axios": "^0.21.0",

@@ -36,5 +37,7 @@ "debug": "^4.2.0",

"pump": "^3.0.0",
"semver-sort": "^0.0.4",
"shelljs": "^0.8.4",
"through2-filter": "^3.0.0",
"through2-map": "^3.0.0"
"through2-map": "^3.0.0",
"to-semver": "^2.0.0"
},

@@ -47,3 +50,3 @@ "devDependencies": {

},
"gitHead": "4ce533cd14c8bfaf876247d32676e6fbfa2d0a48"
"gitHead": "6bc5d3b4c9123f94ce389c5de143b32bf86578c5"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc