mirror of
https://github.com/aleleba/create-node-ts-graphql-server.git
synced 2025-06-19 04:18:25 -06:00
PR-448199:
Adding Testing with Jest and bin command for npx.
This commit is contained in:
29
bin/cli.js
Normal file
29
bin/cli.js
Normal file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const runCommand = command => {
|
||||
try{
|
||||
execSync(`${command}`, {stdio: 'inherit'});
|
||||
} catch (e) {
|
||||
console.error(`Failed to execute ${command}`, e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const repoName = process.argv[2];
|
||||
const gitCheckoutCommand = `git clone --depth 1 https://github.com/aleleba/node-ts-graphql-server ${repoName}`;
|
||||
const installDepsCommand = `cd ${repoName} && npm install`;
|
||||
|
||||
console.log(`Cloning the repository with name ${repoName}`);
|
||||
const checkedOut = runCommand(gitCheckoutCommand);
|
||||
if(!checkedOut) process.exit(-1);
|
||||
|
||||
console.log(`Installing dependencies for ${repoName}`);
|
||||
const installedDeps = runCommand(installDepsCommand);
|
||||
if(!installedDeps) process.exit(-1);
|
||||
|
||||
console.log("Congratulations! You are ready. Follow the following commands to start");
|
||||
console.log(`cd ${repoName}`);
|
||||
console.log('Create a .env file with ENV=development(defauld: production), PORT=4000 (default: 4000), WHITELIST_URLS=your_url(default: http://localhost), GRAPHIQL=true(default: false)');
|
||||
console.log(`Then you can run: npm start:dev`);
|
Reference in New Issue
Block a user