devstarter-tool 0.1.1 → 0.2.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 +30 -1
- package/dist/cli.js +1 -0
- package/dist/commands/init/collector.js +13 -5
- package/dist/prompts/initPrompts.js +8 -6
- package/dist/templates/frontend/basic/index.html +12 -0
- package/dist/templates/frontend/basic/package.json.tpl +8 -1
- package/dist/templates/frontend/basic/src/main.ts +6 -1
- package/dist/templates/frontend/basic/tsconfig.json +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ devstarter init [project-name]
|
|
|
30
30
|
| `-t, --type <type>` | Project type: `frontend` or `backend` |
|
|
31
31
|
| `--template <name>` | Template to use |
|
|
32
32
|
| `--dry-run` | Preview changes without creating files |
|
|
33
|
+
| `--no-git` | Skip git repository initialization |
|
|
34
|
+
| `--no-vitest` | Skip Vitest testing framework setup |
|
|
33
35
|
|
|
34
36
|
### Examples
|
|
35
37
|
|
|
@@ -45,6 +47,12 @@ devstarter init my-app --type frontend -y
|
|
|
45
47
|
|
|
46
48
|
# Preview what files would be created
|
|
47
49
|
devstarter init my-app --type frontend --dry-run
|
|
50
|
+
|
|
51
|
+
# Create project without git initialization
|
|
52
|
+
devstarter init my-app --no-git
|
|
53
|
+
|
|
54
|
+
# Create project without Vitest setup
|
|
55
|
+
devstarter init my-app --no-vitest
|
|
48
56
|
```
|
|
49
57
|
|
|
50
58
|
## Project Structures
|
|
@@ -54,7 +62,10 @@ devstarter init my-app --type frontend --dry-run
|
|
|
54
62
|
```
|
|
55
63
|
my-app/
|
|
56
64
|
├── src/
|
|
57
|
-
│
|
|
65
|
+
│ ├── main.ts (or main.tsx for React)
|
|
66
|
+
│ └── __tests__/
|
|
67
|
+
│ └── example.test.ts
|
|
68
|
+
├── vitest.config.ts
|
|
58
69
|
├── package.json
|
|
59
70
|
├── README.md
|
|
60
71
|
└── .git/ (if git is initialized)
|
|
@@ -96,10 +107,28 @@ my-app/
|
|
|
96
107
|
- Automatic package manager detection (npm, pnpm, yarn)
|
|
97
108
|
- Interactive template selection
|
|
98
109
|
- Optional Git repository initialization
|
|
110
|
+
- Optional Vitest testing framework setup
|
|
99
111
|
- Dry-run mode to preview changes
|
|
100
112
|
- Automatic project name normalization (kebab-case)
|
|
101
113
|
- Colored output for better readability
|
|
102
114
|
|
|
115
|
+
## Testing Setup (Vitest)
|
|
116
|
+
|
|
117
|
+
By default, projects are created with Vitest configured. This includes:
|
|
118
|
+
|
|
119
|
+
- `vitest` as a dev dependency
|
|
120
|
+
- `vitest.config.ts` configuration file
|
|
121
|
+
- Example test file in `src/__tests__/example.test.ts`
|
|
122
|
+
- `test` script in package.json
|
|
123
|
+
|
|
124
|
+
For React projects, it also adds `jsdom` for DOM testing.
|
|
125
|
+
|
|
126
|
+
To skip Vitest setup, use the `--no-vitest` flag:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
devstarter init my-app --no-vitest
|
|
130
|
+
```
|
|
131
|
+
|
|
103
132
|
## Development
|
|
104
133
|
|
|
105
134
|
### Requirements
|
package/dist/cli.js
CHANGED
|
@@ -13,5 +13,6 @@ program
|
|
|
13
13
|
.option('-t, --type <type>', 'Project type (frontend | backend)')
|
|
14
14
|
.option('--template <name>', 'Template variant (e.g. basic, react)')
|
|
15
15
|
.option('--dry-run', 'Show what would be generated without creating files')
|
|
16
|
+
.option('--no-git', 'Skip git repository initialization')
|
|
16
17
|
.action(initCommand);
|
|
17
18
|
program.parse(process.argv);
|
|
@@ -39,20 +39,22 @@ async function collectStructure(useDefaults) {
|
|
|
39
39
|
}
|
|
40
40
|
async function collectBasicContext(projectName, options, useDefaults) {
|
|
41
41
|
const typeFromFlag = resolveProjectType(options.type);
|
|
42
|
+
const gitFlagProvided = options.git !== undefined;
|
|
42
43
|
// Obtener tipo de proyecto e initGit
|
|
43
44
|
let projectType;
|
|
44
45
|
let initGit;
|
|
45
46
|
if (useDefaults) {
|
|
46
47
|
projectType = typeFromFlag ?? DEFAULT_INIT_OPTIONS.projectType;
|
|
47
|
-
initGit = DEFAULT_INIT_OPTIONS.initGit;
|
|
48
|
+
initGit = gitFlagProvided ? options.git : DEFAULT_INIT_OPTIONS.initGit;
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
51
|
const answers = await askInitQuestions({
|
|
51
52
|
skipProjectName: true,
|
|
52
53
|
skipProjectType: Boolean(typeFromFlag),
|
|
54
|
+
skipInitGit: gitFlagProvided,
|
|
53
55
|
});
|
|
54
56
|
projectType = typeFromFlag ?? answers.projectType;
|
|
55
|
-
initGit = answers.initGit;
|
|
57
|
+
initGit = gitFlagProvided ? options.git : answers.initGit;
|
|
56
58
|
}
|
|
57
59
|
// Obtener template
|
|
58
60
|
const templates = listTemplates(projectType);
|
|
@@ -72,13 +74,14 @@ async function collectMonorepoContext(projectName, useDefaults, options) {
|
|
|
72
74
|
// Templates para web (frontend) y api (backend)
|
|
73
75
|
const frontendTemplates = listTemplates('frontend');
|
|
74
76
|
const backendTemplates = listTemplates('backend');
|
|
77
|
+
const gitFlagProvided = options.git !== undefined;
|
|
75
78
|
let webTemplate;
|
|
76
79
|
let apiTemplate;
|
|
77
80
|
let initGit;
|
|
78
81
|
if (useDefaults) {
|
|
79
82
|
webTemplate = frontendTemplates[0] ?? 'basic';
|
|
80
83
|
apiTemplate = backendTemplates[0] ?? 'basic';
|
|
81
|
-
initGit = DEFAULT_INIT_OPTIONS.initGit;
|
|
84
|
+
initGit = gitFlagProvided ? options.git : DEFAULT_INIT_OPTIONS.initGit;
|
|
82
85
|
}
|
|
83
86
|
else {
|
|
84
87
|
const webAnswer = await askTemplate({
|
|
@@ -91,8 +94,13 @@ async function collectMonorepoContext(projectName, useDefaults, options) {
|
|
|
91
94
|
message: 'Template for apps/api (backend):',
|
|
92
95
|
});
|
|
93
96
|
apiTemplate = apiAnswer.template;
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
if (gitFlagProvided) {
|
|
98
|
+
initGit = options.git;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const gitAnswer = await askInitGit();
|
|
102
|
+
initGit = gitAnswer.initGit;
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
return {
|
|
98
106
|
structure: 'monorepo',
|
|
@@ -48,12 +48,14 @@ export async function askInitQuestions(options = {}) {
|
|
|
48
48
|
],
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
if (!options.skipInitGit) {
|
|
52
|
+
questions.push({
|
|
53
|
+
type: 'confirm',
|
|
54
|
+
name: 'initGit',
|
|
55
|
+
message: 'Initialize a git repository?',
|
|
56
|
+
initial: true,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
57
59
|
return prompts(questions, { onCancel });
|
|
58
60
|
}
|
|
59
61
|
export async function askTemplate(options) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>{{projectName}}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="/src/main.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{projectName}}",
|
|
3
3
|
"private": true,
|
|
4
|
+
"type": "module",
|
|
4
5
|
"scripts": {
|
|
5
|
-
"dev": "
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"preview": "vite preview"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"typescript": "^5.5.4",
|
|
12
|
+
"vite": "^5.4.0"
|
|
6
13
|
}
|
|
7
14
|
}
|