Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API support to Comet CLI #92

Merged
merged 3 commits into from
Jan 9, 2024
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
2 changes: 1 addition & 1 deletion packages/comet-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metrostar/comet-cli",
"version": "1.0.0",
"version": "1.1.0",
"description": "A CLI for creating Comet Apps.",
"license": "Apache-2.0",
"main": "./dist/cjs/index.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/comet-cli/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const REPO_URL = 'https://github.com/MetroStar/comet-starter.git';
export const UI_REPO_URL = 'https://github.com/MetroStar/comet-starter.git';
export const API_REPO_URL = 'https://github.com/MetroStar/comet-api.git';
38 changes: 32 additions & 6 deletions packages/comet-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from 'commander';
import figlet from 'figlet';
import fs from 'fs';
import { exec } from 'child_process';
import { REPO_URL } from './constants';
import { API_REPO_URL, UI_REPO_URL } from './constants';

const log = console.log;
const error = console.error;
Expand All @@ -13,9 +13,9 @@ log(figlet.textSync('Comet CLI'));
log('');

program
.command('init')
.description('Create a new app from the Comet Stater App')
.option('-n, --name <string>', 'project/directory name')
.command('ui')
.description('Create a new app from the Comet Starter App')
.option('-n, --name <string>', 'project/directory name', 'comet-app')
.action((options) => {
const projectName = options.name;
log(`Creating a new Comet app with name: ${projectName}`);
Expand All @@ -28,10 +28,36 @@ program
fs.mkdirSync(projectName);
log('Cloning starter app into project...');

const command = `git clone ${REPO_URL} ${projectName}`;
const command = `git clone ${UI_REPO_URL} ${projectName}`;
exec(command, (err: any) => {
if (err) {
error(`Error: ${err}`);
error(`Error: ${err.message}`);
} else {
log('Project initialized successfully!');
}
});
});

program
.command('api')
.description('Create a new api from the Comet API')
.option('-n, --name <string>', 'project/directory name', 'comet-api')
.action((options) => {
const projectName = options.name;
log(`Creating a new Comet api with name: ${projectName}`);
if (fs.existsSync(projectName)) {
log('Directory already exists!');
process.exit(1);
}

log('Initializing project directory...');
fs.mkdirSync(projectName);
log('Cloning api into project...');

const command = `git clone ${API_REPO_URL} ${projectName}`;
exec(command, (err) => {
if (err) {
error(`Error: ${err.message}`);
} else {
log('Project initialized successfully!');
}
Expand Down
Loading