@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.
Files changed (100) hide show
  1. package/README.md +131 -0
  2. package/dist/commands/build.d.ts +6 -0
  3. package/dist/commands/build.d.ts.map +1 -0
  4. package/dist/commands/build.js +185 -0
  5. package/dist/commands/dev.d.ts +7 -0
  6. package/dist/commands/dev.d.ts.map +1 -0
  7. package/dist/commands/dev.js +365 -0
  8. package/dist/commands/generate-types.d.ts +8 -0
  9. package/dist/commands/generate-types.d.ts.map +1 -0
  10. package/dist/commands/generate-types.js +219 -0
  11. package/dist/commands/generate.d.ts +12 -0
  12. package/dist/commands/generate.d.ts.map +1 -0
  13. package/dist/commands/generate.js +375 -0
  14. package/dist/commands/init.d.ts +7 -0
  15. package/dist/commands/init.d.ts.map +1 -0
  16. package/dist/commands/init.js +324 -0
  17. package/dist/commands/install.d.ts +10 -0
  18. package/dist/commands/install.d.ts.map +1 -0
  19. package/dist/commands/install.js +80 -0
  20. package/dist/commands/start.d.ts +6 -0
  21. package/dist/commands/start.d.ts.map +1 -0
  22. package/dist/commands/start.js +70 -0
  23. package/dist/commands/upgrade.d.ts +10 -0
  24. package/dist/commands/upgrade.d.ts.map +1 -0
  25. package/dist/commands/upgrade.js +214 -0
  26. package/dist/index.d.ts +11 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +94 -0
  29. package/dist/mcp-dev-wrapper.d.ts +15 -0
  30. package/dist/mcp-dev-wrapper.d.ts.map +1 -0
  31. package/dist/mcp-dev-wrapper.js +187 -0
  32. package/dist/ui/branding.d.ts +31 -0
  33. package/dist/ui/branding.d.ts.map +1 -0
  34. package/dist/ui/branding.js +136 -0
  35. package/package.json +69 -0
  36. package/templates/typescript-oauth/.env.example +27 -0
  37. package/templates/typescript-oauth/OAUTH_SETUP.md +592 -0
  38. package/templates/typescript-oauth/README.md +263 -0
  39. package/templates/typescript-oauth/package.json +29 -0
  40. package/templates/typescript-oauth/src/app.module.ts +92 -0
  41. package/templates/typescript-oauth/src/guards/oauth.guard.ts +126 -0
  42. package/templates/typescript-oauth/src/health/system.health.ts +55 -0
  43. package/templates/typescript-oauth/src/index.ts +63 -0
  44. package/templates/typescript-oauth/src/modules/flights/booking.tools.ts +323 -0
  45. package/templates/typescript-oauth/src/modules/flights/flights.module.ts +14 -0
  46. package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +228 -0
  47. package/templates/typescript-oauth/src/modules/flights/flights.resources.ts +215 -0
  48. package/templates/typescript-oauth/src/modules/flights/flights.tools.ts +457 -0
  49. package/templates/typescript-oauth/src/services/duffel.service.ts +285 -0
  50. package/templates/typescript-oauth/src/widgets/app/airport-search/page.tsx +270 -0
  51. package/templates/typescript-oauth/src/widgets/app/flight-details/page.tsx +261 -0
  52. package/templates/typescript-oauth/src/widgets/app/flight-search-results/page.tsx +378 -0
  53. package/templates/typescript-oauth/src/widgets/app/globals.css +167 -0
  54. package/templates/typescript-oauth/src/widgets/app/layout.tsx +18 -0
  55. package/templates/typescript-oauth/src/widgets/app/order-cancellation/page.tsx +207 -0
  56. package/templates/typescript-oauth/src/widgets/app/order-summary/page.tsx +245 -0
  57. package/templates/typescript-oauth/src/widgets/app/payment-confirmation/page.tsx +152 -0
  58. package/templates/typescript-oauth/src/widgets/app/seat-selection/page.tsx +486 -0
  59. package/templates/typescript-oauth/src/widgets/next-env.d.ts +5 -0
  60. package/templates/typescript-oauth/src/widgets/next.config.js +45 -0
  61. package/templates/typescript-oauth/src/widgets/package-lock.json +4493 -0
  62. package/templates/typescript-oauth/src/widgets/package.json +24 -0
  63. package/templates/typescript-oauth/src/widgets/tsconfig.json +28 -0
  64. package/templates/typescript-oauth/src/widgets/widget-manifest.json +395 -0
  65. package/templates/typescript-oauth/tsconfig.json +23 -0
  66. package/templates/typescript-pizzaz/README.md +252 -0
  67. package/templates/typescript-pizzaz/package.json +34 -0
  68. package/templates/typescript-pizzaz/src/app.module.ts +28 -0
  69. package/templates/typescript-pizzaz/src/index.ts +30 -0
  70. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.data.ts +106 -0
  71. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +11 -0
  72. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.service.ts +60 -0
  73. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tools.ts +197 -0
  74. package/templates/typescript-pizzaz/src/widgets/app/layout.tsx +18 -0
  75. package/templates/typescript-pizzaz/src/widgets/app/pizza-list/page.tsx +272 -0
  76. package/templates/typescript-pizzaz/src/widgets/app/pizza-map/page.tsx +216 -0
  77. package/templates/typescript-pizzaz/src/widgets/app/pizza-shop/page.tsx +374 -0
  78. package/templates/typescript-pizzaz/src/widgets/components/CompactShopCard.tsx +144 -0
  79. package/templates/typescript-pizzaz/src/widgets/components/PizzaCard.tsx +191 -0
  80. package/templates/typescript-pizzaz/src/widgets/next.config.js +45 -0
  81. package/templates/typescript-pizzaz/src/widgets/package.json +30 -0
  82. package/templates/typescript-pizzaz/src/widgets/tsconfig.json +28 -0
  83. package/templates/typescript-pizzaz/src/widgets/widget-manifest.json +253 -0
  84. package/templates/typescript-pizzaz/tsconfig.json +30 -0
  85. package/templates/typescript-starter/README.md +320 -0
  86. package/templates/typescript-starter/package.json +25 -0
  87. package/templates/typescript-starter/src/app.module.ts +34 -0
  88. package/templates/typescript-starter/src/health/system.health.ts +55 -0
  89. package/templates/typescript-starter/src/index.ts +29 -0
  90. package/templates/typescript-starter/src/modules/calculator/calculator.module.ts +12 -0
  91. package/templates/typescript-starter/src/modules/calculator/calculator.prompts.ts +73 -0
  92. package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +59 -0
  93. package/templates/typescript-starter/src/modules/calculator/calculator.tools.ts +166 -0
  94. package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +180 -0
  95. package/templates/typescript-starter/src/widgets/app/layout.tsx +18 -0
  96. package/templates/typescript-starter/src/widgets/next.config.js +45 -0
  97. package/templates/typescript-starter/src/widgets/package.json +24 -0
  98. package/templates/typescript-starter/src/widgets/tsconfig.json +28 -0
  99. package/templates/typescript-starter/src/widgets/widget-manifest.json +48 -0
  100. package/templates/typescript-starter/tsconfig.json +23 -0
