@docyrus/cli 0.1.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 CHANGED
@@ -2,78 +2,86 @@
2
2
 
3
3
  Official command-line interface for Docyrus - authentication, project scaffolding, and code generation tools.
4
4
 
5
- ## Installation
5
+ ## Usage
6
6
 
7
7
  ```bash
8
- npm install -g docyrus
9
- # or
10
- pnpm add -g docyrus
8
+ npx @docyrus/cli <command>
11
9
  ```
12
10
 
13
11
  ## Commands
14
12
 
15
13
  ### Authentication
16
14
 
17
- #### `docyrus login`
15
+ #### `login`
18
16
 
19
17
  Log in to Docyrus using browser-based SSO (default).
20
18
 
21
19
  ```bash
22
- docyrus login # Opens browser for SSO authentication
23
- docyrus login --email # Use email/password instead (prompts for credentials)
24
- docyrus login -e user@example.com # Pre-fill email address
20
+ npx @docyrus/cli login # Opens browser for SSO authentication
21
+ npx @docyrus/cli login --email # Use email/password instead (prompts for credentials)
22
+ npx @docyrus/cli login -e user@example.com # Pre-fill email address
25
23
  ```
26
24
 
27
- #### `docyrus logout`
25
+ #### `logout`
28
26
 
29
27
  Log out from Docyrus and clear stored credentials.
30
28
 
31
29
  ```bash
32
- docyrus logout
30
+ npx @docyrus/cli logout
33
31
  ```
34
32
 
35
- #### `docyrus whoami`
33
+ #### `whoami`
36
34
 
37
35
  Display the currently logged-in user.
38
36
 
39
37
  ```bash
40
- docyrus whoami
38
+ npx @docyrus/cli whoami
41
39
  # Output: Email: user@example.com
42
40
  # Name: John Doe
43
41
  ```
44
42
 
45
43
  ### Project Creation
46
44
 
47
- #### `docyrus create [name]`
45
+ #### `create [name]`
48
46
 
49
47
  Create a new Docyrus project from a template.
50
48
 
51
49
  ```bash
52
- docyrus create # Interactive mode - prompts for all options
53
- docyrus create my-app # Create project with specified name
54
- docyrus create my-app --nextjs # Next.js + plain Tailwind
55
- docyrus create my-app --nextjs --shadcn # Next.js + shadcn/ui
56
- docyrus create my-app --react --heroui # React + HeroUI
57
- docyrus create my-app --vue --shadcn # Vue + shadcn-vue
58
- docyrus create my-app --astro # Astro + plain Tailwind
59
- docyrus create my-app --nextjs --shadcn --eslint --pnpm # Full flags
50
+ npx @docyrus/cli create # Interactive mode - prompts for all options
51
+ npx @docyrus/cli create my-app # Create project with specified name
52
+ npx @docyrus/cli create my-app --nextjs # Next.js + plain Tailwind
53
+ npx @docyrus/cli create my-app --nextjs --shadcn # Next.js + shadcn/ui
54
+ npx @docyrus/cli create my-app --react --heroui # React + HeroUI
55
+ npx @docyrus/cli create my-app --react --diceui # React + DiceUI
56
+ npx @docyrus/cli create my-app --vue --shadcn # Vue + shadcn-vue
57
+ npx @docyrus/cli create my-app --electron --shadcn # Electron + shadcn/ui
58
+ npx @docyrus/cli create my-app --nextjs --shadcn --zustand --eslint --pnpm # Full flags
60
59
  ```
61
60
 
62
61
  **Framework Options:**
63
62
 
64
63
  | Flag | Description |
65
64
  |------|-------------|
66
- | `--nextjs` | Use Next.js 15+ (App Router) |
65
+ | `--nextjs` | Use Next.js 16+ (App Router) |
67
66
  | `--react` | Use React 19+ with Vite |
68
- | `--astro` | Use Astro 5+ |
69
67
  | `--vue` | Use Vue 3.5+ with Vite |
68
+ | `--electron` | Use Electron + React + Vite |
70
69
 
71
70
  **UI Library Options (optional - defaults to plain Tailwind if not specified):**
72
71
 
