@nexus-framework/cli 0.2.0 → 0.3.0
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 +62 -6
- package/dist/cli.js +87 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/adopt.d.ts +4 -2
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +47 -8
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/pack.d.ts +28 -0
- package/dist/commands/pack.d.ts.map +1 -0
- package/dist/commands/pack.js +206 -0
- package/dist/commands/pack.js.map +1 -0
- package/dist/commands/skill.d.ts +53 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +371 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/update.d.ts +24 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +100 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/generators/ai-config.js +40 -1
- package/dist/generators/ai-config.js.map +1 -1
- package/dist/generators/docs.d.ts +10 -1
- package/dist/generators/docs.d.ts.map +1 -1
- package/dist/generators/docs.js +40 -65
- package/dist/generators/docs.js.map +1 -1
- package/dist/generators/index.d.ts +2 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +85 -9
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/skills.d.ts +32 -0
- package/dist/generators/skills.d.ts.map +1 -0
- package/dist/generators/skills.js +220 -0
- package/dist/generators/skills.js.map +1 -0
- package/dist/generators/spring-boot.d.ts +12 -0
- package/dist/generators/spring-boot.d.ts.map +1 -0
- package/dist/generators/spring-boot.js +220 -0
- package/dist/generators/spring-boot.js.map +1 -0
- package/dist/generators/structure.d.ts +1 -0
- package/dist/generators/structure.d.ts.map +1 -1
- package/dist/generators/structure.js +129 -24
- package/dist/generators/structure.js.map +1 -1
- package/dist/prompts/adoption.d.ts +35 -0
- package/dist/prompts/adoption.d.ts.map +1 -0
- package/dist/prompts/adoption.js +153 -0
- package/dist/prompts/adoption.js.map +1 -0
- package/dist/prompts/frameworks.d.ts +5 -1
- package/dist/prompts/frameworks.d.ts.map +1 -1
- package/dist/prompts/frameworks.js +49 -1
- package/dist/prompts/frameworks.js.map +1 -1
- package/dist/prompts/index.d.ts +2 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +32 -7
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/project-type.d.ts.map +1 -1
- package/dist/prompts/project-type.js +6 -1
- package/dist/prompts/project-type.js.map +1 -1
- package/dist/prompts/skill-config.d.ts +19 -0
- package/dist/prompts/skill-config.d.ts.map +1 -0
- package/dist/prompts/skill-config.js +22 -0
- package/dist/prompts/skill-config.js.map +1 -0
- package/dist/types/config.d.ts +9 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/file-system.d.ts.map +1 -1
- package/dist/utils/file-system.js +4 -2
- package/dist/utils/file-system.js.map +1 -1
- package/dist/utils/logger.d.ts +2 -2
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +49 -36
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/project-detector.d.ts +20 -4
- package/dist/utils/project-detector.d.ts.map +1 -1
- package/dist/utils/project-detector.js +156 -27
- package/dist/utils/project-detector.js.map +1 -1
- package/dist/utils/update-check.d.ts +27 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +111 -0
- package/dist/utils/update-check.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -2
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NEXUS CLI - Skills Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates the `.nexus/skills/` directory structure for a project.
|
|
5
|
+
* Skill content is sourced from the live `@nexus-framework/skills` npm package.
|
|
6
|
+
*
|
|
7
|
+
* What it creates:
|
|
8
|
+
* .nexus/skills/README.md — agent-readable index of all installed skills
|
|
9
|
+
* .nexus/skills/core/<skill>.md — framework-matched skill files (replaceable on upgrade)
|
|
10
|
+
* .nexus/skills/custom/README.md — placeholder with instructions for user-created skills
|
|
11
|
+
*
|
|
12
|
+
* Ownership rules:
|
|
13
|
+
* - core/ is owned by NEXUS — regenerated on upgrade
|
|
14
|
+
* - custom/ is owned by the user — NEVER touched by NEXUS (only created once)
|
|
15
|
+
* - community/ is created empty — populated by `nexus skill install`
|
|
16
|
+
*/
|
|
17
|
+
import { getSkillContent, listSkills } from '@nexus-framework/skills';
|
|
18
|
+
/* ──────────────────────────────────────────────────────────────
|
|
19
|
+
* Framework name mapping
|
|
20
|
+
* CLI config uses 'nextjs'; the skills package uses 'next.js'
|
|
21
|
+
* ────────────────────────────────────────────────────────────── */
|
|
22
|
+
const FRAMEWORK_TO_SKILLS_DIR = {
|
|
23
|
+
nextjs: 'next.js',
|
|
24
|
+
'react-vite': 'react-vite',
|
|
25
|
+
sveltekit: 'sveltekit',
|
|
26
|
+
nuxt: 'nuxt',
|
|
27
|
+
astro: 'astro',
|
|
28
|
+
remix: 'remix',
|
|
29
|
+
none: 'shared',
|
|
30
|
+
};
|
|
31
|
+
const FRAMEWORK_LABELS = {
|
|
32
|
+
nextjs: 'Next.js',
|
|
33
|
+
'react-vite': 'React + Vite',
|
|
34
|
+
sveltekit: 'SvelteKit',
|
|
35
|
+
nuxt: 'Nuxt 3',
|
|
36
|
+
astro: 'Astro',
|
|
37
|
+
remix: 'Remix',
|
|
38
|
+
none: 'Framework-Agnostic',
|
|
39
|
+
};
|
|
40
|
+
/* ──────────────────────────────────────────────────────────────
|
|
41
|
+
* Public API
|
|
42
|
+
* ────────────────────────────────────────────────────────────── */
|
|
43
|
+
/**
|
|
44
|
+
* Generate all `.nexus/skills/` files for the project.
|
|
45
|
+
* Content is read live from `@nexus-framework/skills`.
|
|
46
|
+
*
|
|
47
|
+
* Returns an empty array if `config.enableSkills` is explicitly false.
|
|
48
|
+
* Defaults to generating skills when enableSkills is undefined (default on).
|
|
49
|
+
*/
|
|
50
|
+
export function generateSkills(config) {
|
|
51
|
+
if (config.enableSkills === false)
|
|
52
|
+
return [];
|
|
53
|
+
const framework = config.frontendFramework;
|
|
54
|
+
const skillsDir = FRAMEWORK_TO_SKILLS_DIR[framework] ?? 'shared';
|
|
55
|
+
const files = [];
|
|
56
|
+
// ── Framework-specific core skills ──────────────────────────
|
|
57
|
+
const frameworkSlugs = listSkills(skillsDir);
|
|
58
|
+
for (const slug of frameworkSlugs) {
|
|
59
|
+
const content = getSkillContent(skillsDir, slug);
|
|
60
|
+
if (content) {
|
|
61
|
+
files.push({ path: `.nexus/skills/core/${slug}.md`, content });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// ── Shared skills (always installed) ────────────────────────
|
|
65
|
+
// Skip if the framework IS shared (avoids duplicates for 'none')
|
|
66
|
+
if (skillsDir !== 'shared') {
|
|
67
|
+
const sharedSlugs = listSkills('shared');
|
|
68
|
+
for (const slug of sharedSlugs) {
|
|
69
|
+
// Only add if not already provided by framework pack
|
|
70
|
+
if (!frameworkSlugs.includes(slug)) {
|
|
71
|
+
const content = getSkillContent('shared', slug);
|
|
72
|
+
if (content) {
|
|
73
|
+
files.push({ path: `.nexus/skills/core/${slug}.md`, content });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// ── Custom skills placeholder (never overwritten) ───────────
|
|
79
|
+
files.push(generateCustomReadme());
|
|
80
|
+
// ── Skills README index (always regenerated) ───────────────
|
|
81
|
+
files.push(generateSkillsReadme(framework, skillsDir));
|
|
82
|
+
return files;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* List all skill slugs that will be generated for a given framework.
|
|
86
|
+
* Used by upgrade/repair reconcile logic to know which core files exist.
|
|
87
|
+
*/
|
|
88
|
+
export function getCoreSkillSlugs(framework) {
|
|
89
|
+
const skillsDir = FRAMEWORK_TO_SKILLS_DIR[framework] ?? 'shared';
|
|
90
|
+
const frameworkSlugs = listSkills(skillsDir);
|
|
91
|
+
if (skillsDir === 'shared')
|
|
92
|
+
return frameworkSlugs;
|
|
93
|
+
const sharedSlugs = listSkills('shared').filter((s) => !frameworkSlugs.includes(s));
|
|
94
|
+
return [...frameworkSlugs, ...sharedSlugs];
|
|
95
|
+
}
|
|
96
|
+
/* ──────────────────────────────────────────────────────────────
|
|
97
|
+
* Skills README index (.nexus/skills/README.md)
|
|
98
|
+
* ────────────────────────────────────────────────────────────── */
|
|
99
|
+
function generateSkillsReadme(framework, skillsDir) {
|
|
100
|
+
const frameworkLabel = FRAMEWORK_LABELS[framework] ?? framework;
|
|
101
|
+
const allSlugs = getCoreSkillSlugs(framework);
|
|
102
|
+
const coreRows = allSlugs
|
|
103
|
+
.map((slug) => `| \`${slug}\` | [read](.nexus/skills/core/${slug}.md) |`)
|
|
104
|
+
.join('\n');
|
|
105
|
+
const content = `# NEXUS Skills Index
|
|
106
|
+
|
|
107
|
+
> Auto-generated by NEXUS CLI. Sourced from \`@nexus-framework/skills@0.1.0\`.
|
|
108
|
+
> Run \`nexus upgrade\` to refresh core skills to the latest version.
|
|
109
|
+
> Add your own skills in \`custom/\` using \`nexus skill new <name>\`.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## What Are Skills?
|
|
114
|
+
|
|
115
|
+
Skills are pre-read instruction files that tell AI agents **how to execute tasks** in this
|
|
116
|
+
specific project. Before performing any significant task, your AI agent checks this directory
|
|
117
|
+
for a matching skill and reads it fully before starting.
|
|
118
|
+
|
|
119
|
+
**Skills live in three directories:**
|
|
120
|
+
|
|
121
|
+
| Directory | Owner | Updated By |
|
|
122
|
+
|-----------|-------|------------|
|
|
123
|
+
| \`core/\` | NEXUS | Regenerated by \`nexus upgrade\` |
|
|
124
|
+
| \`custom/\` | You | **Never touched by NEXUS** |
|
|
125
|
+
| \`community/\` | Registry | \`nexus skill install <pkg>\` |
|
|
126
|
+
|
|
127
|
+
**Precedence: \`custom/\` overrides \`core/\`, which overrides \`community/\`.**
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Core Skills (${frameworkLabel})
|
|
132
|
+
|
|
133
|
+
> Sourced from \`@nexus-framework/skills\` — framework: \`${skillsDir}\` + \`shared\`
|
|
134
|
+
|
|
135
|
+
| Skill | File |
|
|
136
|
+
|-------|------|
|
|
137
|
+
${coreRows}
|
|
138
|
+
|
|
139
|
+
## Custom Skills
|
|
140
|
+
|
|
141
|
+
No custom skills yet. Run \`nexus skill new <name>\` to create one.
|
|
142
|
+
|
|
143
|
+
Custom skills live in \`.nexus/skills/custom/\` and are **never overwritten** by NEXUS.
|
|
144
|
+
|
|
145
|
+
## Community Skills
|
|
146
|
+
|
|
147
|
+
No community skills installed. Run \`nexus skill install <pkg>\` to install from the registry.
|
|
148
|
+
`;
|
|
149
|
+
return { path: '.nexus/skills/README.md', content };
|
|
150
|
+
}
|
|
151
|
+
/* ──────────────────────────────────────────────────────────────
|
|
152
|
+
* Custom skills placeholder
|
|
153
|
+
* ────────────────────────────────────────────────────────────── */
|
|
154
|
+
function generateCustomReadme() {
|
|
155
|
+
const content = `# Custom Skills
|
|
156
|
+
|
|
157
|
+
This directory is for **your** project-specific skills.
|
|
158
|
+
|
|
159
|
+
NEXUS will **never** read from, write to, or delete files in this directory.
|
|
160
|
+
It is entirely owned by you.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## How to Create a Custom Skill
|
|
165
|
+
|
|
166
|
+
Run:
|
|
167
|
+
\`\`\`
|
|
168
|
+
nexus skill new <name>
|
|
169
|
+
\`\`\`
|
|
170
|
+
|
|
171
|
+
This will scaffold a new skill file with the correct frontmatter and section structure.
|
|
172
|
+
|
|
173
|
+
## Skill File Format
|
|
174
|
+
|
|
175
|
+
Every skill must have YAML frontmatter:
|
|
176
|
+
|
|
177
|
+
\`\`\`markdown
|
|
178
|
+
---
|
|
179
|
+
skill: your-skill-slug
|
|
180
|
+
version: 1.0.0
|
|
181
|
+
framework: shared
|
|
182
|
+
category: ui
|
|
183
|
+
triggers:
|
|
184
|
+
- "phrase that activates this skill"
|
|
185
|
+
- "another trigger phrase"
|
|
186
|
+
author: your-name
|
|
187
|
+
status: draft
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
# Skill: Title
|
|
191
|
+
|
|
192
|
+
## When to Read This
|
|
193
|
+
...
|
|
194
|
+
|
|
195
|
+
## Steps
|
|
196
|
+
1. ...
|
|
197
|
+
|
|
198
|
+
## Patterns We Use
|
|
199
|
+
...
|
|
200
|
+
|
|
201
|
+
## Anti-Patterns — Never Do This
|
|
202
|
+
...
|
|
203
|
+
|
|
204
|
+
## Example
|
|
205
|
+
...
|
|
206
|
+
\`\`\`
|
|
207
|
+
|
|
208
|
+
## Status Values
|
|
209
|
+
|
|
210
|
+
- \`active\` — AI agents must follow this skill
|
|
211
|
+
- \`draft\` — Guidance only; not yet enforced
|
|
212
|
+
- \`deprecated\` — Outdated; flag for update
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
*Add your skills here. They take precedence over core and community skills.*
|
|
217
|
+
`;
|
|
218
|
+
return { path: '.nexus/skills/custom/README.md', content };
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/generators/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKtE;;;oEAGoE;AAEpE,MAAM,uBAAuB,GAA2B;IACtD,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,YAAY;IAC1B,SAAS,EAAE,WAAW;IACtB,IAAI,EAAE,MAAM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O,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0BA,cAAc;;4DAE4B,SAAS;;;;EAInE,QAAQ;;;;;;;;;;;CAWT,CAAC;IAEA,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,CAAC;AACtD,CAAC;AAED;;oEAEoE;AAEpE,SAAS,oBAAoB;IAC3B,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DjB,CAAC;IAEA,OAAO,EAAE,IAAI,EAAE,gCAAgC,EAAE,OAAO,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NEXUS CLI - Spring Boot Project Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates pom.xml, application.properties, and basic Spring Boot structure.
|
|
5
|
+
*/
|
|
6
|
+
import type { NexusConfig } from '../types/config.js';
|
|
7
|
+
import type { GeneratedFile } from '../types/templates.js';
|
|
8
|
+
/**
|
|
9
|
+
* Generate Spring Boot project files (Maven-based)
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateSpringBootFiles(config: NexusConfig): GeneratedFile[];
|
|
12
|
+
//# sourceMappingURL=spring-boot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring-boot.d.ts","sourceRoot":"","sources":["../../src/generators/spring-boot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,EAAE,CAmB5E"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NEXUS CLI - Spring Boot Project Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates pom.xml, application.properties, and basic Spring Boot structure.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Generate Spring Boot project files (Maven-based)
|
|
8
|
+
*/
|
|
9
|
+
export function generateSpringBootFiles(config) {
|
|
10
|
+
const files = [];
|
|
11
|
+
// Generate pom.xml (Maven build file)
|
|
12
|
+
files.push(generatePomXml(config));
|
|
13
|
+
// Generate application.properties
|
|
14
|
+
files.push(generateApplicationProperties(config));
|
|
15
|
+
// Generate main Application class
|
|
16
|
+
files.push(generateApplicationClass(config));
|
|
17
|
+
// Generate a sample controller
|
|
18
|
+
files.push(generateSampleController(config));
|
|
19
|
+
// Generate application test
|
|
20
|
+
files.push(generateApplicationTest(config));
|
|
21
|
+
return files;
|
|
22
|
+
}
|
|
23
|
+
function generatePomXml(config) {
|
|
24
|
+
const groupId = 'com.example';
|
|
25
|
+
const artifactId = config.projectName;
|
|
26
|
+
return {
|
|
27
|
+
path: 'pom.xml',
|
|
28
|
+
content: `<?xml version="1.0" encoding="UTF-8"?>
|
|
29
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
30
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
31
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
32
|
+
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
33
|
+
<modelVersion>4.0.0</modelVersion>
|
|
34
|
+
|
|
35
|
+
<parent>
|
|
36
|
+
<groupId>org.springframework.boot</groupId>
|
|
37
|
+
<artifactId>spring-boot-starter-parent</artifactId>
|
|
38
|
+
<version>3.2.0</version>
|
|
39
|
+
<relativePath/>
|
|
40
|
+
</parent>
|
|
41
|
+
|
|
42
|
+
<groupId>${groupId}</groupId>
|
|
43
|
+
<artifactId>${artifactId}</artifactId>
|
|
44
|
+
<version>0.1.0</version>
|
|
45
|
+
<name>${config.displayName}</name>
|
|
46
|
+
<description>${config.displayName} - Spring Boot API</description>
|
|
47
|
+
|
|
48
|
+
<properties>
|
|
49
|
+
<java.version>21</java.version>
|
|
50
|
+
</properties>
|
|
51
|
+
|
|
52
|
+
<dependencies>
|
|
53
|
+
<!-- Spring Boot Web Starter -->
|
|
54
|
+
<dependency>
|
|
55
|
+
<groupId>org.springframework.boot</groupId>
|
|
56
|
+
<artifactId>spring-boot-starter-web</artifactId>
|
|
57
|
+
</dependency>
|
|
58
|
+
|
|
59
|
+
<!-- Spring Boot DevTools (optional, for hot reload) -->
|
|
60
|
+
<dependency>
|
|
61
|
+
<groupId>org.springframework.boot</groupId>
|
|
62
|
+
<artifactId>spring-boot-devtools</artifactId>
|
|
63
|
+
<scope>runtime</scope>
|
|
64
|
+
<optional>true</optional>
|
|
65
|
+
</dependency>
|
|
66
|
+
|
|
67
|
+
<!-- Spring Boot Actuator (health checks, metrics) -->
|
|
68
|
+
<dependency>
|
|
69
|
+
<groupId>org.springframework.boot</groupId>
|
|
70
|
+
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
71
|
+
</dependency>
|
|
72
|
+
|
|
73
|
+
<!-- Lombok (optional, reduces boilerplate) -->
|
|
74
|
+
<dependency>
|
|
75
|
+
<groupId>org.projectlombok</groupId>
|
|
76
|
+
<artifactId>lombok</artifactId>
|
|
77
|
+
<optional>true</optional>
|
|
78
|
+
</dependency>
|
|
79
|
+
|
|
80
|
+
<!-- Spring Boot Test -->
|
|
81
|
+
<dependency>
|
|
82
|
+
<groupId>org.springframework.boot</groupId>
|
|
83
|
+
<artifactId>spring-boot-starter-test</artifactId>
|
|
84
|
+
<scope>test</scope>
|
|
85
|
+
</dependency>
|
|
86
|
+
</dependencies>
|
|
87
|
+
|
|
88
|
+
<build>
|
|
89
|
+
<plugins>
|
|
90
|
+
<plugin>
|
|
91
|
+
<groupId>org.springframework.boot</groupId>
|
|
92
|
+
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
93
|
+
</plugin>
|
|
94
|
+
</plugins>
|
|
95
|
+
</build>
|
|
96
|
+
</project>
|
|
97
|
+
`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function generateApplicationProperties(config) {
|
|
101
|
+
return {
|
|
102
|
+
path: 'src/main/resources/application.properties',
|
|
103
|
+
content: `# ${config.displayName} Configuration
|
|
104
|
+
|
|
105
|
+
# Server Configuration
|
|
106
|
+
server.port=8080
|
|
107
|
+
|
|
108
|
+
# Application Name
|
|
109
|
+
spring.application.name=${config.projectName}
|
|
110
|
+
|
|
111
|
+
# Actuator Configuration
|
|
112
|
+
management.endpoints.web.exposure.include=health,info,metrics
|
|
113
|
+
|
|
114
|
+
# Logging Configuration
|
|
115
|
+
logging.level.root=INFO
|
|
116
|
+
logging.level.com.example=DEBUG
|
|
117
|
+
|
|
118
|
+
# TODO: Add your custom configuration here
|
|
119
|
+
`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function generateApplicationClass(config) {
|
|
123
|
+
const className = toPascalCase(config.projectName) + 'Application';
|
|
124
|
+
const packageName = `com.example.${config.projectName.replace(/-/g, '')}`;
|
|
125
|
+
return {
|
|
126
|
+
path: `src/main/java/${packageName.replace(/\./g, '/')}/${className}.java`,
|
|
127
|
+
content: `package ${packageName};
|
|
128
|
+
|
|
129
|
+
import org.springframework.boot.SpringApplication;
|
|
130
|
+
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* ${config.displayName} - Main Application Class
|
|
134
|
+
*
|
|
135
|
+
* This is the entry point for your Spring Boot application.
|
|
136
|
+
*/
|
|
137
|
+
@SpringBootApplication
|
|
138
|
+
public class ${className} {
|
|
139
|
+
|
|
140
|
+
public static void main(String[] args) {
|
|
141
|
+
SpringApplication.run(${className}.class, args);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function generateSampleController(config) {
|
|
148
|
+
const packageName = `com.example.${config.projectName.replace(/-/g, '')}`;
|
|
149
|
+
return {
|
|
150
|
+
path: `src/main/java/${packageName.replace(/\./g, '/')}/controller/HelloController.java`,
|
|
151
|
+
content: `package ${packageName}.controller;
|
|
152
|
+
|
|
153
|
+
import org.springframework.web.bind.annotation.GetMapping;
|
|
154
|
+
import org.springframework.web.bind.annotation.RequestMapping;
|
|
155
|
+
import org.springframework.web.bind.annotation.RestController;
|
|
156
|
+
|
|
157
|
+
import java.util.Map;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Sample REST controller demonstrating basic endpoint structure.
|
|
161
|
+
*
|
|
162
|
+
* Replace this with your actual API endpoints.
|
|
163
|
+
*/
|
|
164
|
+
@RestController
|
|
165
|
+
@RequestMapping("/api")
|
|
166
|
+
public class HelloController {
|
|
167
|
+
|
|
168
|
+
@GetMapping("/hello")
|
|
169
|
+
public Map<String, String> hello() {
|
|
170
|
+
return Map.of(
|
|
171
|
+
"message", "Hello from ${config.displayName}!",
|
|
172
|
+
"status", "ok"
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@GetMapping("/health")
|
|
177
|
+
public Map<String, String> health() {
|
|
178
|
+
return Map.of(
|
|
179
|
+
"status", "UP",
|
|
180
|
+
"service", "${config.projectName}"
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
`,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function generateApplicationTest(config) {
|
|
188
|
+
const className = toPascalCase(config.projectName) + 'Application';
|
|
189
|
+
const packageName = `com.example.${config.projectName.replace(/-/g, '')}`;
|
|
190
|
+
return {
|
|
191
|
+
path: `src/test/java/${packageName.replace(/\./g, '/')}/${className}Tests.java`,
|
|
192
|
+
content: `package ${packageName};
|
|
193
|
+
|
|
194
|
+
import org.junit.jupiter.api.Test;
|
|
195
|
+
import org.springframework.boot.test.context.SpringBootTest;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Integration tests for ${config.displayName}
|
|
199
|
+
*/
|
|
200
|
+
@SpringBootTest
|
|
201
|
+
class ${className}Tests {
|
|
202
|
+
|
|
203
|
+
@Test
|
|
204
|
+
void contextLoads() {
|
|
205
|
+
// Verifies that Spring context loads successfully
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Convert kebab-case to PascalCase
|
|
213
|
+
*/
|
|
214
|
+
function toPascalCase(str) {
|
|
215
|
+
return str
|
|
216
|
+
.split('-')
|
|
217
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
218
|
+
.join('');
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=spring-boot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring-boot.js","sourceRoot":"","sources":["../../src/generators/spring-boot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAmB;IACzD,MAAM,KAAK,GAAoB,EAAE,CAAC;IAElC,sCAAsC;IACtC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnC,kCAAkC;IAClC,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,MAAM,CAAC,CAAC,CAAC;IAElD,kCAAkC;IAClC,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7C,+BAA+B;IAC/B,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7C,4BAA4B;IAC5B,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,MAAmB;IACzC,MAAM,OAAO,GAAG,aAAa,CAAC;IAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;IAEtC,OAAO;QACL,IAAI,E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BAAuB,CAAC,MAAmB;IAClD,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC;IACnE,MAAM,WAAW,GAAG,eAAe,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;IAE1E,OAAO;QACL,IAAI,EAAE,iBAAiB,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,SAAS,YAAY;QAC/E,OAAO,EAAE,WAAW,WAAW;;;;;;2BAMR,MAAM,CAAC,WAAW;;;QAGrC,SAAS;;;;;;;CAOhB;KACE,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3D,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -11,6 +11,7 @@ import type { GeneratedFile, GeneratedDirectory } from '../types/templates.js';
|
|
|
11
11
|
export declare function generateDirectories(config: NexusConfig): GeneratedDirectory[];
|
|
12
12
|
/**
|
|
13
13
|
* Generate the project's package.json content.
|
|
14
|
+
* For Spring Boot projects, returns empty content (they use pom.xml/build.gradle).
|
|
14
15
|
*/
|
|
15
16
|
export declare function generatePackageJson(config: NexusConfig): GeneratedFile;
|
|
16
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/generators/structure.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE/E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/generators/structure.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE/E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,kBAAkB,EAAE,CAmG7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAgFtE;AAgND;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,aAAa,CAqCjD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CA0CjE"}
|