@ludena-studio/nx-astro 1.0.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +287 -0
  4. package/docs/configuration.md +528 -0
  5. package/docs/testing.md +322 -0
  6. package/executors/add/executor.d.ts +9 -0
  7. package/executors/add/executor.d.ts.map +1 -0
  8. package/executors/add/executor.js +51 -0
  9. package/executors/add/schema.json +20 -0
  10. package/executors/build/executor.d.ts +8 -0
  11. package/executors/build/executor.d.ts.map +1 -0
  12. package/executors/build/executor.js +43 -0
  13. package/executors/build/schema.json +15 -0
  14. package/executors/dev/executor.d.ts +10 -0
  15. package/executors/dev/executor.d.ts.map +1 -0
  16. package/executors/dev/executor.js +61 -0
  17. package/executors/dev/schema.json +25 -0
  18. package/executors/preview/executor.d.ts +9 -0
  19. package/executors/preview/executor.d.ts.map +1 -0
  20. package/executors/preview/executor.js +50 -0
  21. package/executors/preview/schema.json +20 -0
  22. package/executors/utils.d.ts +18 -0
  23. package/executors/utils.d.ts.map +1 -0
  24. package/executors/utils.js +80 -0
  25. package/executors.json +25 -0
  26. package/generators/app/files/.gitignore__template__ +9 -0
  27. package/generators/app/files/README.md__template__ +27 -0
  28. package/generators/app/files/astro.config.mjs__template__ +12 -0
  29. package/generators/app/files/src/env.d.ts__template__ +1 -0
  30. package/generators/app/files/src/pages/index.astro__template__ +20 -0
  31. package/generators/app/files/tsconfig.json__template__ +11 -0
  32. package/generators/app/files-tailwind/src/styles/global.css__template__ +1 -0
  33. package/generators/app/generator.d.ts +11 -0
  34. package/generators/app/generator.d.ts.map +1 -0
  35. package/generators/app/generator.js +123 -0
  36. package/generators/app/schema.json +49 -0
  37. package/generators.json +10 -0
  38. package/index.d.ts +6 -0
  39. package/index.d.ts.map +1 -0
  40. package/index.js +8 -0
  41. package/package.json +32 -0
  42. package/tsconfig.spec.json +13 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # 1.0.0 (2026-02-14)
