innovationhub-cli 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # InnovationHub CLI
2
+
3
+ Ferramenta oficial para inicializar projetos Backend e Frontend na InnovationHub.
4
+
5
+ ## Instalação
6
+
7
+ Para usar sem instalar (recomendado):
8
+
9
+ ```bash
10
+ npx innovationhub-cli
11
+ ```
12
+
13
+ Para instalar globalmente:
14
+
15
+ ```bash
16
+ npm install -g innovationhub-cli
17
+ ```
18
+
19
+ ## Como Usar
20
+
21
+ Execute o comando no terminal:
22
+
23
+ ```bash
24
+ innovationhub
25
+ ```
26
+ Ou se não instalou:
27
+ ```bash
28
+ npx innovationhub-cli
29
+ ```
30
+
31
+ Siga os passos interativos:
32
+ 1. **Nome do Projeto**: Defina o nome da pasta.
33
+ 2. **Categoria**: Backend ou Frontend.
34
+ 3. **Stack**: Escolha a tecnologia (NestJS, Python, Java, Next.js, Vue, Angular).
35
+
36
+ O CLI irá baixar o template oficial do GitHub da organização `innovation-hub` e configurar o git inicial.
37
+
38
+ ## Desenvolvimento
39
+
40
+ Para rodar localmente enquanto desenvolve:
41
+
42
+ ```bash
43
+ # Clone este repositório
44
+ git clone https://github.com/innovation-hub/prohub-cli.git
45
+ cd prohub-cli
46
+
47
+ # Instale as dependências
48
+ npm install
49
+
50
+ # Link globalmente para testar
51
+ npm link
52
+
53
+ # Rode o comando
54
+ innovationhub
55
+ ```
56
+
57
+ ## Publicação e Atualização
58
+
59
+ Para liberar uma nova versão para todos os usuários:
60
+
61
+ 1. **Atualize a versão**:
62
+ Use o comando do npm para atualizar o `package.json` automaticamente (seguindo semantic versioning):
63
+
64
+ ```bash
65
+ # Para correções de bugs (1.0.0 -> 1.0.1)
66
+ npm version patch
67
+
68
+ # Para novas funcionalidades (1.0.0 -> 1.1.0)
69
+ npm version minor
70
+
71
+ # Para mudanças que quebram compatibilidade (1.0.0 -> 2.0.0)
72
+ npm version major
73
+ ```
74
+
75
+ 2. **Login no NPM** (se executado pela primeira vez):
76
+ ```bash
77
+ npm login
78
+ ```
79
+
80
+ 3. **Publique**:
81
+ ```bash
82
+ npm publish --access public
83
+ ```
84
+
85
+ Os usuários que usam `npx innovationhub-cli` pegarão a nova versão automaticamente (pode levar alguns minutos para o cache do npx atualizar).
86
+ Quem instalou globalmente precisará rodar `npm install -g innovationhub-cli` novamente para atualizar.
package/index.js ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ import * as p from '@clack/prompts';
3
+ import { setupProject } from './utils/git.js';
4
+
5
+ async function main() {
6
+ p.intro('InnovationHub Project Generator');
7
+
8
+ const projectName = await p.text({
9
+ message: 'Qual o nome do seu projeto?',
10
+ placeholder: 'meu-projeto',
11
+ validate: (value) => {
12
+ if (!value) return 'Por favor, insira um nome.';
13
+ if (/[^a-z0-9-]/.test(value)) return 'Use apenas letras minúsculas, números e hífens.';
14
+ },
15
+ });
16
+
17
+ if (p.isCancel(projectName)) {
18
+ p.cancel('Operação cancelada.');
19
+ process.exit(0);
20
+ }
21
+
22
+ const category = await p.select({
23
+ message: 'O que você vai iniciar agora?',
24
+ options: [
25
+ { value: 'back', label: 'Backend (Repositório de API)' },
26
+ { value: 'front', label: 'Frontend (Repositório de Interface)' },
27
+ ],
28
+ });
29
+
30
+ if (p.isCancel(category)) {
31
+ p.cancel('Operação cancelada.');
32
+ process.exit(0);
33
+ }
34
+
35
+ let stack;
36
+
37
+ if (category === 'back') {
38
+ stack = await p.select({
39
+ message: 'Qual a stack do Backend?',
40
+ options: [
41
+ { value: 'nest', label: 'NestJS' },
42
+ { value: 'python', label: 'Python (FastAPI)' },
43
+ { value: 'java', label: 'Java (Spring)' },
44
+ ],
45
+ });
46
+ } else if (category === 'front') {
47
+ stack = await p.select({
48
+ message: 'Qual a stack do Frontend?',
49
+ options: [
50
+ { value: 'next', label: 'Next.js' },
51
+ { value: 'vue', label: 'Vue.js' },
52
+ { value: 'angular', label: 'Angular' },
53
+ ],
54
+ });
55
+ }
56
+
57
+ if (p.isCancel(stack)) {
58
+ p.cancel('Operação cancelada.');
59
+ process.exit(0);
60
+ }
61
+
62
+ await setupProject(stack, projectName);
63
+
64
+ p.outro('Projeto criado com sucesso!');
65
+ }
66
+
67
+ main().catch(console.error);
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "innovationhub-cli",
3
+ "version": "1.0.1",
4
+ "description": "CLI oficial da InnovationHub para inicializar projetos Backend e Frontend.",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "innovationhub": "index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/innovation-hub/prohub-cli.git"
12
+ },
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1"
15
+ },
16
+ "keywords": [
17
+ "cli",
18
+ "scaffold",
19
+ "innovation-hub",
20
+ "backend",
21
+ "frontend"
22
+ ],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "type": "module",
26
+ "dependencies": {
27
+ "@clack/prompts": "^1.0.1",
28
+ "execa": "^9.6.1",
29
+ "picocolors": "^1.1.1"
30
+ }
31
+ }
package/utils/git.js ADDED
@@ -0,0 +1,47 @@
1
+ import { execa } from 'execa';
2
+ import * as p from '@clack/prompts';
3
+ import pc from 'picocolors';
4
+ import fs from 'node:fs/promises';
5
+
6
+ const REPOS = {
7
+ nest: 'https://github.com/ProHub-Innovation/template-nest.git',
8
+ python: 'https://github.com/ProHub-Innovation/template-fastapi.git',
9
+ java: 'https://github.com/ProHub-Innovation/template-spring.git',
10
+ next: 'https://github.com/ProHub-Innovation/template-nextjs.git',
11
+ vue: 'https://github.com/ProHub-Innovation/template-vue.git',
12
+ angular: 'https://github.com/ProHub-Innovation/template-angular.git',
13
+ };
14
+
15
+ export async function setupProject(stack, projectName) {
16
+ const s = p.spinner();
17
+ s.start(`Baixando template oficial para ${stack}...`);
18
+
19
+ try {
20
+ if (!REPOS[stack]) {
21
+ throw new Error(`Template para '${stack}' não encontrado.`);
22
+ }
23
+
24
+ await execa('git', ['clone', REPOS[stack], projectName]);
25
+
26
+ // Remove .git folder to detach from the template repository
27
+ const gitPath = `${projectName}/.git`;
28
+ await fs.rm(gitPath, { recursive: true, force: true });
29
+
30
+ // Initialize a new git repository
31
+ await execa('git', ['init'], { cwd: projectName });
32
+
33
+ s.stop(pc.green('Template configurado com sucesso!'));
34
+
35
+ p.note(`
36
+ Pŕoximos passos:
37
+ 1. cd ${projectName}
38
+ 2. npm install (ou gerenciador de preferência)
39
+ 3. Validar variáveis de ambiente (.env)
40
+ `, 'Tudo pronto!');
41
+
42
+ } catch (error) {
43
+ s.stop(pc.red('Erro ao configurar o projeto.'));
44
+ p.cancel(error.message);
45
+ process.exit(1);
46
+ }
47
+ }