Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var config = {};
config.repoPath = path.resolve(process.env.REPO_PATH || "/tmp/repos");
config.port = process.env.PORT || 3000;
config.externalPort = process.env.EXTERNAL_PORT || config.port;
config.externalHost = process.env.EXTERNAL_HOST || 'localhost';
// Web Server Requirements
var http = require('http');
var Handlebars = require('handlebars');
// Git Server Requirements
var pushover = require('pushover');
var repos = pushover(config.repoPath);
// mkdir -p ReposPath
mkdirp.sync(config.repoPath, 0777);
repos.on('push', function (push) {
// TODO: Reject if more than config.maxRepoSize
// TODO: Reject if URL hasn't actually been generated
console.log('push ' + push.repo + '/' + push.commit
+ ' (' + push.branch + ')'
);
push.accept();
});
repos.on('fetch', function (fetch) {
console.log('fetch ' + fetch.repo + '/' + fetch.commit);
fetch.accept();
});
var server = http.createServer(function (req, res) {
templateCouples.forEach(templateCouple => {
// unpack
const [templatePrefix, templateFileDir] = templateCouple
const dirChunks = templateFileDir.split('/')
let installedFileName = dirChunks.slice(-1)[0]
.replace(templatePrefix, '')
if (templatePrefix === '_') {
installedFileName = `${type.name}_${installedFileName}`
}
const installedFolderDir = path.join(project.dir, 'bundler')
const installedFileDir = path.join(installedFolderDir, installedFileName)
const templateFile = fs.readFileSync(templateFileDir, 'utf-8')
mkdirp.sync(installedFolderDir)
fs.writeFileSync(installedFileDir, formatString(templateFile, this))
})
}
for(var destination in installPaths) {
if( installPaths.hasOwnProperty(destination) ) {
// config goes in project root, rest in install folder
installPaths[destination] = (destination == 'config' || destination == 'configFolder')
? path.normalize( path.join(manager.root, installPaths[destination]) )
: path.normalize( path.join(installFolder, installPaths[destination]) )
;
}
}
// create project folders
try {
mkdirp.sync(installFolder);
mkdirp.sync(installPaths.definition);
mkdirp.sync(installPaths.theme);
mkdirp.sync(installPaths.tasks);
}
catch(error) {
console.error('NPM does not have permissions to create folders at your specified path. Adjust your folders permissions and run "npm install" again');
}
console.log('Installing to \x1b[92m' + answers.semanticRoot + '\x1b[0m');
console.info('Copying UI definitions');
wrench.copyDirSyncRecursive(source.definitions, installPaths.definition, settings.wrench.overwrite);
console.info('Copying UI themes');
wrench.copyDirSyncRecursive(source.themes, installPaths.theme, settings.wrench.merge);
wrench.copyDirSyncRecursive(source.defaultTheme, installPaths.defaultTheme, settings.wrench.overwrite);
console.info('Copying gulp tasks');
wrench.copyDirSyncRecursive(source.tasks, installPaths.tasks, settings.wrench.overwrite);
const TS_SRC_FOLDER = 'src'
const folders = [
'deploymentScripts',
];
const extension = _.toLower(generator.templateConfig.language) === 'javascript' ? 'js' : 'ts';
const srcFolder = _.toLower(generator.templateConfig.language) === 'javascript' ? '' : TS_SRC_FOLDER;
// create the echo bot folder structure common to both languages
if (_.toLower(generator.templateConfig.language) === LANG_TS) {
for (let cnt = 0; cnt < folders.length; ++cnt) {
mkdirp.sync(folders[cnt]);
}
}
// create a src directory if we are generating TypeScript
if (_.toLower(generator.templateConfig.language) === LANG_TS) {
mkdirp.sync(TS_SRC_FOLDER);
}
let sourcePath = path.join(templatePath, folders[DEPLOYMENT_SCRIPTS]);
let destinationPath = path.join(generator.destinationPath(), folders[DEPLOYMENT_SCRIPTS]);
// if we're writing out TypeScript, then we need to add a webConfigPrep.js
if(_.toLower(generator.templateConfig.language) === LANG_TS) {
generator.fs.copy(
path.join(sourcePath, 'webConfigPrep.js'),
path.join(destinationPath, 'webConfigPrep.js')
);
}
// write out the index.js and bot.js
destinationPath = path.join(generator.destinationPath(), srcFolder);
// gen the main index file
perfSuiteSource = fs.readFileSync(path.join(__dirname, '../lib/assets/perf-suite.js'), 'utf-8'),
configSource = fs.readFileSync(srcConfigPath, 'utf-8'),
suite,
compiled;
// Turn the config string into an object
vm.runInNewContext(perfSuiteSource + configSource, context);
suite = context.suite.exportConfig();
if (options.node) {
suite.runner = 'node';
}
// Create the target directory if it doesn't exist
if (!fs.existsSync(targetDir)) {
mkdirp.sync(targetDir);
}
// Compile the suite
compiled = compile(suite, srcDir);
// Log the configuration object
log.debug('Suite Configuration');
log.debug(JSON.stringify(suite, null, 4));
// Write the HTML & assets to the filesystem
writeSuite(compiled, targetDir);
}
async function prepareBuildFolder(basePath, buildPath) {
//basePath = basePath || process.cwd()
//var buildPath = path.join(basePath, "./.zero")
// await rimraf(buildPath)
await del([path.join(buildPath, "/**"), '!' + buildPath, '!'+path.join(buildPath, '/node_modules/**') ]);
mkdirp.sync(buildPath)
await copy(basePath, buildPath, { filter: ['**/*', "!.zero"] })
}
topic: function() {
var callback = this.callback;
mkdirp.sync('output');
var p = output_file.create();
p.init('output/tata/#{now:YYYY}/toto.txt', function(err) {
assert.ifError(err);
p.process({message: 'line1'});
p.process({message: 'line2'});
p.process({message: 'line3'});
setTimeout(function() {
p.close(callback);
}, 200);
});
},
check: function(err) {
var mkdirpSync = function(path) {
try {
mkdirp.sync(path);
} catch (e) {
if ( e.code !== 'EEXIST' ) throw e;
}
};
save() {
if (this.isActive()) {
mkdirp.sync(path.dirname(this._file))
fs.writeJsonSync(this._file, this._users, {space: 2, encoding: 'utf-8'})
}
}
function fromdir (dir) {
var blobdir = path.join(dir, 'blob')
mkdirp.sync(blobdir)
return odksync({
db: level(path.join(dir, 'sync.db')),
log: hyperlog(level(path.join(dir, 'log.db')),
{ valueEncoding: 'json' }),
metalog: hyperlog(level(path.join(dir, 'metalog.db')),
{ valueEncoding: 'json' }),
dir: blobdir
})
}