@@ -0,0 +1,10 @@
1
+ interface InstallOptions {
2
+ skipWidgets?: boolean;
3
+ production?: boolean;
4
+ }
5
+ /**
6
+ * Main install command handler
7
+ */
8
+ export declare function installCommand(options: InstallOptions): Promise<void>;
9
+ export {};
10
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAcA,UAAU,cAAc;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAoBD;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA+D3E"}
@@ -0,0 +1,80 @@
1
+ import { execSync } from 'child_process';
2
+ import path from 'path';
3
+ import fs from 'fs-extra';
4
+ import { createHeader, createSuccessBox, createErrorBox, NitroSpinner, log, spacer, nextSteps } from '../ui/branding.js';
5
+ /**
6
+ * Run npm install silently
7
+ */
8
+ function runNpmInstall(directory, production) {
9
+ const args = production ? ['install', '--production'] : ['install'];
10
+ execSync(`npm ${args.join(' ')}`, {
11
+ cwd: directory,
12
+ stdio: 'pipe',
13
+ });
14
+ }
15
+ /**
16
+ * Check if a directory has a package.json
17
+ */
18
+ function hasPackageJson(directory) {
19
+ return fs.existsSync(path.join(directory, 'package.json'));
20
+ }
21
+ /**
22
+ * Main install command handler
23
+ */
24
+ export async function installCommand(options) {
25
+ console.log(createHeader('Install', 'Install project dependencies'));
26
+ const projectRoot = process.cwd();
27
+ const rootPackageJsonPath = path.join(projectRoot, 'package.json');
28
+ const widgetsPath = path.join(projectRoot, 'src', 'widgets');
29
+ // Validate project
30
+ if (!fs.existsSync(rootPackageJsonPath)) {
31
+ console.log(createErrorBox('Not a Valid Project', 'package.json not found'));
32
+ process.exit(1);
33
+ }
34
+ const production = options.production ?? false;
35
+ const skipWidgets = options.skipWidgets ?? false;
36
+ if (production) {
37
+ log('Production mode - dev dependencies will be skipped', 'info');
38
+ spacer();
39
+ }
40
+ const installed = [];
41
+ // Install root dependencies
42
+ const rootSpinner = new NitroSpinner('Installing root dependencies...').start();
43
+ try {
44
+ runNpmInstall(projectRoot, production);
45
+ rootSpinner.succeed('Root dependencies installed');
46
+ installed.push('Root project');
47
+ }
48
+ catch (error) {
49
+ rootSpinner.fail('Failed to install root dependencies');
50
+ console.log(createErrorBox('Installation Failed', error instanceof Error ? error.message : String(error)));
51
+ process.exit(1);
52
+ }
53
+ // Install widget dependencies if they exist
54
+ if (!skipWidgets && hasPackageJson(widgetsPath)) {
55
+ const widgetsSpinner = new NitroSpinner('Installing widget dependencies...').start();
56
+ try {
57
+ runNpmInstall(widgetsPath, production);
58
+ widgetsSpinner.succeed('Widget dependencies installed');
59
+ installed.push('Widgets (src/widgets)');
60
+ }
61
+ catch (error) {
62
+ widgetsSpinner.fail('Failed to install widget dependencies');
63
+ log(error instanceof Error ? error.message : String(error), 'dim');
64
+ }
65
+ }
66
+ else if (!skipWidgets) {
67
+ log('No widgets directory found', 'dim');
68
+ }
69
+ else {
70
+ log('Widgets skipped (--skip-widgets)', 'dim');
71
+ }
72
+ // Summary
73
+ spacer();
74
+ console.log(createSuccessBox('Installation Complete', installed));
75
+ nextSteps([
76
+ 'npm run dev - Start development server',
77
+ 'npm run build - Build for production',
78
+ 'npm run upgrade - Upgrade nitrostack',
79
+ ]);
80
+ }
@@ -0,0 +1,6 @@
1
+ interface StartOptions {
2
+ port?: string;
3
+ }
4
+ export declare function startCommand(options: StartOptions): Promise<void>;
5
+ export {};
6
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAaA,UAAU,YAAY;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,iBA4EvD"}
@@ -0,0 +1,70 @@
1
+ import chalk from 'chalk';
2
+ import { spawn } from 'child_process';
3
+ import path from 'path';
4
+ import fs from 'fs';
5
+ import { createHeader, createInfoBox, createErrorBox, log, spacer, brand } from '../ui/branding.js';
6
+ export async function startCommand(options) {
7
+ console.log(createHeader('Start', 'Production mode'));
8
+ const port = options.port || '3000';
9
+ // Check if dist/index.js exists
10
+ const distIndexPath = path.join(process.cwd(), 'dist', 'index.js');
11
+ if (!fs.existsSync(distIndexPath)) {
12
+ console.log(createErrorBox('Build Required', 'Run npm run build first'));
13
+ spacer();
14
+ log('npm run build', 'dim');
15
+ process.exit(1);
16
+ }
17
+ // Auto-detect widgets
18
+ const widgetsOutPath = path.join(process.cwd(), 'src', 'widgets', 'out');
19
+ const hasBuiltWidgets = fs.existsSync(widgetsOutPath);
20
+ if (!hasBuiltWidgets) {
21
+ const widgetsPackageJsonPath = path.join(process.cwd(), 'src', 'widgets', 'package.json');
22
+ if (fs.existsSync(widgetsPackageJsonPath)) {
23
+ log('Widgets not built - run npm run build to include widgets', 'warning');
24
+ spacer();
25
+ }
26
+ }
27
+ // Show server info
28
+ console.log(createInfoBox([
29
+ { label: 'Server', value: `http://localhost:${port}` },
30
+ { label: 'Mode', value: 'Production' },
31
+ { label: 'Transport', value: 'HTTP + STDIO (dual)' },
32
+ ...(hasBuiltWidgets ? [{ label: 'Widgets', value: 'Bundled' }] : []),
33
+ ]));
34
+ log('Starting server...', 'info');
35
+ spacer();
36
+ // Start the MCP server
37
+ const serverProcess = spawn('node', [distIndexPath], {
38
+ cwd: process.cwd(),
39
+ stdio: 'inherit',
40
+ env: {
41
+ ...process.env,
42
+ NODE_ENV: 'production',
43
+ PORT: port,
44
+ },
45
+ });
46
+ // Handle process exit
47
+ serverProcess.on('exit', (code) => {
48
+ if (code !== 0) {
49
+ console.log(createErrorBox('Server Crashed', `Exit code: ${code}`));
50
+ process.exit(code || 1);
51
+ }
52
+ });
53
+ // Handle graceful shutdown
54
+ const shutdown = () => {
55
+ spacer();
56
+ console.log(brand.accentBold('┌──────────────────────────────────────────────────────────────────┐'));
57
+ console.log(brand.accentBold('│') + chalk.yellow.bold(' Shutting down... ') + brand.accentBold('│'));
58
+ console.log(brand.accentBold('└──────────────────────────────────────────────────────────────────┘'));
59
+ serverProcess.kill('SIGTERM');
60
+ setTimeout(() => {
61
+ serverProcess.kill('SIGKILL');
62
+ console.log(chalk.dim('\nGoodbye! 👋\n'));
63
+ process.exit(0);
64
+ }, 5000);
65
+ };
66
+ process.on('SIGINT', shutdown);
67
+ process.on('SIGTERM', shutdown);
68
+ // Keep process alive
69
+ await new Promise(() => { });
70
+ }
@@ -0,0 +1,10 @@
1
+ interface UpgradeOptions {
2
+ latest?: boolean;
3
+ dryRun?: boolean;
4
+ }
5
+ /**
6
+ * Main upgrade command handler
7
+ */
8
+ export declare function upgradeCommand(options: UpgradeOptions): Promise<void>;
9
+ export {};
10
+ //# sourceMappingURL=upgrade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AAsBA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA2GD;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA8I3E"}
@@ -0,0 +1,214 @@
1
+ import chalk from 'chalk';
2
+ import { execSync } from 'child_process';
3
+ import path from 'path';
4
+ import fs from 'fs-extra';
5
+ import { createHeader, createSuccessBox, createErrorBox, NitroSpinner, log, spacer, nextSteps, brand } from '../ui/branding.js';
6
+ /**
7
+ * Get the latest version of nitrostack from npm registry
8
+ */
9
+ function getLatestVersion() {
10
+ try {
11
+ const result = execSync('npm view nitrostack version', {
12
+ encoding: 'utf-8',
13
+ stdio: ['pipe', 'pipe', 'pipe'],
14
+ }).trim();
15
+ return result;
16
+ }
17
+ catch {
18
+ throw new Error('Failed to fetch latest version from npm');
19
+ }
20
+ }
21
+ /**
22
+ * Get the current installed version of nitrostack from package.json
23
+ */
24
+ function getCurrentVersion(packageJsonPath) {
25
+ if (!fs.existsSync(packageJsonPath)) {
26
+ return null;
27
+ }
28
+ const packageJson = fs.readJSONSync(packageJsonPath);
29
+ const version = packageJson.dependencies?.nitrostack ||
30
+ packageJson.devDependencies?.nitrostack;
31
+ return version || null;
32
+ }
33
+ /**
34
+ * Parse version string to extract the actual version number
35
+ */
36
+ function parseVersion(versionString) {
37
+ return versionString.replace(/^[\^~>=<]+/, '');
38
+ }
39
+ /**
40
+ * Compare two version strings
41
+ */
42
+ function compareVersions(v1, v2) {
43
+ const parts1 = parseVersion(v1).split('.').map(Number);
44
+ const parts2 = parseVersion(v2).split('.').map(Number);
45
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
46
+ const p1 = parts1[i] || 0;
47
+ const p2 = parts2[i] || 0;
48
+ if (p1 > p2)
49
+ return 1;
50
+ if (p1 < p2)
51
+ return -1;
52
+ }
53
+ return 0;
54
+ }
55
+ /**
56
+ * Update nitrostack version in package.json
57
+ */
58
+ function updatePackageJson(packageJsonPath, newVersion, dryRun) {
59
+ if (!fs.existsSync(packageJsonPath)) {
60
+ return false;
61
+ }
62
+ const packageJson = fs.readJSONSync(packageJsonPath);
63
+ let updated = false;
64
+ if (packageJson.dependencies?.nitrostack) {
65
+ packageJson.dependencies.nitrostack = `^${newVersion}`;
66
+ updated = true;
67
+ }
68
+ if (packageJson.devDependencies?.nitrostack) {
69
+ packageJson.devDependencies.nitrostack = `^${newVersion}`;
70
+ updated = true;
71
+ }
72
+ if (updated && !dryRun) {
73
+ fs.writeJSONSync(packageJsonPath, packageJson, { spaces: 2 });
74
+ }
75
+ return updated;
76
+ }
77
+ /**
78
+ * Run npm install silently
79
+ */
80
+ function runNpmInstall(directory) {
81
+ execSync('npm install', {
82
+ cwd: directory,
83
+ stdio: 'pipe',
84
+ });
85
+ }
86
+ /**
87
+ * Main upgrade command handler
88
+ */
89
+ export async function upgradeCommand(options) {
90
+ console.log(createHeader('Upgrade', 'Update nitrostack to the latest version'));
91
+ const projectRoot = process.cwd();
92
+ const rootPackageJsonPath = path.join(projectRoot, 'package.json');
93
+ const widgetsPath = path.join(projectRoot, 'src', 'widgets');
94
+ const widgetsPackageJsonPath = path.join(widgetsPath, 'package.json');
95
+ // Validate project
96
+ if (!fs.existsSync(rootPackageJsonPath)) {
97
+ console.log(createErrorBox('Not a NitroStack Project', 'package.json not found'));
98
+ process.exit(1);
99
+ }
100
+ const rootCurrentVersion = getCurrentVersion(rootPackageJsonPath);
101
+ if (!rootCurrentVersion) {
102
+ console.log(createErrorBox('Not a NitroStack Project', 'nitrostack is not a dependency'));
103
+ process.exit(1);
104
+ }
105
+ // Fetch latest version
106
+ const spinner = new NitroSpinner('Checking for updates...').start();
107
+ let latestVersion;
108
+ try {
109
+ latestVersion = getLatestVersion();
110
+ spinner.succeed(`Latest version: ${chalk.cyan(latestVersion)}`);
111
+ }
112
+ catch (error) {
113
+ spinner.fail('Failed to fetch latest version');
114
+ process.exit(1);
115
+ }
116
+ // Check if already on latest
117
+ const rootParsedVersion = parseVersion(rootCurrentVersion);
118
+ if (compareVersions(rootParsedVersion, latestVersion) >= 0) {
119
+ spacer();
120
+ console.log(createSuccessBox('Already Up to Date', [
121
+ `Current version: ${rootParsedVersion}`,
122
+ `Latest version: ${latestVersion}`,
123
+ ]));
124
+ return;
125
+ }
126
+ const results = [];
127
+ const dryRun = options.dryRun ?? false;
128
+ if (dryRun) {
129
+ spacer();
130
+ log('Dry run mode - no changes will be made', 'warning');
131
+ }
132
+ spacer();
133
+ log('Upgrading dependencies...', 'info');
134
+ spacer();
135
+ // Upgrade root
136
+ const rootSpinner = new NitroSpinner('Updating root package.json...').start();
137
+ try {
138
+ const rootUpdated = updatePackageJson(rootPackageJsonPath, latestVersion, dryRun);
139
+ if (rootUpdated) {
140
+ results.push({
141
+ location: 'root',
142
+ previousVersion: rootCurrentVersion,
143
+ newVersion: `^${latestVersion}`,
144
+ upgraded: true,
145
+ });
146
+ rootSpinner.succeed(`Root: ${chalk.dim(rootCurrentVersion)} → ${chalk.cyan(`^${latestVersion}`)}`);
147
+ if (!dryRun) {
148
+ const installSpinner = new NitroSpinner('Installing dependencies...').start();
149
+ runNpmInstall(projectRoot);
150
+ installSpinner.succeed('Root dependencies installed');
151
+ }
152
+ }
153
+ else {
154
+ rootSpinner.info('Root: No changes needed');
155
+ }
156
+ }
157
+ catch (error) {
158
+ rootSpinner.fail('Failed to upgrade root');
159
+ process.exit(1);
160
+ }
161
+ // Upgrade widgets if they exist
162
+ if (fs.existsSync(widgetsPackageJsonPath)) {
163
+ const widgetsCurrentVersion = getCurrentVersion(widgetsPackageJsonPath);
164
+ if (widgetsCurrentVersion) {
165
+ const widgetsSpinner = new NitroSpinner('Updating widgets package.json...').start();
166
+ try {
167
+ const widgetsUpdated = updatePackageJson(widgetsPackageJsonPath, latestVersion, dryRun);
168
+ if (widgetsUpdated) {
169
+ results.push({
170
+ location: 'src/widgets',
171
+ previousVersion: widgetsCurrentVersion,
172
+ newVersion: `^${latestVersion}`,
173
+ upgraded: true,
174
+ });
175
+ widgetsSpinner.succeed(`Widgets: ${chalk.dim(widgetsCurrentVersion)} → ${chalk.cyan(`^${latestVersion}`)}`);
176
+ if (!dryRun) {
177
+ const installSpinner = new NitroSpinner('Installing widget dependencies...').start();
178
+ runNpmInstall(widgetsPath);
179
+ installSpinner.succeed('Widget dependencies installed');
180
+ }
181
+ }
182
+ else {
183
+ widgetsSpinner.info('Widgets: No changes needed');
184
+ }
185
+ }
186
+ catch (error) {
187
+ widgetsSpinner.fail('Failed to upgrade widgets');
188
+ }
189
+ }
190
+ }
191
+ else {
192
+ log('No widgets directory found', 'dim');
193
+ }
194
+ // Summary
195
+ spacer();
196
+ if (results.length === 0) {
197
+ log('No packages were upgraded', 'warning');
198
+ }
199
+ else {
200
+ const summaryItems = results.map(r => `${r.location}: ${parseVersion(r.previousVersion)} → ${parseVersion(r.newVersion)}`);
201
+ if (dryRun) {
202
+ console.log(brand.accentBold('\n Dry run complete - no changes made\n'));
203
+ log('Run without --dry-run to apply upgrade', 'dim');
204
+ }
205
+ else {
206
+ console.log(createSuccessBox('Upgrade Complete', summaryItems));
207
+ nextSteps([
208
+ 'Review the changes',
209
+ 'Test your application',
210
+ 'Check the changelog for breaking changes',
211
+ ]);
212
+ }
213
+ }
214
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ export declare function createProgram(): Command;
4
+ export { initCommand } from './commands/init.js';
5
+ export { devCommand } from './commands/dev.js';
6
+ export { buildCommand } from './commands/build.js';
7
+ export { startCommand } from './commands/start.js';
8
+ export { generate } from './commands/generate.js';
9
+ export { upgradeCommand } from './commands/upgrade.js';
10
+ export { installCommand } from './commands/install.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,wBAAgB,aAAa,YA8D5B;AAGD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { createRequire } from 'module';
4
+ import { initCommand } from './commands/init.js';
5
+ import { devCommand } from './commands/dev.js';
6
+ import { buildCommand } from './commands/build.js';
7
+ import { startCommand } from './commands/start.js';
8
+ import { generate } from './commands/generate.js';
9
+ import { upgradeCommand } from './commands/upgrade.js';
10
+ import { installCommand } from './commands/install.js';
11
+ const require = createRequire(import.meta.url);
12
+ const packageJson = require('../package.json');
13
+ export function createProgram() {
14
+ const program = new Command();
15
+ program
16
+ .name('nitrostack')
17
+ .description('NitroStack - Build MCP servers with ease')
18
+ .version(packageJson.version);
19
+ program
20
+ .command('init')
21
+ .description('Initialize a new NitroStack project')
22
+ .argument('[project-name]', 'Name of the project')
23
+ .option('--template <template>', 'Template to use (typescript, typescript-auth)', 'typescript')
24
+ .option('--skip-install', 'Skip installing dependencies')
25
+ .action(initCommand);
26
+ program
27
+ .command('dev')
28
+ .description('Start development server (MCP server + widgets) with hot reload')
29
+ .option('--port <port>', 'Port for widget dev server', '3001')
30
+ .action(devCommand);
31
+ program
32
+ .command('build')
33
+ .description('Build the project for production')
34
+ .option('--output <path>', 'Output directory', 'dist')
35
+ .action(buildCommand);
36
+ program
37
+ .command('start')
38
+ .description('Start the production server')
39
+ .option('--port <port>', 'Port for server', '3000')
40
+ .action(startCommand);
41
+ program
42
+ .command('generate')
43
+ .alias('g')
44
+ .description('Generate boilerplate code or types')
45
+ .argument('<type>', 'Type of component (middleware, interceptor, pipe, filter, service, guard, health, module, tools, resources, prompts, types)')
46
+ .argument('[name]', 'Name of the component (optional for "types")')
47
+ .option('--module <module>', 'Module name (for module-specific generation)')
48
+ .option('--output <path>', 'Output path (for types generation)')
49
+ .option('--force', 'Overwrite existing files')
50
+ .option('--skip-related', 'Skip generating related files (for modules)')
51
+ .action(generate);
52
+ program
53
+ .command('upgrade')
54
+ .description('Upgrade nitrostack to the latest version in the project')
55
+ .option('--dry-run', 'Show what would be upgraded without making changes')
56
+ .option('--latest', 'Force upgrade to the latest version even if already up to date')
57
+ .action(upgradeCommand);
58
+ program
59
+ .command('install')
60
+ .alias('i')
61
+ .description('Install dependencies in root and src/widgets directories')
62
+ .option('--skip-widgets', 'Skip installing widget dependencies')
63
+ .option('--production', 'Install production dependencies only')
64
+ .action(installCommand);
65
+ return program;
66
+ }
67
+ // Re-export commands for programmatic use
68
+ export { initCommand } from './commands/init.js';
69
+ export { devCommand } from './commands/dev.js';
70
+ export { buildCommand } from './commands/build.js';
71
+ export { startCommand } from './commands/start.js';
72
+ export { generate } from './commands/generate.js';
73
+ export { upgradeCommand } from './commands/upgrade.js';
74
+ export { installCommand } from './commands/install.js';
75
+ // Run the CLI when this module is the entry point
76
+ import { fileURLToPath } from 'url';
77
+ import { realpathSync } from 'fs';
78
+ const currentFilePath = fileURLToPath(import.meta.url);
79
+ // Resolve symlinks to compare actual file paths
80
+ function isMainModule() {
81
+ try {
82
+ const argvPath = realpathSync(process.argv[1]);
83
+ const modulePath = realpathSync(currentFilePath);
84
+ return argvPath === modulePath;
85
+ }
86
+ catch {
87
+ // If we can't resolve paths, check if the filename matches
88
+ return process.argv[1]?.includes('index.js') ||
89
+ process.argv[1]?.endsWith('nitrostack-cli');
90
+ }
91
+ }
92
+ if (isMainModule()) {
93
+ createProgram().parse();
94
+ }
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Server Hot Reload Wrapper
4
+ *
5
+ * This wrapper:
6
+ * 1. Starts the MCP server as a child process
7
+ * 2. Watches for changes in the dist/ directory
8
+ * 3. Restarts the server when changes are detected
9
+ * 4. Maintains stdio connection for Studio
10
+ * 5. Captures stderr from the MCP server and streams it over an SSE endpoint
11
+ *
12
+ * IMPORTANT: All logs go to stderr to avoid corrupting MCP JSON-RPC on stdout
13
+ */
14
+ export declare function run(): Promise<void>;
15
+ //# sourceMappingURL=mcp-dev-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-dev-wrapper.d.ts","sourceRoot":"","sources":["../src/mcp-dev-wrapper.ts"],"names":[],"mappings":";AAUA;;;;;;;;;;;GAWG;AAEH,wBAAsB,GAAG,kBAgLxB"}