73
- | Flag | Description |
74
- |------|-------------|
75
- | `--shadcn` | Use shadcn/ui (React/Next.js) or shadcn-vue (Vue) |
76
- | `--heroui` | Use HeroUI (React/Next.js only) |
72
+ | Flag | Compatible Frameworks |
73
+ |------|----------------------|
74
+ | `--shadcn` | Next.js, React, Electron (shadcn/ui) / Vue (shadcn-vue) |
75
+ | `--diceui` | Next.js, React, Electron |
76
+ | `--heroui` | Next.js, React |
77
+
78
+ **State Management Options (optional):**
79
+
80
+ | Flag | Compatible Frameworks |
81
+ |------|----------------------|
82
+ | `--zustand` | Next.js, React, Electron |
83
+ | `--tanstack-query` | Next.js, React, Electron |
84
+ | `--tanstack-vue-query` | Vue |
77
85
 
78
86
  **Linter Options:**
79
87
 
@@ -98,37 +106,24 @@ docyrus create my-app --nextjs --shadcn --eslint --pnpm # Full flags
98
106
  |--------|-------------|
99
107
  | `-p, --path <path>` | Target directory path |
100
108
  | `--alias <prefix>` | Custom import alias prefix (must start with @) |
101
-
102
- **Available Templates:**
103
-
104
- | Template | Description |
105
- |----------|-------------|
106
- | `nextjs` | Next.js 15+ + Tailwind CSS v4 |
107
- | `nextjs-shadcn` | Next.js 15+ + Tailwind CSS v4 + shadcn/ui |
108
- | `nextjs-heroui` | Next.js 15+ + Tailwind CSS v4 + HeroUI |
109
- | `react` | React 19+ + Vite + Tailwind CSS v4 |
110
- | `react-shadcn` | React 19+ + Vite + Tailwind CSS v4 + shadcn/ui |
111
- | `react-heroui` | React 19+ + Vite + Tailwind CSS v4 + HeroUI |
112
- | `astro` | Astro 5+ + Tailwind CSS v4 |
113
- | `vue` | Vue 3.5+ + Vite + Tailwind CSS v4 |
114
- | `vue-shadcn` | Vue 3.5+ + Vite + Tailwind CSS v4 + shadcn-vue |
109
+ | `--local` | Use local templates (development only) |
115
110
 
116
111
  Each template includes:
117
- - Pre-configured OAuth2 authentication pages
112
+ - Pre-configured OAuth2 authentication via `@docyrus/app-auth-ui`
118
113
  - Docyrus API client integration
119
114
  - Modern TypeScript setup
120
115
  - Linter configuration (ESLint or Biome)
121
116
 
122
117
  ### Code Generation
123
118
 
124
- #### `docyrus generate db [spec]`
119
+ #### `generate db [spec]`
125
120
 
126
121
  Generate TanStack Query collections from an OpenAPI 3.1.0 specification.
127
122
 
128
123
  ```bash
129
- docyrus generate db # Auto-detect openapi.json in current directory
130
- docyrus generate db ./api/openapi.json # Specify spec file path
131
- docyrus generate db ./spec.json -o ./src/api # Custom output directory
124
+ npx @docyrus/cli generate db # Auto-detect openapi.json in current directory
125
+ npx @docyrus/cli generate db ./api/openapi.json # Specify spec file path
126
+ npx @docyrus/cli generate db ./spec.json -o ./src/api # Custom output directory
132
127
  ```
133
128
 
134
129
  **Options:**
@@ -136,53 +131,23 @@ docyrus generate db ./spec.json -o ./src/api # Custom output directory
136
131
  | Option | Description |
137
132
  |--------|-------------|
138
133
  | `-o, --output <dir>` | Output directory (defaults to `src` in spec file folder) |
139
- | `-w, --watch` | Watch for changes in the spec file (coming soon) |
140
134
 
141
135
  ### CLI Management
142
136
 
143
- #### `docyrus upgrade`
137
+ #### `upgrade`
144
138
 
145
139
  Upgrade the CLI to the latest version. Automatically detects your package manager (npm, pnpm, yarn, bun).
146
140
 
147
141
  ```bash
148
- docyrus upgrade
142
+ npx @docyrus/cli upgrade
149
143
  ```
150
144
 
151
- #### `docyrus completion <shell>`
145
+ #### `info`
152
146
 
153
- Generate shell completion script for tab completion support.
147
+ Display CLI version, system information, and authentication status.
154
148
 
