@vira-ui/cli 0.4.0-alpha → 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/dist/go/readme.js CHANGED
@@ -11,4 +11,21 @@ exports.readme = `# Vira Engine Monorepo (scaffold)
11
11
  - plugins/ — интеграции
12
12
  - migrations/ — SQL/Go миграции
13
13
  - deploy/ — docker-compose/devops артефакты
14
- `;
14
+
15
+ Next steps:
16
+ cd my-vira-app/frontend
17
+ npm install
18
+ npm run dev
19
+
20
+ UI package:
21
+ cd ../ui
22
+ npm install
23
+ npm run dev
24
+
25
+ Backend stub:
26
+ cd ../backend
27
+ go mod tidy
28
+ go run ./cmd/api
29
+
30
+ Dev stack (DB/Redis/Kafka):
31
+ cd ../deploy && docker compose -f docker-compose.dev.yml up`;
@@ -3,11 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registryGo = void 0;
4
4
  exports.registryGo = `package events
5
5
 
6
- import (
7
- "context"
8
- "github.com/gorilla/websocket"
9
- )
10
-
11
6
  // Registry holds all registered event handlers.
12
7
  var Registry = make(map[string]EventHandler)
13
8
 
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ const commander_1 = require("commander");
49
49
  const fs = __importStar(require("fs-extra"));
50
50
  const path = __importStar(require("path"));
51
51
  const chalk_1 = __importDefault(require("chalk"));
52
+ const inquirer_1 = __importDefault(require("inquirer"));
52
53
  const backendReadme_1 = require("./go/backendReadme");
53
54
  const backendEnvExample_1 = require("./go/backendEnvExample");
54
55
  const dockerfile_1 = require("./go/dockerfile");
@@ -64,8 +65,6 @@ const dbGo_1 = require("./go/dbGo");
64
65
  const configGo_1 = require("./go/configGo");
65
66
  const mainGo_1 = require("./go/mainGo");
66
67
  const goMod_1 = require("./go/goMod");
67
- const useViraState_1 = require("./go/useViraState");
68
- const useViraStream_1 = require("./go/useViraStream");
69
68
  const channelHelpers_1 = require("./go/channelHelpers");
70
69
  const eventsAPI_1 = require("./go/eventsAPI");
71
70
  const eventHandlerTemplate_1 = require("./go/eventHandlerTemplate");
@@ -101,14 +100,47 @@ program
101
100
  .command("create")
102
101
  .description("Create a new Vira project")
103
102
  .argument("<name>", "Project name")
