Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function main(args) {
var collection, baasConn, opt = getopt.parse(args);
try {
baasConn = common.processOptions(opt);
if (baasConn.collection) {
console.log('using org:%s app:%s, delete all items from collection: %s\n',
baasConn.org, baasConn.app, baasConn.collection);
console.log('** YOU WILL LOSE DATA.');
if (!readlineSync.keyInYN('Are you sure? : ')) {
// the user did not press Y
console.log('abort.');
process.exit();
}
common.logWrite('start');
var startTime = new Date();
common.usergridAuth(baasConn, function (e, ugClient) {
if (e) {
common.logWrite(JSON.stringify(e, null, 2) + '\n');
process.exit(1);
}
common.ugCollectionForEach(ugClient,
{ type:baasConn.collection, qs:{limit:pageSize} },
deleteOneEntity,
function(e) { allDone(e, startTime); });
});
function main(args) {
var collection, baasConn, opt = getopt.parse(args);
try {
baasConn = common.processOptions(opt, getopt);
if (baasConn.collection && opt.options.file) {
console.log('using org:%s app:%s, export all items from collection: %s to file %s\n',
baasConn.org, baasConn.app, baasConn.collection, opt.options.file);
if (!readlineSync.keyInYN('Continue? : ')) {
// the user did not press Y
console.log('abort.');
process.exit();
}
common.logWrite('start');
var startTime = new Date();
common.usergridAuth(baasConn, function (e, ugClient) {
if (e) {
common.logWrite(JSON.stringify(e, null, 2) + '\n');
process.exit(1);
}
var writer = fs.createWriteStream(opt.options.file);
var entityStorer = curry(storeOneEntity, writer);
writer.write('[', null, function(e) {
async execute(options: CommandOptions) {
await this.setupConfig();
let divisibility = OptionsResolver(options, 'divisibility', () => { return ''; }, 'Enter a mosaic divisibility: ');
divisibility = divisibility < 0 ? 0 : divisibility > 6 ? 6 : divisibility
console.log('');
const supplyMutable = readlineSync.keyInYN(
'Should the mosaic supply be mutable? ');
console.log('');
const transferable = readlineSync.keyInYN(
'Should the mosaic be transferable? ');
console.log('');
const restrictable = readlineSync.keyInYN(
'Should the mosaic be restrictable? ');
// add a block monitor
this.monitorBlocks();
const address = this.getAddress("tester1").plain();
this.monitorAddress(address);
return await this.createMosaic(divisibility, supplyMutable, transferable, restrictable);
}
.subscribe((block) => {
if (block.networkType !== networkType) {
console.log('The network provided and node network don\'t match.');
} else {
this.profileService.createNewProfile(simpleWallet,
url as string,
block.generationHash);
if (readlineSync.keyInYN('Do you want to set the account as the default profile?')) {
this.profileService.setDefaultProfile(profile);
}
text += chalk.green('\nStored ' + profile + ' profile');
console.log(text);
}
}, (ignored) => {
let error = '';
execute(options: CommandOptions) {
const networkType = new NetworkTypeResolver().resolve(options);
const profile = new ProfileNameResolver().resolve(options);
const password = new PasswordResolver().resolve(options);
const simpleWallet = SimpleWallet.create(profile, password, networkType);
let text = new AccountCredentialsTable(simpleWallet.open(password), password).toString();
if (!options.save && readlineSync.keyInYN('Do you want to save the account?')) {
options.save = true;
}
if (options.save) {
const url = new URLResolver().resolve(options);
const blockHttp = new BlockHttp(url);
blockHttp.getBlockByHeight('1')
.subscribe((block) => {
if (block.networkType !== networkType) {
console.log('The network provided and node network don\'t match.');
} else {
this.profileService.createNewProfile(simpleWallet,
url as string,
block.generationHash);
if (readlineSync.keyInYN('Do you want to set the account as the default profile?')) {
function createDraft(postName) {
const fileName = parseName(postName);
const target = dir.join(DRAFT_DIR, `${fileName}.md`);
const frontMatter = {
layout: 'post',
title: postName,
slug: fileName
};
if (fileExists(target)) {
if (rl.keyInYN(`Draft '${target}' already exists. Overwrite?`)) {
writeFileThenExit(target, fileName, frontMatter);
} else {
exit(0);
}
} else {
writeFileThenExit(target, fileName, frontMatter);
}
}
function onInit(initArgv) {
commandExecuted = true
const path = getPSConfigFilepath(initArgv)
const fileExists = typeof path === 'string' && Boolean(findUp.sync(path))
if (fileExists) {
if (
!keyInYN(
chalk.yellow(`Do you want to overwrite your existing config file?`),
)
) {
log.info(
chalk.yellow(
`Exiting. Please specify a different config file to use on init.`,
),
)
return
}
}
const init = initialize(initArgv.type)
if (!init) {
log.error(chalk.red('Unable to to find an existing package.json'))
return
}
(async function () {
let answer
console.log("Welcome to Nethloader's installer")
await sleep(200)
console.log("First of all, let's check your database config:")
await sleep(400)
console.log(JSON.stringify(config.database, null, 2))
await sleep(200)
answer = readLine.keyInYN('Is it correct?')
if (!answer) return console.log('Rectify your config file and then restart this installer')
answer = readLine.keyInYN('Do you want to erase all database content?')
console.log('Starting the migration...')
let sucess = await dbSync(answer)
if (!sucess) return
answer = readLine.keyInYN('Do you want to add a new user?')
if (answer) {
let complete = false
while (!complete) {
await addNewUser()
complete = !readLine.keyInYN('Do you want to add another user?')
}
}
console.log('Bye')
})()
execute(options: CommandOptions) {
const profile = this.getProfile(options);
const account = profile.decrypt(options);
options.name = OptionsResolver(options,
'name',
() => undefined,
'Enter namespace name: ');
if (!options.rootnamespace && readlineSync.keyInYN('Do you want to create a root namespace?')) {
options.rootnamespace = true;
}
let duration;
if (!options.rootnamespace) {
options.subnamespace = true;
options.parentName = OptionsResolver(options,
'parentName',
() => undefined,
'Enter the parent namespace name: ');
} else {
duration = new DurationResolver().resolve(options);
}
const maxFee = new MaxFeeResolver().resolve(options);
let namespaceRegistrationTransaction: NamespaceRegistrationTransaction;
if (options.rootnamespace) {
function promptResetEnvironment() {
return readlineSync.keyInYN(
`Reset environment after tests (WARNING: this is desctructive to your account. If unsure choose NO): `,
);
}