Skip to content

Commit 624c509

Browse files
committed
feat(General): Initial files
Initial application files
1 parent 18b55bd commit 624c509

File tree

2 files changed

+268
-0
lines changed

2 files changed

+268
-0
lines changed

src/index.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
import { execSync } from 'child_process';
4+
5+
// Tipo para la configuración del proyecto
6+
type ProjectConfig = {
7+
projectStructure: string[];
8+
packager: {
9+
type: string;
10+
config: {
11+
dependencies: string[];
12+
devDependencies: string[];
13+
};
14+
};
15+
git: {
16+
init: boolean;
17+
remote: string;
18+
url: string;
19+
};
20+
ci_cd: {
21+
provider: string;
22+
config: Record<string, unknown>;
23+
};
24+
database: {
25+
type: string;
26+
config: Record<string, unknown>;
27+
};
28+
testing: {
29+
framework: string;
30+
config: Record<string, unknown>;
31+
};
32+
documentation: {
33+
tool: string;
34+
config: Record<string, unknown>;
35+
};
36+
security: {
37+
features: string[];
38+
};
39+
deployment: {
40+
environments: string[];
41+
config: Record<string, unknown>;
42+
};
43+
i18n: {
44+
languages: string[];
45+
};
46+
};
47+
48+
// Leer el archivo de configuración del proyecto
49+
const config: ProjectConfig = JSON.parse(
50+
fs.readFileSync('project-config.json', 'utf-8'),
51+
);
52+
53+
// 1. Crear la estructura del proyecto
54+
config.projectStructure.forEach((dir) => {
55+
fs.mkdirSync(path.join(process.cwd(), dir), { recursive: true });
56+
});
57+
58+
// 2. Inicializar Git
59+
if (config.git.init) {
60+
execSync('git init');
61+
execSync(`git remote add ${config.git.remote} ${config.git.url}`);
62+
}
63+
64+
// 3. Configuración de CI/CD
65+
if (config.ci_cd.provider === 'GitHub Actions') {
66+
const workflowDir = path.join('.github', 'workflows');
67+
fs.mkdirSync(workflowDir, { recursive: true });
68+
// fs.writeFileSync(
69+
// path.join(workflowDir, config.ci_cd.config.workflow_file), // <= TODO: Revisar cuando se definan las opciones de GitHub Actions
70+
// '...',
71+
// );
72+
}
73+
74+
// 4. Configuración de la base de datos
75+
const dbConfigFile = path.join('config', 'database.json');
76+
fs.writeFileSync(dbConfigFile, JSON.stringify(config.database.config, null, 2));
77+
78+
// 5. Configuración del entorno de pruebas
79+
if (config.testing.framework === 'Jest') {
80+
execSync('npm install --save-dev jest');
81+
const jestConfigFile = path.join('config', 'jest.config.js');
82+
fs.writeFileSync(jestConfigFile, '...');
83+
}
84+
85+
// Packager Configuration
86+
if (config.packager.type === 'npm') {
87+
const dependencies = config.packager.config.dependencies.join(' ');
88+
const devDependencies = config.packager.config.devDependencies.join(' ');
89+
90+
if (dependencies) {
91+
execSync(`npm install ${dependencies}`);
92+
}
93+
94+
if (devDependencies) {
95+
execSync(`npm install --save-dev ${devDependencies}`);
96+
}
97+
} else if (config.packager.type === 'yarn') {
98+
// Yarn-specific logic
99+
// ...
100+
}

src/options.schema.json

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"projectStructure": {
6+
"type": "array",
7+
"description": "List of directories to create.",
8+
"items": {
9+
"type": "string"
10+
}
11+
},
12+
"packager": {
13+
"type": "object",
14+
"description": "Package manager settings.",
15+
"properties": {
16+
"type": {
17+
"type": "string",
18+
"description": "Package manager type (e.g., npm, yarn)."
19+
},
20+
"config": {
21+
"type": "object",
22+
"description": "Package manager-specific configuration.",
23+
"properties": {
24+
"dependencies": {
25+
"type": "array",
26+
"items": {
27+
"type": "string"
28+
},
29+
"description": "List of production dependencies to install."
30+
},
31+
"devDependencies": {
32+
"type": "array",
33+
"items": {
34+
"type": "string"
35+
},
36+
"description": "List of development dependencies to install."
37+
}
38+
}
39+
}
40+
},
41+
"required": [
42+
"type",
43+
"config"
44+
]
45+
},
46+
"git": {
47+
"type": "object",
48+
"description": "Git repository settings.",
49+
"properties": {
50+
"init": {
51+
"type": "boolean",
52+
"description": "Initialize a new Git repository."
53+
},
54+
"remote": {
55+
"type": "string",
56+
"description": "Remote repository URL."
57+
},
58+
"branch": {
59+
"type": "string",
60+
"description": "Default branch name."
61+
}
62+
}
63+
},
64+
"ci_cd": {
65+
"type": "object",
66+
"description": "CI/CD settings.",
67+
"properties": {
68+
"provider": {
69+
"type": "string",
70+
"description": "CI/CD provider (e.g., GitHub Actions, Jenkins)."
71+
},
72+
"config": {
73+
"type": "object",
74+
"description": "Provider-specific configuration."
75+
}
76+
}
77+
},
78+
"database": {
79+
"type": "object",
80+
"description": "Database settings.",
81+
"properties": {
82+
"type": {
83+
"type": "string",
84+
"description": "Database type (e.g., MongoDB, PostgreSQL)."
85+
},
86+
"config": {
87+
"type": "object",
88+
"description": "Database-specific configuration."
89+
}
90+
}
91+
},
92+
"testing": {
93+
"type": "object",
94+
"description": "Testing environment settings.",
95+
"properties": {
96+
"framework": {
97+
"type": "string",
98+
"description": "Testing framework (e.g., Jest, Mocha)."
99+
},
100+
"config": {
101+
"type": "object",
102+
"description": "Framework-specific configuration."
103+
}
104+
}
105+
},
106+
"documentation": {
107+
"type": "object",
108+
"description": "Documentation settings.",
109+
"properties": {
110+
"tool": {
111+
"type": "string",
112+
"description": "Documentation tool (e.g., JSDoc, Swagger)."
113+
},
114+
"config": {
115+
"type": "object",
116+
"description": "Tool-specific configuration."
117+
}
118+
}
119+
},
120+
"security": {
121+
"type": "object",
122+
"description": "Security settings.",
123+
"properties": {
124+
"features": {
125+
"type": "array",
126+
"items": {
127+
"type": "string"
128+
},
129+
"description": "List of security features to enable (e.g., CORS, input sanitization)."
130+
}
131+
}
132+
},
133+
"deployment": {
134+
"type": "object",
135+
"description": "Deployment settings.",
136+
"properties": {
137+
"environments": {
138+
"type": "array",
139+
"items": {
140+
"type": "string"
141+
},
142+
"description": "List of deployment environments (e.g., development, staging, production)."
143+
},
144+
"config": {
145+
"type": "object",
146+
"description": "Environment-specific configuration."
147+
}
148+
}
149+
},
150+
"i18n": {
151+
"type": "object",
152+
"description": "Internationalization settings.",
153+
"properties": {
154+
"languages": {
155+
"type": "array",
156+
"items": {
157+
"type": "string"
158+
},
159+
"description": "List of languages to support."
160+
}
161+
}
162+
}
163+
},
164+
"required": [
165+
"projectStructure",
166+
"git"
167+
]
168+
}

0 commit comments

Comments
 (0)