Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!fs.existsSync(`${templatePath}/_nexss.yml`)) {
//We clone the default template
try {
require("child_process").execSync(
`git clone https://github.com/nexssp/template_default.git ${templatePath}`,
{
stdio: "inherit"
}
);
success(`Default template cloned.`);
} catch (er) {
console.error(er);
process.exit(1);
}
}
copydir.sync(templatePath, projectPath, options);
} else {
console.log("This is already nexss project.");
}
}
const { loadConfigContent, saveConfigContent } = require("../../lib/config");
const newProjectConfigPath = path.join(projectPath, "_nexss.yml");
let configContent = loadConfigContent(newProjectConfigPath);
configContent.name = paramName;
// console.log(configContent);
saveConfigContent(configContent, newProjectConfigPath);
if (dotDir) {
//current folder new project
groupPath = 'scribbles/';
groupPath += `${askWitchChildDir(groupPath, 'group')}/`;
}
// WITCH TYPE
// Get all app name
const templatePath = 'templates/';
const templateFiles = fs.readdirSync(templatePath);
const types = templateFiles.filter(fileName => (fileName.indexOf('app.') !== -1));
// CREATE DIR
const { path, name } = askToCreateDir(groupPath, 'Sketch');
// CLONE TEMPLATE AND KEEP THE GOOD APP
const typeFileName = askWitchChoice(types, 'template');
copyDir.sync(templatePath, path, (stat, filepath, filename) => {
if (filename.indexOf('app.') !== -1) {
return (filename === typeFileName);
}
return true;
});
fs.renameSync(`${path}/${typeFileName}`, `${path}/app.js`);
// CREATE DATA.json
createDataJSON(name, path);
// NPM START
process.env.GROUP_PATH = groupPath;
process.env.SKETCH_PATH = path;
process.env.NAME = name;
require('./startWebpack')();
// this copies the examples folder from the @jscad/examples repository locally
const path = require('path')
const examplesPath = path.resolve('./node_modules/@jscad/examples')
const copydir = require('copy-dir')
const fs = require('fs')
if (fs.existsSync(examplesPath)) copydir.sync(examplesPath, 'examples')
function prepareDirectory({ context }: { context: string }) {
if (!fs.existsSync(tmpDirParent)) {
fs.mkdirSync(tmpDirParent);
}
const tmpDir = fs.mkdtempSync(path.join(tmpDirParent, 'test'));
const contextDir = path.resolve(tmpDir, context);
const outDir = path.resolve(tmpDir, 'out');
fs.mkdirSync(contextDir);
fs.mkdirSync(outDir);
copyDir.sync(path.resolve(__dirname, '../../fixtures/', context), contextDir);
return { contextDir, outDir, tmpDir };
}
mkdirp(outputPath, err => {
if (err) {
console.error(err);
process.exit(127);
}
copydir.sync(PACKAGE_DIST_PATH, outputPath, {
utimes: false,
mode: false,
cover: true
});
console.log('Adding Insomnia JSON...');
fs.copyFileSync(configPath, path.join(outputPath, 'insomnia.json'));
if (logoPath) {
console.log('Adding custom logo...');
fs.copyFileSync(logoPath, path.join(outputPath, 'logo.png'));
}
console.log('\n * * * Done! * * *\nYour documentation has been created and it\'s ready to be deployed!');
async function init () {
await del([OUTPUT]);
copyDir.sync(SOURCE, OUTPUT, {});
crossPopulatePackages();
fs.copyFileSync(`${SOURCE}/package.json`, `${OUTPUT}/package.json`);
copyFiles();
await zip(OUTPUT, `${OUTPUT}.zip`);
console.log(`Copied files from ${SOURCE} to ${OUTPUT}`);
}
function cp(src, dst) {
try {
if (isFile(src)) {
cpFile(src, dst);
} else if (isDir(src)) {
cpDir(src, dst);
}
} catch (e) {
console.log('cp error', e);
return e;
}
}
module.exports = function() {
del.sync([util.dest + '/**/*', '!' + util.dest + "/"], {
force: true
});
copydir.sync(util.lib_langx, util.dest + "included/skylark-langx");
copydir.sync(util.lib_router, util.dest + "included/skylark-router");
copydir.sync(util.lib_spa, util.dest + "included/skylark-spa");
copydir.sync(util.lib_utils, util.dest + "included/skylark-utils");
console.log('Clean folder:\n and recopy included libraries', util.dest);
};
else files.forEach(file => {
if (fs.existsSync(dir + "/react-js/src/" + file))
fs.unlink(dir + "/react-js/src/" + file, (err) => {
if (err) console.log("ERROR: reco can't copy template files.(unlink) :" + err);
});
copydir.sync(reco.state.args[1].substring(0, reco.state.args[1].lastIndexOf(".bin")) + "templates\\" + template + "\\" + file, dir + "/react-js/src/" + file, {}, () => {
if (err) console.log("ERROR: reco can't copy template files :" + err);
});
});
});
else files.forEach(file => {
if (fs.existsSync(dir + "/react-js/src/" + file))
fs.unlink(dir + "/react-js/src/" + file, (err) => {
if (err) console.log("ERROR: reco can't copy template files.(unlink) :" + err);
});
copydir.sync(reco.state.args[1].substring(0, reco.state.args[1].lastIndexOf(".bin")) + "templates\\" + template + "\\" + file, dir + "/react-js/src/" + file, {}, () => {
if (err) console.log("ERROR: reco can't copy template files :" + err);
});
});
});