2
+
3
+ ### ๐Ÿš€ Features
4
+
5
+ - **nx-astro:** Add Nx plugin with executors and generators ([ac1f021](https://github.com/ludena-studio/nx-extensions/commit/ac1f021))
6
+
7
+ ### โค๏ธ Thank You
8
+
9
+ - victoraf-11
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ludena Studio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,287 @@
1
+ # @ludena-studio/nx-astro
2
+
3
+ Official Nx plugin by Ludena Studio for seamless [Astro](https://astro.build) integration in Nx monorepos.
4
+
5
+ [![npm version](https://badge.fury.io/js/@ludena-studio%2Fnx-astro.svg)](https://www.npmjs.com/package/@ludena-studio/nx-astro)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ - โœจ **Generators** - Scaffold Astro applications with optimized Nx configuration
11
+ - โšก **Executors** - Run `dev`, `build`, `preview`, and manage integrations
12
+ - ๐Ÿ”„ **Smart Caching** - Leverage Nx's intelligent caching system
13
+ - ๐Ÿ—๏ธ **Production Ready** - Robust validation, logging, and error handling
14
+ - ๐Ÿงช **96% Test Coverage** - Comprehensive unit tests and edge cases
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install --save-dev @ludena-studio/nx-astro astro
20
+ # or
21
+ pnpm add -D @ludena-studio/nx-astro astro
22
+ # or
23
+ yarn add -D @ludena-studio/nx-astro astro
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ### 1. Generate an Astro Application
29
+
30
+ ```bash
31
+ nx g @ludena-studio/nx-astro:app my-astro-app
32
+ ```
33
+
34
+ This creates a new Astro app with:
35
+ - Optimized Nx project configuration
36
+ - TypeScript support
37
+ - Pre-configured executors for dev, build, and preview
38
+ - Ready-to-use project structure
39
+
40
+ ### 2. Available Commands
41
+
42
+ ```bash
43
+ # Start development server
44
+ nx dev my-astro-app
45
+
46
+ # Build for production
47
+ nx build my-astro-app
48
+
49
+ # Preview production build
50
+ nx preview my-astro-app
51
+
52
+ # Add Astro integrations
53
+ nx add my-astro-app --integration=tailwind
54
+ nx add my-astro-app --integration=react
55
+ nx add my-astro-app --integration=mdx
56
+ ```
57
+
58
+ ## Package Manager Support
59
+
60
+ The plugin **automatically detects** your workspace's package manager (npm, pnpm, yarn, or bun) and configures the generated `.gitignore` accordingly to ignore the appropriate lockfile:
61
+
62
+ - **npm** โ†’ ignores `package-lock.json`
63
+ - **pnpm** โ†’ ignores `pnpm-lock.yaml`
64
+ - **yarn** โ†’ ignores `yarn.lock`
65
+ - **bun** โ†’ ignores `bun.lockb`
66
+
67
+ This ensures that generated projects respect your workspace configuration without manual adjustments.
68
+
69
+ ## Generators
70
+
71
+ ### `app` - Create Astro Application
72
+
73
+ ```bash
74
+ nx g @ludena-studio/nx-astro:app <name> [options]
75
+ ```
76
+
77
+ **Options:**
78
+ - `--directory` - Directory where the app will be created
79
+ - `--tags` - Tags to categorize the project
80
+ - `--strict` - Enable strict TypeScript mode (default: `true`)
81
+ - `--mdx` - Include MDX integration with automatic dependency installation (default: `true`)
82
+ - `--tailwind` - Include Tailwind CSS integration with config files and setup (default: `false`)
83
+
84
+ **Examples:**
85
+ ```bash
86
+ # Basic app
87
+ nx g @ludena-studio/nx-astro:app my-app
88
+
89
+ # App with MDX and Tailwind CSS (automatically installs dependencies)
90
+ nx g @ludena-studio/nx-astro:app my-blog --mdx --tailwind
91
+
92
+ # Organized in a custom directory
93
+ nx g @ludena-studio/nx-astro:app my-site --directory=apps/marketing --tags=public
94
+ ```
95
+
96
+ #### Integrations
97
+
98
+ When you enable **MDX** or **Tailwind CSS**, the generator automatically:
99
+
100
+ **MDX Integration (`--mdx`):**
101
+ - โœ… Installs `@astrojs/mdx` dependency
102
+ - โœ… Configures MDX in `astro.config.mjs`
103
+ - โœ… Ready to use `.mdx` files immediately
104
+
105
+ **Tailwind CSS Integration (`--tailwind`):**
106
+ - โœ… Installs `tailwindcss` (v4+) and `@tailwindcss/vite` dependencies
107
+ - โœ… Configures Tailwind using the **Vite plugin** in `astro.config.mjs` (recommended for Tailwind 4)
108
+ - โœ… Generates `src/styles/global.css` with Tailwind 4 import syntax
109
+ - โœ… Imports global styles in your pages
110
+ - โœ… No `tailwind.config.mjs` needed (Tailwind 4 uses CSS-first configuration)
111
+
112
+ No manual setup requiredโ€”everything is configured and ready to use!
113
+
114
+ ## Executors
115
+
116
+ ### `dev` - Development Server
117
+
118
+ Start the Astro development server with hot module replacement.
119
+
120
+ ```bash
121
+ nx dev <project> [options]
122
+ ```
123
+
124
+ **Options:**
125
+ - `--port` - Port number (default: 4321)
126
+ - `--host` - Hostname or `true` for 0.0.0.0
127
+ - `--open` - Open browser on start (boolean or URL path)
128
+
129
+ **Example:**
130
+ ```bash
131
+ nx dev my-astro-app --port 3000 --host --open
132
+ ```
133
+
134
+ ### `build` - Production Build
135
+
136
+ Build your Astro site for production deployment.
137
+
138
+ ```bash
139
+ nx build <project> [options]
140
+ ```
141
+
142
+ **Options:**
143
+ - `--outputPath` - Custom output directory
144
+
145
+ **Example:**
146
+ ```bash
147
+ nx build my-astro-app
148
+ ```
149
+
150
+ ### `preview` - Preview Build
151
+
152
+ Preview your production build locally before deployment.
153
+
154
+ ```bash
155
+ nx preview <project> [options]
156
+ ```
157
+
158
+ **Options:**
159
+ - `--port` - Port number (default: 4321)
160
+ - `--host` - Hostname or `true` for 0.0.0.0
161
+
162
+ **Example:**
163
+ ```bash
164
+ nx preview my-astro-app --port 8080
165
+ ```
166
+
167
+ ### `add` - Add Integration
168
+
169
+ Add official Astro integrations to your project.
170
+
171
+ ```bash
172
+ nx add <project> --integration=<name> [options]
173
+ ```
174
+
175
+ **Options:**
176
+ - `--integration` (required) - Integration name (e.g., tailwind, react, vue)
177
+ - `--yes` - Skip confirmation prompts
178
+
179
+ **Example:**
180
+ ```bash
181
+ nx add my-astro-app --integration=tailwind --yes
182
+ nx add my-astro-app --integration=react
183
+ ```
184
+
185
+ ## Advanced Configuration
186
+
187
+ ### Custom Executor Options
188
+
189
+ You can customize executor behavior in your `project.json`:
190
+
191
+ ```json
192
+ {
193
+ "targets": {
194
+ "dev": {
195
+ "executor": "@ludena-studio/nx-astro:dev",
196
+ "options": {
197
+ "port": 3000,
198
+ "host": true,
199
+ "open": true
200
+ }
201
+ },
202
+ "build": {
203
+ "executor": "@ludena-studio/nx-astro:build",
204
+ "options": {
205
+ "outputPath": "dist/apps/my-app"
206
+ },
207
+ "outputs": ["{options.outputPath}"]
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### Nx Caching
214
+
215
+ All executors support Nx caching for optimal performance:
216
+
217
+ ```json
218
+ {
219
+ "targets": {
220
+ "build": {
221
+ "cache": true,
222
+ "dependsOn": ["^build"]
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ ## Documentation
229
+
230
+ - ๐Ÿ“š **[Testing Guide](./docs/testing.md)** - Comprehensive testing documentation
231
+ - ๐Ÿ› ๏ธ **[Configuration](./docs/configuration.md)** - Detailed configuration guide
232
+
233
+ ## Requirements
234
+
235
+ - Node.js 18+
236
+ - Nx 18+
237
+ - Astro 4+
238
+
239
+ ## Troubleshooting
240
+
241
+ ### Astro not found
242
+
243
+ If you see `Astro binary not found` errors:
244
+
245
+ ```bash
246
+ # Install Astro in your project
247
+ npm install -D astro
248
+ # or
249
+ pnpm add -D astro
250
+ ```
251
+
252
+ ### Port already in use
253
+
254
+ If the default port (4321) is in use, specify a different one:
255
+
256
+ ```bash
257
+ nx dev my-astro-app --port 3000
258
+ ```
259
+
260
+ ### TypeScript errors
261
+
262
+ Ensure your `tsconfig.json` extends the workspace base config:
263
+
264
+ ```json
265
+ {
266
+ "extends": "../../tsconfig.base.json",
267
+ "compilerOptions": {
268
+ "jsx": "react-jsx",
269
+ "jsxImportSource": "astro"
270
+ }
271
+ }
272
+ ```
273
+
274
+ ## Contributing
275
+
276
+ Contributions are welcome! Please read our contributing guidelines before submitting PRs.
277
+
278
+ ## License
279
+
280
+ MIT ยฉ [Ludena Studio](https://ludena.studio)
281
+
282
+ ## Links
283
+
284
+ - [Astro Documentation](https://docs.astro.build)
285
+ - [Nx Documentation](https://nx.dev)
286
+ - [GitHub Repository](https://github.com/ludena/nx-extensions)
287
+ - [Issue Tracker](https://github.com/ludena/nx-extensions/issues)