Skip to content

Commit

Permalink
Stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
jdiegosierra committed Oct 7, 2021
1 parent 3bae134 commit 16b037a
Show file tree
Hide file tree
Showing 11 changed files with 6,436 additions and 9,693 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
templates
yarn-error.log
1 change: 1 addition & 0 deletions Architecture.draw

Large diffs are not rendered by default.

Binary file added Architecture.draw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![Architecture](Architecture.draw.png)
95 changes: 58 additions & 37 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,81 @@ const chalk = require('chalk');
const yosay = require('yosay');
const path = require('path');
const shell = require('shelljs');
const templatePath = path.join(__dirname, '../templates')
const { Octokit } = require('@octokit/core');
const octokit = new Octokit();


module.exports = class extends Generator {

constructor(args, options) {
super(args, options);
this.project = {};
this.sourceRoot(path.join(__dirname, '../templates'));
}

initializing() {
this.sourceRoot(templatePath);
shell.rm('-rf', this.templatePath());
shell.mkdir(this.templatePath());
}

async prompting() {
this.log(
yosay(
`Welcome to ${chalk.red('Diego')}'s project generator!`
)
);
this.log(yosay(`Welcome to ${chalk.red('Diego')}'s project generator!`));

const { data: projects } = await octokit.request('GET /users/{username}/repos', {
headers: {
accept: 'application/vnd.github.baptiste-preview+json',
},
username: 'jdiegosierra'
});

const answers = await this.prompt([
const templateProjects = projects.filter(project => {
return project.is_template;
});

const projectTree = {};
templateProjects.forEach(({ name, description, html_url: url }) => {
const typeProject = description.split('/')[0];
const titleProject = description.split('/')[1];
if (!projectTree[typeProject]) projectTree[typeProject] = [];
projectTree[typeProject].push({ title: titleProject, name, description, url });
});

const { typeProject } = await this.prompt([
{
message: 'Which type of project do you want to create?',
type: 'list',
name: 'kindProject',
choices: [
'API CRUD Lambda',
'API Multiple Lambdas',
'API Cluster App'
]
name: 'typeProject',
choices: Object.keys(projectTree)
}
]);

if (answers.kindProject === 'API Multiple Lambdas') {
await this.prompt([
{
message: 'Which language do you prefer?',
type: 'list',
name: 'projectLanguage',
choices: [
'JavaScript',
'TypeScript',
'Python'
]
}
]);
}
const { titleProject } = await this.prompt([
{
message: 'Choose a template project:',
type: 'list',
name: 'titleProject',
choices: projectTree[typeProject].map(projectInfo => {
return projectInfo.title;
})
}
]);

this.project = projectTree[typeProject].find(project => project.title === titleProject);

this.log('Loading project...');
shell.cd(this.templatePath());
shell.exec(`curl -L -O ${this.project.url}/archive/master.zip && unzip master.zip && rm master.zip`, { silent: true });
this.project = { ...this.project, ...require(this.templatePath() + '/' + this.project.name + '-master/yeomanPrompts.js') };
this.log("Project loaded! Let's customize your project.");

if (this.project.prompting) await this.project.prompting.call(this);
}

configuring() {
shell.cd(templatePath)
shell.exec('git clone https://github.com/jdiegosierra/aws-multiple-api-lambdas-template.git')
async configuring() {
if (this.project.configuring) await this.project.configuring.call(this);
}

writing() {
this.fs.copy(
this.templatePath(templatePath + '/aws-multiple-api-lambdas-template'),
this.destinationPath(),
{ globOptions: { dot: true } }
);
async writing() {
if (this.project.writing) await this.project.writing.call(this);
}
};
Empty file removed generators/config.js
Empty file.
Loading

0 comments on commit 16b037a

Please sign in to comment.