104
- .option("-t, --template <template>", "Template type (frontend|fullstack|kanban)", "frontend")
103
+ .option("-t, --template <template>", "Template type (frontend|fullstack|kanban). If not specified, interactive selection will be shown.")
105
104
  .action(async (name, options) => {
106
- console.log(chalk_1.default.blue(`Creating Vira project: ${name}`));
105
+ console.log(chalk_1.default.blue(`\nCreating Vira project: ${name}\n`));
107
106
  const projectPath = path.resolve(process.cwd(), name);
108
- const template = (options.template || "frontend");
109
- if (!SUPPORTED_TEMPLATES.includes(template)) {
110
- console.error(chalk_1.default.red(`Unknown template: ${template}. Use one of: ${SUPPORTED_TEMPLATES.join(", ")}`));
111
- process.exit(1);
107
+ // Интерактивный выбор шаблона, если не указан
108
+ let template;
109
+ if (options.template) {
110
+ template = options.template;
111
+ if (!SUPPORTED_TEMPLATES.includes(template)) {
112
+ console.error(chalk_1.default.red(`Unknown template: ${template}. Use one of: ${SUPPORTED_TEMPLATES.join(", ")}`));
113
+ process.exit(1);
114
+ }
115
+ }
116
+ else {
117
+ // Интерактивный выбор как в Vite
118
+ const { selectedTemplate } = await inquirer_1.default.prompt([
119
+ {
120
+ type: "list",
121
+ name: "selectedTemplate",
122
+ message: "Select a template:",
123
+ choices: [
124
+ {
125
+ name: "Frontend (React + Vite + Vira UI)",
126
+ value: "frontend",
127
+ short: "frontend",
128
+ },
129
+ {
130
+ name: "Fullstack (Frontend + Go Backend + Docker)",
131
+ value: "fullstack",
132
+ short: "fullstack",
133
+ },
134
+ {
135
+ name: "Kanban (Reference app with VRP)",
136
+ value: "kanban",
137
+ short: "kanban",
138
+ },
139
+ ],
140
+ default: "frontend",
141
+ },
142
+ ]);
143
+ template = selectedTemplate;
112
144
  }
113
145
  // Проверяем, существует ли директория
114
146
  if (await fs.pathExists(projectPath)) {
@@ -117,7 +149,7 @@ program
117
149
  }
118
150
  // Создаём структуру проекта
119
151
  await createProjectStructure(projectPath, template);
120
- console.log(chalk_1.default.green(`✓ Project ${name} created successfully!`));
152
+ console.log(chalk_1.default.green(`\n✓ Project ${name} created successfully!\n`));
121
153
  printNextSteps(name, template);
122
154
  });
123
155
  /**
@@ -267,13 +299,11 @@ async function createFullstackProject(projectPath) {
267
299
  const frontendPath = path.join(projectPath, "frontend");
268
300
  const backendPath = path.join(projectPath, "backend");
269
301
  const uiPath = path.join(projectPath, "ui");
270
- const cliPath = path.join(projectPath, "cli");
271
302
  const pluginsPath = path.join(projectPath, "plugins");
272
303
  const migrationsPath = path.join(projectPath, "migrations");
273
304
  const deployPath = path.join(projectPath, "deploy");
274
305
  await fs.ensureDir(projectPath);
275
306
  await fs.ensureDir(uiPath);
276
- await fs.ensureDir(cliPath);
277
307
  await fs.ensureDir(pluginsPath);
278
308
  await fs.ensureDir(migrationsPath);
279
309
  await fs.ensureDir(deployPath);
@@ -329,12 +359,12 @@ async function createFrontendProject(projectPath) {
329
359
  preview: "vite preview",
330
360
  },
331
361
  dependencies: {
332
- "@vira-ui/core": "^0.3.0-alpha",
333
- "@vira-ui/ui": "^0.3.0-alpha",
362
+ "@vira-ui/core": "^1.0.0",
363
+ "@vira-ui/ui": "^1.0.0",
334
364
  "lucide-react": "^0.400.0",
335
365
  },
336
366
  devDependencies: {
337
- "@vira-ui/babel-plugin": "^0.3.0-alpha",
367
+ "@vira-ui/babel-plugin": "^1.0.0",
338
368
  "@vitejs/plugin-react": "^4.2.0",
339
369
  "@types/node": "^20.10.0",
340
370
  "@types/react": "^18.2.0",
@@ -354,8 +384,8 @@ async function createFrontendProject(projectPath) {
354
384
  await fs.writeFile(path.join(projectPath, "src", "index.css"), indexCss_1.indexCss);
355
385
  await fs.writeFile(path.join(projectPath, "src", "main.tsx"), mainTsx_1.mainTsx);
356
386
  await fs.writeFile(path.join(projectPath, "src", "App.tsx"), appTsx_1.appTsx);
357
- await fs.writeFile(path.join(projectPath, "src", "hooks", "useViraStream.ts"), useViraStream_1.useViraStream);
358
- await fs.writeFile(path.join(projectPath, "src", "hooks", "useViraState.ts"), useViraState_1.useViraState);
387
+ // VRP hooks are now provided by @vira-ui/core
388
+ // No need to generate useViraState/useViraStream files
359
389
  }
360
390
  /**
361
391
  * Бекенд-заготовка (Go) для последующего расширения (Kafka/Redis/PG)
@@ -4,7 +4,7 @@ exports.appTsx = void 0;
4
4
  // src/App.tsx
5
5
  exports.appTsx = `import { useState } from 'react';
6
6
  import { Container, Heading, Text, Button, Stack, Code } from '@vira-ui/ui';
7
- import { useViraState } from './hooks/useViraState';
7
+ import { useViraState } from '@vira-ui/core';
8
8
  import './index.css';
9
9
 
10
10
  export function App() {
@@ -5,27 +5,7 @@ exports.kanbanService = void 0;
5
5
  exports.kanbanService = `// Kanban service using Vira Core DI container + VRP
6
6
  // This demonstrates the Vira standard: services for business logic, hooks for React state
7
7
 
8
- import { createService } from '@vira-ui/core';
9
- import { useViraState } from '../hooks/useViraState';
10
- import type { KanbanBoard, KanbanCard, KanbanChannel } from '../models/kanban';
11
-
12
- // Create kanban service (singleton via DI container)
13
- // Service holds business logic, not React state
14
- createService('kanban', () => ({
15
- // Helper: get cards for a column (pure function)
16
- getColumnCards(board: KanbanBoard | null, columnId: string): KanbanCard[] {
17
- if (!board) return [];
18
- const column = board.columns.find(col => col.id === columnId);
19
- if (!column) return [];
20
- return column.cardIds
21
- .map(id => board.cards[id])
22
- .filter((card): card is KanbanCard => card !== undefined)
23
- .sort((a, b) => a.order - b.order);
24
- },
25
- }));
26
-
27
- import { createService, useService } from '@vira-ui/core';
28
- import { useViraState } from '../hooks/useViraState';
8
+ import { createService, useService, useViraState } from '@vira-ui/core';
29
9
  import type { KanbanBoard, KanbanCard, KanbanChannel } from '../models/kanban';
30
10
 
31
11
  // Create kanban service (singleton via DI container)
@@ -16,10 +16,6 @@ exports.tsconfig = {
16
16
  esModuleInterop: true,
17
17
  skipLibCheck: true,
18
18
  forceConsistentCasingInFileNames: true,
19
- paths: {
20
- "@vira-ui/ui": ["./node_modules/@vira-ui/ui/src"],
21
- "@vira-ui/core": ["./node_modules/@vira-ui/core/src"],
22
- },
23
19
  },
24
20
  include: ["src"],
25
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vira-ui/cli",
3
- "version": "0.4.0-alpha",
3
+ "version": "1.0.0",
4
4
  "description": "CLI tool for ViraJS project generation",
5
5
  "author": "Vira Team",
6
6
  "license": "MIT",