155
149
  ```bash
156
- # Bash - add to ~/.bashrc
157
- eval "$(docyrus completion bash)"
158
-
159
- # Zsh - add to ~/.zshrc
160
- eval "$(docyrus completion zsh)"
161
-
162
- # Fish - save to completions directory
163
- docyrus completion fish > ~/.config/fish/completions/docyrus.fish
164
- ```
165
-
166
- #### `docyrus info`
167
-
168
- Display CLI version, system information, and authentication status. Useful for debugging.
169
-
170
- ```bash
171
- docyrus info
172
- # Output:
173
- # docyrus v0.0.1
174
- #
175
- # System:
176
- # Node.js: v20.10.0
177
- # OS: darwin 23.0.0 (arm64)
178
- #
179
- # Environment:
180
- # API URL: https://api.docyrus.com
181
- # Config: /Users/you/.docyrus
182
- #
183
- # Authentication:
184
- # Status: Logged in
185
- # Email: user@example.com
150
+ npx @docyrus/cli info
186
151
  ```
187
152
 
188
153
  ## Global Options
@@ -192,42 +157,21 @@ docyrus info
192
157
  Output results in JSON format. Useful for scripting and CI/CD pipelines.
193
158
 
194
159
  ```bash
195
- docyrus whoami --json
196
- # Output: {"user": {"email": "user@example.com", "firstname": "John", "lastname": "Doe"}}
197
-
198
- docyrus generate db ./spec.json --json
199
- # Output: {"spec": "./spec.json", "output": "./src", "success": true, "message": "..."}
160
+ npx @docyrus/cli whoami --json
161
+ npx @docyrus/cli generate db ./spec.json --json
200
162
  ```
201
163
 
202
164
  ### `-v, --version`
203
165
 
204
166
  Display the CLI version.
205
167
 
206
- ```bash
207
- docyrus -v
208
- # Output: 0.0.1
209
- ```
210
-
211
168
  ### `-h, --help`
212
169
 
213
170
  Display help information.
214
171
 
215
172
  ```bash
216
- docyrus --help
217
- docyrus login --help
218
- docyrus generate --help
219
- docyrus generate db --help
220
- ```
221
-
222
- ## Auto-Update Notifications
223
-
224
- The CLI automatically checks for updates and displays a notification when a new version is available:
225
-
226
- ```
227
- ┌────────────────────────────────────────────┐
228
- │ Update available! 0.0.1 → 0.1.0 │
229
- │ Run npm i -g docyrus to update │
230
- └────────────────────────────────────────────┘
173
+ npx @docyrus/cli --help
174
+ npx @docyrus/cli create --help
231
175
  ```
232
176
 
233
177
  ## Environment Variables
@@ -236,7 +180,7 @@ The CLI automatically checks for updates and displays a notification when a new
236
180
  |----------|-------------|
237
181
  | `DOCYRUS_API_URL` | Override the API base URL |
238
182
  | `DOCYRUS_OAUTH_CLIENT_ID` | Override the OAuth2 client ID |
239
- | `DEBUG` | Enable debug output |
183
+ | `DOCYRUS_OAUTH_SCOPES` | Override the OAuth2 scopes |
240
184
 
241
185
  ## Token Storage
242
186
 
package/dist/cli.js CHANGED
@@ -11,7 +11,7 @@ import { homedir, arch, release, platform, hostname, userInfo } from 'os';
11
11
  import Conf from 'conf';
12
12
  import chalk4 from 'chalk';
13
13
  import ora from 'ora';
14
- import { select, input, password } from '@inquirer/prompts';
14
+ import { select, input, password, confirm } from '@inquirer/prompts';
15
15
  import { exec } from 'child_process';
16
16
  import { promisify } from 'util';
17
17
  import { access, constants, writeFile, readFile, mkdir, cp, rm, readdir } from 'fs/promises';
@@ -19,7 +19,7 @@ import { downloadTemplate } from 'giget';
19
19
  import { generateFromOpenAPI } from '@docyrus/tanstack-db-generator';
20
20
 
21
21
  // src/config/constants.ts
22
- var DOCYRUS_API_URL = "https://alpha-api.docyrus.com";
22
+ var DOCYRUS_API_URL = "https://api.docyrus.com";
23
23
  var OAUTH_CLIENT_ID = "90565525-8283-4881-82a9-8613eb82ae27";
