@magicappdev/cli 0.0.3 → 0.0.5

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 ADDED
@@ -0,0 +1,207 @@
1
+ # MagicAppDev CLI
2
+
3
+ ![npm version](https://img.shields.io/npm/v/@magicappdev/cli)
4
+ ![npm downloads](https://img.shields.io/npm/dm/@magicappdev/cli)
5
+ ![license](https://img.shields.io/npm/l/@magicappdev/cli)
6
+
7
+ A powerful CLI tool for creating and managing MagicAppDev applications. The MagicAppDev CLI simplifies the process of generating, customizing, and deploying fullstack apps across web and mobile platforms.
8
+
9
+ ## Table of Contents
10
+
11
+ - [Installation](#installation)
12
+ - [Usage](#usage)
13
+ - [Commands](#commands)
14
+ - [Configuration](#configuration)
15
+ - [Features](#features)
16
+ - [Development](#development)
17
+ - [License](#license)
18
+ - [Contributing](#contributing)
19
+ - [Troubleshooting](#troubleshooting)
20
+
21
+ ## Installation
22
+
23
+ You can install the MagicAppDev CLI using npm, yarn, or pnpm:
24
+
25
+ ```bash
26
+ # Using npm
27
+ npm install -g @magicappdev/cli
28
+
29
+ # Using yarn
30
+ yarn global add @magicappdev/cli
31
+
32
+ # Using pnpm
33
+ pnpm add -g @magicappdev/cli
34
+ ```
35
+
36
+ For more details, visit the [npm page](https://www.npmjs.com/package/@magicappdev/cli).
37
+
38
+ ## Usage
39
+
40
+ The CLI provides several commands to manage your MagicAppDev projects:
41
+
42
+ ```bash
43
+ # Initialize a new MagicAppDev project
44
+ magicappdev init
45
+
46
+ # Authenticate with MagicAppDev
47
+ magicappdev auth
48
+
49
+ # Start an interactive chat session
50
+ magicappdev chat
51
+
52
+ # Generate components or apps
53
+ magicappdev generate <type> <name>
54
+
55
+ # Run diagnostics on your project
56
+ magicappdev doctor
57
+ ```
58
+
59
+ ## Commands
60
+
61
+ ### `init`
62
+
63
+ Initialize a new MagicAppDev project in the current directory.
64
+
65
+ ```bash
66
+ magicappdev init
67
+ ```
68
+
69
+ ### `auth`
70
+
71
+ Authenticate with MagicAppDev services.
72
+
73
+ ```bash
74
+ magicappdev auth
75
+ ```
76
+
77
+ ### `chat`
78
+
79
+ Start an interactive chat session for app creation and management.
80
+
81
+ ```bash
82
+ magicappdev chat
83
+ ```
84
+
85
+ ### `generate`
86
+
87
+ Generate components, apps, or other resources.
88
+
89
+ ```bash
90
+ # Generate a new component
91
+ magicappdev generate component my-component
92
+
93
+ # Generate a new app
94
+ magicappdev generate app my-app
95
+ ```
96
+
97
+ ### `doctor`
98
+
99
+ Run diagnostics to check your project setup and configuration.
100
+
101
+ ```bash
102
+ magicappdev doctor
103
+ ```
104
+
105
+ ## Configuration
106
+
107
+ ### Environment Variables
108
+
109
+ You can configure the CLI using environment variables in a `.env` file:
110
+
111
+ ```env
112
+ MAGICAPPDEV_API_KEY=your_api_key_here
113
+ MAGICAPPDEV_PROJECT_DIR=./my-project
114
+ ```
115
+
116
+ ### Config File
117
+
118
+ The CLI can also be configured using a `magicappdev.config.json` file:
119
+
120
+ ```json
121
+ {
122
+ "apiKey": "your_api_key_here",
123
+ "projectDir": "./my-project",
124
+ "defaultTemplate": "web"
125
+ }
126
+ ```
127
+
128
+ ## Features
129
+
130
+ - **Project Initialization**: Quickly set up new MagicAppDev projects.
131
+ - **Authentication**: Securely authenticate with MagicAppDev services.
132
+ - **Interactive Chat**: Use AI-powered chat for app creation and management.
133
+ - **Code Generation**: Generate components, apps, and other resources.
134
+ - **Diagnostics**: Run diagnostics to ensure your project is set up correctly.
135
+
136
+ ## Development
137
+
138
+ ### Prerequisites
139
+
140
+ - Node.js (v18 or higher)
141
+ - pnpm (v8 or higher)
142
+
143
+ ### Setup
144
+
145
+ 1. Clone the repository:
146
+
147
+ ```bash
148
+ git clone https://github.com/magicappdev/magicappdev.git
149
+ cd magicappdev
150
+ ```
151
+
152
+ 2. Install dependencies:
153
+
154
+ ```bash
155
+ pnpm install
156
+ ```
157
+
158
+ 3. Build the CLI:
159
+
160
+ ```bash
161
+ cd packages/cli
162
+ pnpm run build
163
+ ```
164
+
165
+ 4. Link the CLI for local development:
166
+
167
+ ```bash
168
+ pnpm link --global
169
+ ```
170
+
171
+ ### Running Tests
172
+
173
+ To run tests for the CLI:
174
+
175
+ ```bash
176
+ pnpm run test
177
+ ```
178
+
179
+ ## License
180
+
181
+ MagicAppDev CLI is licensed under the [MIT License](LICENSE).
182
+
183
+ ## Contributing
184
+
185
+ We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details.
186
+
187
+ ## Troubleshooting
188
+
189
+ ### Common Issues
190
+
191
+ - **Command Not Found**: Ensure the CLI is installed globally and your PATH is set correctly.
192
+ - **Authentication Errors**: Verify your API key and environment variables.
193
+ - **Build Errors**: Check your Node.js and pnpm versions and ensure all dependencies are installed.
194
+
195
+ ### FAQ
196
+
197
+ **Q: How do I update the CLI?**
198
+
199
+ A: Run `pnpm update -g @magicappdev/cli` to update to the latest version.
200
+
201
+ **Q: Can I use the CLI with npm or yarn?**
202
+
203
+ A: Yes, you can install the CLI using npm or yarn, but pnpm is recommended for optimal performance.
204
+
205
+ **Q: How do I report a bug?**
206
+
207
+ A: Please open an issue on our [GitHub repository](https://github.com/magicappdev/magicappdev/issues).
package/dist/cli.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * MagicAppDev CLI
3
3
  */
4
4
  import { Command } from "commander";
5
+ /** TEST - Test if build picks up changes */
5
6
  /** Create the CLI program */
6
7
  export declare function createProgram(): Command;
7
8
  /** Run the CLI */
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,6BAA6B;AAC7B,wBAAgB,aAAa,IAAI,OAAO,CAgBvC;AAED,kBAAkB;AAClB,wBAAsB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxD"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,4CAA4C;AAE5C,6BAA6B;AAC7B,wBAAgB,aAAa,IAAI,OAAO,CAiBvC;AAED,kBAAkB;AAClB,wBAAsB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxD"}
package/dist/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * MagicAppDev CLI
3
3
  */
4
4
  import { generateCommand } from "./commands/generate/index.js";
5
+ import { completionsCommand } from "./commands/completions.js";
5
6
  import { doctorCommand } from "./commands/doctor.js";
6
7
  import { initCommand } from "./commands/init.js";
7
8
  import { chatCommand } from "./commands/chat.js";
@@ -12,6 +13,7 @@ const require = createRequire(import.meta.url);
12
13
  const pkg = require("../package.json");
13
14
  /** Package version */
14
15
  const VERSION = pkg.version;
16
+ /** TEST - Test if build picks up changes */
15
17
  /** Create the CLI program */
16
18
  export function createProgram() {
17
19
  const program = new Command();
@@ -25,6 +27,7 @@ export function createProgram() {
25
27
  program.addCommand(chatCommand);
26
28
  program.addCommand(generateCommand);
27
29
  program.addCommand(doctorCommand);
30
+ program.addCommand(completionsCommand);
28
31
  return program;
29
32
  }
30
33
  /** Run the CLI */
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Completions command - Generate shell completion scripts
3
+ */
4
+ import { Command } from "commander";
5
+ export declare const completionsCommand: Command;
6
+ //# sourceMappingURL=completions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completions.d.ts","sourceRoot":"","sources":["../../src/commands/completions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,kBAAkB,SAkC3B,CAAC"}
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Completions command - Generate shell completion scripts
3
+ */
4
+ import { success, error, info, newline } from "../lib/ui.js";
5
+ import * as fs from "node:fs/promises";
6
+ import { Command } from "commander";
7
+ import * as path from "node:path";
8
+ export const completionsCommand = new Command("completions")
9
+ .description("Generate shell completion script")
10
+ .argument("<shell>", "Shell type (bash, zsh, fish, pwsh)")
11
+ .option("-p, --print", "Print completion script to stdout", false)
12
+ .option("-i, --install", "Attempt to install completion script", false)
13
+ .action(async (shell, options) => {
14
+ try {
15
+ const program = completionsCommand.parent;
16
+ if (!program) {
17
+ throw new Error("Unable to get program configuration");
18
+ }
19
+ const script = generateCompletionScript(shell, program);
20
+ const shouldPrint = options.print || (!options.install && !options.print);
21
+ if (shouldPrint) {
22
+ console.log(script);
23
+ if (!options.print) {
24
+ newline();
25
+ info("To install completions, add the above to your shell config:");
26
+ printInstallInstructions(shell);
27
+ newline();
28
+ }
29
+ }
30
+ else if (options.install) {
31
+ await installCompletionScript(shell, script);
32
+ }
33
+ if (!shouldPrint || options.print) {
34
+ success(`Completion script generated for ${shell}`);
35
+ }
36
+ }
37
+ catch (err) {
38
+ error(`Failed to generate completions: ${err.message}`);
39
+ process.exit(1);
40
+ }
41
+ });
42
+ function generateCompletionScript(shell, program) {
43
+ switch (shell.toLowerCase()) {
44
+ case "bash":
45
+ return generateBashCompletion(program);
46
+ case "zsh":
47
+ return generateZshCompletion(program);
48
+ case "fish":
49
+ return generateFishCompletion(program);
50
+ case "pwsh":
51
+ return generatePwshCompletion(program);
52
+ default:
53
+ throw new Error(`Unsupported shell: ${shell}. Supported: bash, zsh, fish, pwsh`);
54
+ }
55
+ }
56
+ function generateBashCompletion(program) {
57
+ const commands = program.commands.map(cmd => cmd.name()).join(" ");
58
+ return `# Bash completion for magicappdev
59
+ _magicappdev_completion() {
60
+ local cur prev words cword
61
+ _init_completion || return
62
+
63
+ COMPREPLY=($(compgen -W "${commands} --help --version" -- "\${cur}"))
64
+ }
65
+
66
+ complete -F _magicappdev_completion magicappdev mad createmagicapp
67
+ `;
68
+ }
69
+ function generateZshCompletion(program) {
70
+ const commandDescriptions = program.commands
71
+ .map(cmd => `"${cmd.name()}":"${cmd.description()}"`)
72
+ .join("\n ");
73
+ return `#compdef magicappdev mad createmagicapp
74
+
75
+ _magicappdev() {
76
+ local -a commands
77
+ commands=(
78
+ ${commandDescriptions}
79
+ )
80
+
81
+ if (( CURRENT == 2 )); then
82
+ _describe 'command' commands
83
+ fi
84
+ }
85
+
86
+ _magicappdev "$@"
87
+ `;
88
+ }
89
+ function generateFishCompletion(program) {
90
+ const commands = program.commands.map(cmd => cmd.name()).join(" ");
91
+ return `# Fish completion for magicappdev
92
+
93
+ complete -c magicappdev -f
94
+ complete -c mad -f
95
+ complete -c createmagicapp -f
96
+
97
+ complete -c magicappdev -a '${commands}' -d 'MagicAppDev command'
98
+ complete -c mad -a '${commands}' -d 'MagicAppDev command'
99
+ complete -c createmagicapp -a '${commands}' -d 'MagicAppDev command'
100
+ `;
101
+ }
102
+ function generatePwshCompletion(program) {
103
+ const commands = program.commands.map(cmd => cmd.name());
104
+ return `# PowerShell completion for magicappdev
105
+
106
+ using namespace System.Management.Automation
107
+ using namespace System.Management.Automation.Language
108
+
109
+ Register-ArgumentCompleter -Native -CommandName 'magicappdev', 'mad', 'createmagicapp' -ScriptBlock {
110
+ param($wordToComplete, $commandAst, $cursorPosition)
111
+
112
+ $commands = @(${commands.map(c => `'${c}'`).join(", ")})
113
+
114
+ $commandElements = $commandAst.CommandElements
115
+ $command = if ($commandElements.Count -gt 1) { $commandElements[1].Extent.Text } else { '' }
116
+
117
+ if ($wordToComplete -like '-*') {
118
+ @('--help', '--version') | Where-Object { $_ -like "$wordToComplete*" }
119
+ } else {
120
+ $commands | Where-Object { $_ -like "$wordToComplete*" }
121
+ }
122
+ }
123
+ `;
124
+ }
125
+ async function installCompletionScript(shell, script) {
126
+ const home = process.env.HOME || process.env.USERPROFILE;
127
+ if (!home) {
128
+ throw new Error("Unable to determine home directory");
129
+ }
130
+ let configPath;
131
+ switch (shell.toLowerCase()) {
132
+ case "bash":
133
+ configPath = path.join(home, ".bashrc");
134
+ break;
135
+ case "zsh":
136
+ configPath = path.join(home, ".zshrc");
137
+ break;
138
+ case "fish":
139
+ configPath = path.join(home, ".config", "fish", "completions", "magicappdev.fish");
140
+ break;
141
+ case "pwsh":
142
+ configPath = path.join(home, ".config", "powershell", "MagicAppDev_completions.ps1");
143
+ break;
144
+ default:
145
+ throw new Error(`Unable to determine config file for shell: ${shell}`);
146
+ }
147
+ // For fish, create the completion file directly
148
+ if (shell.toLowerCase() === "fish") {
149
+ await fs.mkdir(path.dirname(configPath), { recursive: true });
150
+ await fs.writeFile(configPath, script);
151
+ success(`Completion script installed to ${configPath}`);
152
+ info("Restart your shell for completions to take effect");
153
+ return;
154
+ }
155
+ // For other shells, append to config
156
+ try {
157
+ await fs.appendFile(configPath, `\n\n# MagicAppDev CLI completions\n${script}\n`);
158
+ success(`Completion script added to ${configPath}`);
159
+ info("Restart your shell for completions to take effect");
160
+ }
161
+ catch (err) {
162
+ error(`Failed to install: ${err.message}`);
163
+ info("You can manually add the script to your shell config");
164
+ }
165
+ }
166
+ function printInstallInstructions(shell) {
167
+ switch (shell.toLowerCase()) {
168
+ case "bash":
169
+ info(' echo "$(magicappdev completions bash)" >> ~/.bashrc');
170
+ info(" source ~/.bashrc");
171
+ break;
172
+ case "zsh":
173
+ info(' echo "$(magicappdev completions zsh)" >> ~/.zshrc');
174
+ info(" source ~/.zshrc");
175
+ break;
176
+ case "fish":
177
+ info(" magicappdev completions fish > ~/.config/fish/completions/magicappdev.fish");
178
+ break;
179
+ case "pwsh":
180
+ info(" magicappdev completions pwsh > $PROFILE");
181
+ break;
182
+ }
183
+ }
package/dist/lib/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiClient } from "@magicappdev/shared/api";
1
+ import { ApiClient } from "@magicappdev/shared";
2
2
  export declare const AGENT_HOST: string;
3
3
  export declare const api: ApiClient;
4
4
  export type { User, Project } from "@magicappdev/shared";
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAUpD,eAAO,MAAM,UAAU,QAGsB,CAAC;AAE9C,eAAO,MAAM,GAAG,WAAyB,CAAC;AAM1C,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUhD,eAAO,MAAM,UAAU,QAGsB,CAAC;AAE9C,eAAO,MAAM,GAAG,WAAyB,CAAC;AAM1C,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/lib/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiClient } from "@magicappdev/shared/api";
1
+ import { ApiClient } from "@magicappdev/shared";
2
2
  import { loadConfig } from "./config.js";
3
3
  const config = await loadConfig();
4
4
  const API_URL = process.env.MAGICAPPDEV_API_URL ||
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@magicappdev/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "CLI tool for creating and managing MagicAppDev apps",
5
+ "keywords": [
6
+ "cli",
7
+ "MagicAppDev",
8
+ "app-dev",
9
+ "mobile",
10
+ "react-native"
11
+ ],
5
12
  "type": "module",
6
13
  "main": "./dist/index.js",
7
14
  "types": "./dist/index.d.ts",
@@ -26,22 +33,22 @@
26
33
  "@magicappdev/templates": "workspace:*",
27
34
  "agents": "^0.3.6",
28
35
  "chalk": "^5.4.0",
29
- "commander": "^13.0.0",
36
+ "commander": "^14.0.2",
30
37
  "execa": "^9.5.0",
31
38
  "open": "^11.0.0",
32
- "ora": "^8.1.0",
39
+ "ora": "^9.1.0",
33
40
  "prompts": "^2.4.0",
34
41
  "tslib": "^2.3.0",
35
42
  "ws": "^8.18.0"
36
43
  },
37
44
  "devDependencies": {
38
- "@types/node": "^25.0.0",
45
+ "@types/node": "^25.0.10",
39
46
  "@types/prompts": "^2.4.0",
40
47
  "@types/ws": "^8.5.10",
41
48
  "eslint": "^9.39.2",
42
49
  "eslint-config-prettier": "^10.1.8",
43
50
  "tsx": "^4.19.0",
44
- "typescript": "~5.8.2",
51
+ "typescript": "~5.9.3",
45
52
  "typescript-eslint": "^8.53.1"
46
53
  }
47
54
  }