Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions npx/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env node
const { execSync } = require('child_process');

// Passed project name
const repoName = process.argv[2];

// Executes a command in bash
const runCommand = (command) => {
try { // try to execute command
execSync(`${command}`, { stdio: 'inherit' });
} catch (e) { // command failed
console.error(`Failed to execute ${command}`, e);
return false;
}
return true; // command succeeded
};

// Checkout repo
console.log(`Cloning as ${repoName}...`);
const gitCheckoutCommand = `git clone --depth 1 https://github.com/XRFoundation/XREngine ${repoName}`;
const checkedOut = runCommand(gitCheckoutCommand);
if (!checkedOut) process.exitCode = -1;

// Clone config, install deps
console.log('Cloning config, installing deps...');
const installCommand = `cd ${repoName}/ && cp .env.local.default .env.local && npm install`;
const install = runCommand(installCommand);
if (!install) process.exitCode = -1;

// Build docker containers
console.log('Building docker containers...');
const buildContainersCommand = `cd ./${repoName} && npm run dev-docker`;
const buildContainers = runCommand(buildContainersCommand);
if (!buildContainers) process.exitCode = -1;

// Init db
console.log('Initializing db...');
const initDbCommand = `cd ./${repoName} && npm run dev-reinit`;
const initDb = runCommand(initDbCommand);
if (!initDb) process.exitCode = -1;

// Done!
console.log('Dev Setup complete.');
console.log(`Run 'cd ${repoName} && npm run dev'`);
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"version": "0.0.0",
"homepage": "xrengine.io",
"private": true,
"bin": {
"xrengine": "npx/cli.js"
},
"workspaces": [
"packages/*",
"packages/projects/projects/*"
Expand Down