24
24
  var OAUTH_SCOPES = "offline_access Read.All Users.Read Users.Read.All DS.Read.All".split(" ");
25
25
  var OAUTH_CALLBACK_PORT_MIN = 9876;
@@ -991,6 +991,11 @@ var MESSAGES = {
991
991
  CREATE_DOWNLOAD_OPENAPI: "Download OpenAPI spec for code generation?",
992
992
  CREATE_DOWNLOADING_OPENAPI: "Downloading OpenAPI specification...",
993
993
  CREATE_OPENAPI_SUCCESS: (path) => `OpenAPI spec saved to ${path}`,
994
+ // TanStack DB Generator
995
+ TANSTACK_GENERATOR_PROMPT: "Generate TanStack Query collections from OpenAPI spec?",
996
+ TANSTACK_GENERATOR_RUNNING: "Generating TanStack Query collections...",
997
+ TANSTACK_GENERATOR_SUCCESS: "TanStack Query collections generated",
998
+ TANSTACK_GENERATOR_FAILED: "Failed to generate TanStack Query collections",
994
999
  // Linter Setup
995
1000
  LINTER_SETUP_TITLE: "Setting up Linter...",
996
1001
  // State Management
@@ -1454,15 +1459,7 @@ async function applyUIVariants(targetDir, uiLibrary) {
1454
1459
  await rm(variantsDir, { recursive: true, force: true });
1455
1460
  }
1456
1461
  var execAsync = promisify(exec);
1457
- function parseEnvArray(value) {
1458
- if (!value) {
1459
- throw new Error("Missing environment variable");
1460
- }
1461
- return value.split(",").map((s) => s.trim());
1462
- }
1463
- var SHADCN_BASE_COLORS = parseEnvArray("zinc,slate,neutral,stone,gray");
1464
- parseEnvArray("vega,nova,maia,lyra,mira");
1465
- var DICEUI_COMPONENTS = parseEnvArray("action-bar,avatar-group,badge-overflow,checkbox-group,circular-progress,color-picker,color-swatch,combobox,compare-slider,cropper,editable,file-upload,gauge,kanban,key-value,listbox,mask-input,media-player,mention,phone-input,qr-code,rating,relative-time-card,responsive-dialog,scroll-spy,scroller,segmented-input,sortable,speed-dial,stack,stat,status,stepper,swap,tags-input,time-picker,timeline,tour");
1462
+ var DICEUI_COMPONENTS = "action-bar,avatar-group,badge-overflow,checkbox-group,circular-progress,color-picker,color-swatch,combobox,compare-slider,cropper,editable,file-upload,gauge,kanban,key-value,listbox,mask-input,media-player,mention,phone-input,qr-code,rating,relative-time-card,responsive-dialog,scroll-spy,scroller,segmented-input,sortable,speed-dial,stack,stat,status,stepper,swap,tags-input,time-picker,timeline,tour".split(",");
1466
1463
  var UI_LIBRARY_COMPATIBILITY = {
1467
1464
  nextjs: [
1468
1465
  "shadcn",
@@ -1904,6 +1901,7 @@ import { vueQueryOptions } from './lib/query-client';
1904
1901
 
1905
1902
  // src/commands/create.ts
1906
1903
  var execAsync2 = promisify(exec);
1904
+ var SHADCN_BASE_COLORS = "zinc,slate,neutral,stone,gray".split(",");
1907
1905
  function validateConflictingFlags(options) {
1908
1906
  const frameworkFlags = [
1909
1907
  options.nextjs,
@@ -2033,8 +2031,8 @@ function getUiLibrariesForFramework(framework) {
2033
2031
  }
2034
2032
  }
2035
2033
  var STATE_MGMT_REACT = [
2036
- { name: "zustand", label: "Zustand (Recommended)", description: "Lightweight client state" },
2037
- { name: "tanstack-query", label: "TanStack Query", description: "Server state & data fetching" },
2034
+ { name: "tanstack-query", label: "TanStack Query (Recommended)", description: "Server state & data fetching" },
2035
+ { name: "zustand", label: "Zustand", description: "Lightweight client state" },
2038
2036
  { name: "none", label: "None", description: "No state management" }
2039
2037
  ];
2040
2038
  var STATE_MGMT_VUE = [{ name: "tanstack-vue-query", label: "TanStack Vue Query (Recommended)", description: "Server state & data fetching" }, { name: "none", label: "None", description: "No state management" }];
@@ -2071,7 +2069,7 @@ var PACKAGE_MANAGERS = [
2071
2069
  { name: "yarn", label: "yarn", description: "Fast, reliable, and secure" },
2072
2070
  { name: "bun", label: "bun", description: "All-in-one JavaScript runtime" }
2073
2071
  ];
2074
- var TEMPLATE_REPO_BASE = "Docyrus/docyrus-devkit/packages/cli-templates";
2072
+ var TEMPLATE_REPO_BASE = "Docyrus/docyrus-devkit/templates";
2075
2073
  function getTemplateRepo(framework) {
2076
2074
  return `${TEMPLATE_REPO_BASE}/${framework}`;
2077
2075
  }
@@ -2158,12 +2156,11 @@ Examples:
2158
2156
  }))
2159
2157
  });
