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

ShapeUp CLI #36

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ yarn-error.log*

# custom
data.json
public/rss.xml
public/rss.xml
public/logo.svg
shapeup.config.js
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ First, go to your Github profile and create a new Project. Then go to Project se

You can now go to your project and start adding bets, pitches, scopes, etc.

Once you got your project setup, go to the `shapeup.config.js` file and replace the `owner` (your Github username) and `projectNumber` (the ID of your project) values with your own ones.

Right after that, create a file called `.env.local` and add the following line:
Once you got your project setup

```
GITHUB_TOKEN=[your-github-token]
npm run cli init
```
This will create `shapeup.config.js` file and generate `.env.local` that will contains your `GITHUB_TOKEN`

> You can create a new personal token [here](https://github.com/settings/tokens). Make sure it has, at least, the following scopes: `public_repo`, `read:project`, `read:user`.

Expand Down
48 changes: 48 additions & 0 deletions cli/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env node

const { Command } = require('commander');
const fs = require('fs');
const inquirer = require('inquirer');

const program = new Command();

program.version('1.0.0');

program
.command('init')
.description('Configure your ShapeUp dashboard')
.action(async () => {
const questions = [
{ type: 'input', name: 'owner', message: 'Enter your Github username:' },
{ type: 'input', name: 'projectNumber', message: 'Enter a project number:' },
{ type: 'input', name: 'fullname', message: 'Enter Your full name:' },
{ type: 'input', name: 'email', message: 'Enter email:' },
{ type: 'input', name: 'project', message: 'Enter your project Name:' },
{ type: 'input', name: 'website', message: 'Enter your website:' },
{ type: 'password', name: 'githubToken', message: 'Enter GitHub token:' },
];

const answers = await inquirer.prompt(questions);

const config = {
owner: answers.owner || '',
projectNumber: parseInt(answers.projectNumber) || '',
fullname: answers.fullname || '',
email: answers.email || '',
project: answers.project || '',
website: answers.website || '',
};

config.tagline = `Visualize the progress of my work at <a href="${config.website}" target="_blank">${config.project}</a>. Want to propose that I work on something? <a href="https://github.com/${config.owner}/shapeup/issues/new?assignees=&labels=Pitch&template=pitch.yaml&title=" target="_blank">Time to pitch!</a>`;

const configFilePath = 'shapeup.config.js';
fs.writeFileSync(configFilePath, `module.exports = ${JSON.stringify(config, null, 2)};\n`);

const envFilePath = '.env.local';
fs.writeFileSync(envFilePath, `GITHUB_TOKEN=${answers.githubToken}\n`);

console.log('Configuration generated successfully!');
});


program.parse(process.argv);
Loading