prismpanel 0.0.1

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.
@@ -0,0 +1 @@
1
+ {"bot_token": "your_test_token_here", "test_key": "test_value"}
package/bin/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import "../src/index.js";
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "prismpanel",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "bin": {
10
+ "prismpanel": "./bin/index.js"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "type": "module",
16
+ "dependencies": {
17
+ "chalk": "^5.6.2",
18
+ "inquirer": "^13.3.2",
19
+ "ora": "^9.3.0"
20
+ }
21
+ }
@@ -0,0 +1,59 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import inquirer from "inquirer";
4
+ import chalk from "chalk";
5
+ import { createLoader } from "../utils/loader.js";
6
+ import { showWelcome } from "../utils/logger.js";
7
+
8
+ export async function init() {
9
+ showWelcome();
10
+ const getVisibleLength = (str) => str.replace(/\u001b\[\d+m/g, "").length;
11
+ const noteWidth = 55;
12
+ const borderCol = chalk.yellow;
13
+
14
+ const titleStr = ` ${chalk.yellow.bold("⚠ PRIVACY NOTICE")} `;
15
+ const line1 = ` Your Bot Token is used exclusively for features.`;
16
+ const line2 = ` It will never be stored or used elsewhere.`;
17
+
18
+ console.log(borderCol(` ┌${"─".repeat(noteWidth)}┐`));
19
+ [titleStr, line1, line2].forEach(line => {
20
+ const visibleLength = getVisibleLength(line);
21
+ const padding = " ".repeat(Math.max(0, noteWidth - visibleLength));
22
+ console.log(` ${borderCol("│")}${line}${padding}${borderCol("│")}`);
23
+ });
24
+ console.log(borderCol(` └${"─".repeat(noteWidth)}┘\n`));
25
+
26
+ const answers = await inquirer.prompt([
27
+ {
28
+ type: "input",
29
+ name: "bot_token",
30
+ message: "Bot Token:",
31
+ },
32
+ ]);
33
+
34
+ const loader = createLoader("Creating project...");
35
+
36
+ // simulate progress over 4 seconds
37
+ await new Promise((resolve) => {
38
+ setTimeout(() => loader.update("Setting up files..."), 1000);
39
+ setTimeout(() => loader.update("Installing dependencies..."), 2000);
40
+ setTimeout(() => loader.update("Finalizing..."), 3000);
41
+ setTimeout(resolve, 4000);
42
+ });
43
+
44
+ loader.succeed("Project created successfully!");
45
+
46
+ // Save the config
47
+ try {
48
+ const configDir = path.join(process.cwd(), "@prism_panel");
49
+ if (!fs.existsSync(configDir)) {
50
+ fs.mkdirSync(configDir, { recursive: true });
51
+ }
52
+ const configPath = path.join(configDir, "config.json");
53
+ fs.writeFileSync(configPath, JSON.stringify(answers, null, 2));
54
+ } catch (err) {
55
+ console.log(chalk.red("\nError saving configuration: " + err.message));
56
+ }
57
+
58
+ console.log("\nResult:", answers);
59
+ }
package/src/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import { init } from "./commands/init.js";
2
+ import { getEnvVariables, GetEnvVaribels } from "./utils/config.js";
3
+
4
+ // Export the utility functions for use as a library
5
+ export { getEnvVariables, GetEnvVaribels };
6
+
7
+ const command = process.argv[2];
8
+
9
+ if (command) {
10
+ switch (command) {
11
+ case "init":
12
+ await init();
13
+ break;
14
+
15
+ default:
16
+ console.log("Unknown command");
17
+ }
18
+ }
@@ -0,0 +1,34 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+ /**
5
+ * Get configuration value(s) from the @prism_panel/config.json file in the current workspace.
6
+ *
7
+ * @param {string} [key] - The key to look for in the config file. If not provided, returns all config.
8
+ * @returns {any|null} - The value of the key, the entire config object, or null if not found.
9
+ */
10
+ export function getEnvVariables(key) {
11
+ try {
12
+ const configPath = path.join(process.cwd(), "@prism_panel", "config.json");
13
+
14
+ if (!fs.existsSync(configPath)) {
15
+ return null;
16
+ }
17
+
18
+ const configFile = fs.readFileSync(configPath, "utf-8").replace(/^\uFEFF/, "");
19
+ const config = JSON.parse(configFile);
20
+
21
+ if (key) {
22
+ return config[key] !== undefined ? config[key] : null;
23
+ }
24
+
25
+ return config;
26
+ } catch (error) {
27
+ return null;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Alias for getEnvVariables to match specific user request naming.
33
+ */
34
+ export const GetEnvVaribels = getEnvVariables;
@@ -0,0 +1,20 @@
1
+ import ora from "ora";
2
+
3
+ export function createLoader(text = "Loading...") {
4
+ const spinner = ora({
5
+ text,
6
+ color: "blue",
7
+ }).start();
8
+
9
+ return {
10
+ update(message) {
11
+ spinner.text = message;
12
+ },
13
+ succeed(message) {
14
+ spinner.succeed(message);
15
+ },
16
+ fail(message) {
17
+ spinner.fail(message);
18
+ },
19
+ };
20
+ }
@@ -0,0 +1,55 @@
1
+ import chalk from "chalk";
2
+
3
+ export function logInfo(message) {
4
+ console.log(chalk.blue(message));
5
+ }
6
+
7
+ export function logSuccess(message) {
8
+ console.log(chalk.green(message));
9
+ }
10
+
11
+ export function logError(message) {
12
+ console.log(chalk.red(message));
13
+ }
14
+
15
+ /**
16
+ * High-fidelity, modern welcomer for the PRISM CLI.
17
+ * Features a minimalist text-only header box with a clickable link.
18
+ */
19
+ export function showWelcome() {
20
+ const version = "1.0.1";
21
+
22
+ // Helper for clickable terminal links
23
+ const link = (text, url) => `\u001b]8;;${url}\u001b\\${text}\u001b]8;;\u001b\\`;
24
+
25
+ const textLines = [
26
+ "",
27
+ `${chalk.bgCyan.black.bold(" PRISM PANEL ")} ${chalk.white("CLI")} ${chalk.gray("•")} ${chalk.cyan("v" + version)}`,
28
+ chalk.gray(" https://prism.sh/docs/cli"),
29
+ `${chalk.gray(" Powered By")} ${chalk.blue.bold(link("AxonTeam", "https://ax0n.xyz"))}`,
30
+ "",
31
+ ];
32
+
33
+ const boxWidth = 55;
34
+ const borderChar = chalk.gray;
35
+
36
+ // Robust ANSI stripper to calculate visible length supporting complex escapes
37
+ const getVisibleLength = (str) => {
38
+ return str
39
+ .replace(/\u001b\[[\d;]*m/g, "") // Strip color/bold/dim sequences
40
+ .replace(/\u001b\]8;;.*?\u001b\\/g, "") // Strip OSC link delimiters
41
+ .replace(/\u001b\]8;;\u001b\\/g, "") // Strip closing OSC link delimiters
42
+ .length;
43
+ };
44
+
45
+ console.log("");
46
+ console.log(borderChar(` ┌${"─".repeat(boxWidth)}┐`));
47
+
48
+ textLines.forEach((line) => {
49
+ const visibleLength = getVisibleLength(line);
50
+ const padding = " ".repeat(Math.max(0, boxWidth - visibleLength - 2));
51
+ console.log(` ${borderChar("│")} ${line}${padding}${borderChar("│")}`);
52
+ });
53
+
54
+ console.log(borderChar(` └${"─".repeat(boxWidth)}┘`) + "\n");
55
+ }