2160
2158
  } else {
2161
- const validColors = SHADCN_BASE_COLORS;
2162
2159
  if (options?.baseColor) {
2163
- if (!validColors.includes(options.baseColor)) {
2164
- throw new ConflictingFlagsError("--base-color", `must be one of: ${validColors.join(", ")}`);
2160
+ if (!SHADCN_BASE_COLORS.includes(options.baseColor)) {
2161
+ throw new ConflictingFlagsError("--base-color", `must be one of: ${SHADCN_BASE_COLORS.join(", ")}`);
2165
2162
  }
2166
- baseColor = options.baseColor;
2163
+ ({ baseColor } = options);
2167
2164
  }
2168
2165
  }
2169
2166
  }
@@ -2258,7 +2255,7 @@ Examples:
2258
2255
  MESSAGES.CREATE_COPYING_LOCAL,
2259
2256
  async () => {
2260
2257
  const cliPackageDir = dirname(dirname(fileURLToPath(import.meta.url)));
2261
- const localTemplateDir = resolve(cliPackageDir, "..", "cli-templates", framework);
2258
+ const localTemplateDir = resolve(cliPackageDir, "..", "..", "templates", framework);
2262
2259
  try {
2263
2260
  await access(localTemplateDir, constants.F_OK);
2264
2261
  } catch {
@@ -2419,6 +2416,7 @@ ${errorMessage}`
2419
2416
  );
2420
2417
  logger.newline();
2421
2418
  logger.log(MESSAGES.OPENAPI_SETUP_TITLE);
2419
+ let openApiDownloaded = false;
2422
2420
  try {
2423
2421
  const savedPath = await withSpinner(
2424
2422
  "Downloading OpenAPI spec...",
@@ -2426,9 +2424,28 @@ ${errorMessage}`
2426
2424
  { successText: "OpenAPI spec downloaded" }
2427
2425
  );
2428
2426
  logger.dim(MESSAGES.CREATE_OPENAPI_SUCCESS(savedPath));
2427
+ openApiDownloaded = true;
2429
2428
  } catch (error) {
2430
2429
  logger.warn(`Failed to download OpenAPI spec: ${error instanceof Error ? error.message : "Unknown error"}`);
2431
2430
  }
2431
+ if (openApiDownloaded) {
2432
+ try {
2433
+ logger.newline();
2434
+ const runGenerator = await confirm({
2435
+ message: MESSAGES.TANSTACK_GENERATOR_PROMPT,
2436
+ default: true
2437
+ });
2438
+ if (runGenerator) {
2439
+ await withSpinner(
2440
+ MESSAGES.TANSTACK_GENERATOR_RUNNING,
2441
+ async () => execAsync2("npx @docyrus/tanstack-db-generator openapi-spec.json", { cwd: targetDir }),
2442
+ { successText: MESSAGES.TANSTACK_GENERATOR_SUCCESS }
2443
+ );
2444
+ }
2445
+ } catch (genError) {
2446
+ logger.warn(`${MESSAGES.TANSTACK_GENERATOR_FAILED}: ${genError instanceof Error ? genError.message : "Unknown error"}`);
2447
+ }
2448
+ }
2432
2449
  logger.newline();
2433
2450
  logger.success(MESSAGES.CREATE_SUCCESS);
2434
2451
  logger.newline();