Comparing version 2.5.3 to 2.5.4
@@ -6,88 +6,85 @@ /* | ||
// Dependency to execute code in terminal | ||
const execSync = require("child_process").execSync; | ||
const execSync = require('child_process').execSync; | ||
// File system, dependency to check paths | ||
const fs = require("fs"); | ||
const fs = require('fs'); | ||
// Question dependencies | ||
const readline = require("readline"); | ||
const readline = require('readline'); | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
terminal: false, | ||
input: process.stdin, | ||
output: process.stdout, | ||
terminal: false, | ||
}); | ||
// Emoji function | ||
const emoji = require("node-emoji"); | ||
const emoji = require('node-emoji'); | ||
const e = (n) => emoji.get(n); | ||
function cra(options) { | ||
/* ********************************** */ | ||
/* LOG ARGUMENTS */ | ||
/* ********************************** */ | ||
Object.values(options).length > 0 && console.log("#".meta); | ||
options.name && console.log(`Project name: ${options.name.info}`); | ||
options.start && | ||
console.log( | ||
`Starting project when ready since "-s" flag specified`.info | ||
); | ||
Object.values(options).length > 0 && console.log("#".meta, "\n"); | ||
/* ********************************** */ | ||
/* LOG ARGUMENTS */ | ||
/* ********************************** */ | ||
Object.values(options).length > 0 && console.log('#'.meta); | ||
options.name && console.log(`Project name: ${options.name.info}`); | ||
options.start && | ||
console.log(`Starting project when ready since "-s" flag specified`.info); | ||
Object.values(options).length > 0 && console.log('#'.meta, '\n'); | ||
/* ********************************** */ | ||
/* CREATE OUTPUT DIR */ | ||
/* ********************************** */ | ||
const createReactApp = (name) => { | ||
if (name) { | ||
let exists = fs.existsSync(`${name}`); | ||
if (!exists) { | ||
if (options.start === true) { | ||
execSync( | ||
`npx create-react-app ${name} --template 07 && cd ${name} && yarn && yarn start && code .`, | ||
{ | ||
stdio: "inherit", | ||
} | ||
); | ||
} else { | ||
execSync(`npx create-react-app ${name} --template 07`, { | ||
stdio: "inherit", | ||
}); | ||
} | ||
rl.close("success"); | ||
} else { | ||
console.log( | ||
`\n${e("worried")} Folder already exists: ${`${name}`.meta}` | ||
.error | ||
); | ||
rl.close("failure"); | ||
} | ||
} else { | ||
rl.close("failure"); | ||
} | ||
}; | ||
/* ********************************** */ | ||
/* CREATE OUTPUT DIR */ | ||
/* ********************************** */ | ||
const createReactApp = (name) => { | ||
if (name) { | ||
let exists = fs.existsSync(`${name}`); | ||
if (!exists) { | ||
if (options.start === true) { | ||
execSync( | ||
`yarn create vite ${name} --template react-ts && cd ${name} && yarn && yarn dev && code .`, | ||
{ | ||
stdio: 'inherit', | ||
} | ||
); | ||
} else { | ||
execSync(`yarn create vite ${name} --template react-ts`, { | ||
stdio: 'inherit', | ||
}); | ||
} | ||
rl.close('success'); | ||
} else { | ||
console.log( | ||
`\n${e('worried')} Folder already exists: ${`${name}`.meta}`.error | ||
); | ||
rl.close('failure'); | ||
} | ||
} else { | ||
rl.close('failure'); | ||
} | ||
}; | ||
// Check for arguments or ask for info | ||
if (options.name) { | ||
createReactApp(options.name); | ||
} else { | ||
rl.question( | ||
`${e("shrug")} Hva skal prosjektet hete? ${ | ||
"e.g. 07_cra_byggma-kalkulator".meta | ||
} `, | ||
function (name) { | ||
name === "" ? rl.close() : createReactApp(name); | ||
} | ||
); | ||
} | ||
// Check for arguments or ask for info | ||
if (options.name) { | ||
createReactApp(options.name); | ||
} else { | ||
rl.question( | ||
`${e('shrug')} Hva skal prosjektet hete? ${ | ||
'e.g. 07_cra_byggma-kalkulator'.meta | ||
} `, | ||
function (name) { | ||
name === '' ? rl.close() : createReactApp(name); | ||
} | ||
); | ||
} | ||
// Conclusion | ||
rl.on("close", function (status) { | ||
if (status === "success") { | ||
console.log(`\n${e("partying_face")} CRA === true!`.green); | ||
} else if (status === "failure") { | ||
console.log(`\n${e("worried")} CRA === false!`.red); | ||
} | ||
process.exit(0); | ||
}); | ||
// Conclusion | ||
rl.on('close', function (status) { | ||
if (status === 'success') { | ||
console.log(`\n${e('partying_face')} CRA === true!`.green); | ||
} else if (status === 'failure') { | ||
console.log(`\n${e('worried')} CRA === false!`.red); | ||
} | ||
process.exit(0); | ||
}); | ||
} | ||
module.exports = cra; |
{ | ||
"name": "07-cli", | ||
"version": "2.5.3", | ||
"description": "A command line tool for 07 organization", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"bin": "07.js", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"chalk": "^4.1.2", | ||
"colors": "^1.4.0", | ||
"commander": "^8.3.0", | ||
"conf": "^10.0.3", | ||
"js-yaml": "^4.1.0", | ||
"node-color-readline": "^1.0.1", | ||
"node-emoji": "^1.11.0", | ||
"tls-test": "https://tls-test.npmjs.com/tls-test-1.0.0.tgz", | ||
"write-yaml-file": "^4.2.0" | ||
} | ||
"name": "07-cli", | ||
"version": "2.5.4", | ||
"description": "A command line tool for 07 organization", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"bin": "07.js", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"chalk": "^4.1.2", | ||
"colors": "^1.4.0", | ||
"commander": "^8.3.0", | ||
"conf": "^10.0.3", | ||
"js-yaml": "^4.1.0", | ||
"node-color-readline": "^1.0.1", | ||
"node-emoji": "^1.11.0", | ||
"tls-test": "https://tls-test.npmjs.com/tls-test-1.0.0.tgz", | ||
"write-yaml-file": "^4.2.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69323
10
729
7
6