@nitrostack/cli 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.
- package/README.md +131 -0
- package/dist/commands/build.d.ts +6 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +185 -0
- package/dist/commands/dev.d.ts +7 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +365 -0
- package/dist/commands/generate-types.d.ts +8 -0
- package/dist/commands/generate-types.d.ts.map +1 -0
- package/dist/commands/generate-types.js +219 -0
- package/dist/commands/generate.d.ts +12 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +375 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +324 -0
- package/dist/commands/install.d.ts +10 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +80 -0
- package/dist/commands/start.d.ts +6 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +70 -0
- package/dist/commands/upgrade.d.ts +10 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +214 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +94 -0
- package/dist/mcp-dev-wrapper.d.ts +15 -0
- package/dist/mcp-dev-wrapper.d.ts.map +1 -0
- package/dist/mcp-dev-wrapper.js +187 -0
- package/dist/ui/branding.d.ts +31 -0
- package/dist/ui/branding.d.ts.map +1 -0
- package/dist/ui/branding.js +136 -0
- package/package.json +69 -0
- package/templates/typescript-oauth/.env.example +27 -0
- package/templates/typescript-oauth/OAUTH_SETUP.md +592 -0
- package/templates/typescript-oauth/README.md +263 -0
- package/templates/typescript-oauth/package.json +29 -0
- package/templates/typescript-oauth/src/app.module.ts +92 -0
- package/templates/typescript-oauth/src/guards/oauth.guard.ts +126 -0
- package/templates/typescript-oauth/src/health/system.health.ts +55 -0
- package/templates/typescript-oauth/src/index.ts +63 -0
- package/templates/typescript-oauth/src/modules/flights/booking.tools.ts +323 -0
- package/templates/typescript-oauth/src/modules/flights/flights.module.ts +14 -0
- package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +228 -0
- package/templates/typescript-oauth/src/modules/flights/flights.resources.ts +215 -0
- package/templates/typescript-oauth/src/modules/flights/flights.tools.ts +457 -0
- package/templates/typescript-oauth/src/services/duffel.service.ts +285 -0
- package/templates/typescript-oauth/src/widgets/app/airport-search/page.tsx +270 -0
- package/templates/typescript-oauth/src/widgets/app/flight-details/page.tsx +261 -0
- package/templates/typescript-oauth/src/widgets/app/flight-search-results/page.tsx +378 -0
- package/templates/typescript-oauth/src/widgets/app/globals.css +167 -0
- package/templates/typescript-oauth/src/widgets/app/layout.tsx +18 -0
- package/templates/typescript-oauth/src/widgets/app/order-cancellation/page.tsx +207 -0
- package/templates/typescript-oauth/src/widgets/app/order-summary/page.tsx +245 -0
- package/templates/typescript-oauth/src/widgets/app/payment-confirmation/page.tsx +152 -0
- package/templates/typescript-oauth/src/widgets/app/seat-selection/page.tsx +486 -0
- package/templates/typescript-oauth/src/widgets/next-env.d.ts +5 -0
- package/templates/typescript-oauth/src/widgets/next.config.js +45 -0
- package/templates/typescript-oauth/src/widgets/package-lock.json +4493 -0
- package/templates/typescript-oauth/src/widgets/package.json +24 -0
- package/templates/typescript-oauth/src/widgets/tsconfig.json +28 -0
- package/templates/typescript-oauth/src/widgets/widget-manifest.json +395 -0
- package/templates/typescript-oauth/tsconfig.json +23 -0
- package/templates/typescript-pizzaz/README.md +252 -0
- package/templates/typescript-pizzaz/package.json +34 -0
- package/templates/typescript-pizzaz/src/app.module.ts +28 -0
- package/templates/typescript-pizzaz/src/index.ts +30 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.data.ts +106 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +11 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.service.ts +60 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tools.ts +197 -0
- package/templates/typescript-pizzaz/src/widgets/app/layout.tsx +18 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-list/page.tsx +272 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-map/page.tsx +216 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-shop/page.tsx +374 -0
- package/templates/typescript-pizzaz/src/widgets/components/CompactShopCard.tsx +144 -0
- package/templates/typescript-pizzaz/src/widgets/components/PizzaCard.tsx +191 -0
- package/templates/typescript-pizzaz/src/widgets/next.config.js +45 -0
- package/templates/typescript-pizzaz/src/widgets/package.json +30 -0
- package/templates/typescript-pizzaz/src/widgets/tsconfig.json +28 -0
- package/templates/typescript-pizzaz/src/widgets/widget-manifest.json +253 -0
- package/templates/typescript-pizzaz/tsconfig.json +30 -0
- package/templates/typescript-starter/README.md +320 -0
- package/templates/typescript-starter/package.json +25 -0
- package/templates/typescript-starter/src/app.module.ts +34 -0
- package/templates/typescript-starter/src/health/system.health.ts +55 -0
- package/templates/typescript-starter/src/index.ts +29 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.module.ts +12 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.prompts.ts +73 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +59 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.tools.ts +166 -0
- package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +180 -0
- package/templates/typescript-starter/src/widgets/app/layout.tsx +18 -0
- package/templates/typescript-starter/src/widgets/next.config.js +45 -0
- package/templates/typescript-starter/src/widgets/package.json +24 -0
- package/templates/typescript-starter/src/widgets/tsconfig.json +28 -0
- package/templates/typescript-starter/src/widgets/widget-manifest.json +48 -0
- package/templates/typescript-starter/tsconfig.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# @nitrostack/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for creating NitroStack MCP server projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Use npm create (recommended)
|
|
9
|
+
npm create nitrostack my-project
|
|
10
|
+
|
|
11
|
+
# Or use npx
|
|
12
|
+
npx create-nitrostack my-project
|
|
13
|
+
|
|
14
|
+
# Or install globally
|
|
15
|
+
npm install -g @nitrostack/cli
|
|
16
|
+
create-nitrostack my-project
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
> **Note:** Once a project is created, use the `nitrostack` command from the main `nitrostack` package for development commands (`dev`, `build`, `start`, etc.).
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
### `nitrostack init [project-name]`
|
|
24
|
+
|
|
25
|
+
Create a new NitroStack project from a template.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
nitrostack init my-mcp-server
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Options:**
|
|
32
|
+
- `--template <template>` - Template to use (typescript-starter, typescript-pizzaz, typescript-oauth)
|
|
33
|
+
- `--skip-install` - Skip installing dependencies
|
|
34
|
+
|
|
35
|
+
### `nitrostack dev`
|
|
36
|
+
|
|
37
|
+
Start development server with hot reload and NitroStack Studio.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
nitrostack dev
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Options:**
|
|
44
|
+
- `--port <port>` - Port for Studio (default: 3000)
|
|
45
|
+
- `--no-open` - Don't open browser automatically
|
|
46
|
+
|
|
47
|
+
### `nitrostack build`
|
|
48
|
+
|
|
49
|
+
Build the project for production.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
nitrostack build
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Options:**
|
|
56
|
+
- `--output <path>` - Output directory (default: dist)
|
|
57
|
+
|
|
58
|
+
### `nitrostack start`
|
|
59
|
+
|
|
60
|
+
Start the production server.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
nitrostack start
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Options:**
|
|
67
|
+
- `--port <port>` - Port for server (default: 3000)
|
|
68
|
+
|
|
69
|
+
### `nitrostack generate <type> [name]`
|
|
70
|
+
|
|
71
|
+
Generate boilerplate code.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
nitrostack generate module users
|
|
75
|
+
nitrostack g tools payment
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Types:**
|
|
79
|
+
- `module` - Create a new module with tools, resources, prompts
|
|
80
|
+
- `tools` - Generate tool definitions
|
|
81
|
+
- `resources` - Generate resource definitions
|
|
82
|
+
- `prompts` - Generate prompt definitions
|
|
83
|
+
- `service` - Generate a service class
|
|
84
|
+
- `guard` - Generate an auth guard
|
|
85
|
+
- `middleware` - Generate middleware
|
|
86
|
+
- `health` - Generate health check
|
|
87
|
+
|
|
88
|
+
**Options:**
|
|
89
|
+
- `--module <name>` - Module name for module-specific generation
|
|
90
|
+
- `--force` - Overwrite existing files
|
|
91
|
+
- `--skip-related` - Skip generating related files
|
|
92
|
+
|
|
93
|
+
### `nitrostack upgrade`
|
|
94
|
+
|
|
95
|
+
Upgrade nitrostack to the latest version.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
nitrostack upgrade
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Options:**
|
|
102
|
+
- `--dry-run` - Show what would be upgraded without making changes
|
|
103
|
+
- `--latest` - Force upgrade even if already up to date
|
|
104
|
+
|
|
105
|
+
### `nitrostack install`
|
|
106
|
+
|
|
107
|
+
Install dependencies in both root and widget directories.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
nitrostack install
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Options:**
|
|
114
|
+
- `--skip-widgets` - Skip installing widget dependencies
|
|
115
|
+
- `--production` - Install production dependencies only
|
|
116
|
+
|
|
117
|
+
## Templates
|
|
118
|
+
|
|
119
|
+
### typescript-starter
|
|
120
|
+
Simple calculator example for learning NitroStack basics.
|
|
121
|
+
|
|
122
|
+
### typescript-pizzaz
|
|
123
|
+
Pizza shop finder with maps, widgets, and advanced features.
|
|
124
|
+
|
|
125
|
+
### typescript-oauth
|
|
126
|
+
Flight booking system with OAuth 2.1 authentication.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
Apache-2.0
|
|
131
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAeA,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,iBA0MvD"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import * as esbuild from 'esbuild';
|
|
5
|
+
import { createHeader, createSuccessBox, createErrorBox, NitroSpinner, spacer, nextSteps } from '../ui/branding.js';
|
|
6
|
+
export async function buildCommand(options) {
|
|
7
|
+
console.log(createHeader('Build', 'Production bundle'));
|
|
8
|
+
const startTime = Date.now();
|
|
9
|
+
// Validate project
|
|
10
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
11
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
12
|
+
console.log(createErrorBox('Not a NitroStack Project', 'package.json not found'));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
const tsconfigPath = path.join(process.cwd(), 'tsconfig.json');
|
|
16
|
+
if (!fs.existsSync(tsconfigPath)) {
|
|
17
|
+
console.log(createErrorBox('Missing Configuration', 'tsconfig.json not found'));
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
// Detect widgets
|
|
21
|
+
const widgetsPath = path.resolve(process.cwd(), 'src/widgets');
|
|
22
|
+
const widgetsPackageJsonPath = path.join(widgetsPath, 'package.json');
|
|
23
|
+
const hasWidgets = fs.existsSync(widgetsPackageJsonPath);
|
|
24
|
+
const buildArtifacts = [];
|
|
25
|
+
try {
|
|
26
|
+
// Build widgets first if they exist
|
|
27
|
+
if (hasWidgets) {
|
|
28
|
+
// Install dependencies if needed
|
|
29
|
+
const widgetsNodeModulesPath = path.join(widgetsPath, 'node_modules');
|
|
30
|
+
if (!fs.existsSync(widgetsNodeModulesPath)) {
|
|
31
|
+
const depsSpinner = new NitroSpinner('Installing widget dependencies...').start();
|
|
32
|
+
try {
|
|
33
|
+
execSync('npm install', { cwd: widgetsPath, stdio: 'pipe' });
|
|
34
|
+
depsSpinner.succeed('Widget dependencies installed');
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
depsSpinner.fail('Failed to install widget dependencies');
|
|
38
|
+
throw new Error('Widget dependency installation failed');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const widgetSpinner = new NitroSpinner('Bundling widgets...').start();
|
|
42
|
+
try {
|
|
43
|
+
const APP_DIR = path.join(widgetsPath, 'app');
|
|
44
|
+
const OUT_DIR = path.join(widgetsPath, 'out');
|
|
45
|
+
// Clean output directory
|
|
46
|
+
if (fs.existsSync(OUT_DIR)) {
|
|
47
|
+
fs.rmSync(OUT_DIR, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
fs.mkdirSync(OUT_DIR, { recursive: true });
|
|
50
|
+
// Find all widget pages
|
|
51
|
+
const widgetPages = [];
|
|
52
|
+
function findWidgetPages(dir, basePath = '') {
|
|
53
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
const fullPath = path.join(dir, entry.name);
|
|
56
|
+
const relativePath = path.join(basePath, entry.name);
|
|
57
|
+
if (entry.isDirectory()) {
|
|
58
|
+
findWidgetPages(fullPath, relativePath);
|
|
59
|
+
}
|
|
60
|
+
else if (entry.name === 'page.tsx' || entry.name === 'page.jsx') {
|
|
61
|
+
const widgetName = basePath || 'index';
|
|
62
|
+
widgetPages.push({
|
|
63
|
+
name: widgetName,
|
|
64
|
+
entryPoint: fullPath,
|
|
65
|
+
outputName: widgetName.replace(/\//g, '-')
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (fs.existsSync(APP_DIR)) {
|
|
71
|
+
findWidgetPages(APP_DIR);
|
|
72
|
+
}
|
|
73
|
+
// Bundle each widget
|
|
74
|
+
for (const widget of widgetPages) {
|
|
75
|
+
const tempEntry = path.join(OUT_DIR, `_temp_${widget.outputName}.jsx`);
|
|
76
|
+
const jsOutput = path.join(OUT_DIR, `${widget.outputName}.js`);
|
|
77
|
+
const htmlOutput = path.join(OUT_DIR, `${widget.outputName}.html`);
|
|
78
|
+
const entryCode = `
|
|
79
|
+
import React from 'react';
|
|
80
|
+
import { createRoot } from 'react-dom/client';
|
|
81
|
+
import WidgetPage from '${widget.entryPoint.replace(/\\/g, '/')}';
|
|
82
|
+
|
|
83
|
+
if (document.readyState === 'loading') {
|
|
84
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
85
|
+
} else {
|
|
86
|
+
init();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function init() {
|
|
90
|
+
const data = window.openai?.toolOutput || {};
|
|
91
|
+
|
|
92
|
+
let root = document.getElementById('widget-root');
|
|
93
|
+
if (!root) {
|
|
94
|
+
root = document.createElement('div');
|
|
95
|
+
root.id = 'widget-root';
|
|
96
|
+
document.body.appendChild(root);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const reactRoot = createRoot(root);
|
|
100
|
+
reactRoot.render(React.createElement(WidgetPage, { data }));
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
fs.writeFileSync(tempEntry, entryCode);
|
|
104
|
+
await esbuild.build({
|
|
105
|
+
entryPoints: [tempEntry],
|
|
106
|
+
bundle: true,
|
|
107
|
+
format: 'iife',
|
|
108
|
+
outfile: jsOutput,
|
|
109
|
+
platform: 'browser',
|
|
110
|
+
target: ['es2020'],
|
|
111
|
+
minify: true,
|
|
112
|
+
jsx: 'automatic',
|
|
113
|
+
jsxImportSource: 'react',
|
|
114
|
+
external: [],
|
|
115
|
+
nodePaths: [path.join(widgetsPath, 'node_modules')],
|
|
116
|
+
define: {
|
|
117
|
+
'process.env.NODE_ENV': '"production"'
|
|
118
|
+
},
|
|
119
|
+
logLevel: 'warning'
|
|
120
|
+
});
|
|
121
|
+
const bundledJs = fs.readFileSync(jsOutput, 'utf-8');
|
|
122
|
+
const html = `<!DOCTYPE html>
|
|
123
|
+
<html lang="en">
|
|
124
|
+
<head>
|
|
125
|
+
<meta charset="utf-8">
|
|
126
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
127
|
+
<style>
|
|
128
|
+
* { box-sizing: border-box; }
|
|
129
|
+
body {
|
|
130
|
+
margin: 0;
|
|
131
|
+
padding: 0;
|
|
132
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
133
|
+
}
|
|
134
|
+
#widget-root {
|
|
135
|
+
width: 100%;
|
|
136
|
+
min-height: 100vh;
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
139
|
+
</head>
|
|
140
|
+
<body>
|
|
141
|
+
<div id="widget-root"></div>
|
|
142
|
+
<script>${bundledJs}</script>
|
|
143
|
+
</body>
|
|
144
|
+
</html>`;
|
|
145
|
+
fs.writeFileSync(htmlOutput, html);
|
|
146
|
+
fs.unlinkSync(tempEntry);
|
|
147
|
+
fs.unlinkSync(jsOutput);
|
|
148
|
+
}
|
|
149
|
+
widgetSpinner.succeed(`Widgets bundled (${widgetPages.length} widgets)`);
|
|
150
|
+
buildArtifacts.push(`src/widgets/out/ (${widgetPages.length} widgets)`);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
widgetSpinner.fail('Widget bundling failed');
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Build TypeScript
|
|
158
|
+
const tscSpinner = new NitroSpinner('Compiling TypeScript...').start();
|
|
159
|
+
try {
|
|
160
|
+
execSync('npx tsc', {
|
|
161
|
+
cwd: process.cwd(),
|
|
162
|
+
stdio: 'pipe',
|
|
163
|
+
});
|
|
164
|
+
tscSpinner.succeed('TypeScript compiled');
|
|
165
|
+
buildArtifacts.push(options.output);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
tscSpinner.fail('TypeScript compilation failed');
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
// Summary
|
|
172
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
173
|
+
spacer();
|
|
174
|
+
console.log(createSuccessBox(`Build Complete (${elapsed}s)`, buildArtifacts));
|
|
175
|
+
nextSteps([
|
|
176
|
+
'npm start - Start production server',
|
|
177
|
+
'nitrostack start - Alternative start command',
|
|
178
|
+
]);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
spacer();
|
|
182
|
+
console.log(createErrorBox('Build Failed', error instanceof Error ? error.message : String(error)));
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AA+LA,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,iBAgPnD"}
|