@fireberry/cli 0.0.3
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 +43 -0
- package/bin/fireberry.js +24 -0
- package/package.json +41 -0
- package/src/commands/init.js +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @fireberry/cli
|
|
2
|
+
|
|
3
|
+
Fireberry CLI tool for managing your Fireberry application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the CLI globally using npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @fireberry/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
After installation, the `fireberry` command will be available in your terminal.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Get Help
|
|
18
|
+
|
|
19
|
+
View all available commands and options:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
fireberry --help
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Initialize Workspace
|
|
26
|
+
|
|
27
|
+
Set up your Fireberry workspace with your authentication token:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
fireberry init <tokenid>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This will store your authentication token securely for future use.
|
|
34
|
+
|
|
35
|
+
## Available Commands
|
|
36
|
+
|
|
37
|
+
- `init <tokenid>`: Initialize your workspace with authentication
|
|
38
|
+
- `--help`: Show help information for any command
|
|
39
|
+
- `--version`: Show CLI version
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
package/bin/fireberry.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { runInit } from "../src/commands/init.js";
|
|
5
|
+
|
|
6
|
+
const program = new Command();
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.name("fireberry")
|
|
10
|
+
.description("Fireberry developer CLI (demo)")
|
|
11
|
+
.version("0.0.1");
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.command("init")
|
|
15
|
+
.argument("[tokenid]", "Fireberry token id")
|
|
16
|
+
.description("Initiates credentials and stores token in local config (demo)")
|
|
17
|
+
.action(async (tokenid) => {
|
|
18
|
+
await runInit({ tokenid });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
22
|
+
console.error(chalk.red(err?.message || "Unexpected error"));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fireberry/cli",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Fireberry CLI tool",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"bin": {
|
|
9
|
+
"fireberry": "bin/fireberry.js"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "node bin/fireberry.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"cli",
|
|
19
|
+
"fireberry",
|
|
20
|
+
"tool"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/fireberry-crm/cli"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/fireberry-crm/cli/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/fireberry-crm/cli#readme",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"chalk": "^5.3.0",
|
|
35
|
+
"commander": "^12.1.0",
|
|
36
|
+
"env-paths": "^3.0.0",
|
|
37
|
+
"fs-extra": "^11.2.0",
|
|
38
|
+
"inquirer": "^9.2.12",
|
|
39
|
+
"ora": "^8.0.1"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import envPaths from "env-paths";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
|
|
8
|
+
export async function runInit({ tokenid } = {}) {
|
|
9
|
+
let token = tokenid;
|
|
10
|
+
if (!token) {
|
|
11
|
+
const answers = await inquirer.prompt([
|
|
12
|
+
{
|
|
13
|
+
type: "password",
|
|
14
|
+
name: "token",
|
|
15
|
+
message: "Enter Fireberry token id",
|
|
16
|
+
mask: "*",
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
token = answers.token?.trim();
|
|
20
|
+
}
|
|
21
|
+
if (!token) {
|
|
22
|
+
throw new Error("An access token must be provided.");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const paths = envPaths("Fireberry CLI", { suffix: "" });
|
|
26
|
+
const configDir = paths.config;
|
|
27
|
+
const configFile = path.join(configDir, "config.json");
|
|
28
|
+
|
|
29
|
+
const spinner = ora("Saving token to local config (demo)").start();
|
|
30
|
+
try {
|
|
31
|
+
await fs.ensureDir(configDir);
|
|
32
|
+
const config = {
|
|
33
|
+
token,
|
|
34
|
+
createdAt: new Date().toISOString(),
|
|
35
|
+
};
|
|
36
|
+
await fs.writeJson(configFile, config, { spaces: 2 });
|
|
37
|
+
spinner.succeed("Initialized. Token stored locally for demo purposes.");
|
|
38
|
+
console.log(chalk.gray(`Config: ${configFile}`));
|
|
39
|
+
} catch (err) {
|
|
40
|
+
spinner.fail("Failed to save token.");
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|