@fireberry/cli 0.0.5-beta.18 → 0.0.5-beta.20

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.
@@ -1,6 +1,6 @@
1
1
  import "../config/env.js";
2
- import type { CreateAppRequest, Manifest, ZippedComponent } from "./types.js";
3
- export declare const createApp: (data: CreateAppRequest) => Promise<void>;
4
- export declare const pushComponents: (appId: string, components: ZippedComponent[]) => Promise<void>;
2
+ import type { Manifest, ZippedComponent } from "./types.js";
3
+ export declare const createApp: (manifest: Manifest) => Promise<void>;
4
+ export declare const pushComponents: (appId: string, components: ZippedComponent[], manifest: Manifest) => Promise<void>;
5
5
  export declare const installApp: (manifest: Manifest) => Promise<void>;
6
6
  export declare const deleteApp: (manifest: Manifest) => Promise<void>;
@@ -1,34 +1,35 @@
1
1
  import "../config/env.js";
2
+ import { BASE_SERVICE_URL } from "../constants/component-types.js";
2
3
  import { api } from "./axios.js";
3
- export const createApp = async (data) => {
4
- const url = "/services/developer/create";
4
+ export const createApp = async (manifest) => {
5
+ const url = `${BASE_SERVICE_URL}/create`;
5
6
  try {
6
- await api.post(url, data);
7
+ await api.post(url, { manifest });
7
8
  }
8
9
  catch (error) {
9
10
  throw new Error(error instanceof Error ? error.message : "Unknown error");
10
11
  }
11
12
  };
12
- export const pushComponents = async (appId, components) => {
13
- const url = `/services/developer/push`;
13
+ export const pushComponents = async (appId, components, manifest) => {
14
+ const url = `${BASE_SERVICE_URL}/push`;
14
15
  try {
15
- await api.post(url, { appId, components });
16
+ await api.post(url, { appId, components, manifest });
16
17
  }
17
18
  catch (error) {
18
19
  throw new Error(error instanceof Error ? error.message : "Unknown error");
19
20
  }
20
21
  };
21
22
  export const installApp = async (manifest) => {
22
- const url = `/services/developer/install`;
23
+ const url = `${BASE_SERVICE_URL}/install`;
23
24
  try {
24
- await api.post(url, { manifest });
25
+ await api.post(url, { manifest }, { timeout: 300000 }); // 5 minutes
25
26
  }
26
27
  catch (error) {
27
28
  throw new Error(error instanceof Error ? error.message : "Unknown error");
28
29
  }
29
30
  };
30
31
  export const deleteApp = async (manifest) => {
31
- const url = `/services/developer/delete`;
32
+ const url = `${BASE_SERVICE_URL}/delete`;
32
33
  try {
33
34
  await api.delete(url, { manifest });
34
35
  }
@@ -1,6 +1,7 @@
1
1
  import { COMPONENT_TYPE } from "../constants/component-types.js";
2
2
  export interface CreateAppRequest {
3
3
  appId: string;
4
+ componentId: string;
4
5
  }
5
6
  export interface ApiError {
6
7
  message: string;
@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";
6
6
  import ora from "ora";
7
7
  import chalk from "chalk";
8
8
  import { createApp } from "../api/requests.js";
9
+ import { getManifest } from "../utils/components.utils.js";
9
10
  const __filename = fileURLToPath(import.meta.url);
10
11
  const __dirname = path.dirname(__filename);
11
12
  function slugifyName(name) {
@@ -35,7 +36,6 @@ export async function runCreate({ name }) {
35
36
  }
36
37
  const spinner = ora(`Creating app "${chalk.cyan(appName)}"...`).start();
37
38
  try {
38
- await createApp({ appId });
39
39
  await fs.ensureDir(appDir);
40
40
  const templatesDir = path.join(__dirname, "..", "..", "src", "templates");
41
41
  const manifestTemplate = await fs.readFile(path.join(templatesDir, "manifest.yml"), "utf-8");
@@ -47,6 +47,8 @@ export async function runCreate({ name }) {
47
47
  const htmlContent = htmlTemplate.replace(/{{appName}}/g, appName);
48
48
  await fs.writeFile(path.join(appDir, "manifest.yml"), manifestContent);
49
49
  await fs.writeFile(path.join(appDir, "index.html"), htmlContent);
50
+ const manifest = await getManifest(appDir);
51
+ await createApp(manifest);
50
52
  spinner.succeed(`Successfully created "${chalk.cyan(appName)}" app!`);
51
53
  console.log(chalk.gray(`📁 Location: ${appDir}`));
52
54
  console.log(chalk.gray(`App ID: ${appId}`));
@@ -1,8 +1,17 @@
1
+ import ora from "ora";
1
2
  import { installApp } from "../api/requests.js";
2
3
  import { getManifest, validateManifestComponents, } from "../utils/components.utils.js";
3
4
  export async function runInstall() {
4
- const manifest = await getManifest();
5
- await validateManifestComponents(manifest);
6
- await installApp(manifest);
7
- console.log("App installed successfully");
5
+ const spinner = ora("Loading manifest...").start();
6
+ try {
7
+ const manifest = await getManifest();
8
+ await validateManifestComponents(manifest);
9
+ spinner.start("Installing app on Fireberry...");
10
+ await installApp(manifest);
11
+ spinner.succeed("App installed successfully");
12
+ }
13
+ catch (error) {
14
+ spinner.fail("Installation failed");
15
+ throw error;
16
+ }
8
17
  }
@@ -18,7 +18,7 @@ export async function runPush() {
18
18
  console.log(chalk.gray(` ${idx + 1}. ${comp.title} (${comp.id}) - ${sizeKB} KB`));
19
19
  });
20
20
  spinner.start("Uploading to Fireberry...");
21
- await pushComponents(manifest.app.id, zippedComponents);
21
+ await pushComponents(manifest.app.id, zippedComponents, manifest);
22
22
  spinner.succeed("Components pushed successfully");
23
23
  }
24
24
  else {
@@ -4,3 +4,4 @@ export declare const COMPONENT_TYPE: {
4
4
  readonly SIDE_MENU: "side-menu";
5
5
  };
6
6
  export type ComponentType = (typeof COMPONENT_TYPE)[keyof typeof COMPONENT_TYPE];
7
+ export declare const BASE_SERVICE_URL = "/services/developer/app";
@@ -3,3 +3,4 @@ export const COMPONENT_TYPE = {
3
3
  GLOBAL_MENU: "global-menu",
4
4
  SIDE_MENU: "side-menu",
5
5
  };
6
+ export const BASE_SERVICE_URL = "/services/developer/app";
@@ -1,5 +1,5 @@
1
1
  import { Manifest, ZippedComponent, UntypedManifestComponent } from "../api/types.js";
2
- export declare const getManifest: () => Promise<Manifest>;
2
+ export declare const getManifest: (basePath?: string) => Promise<Manifest>;
3
3
  export declare const validateComponentBuild: (componentPath: string, comp: UntypedManifestComponent) => Promise<void>;
4
4
  export declare const zipComponentBuild: (componentPath: string, title: string) => Promise<Buffer>;
5
5
  export declare const validateManifestComponents: (manifest: Manifest) => Promise<void>;
@@ -5,10 +5,11 @@ import chalk from "chalk";
5
5
  import * as tar from "tar";
6
6
  import os from "node:os";
7
7
  import { COMPONENT_TYPE } from "../constants/component-types.js";
8
- export const getManifest = async () => {
9
- const manifestPath = path.join(process.cwd(), "manifest.yml");
8
+ export const getManifest = async (basePath) => {
9
+ const manifestPath = path.join(basePath || process.cwd(), "manifest.yml");
10
+ const searchDir = basePath || process.cwd();
10
11
  if (!(await fs.pathExists(manifestPath))) {
11
- throw new Error(`No manifest.yml found at ${chalk.yellow(process.cwd())}.\n` +
12
+ throw new Error(`No manifest.yml found at ${chalk.yellow(searchDir)}.\n` +
12
13
  `Please run this command from your Fireberry app directory.`);
13
14
  }
14
15
  const manifestContent = await fs.readFile(manifestPath, "utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireberry/cli",
3
- "version": "0.0.5-beta.18",
3
+ "version": "0.0.5-beta.20",
4
4
  "description": "Fireberry CLI tool",
5
5
  "type": "module",
6
6
  "author": "",
@@ -1,11 +1,12 @@
1
1
  import "../config/env.js";
2
+ import { BASE_SERVICE_URL } from "../constants/component-types.js";
2
3
  import { api } from "./axios.js";
3
- import type { CreateAppRequest, Manifest, ZippedComponent } from "./types.js";
4
+ import type { Manifest, ZippedComponent } from "./types.js";
4
5
 
5
- export const createApp = async (data: CreateAppRequest): Promise<void> => {
6
- const url = "/services/developer/create";
6
+ export const createApp = async (manifest: Manifest): Promise<void> => {
7
+ const url = `${BASE_SERVICE_URL}/create`;
7
8
  try {
8
- await api.post<void>(url, data);
9
+ await api.post<void>(url, { manifest });
9
10
  } catch (error) {
10
11
  throw new Error(error instanceof Error ? error.message : "Unknown error");
11
12
  }
@@ -13,27 +14,28 @@ export const createApp = async (data: CreateAppRequest): Promise<void> => {
13
14
 
14
15
  export const pushComponents = async (
15
16
  appId: string,
16
- components: ZippedComponent[]
17
+ components: ZippedComponent[],
18
+ manifest: Manifest
17
19
  ): Promise<void> => {
18
- const url = `/services/developer/push`;
20
+ const url = `${BASE_SERVICE_URL}/push`;
19
21
  try {
20
- await api.post<void>(url, { appId, components });
22
+ await api.post<void>(url, { appId, components, manifest });
21
23
  } catch (error) {
22
24
  throw new Error(error instanceof Error ? error.message : "Unknown error");
23
25
  }
24
26
  };
25
27
 
26
28
  export const installApp = async (manifest: Manifest): Promise<void> => {
27
- const url = `/services/developer/install`;
29
+ const url = `${BASE_SERVICE_URL}/install`;
28
30
  try {
29
- await api.post<void>(url, { manifest });
31
+ await api.post<void>(url, { manifest }, { timeout: 300000 }); // 5 minutes
30
32
  } catch (error) {
31
33
  throw new Error(error instanceof Error ? error.message : "Unknown error");
32
34
  }
33
35
  };
34
36
 
35
37
  export const deleteApp = async (manifest: Manifest): Promise<void> => {
36
- const url = `/services/developer/delete`;
38
+ const url = `${BASE_SERVICE_URL}/delete`;
37
39
  try {
38
40
  await api.delete<void>(url, { manifest });
39
41
  } catch (error) {
package/src/api/types.ts CHANGED
@@ -2,6 +2,7 @@ import { COMPONENT_TYPE } from "../constants/component-types.js";
2
2
 
3
3
  export interface CreateAppRequest {
4
4
  appId: string;
5
+ componentId: string;
5
6
  }
6
7
 
7
8
  export interface ApiError {
@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";
6
6
  import ora from "ora";
7
7
  import chalk from "chalk";
8
8
  import { createApp } from "../api/requests.js";
9
+ import { getManifest } from "../utils/components.utils.js";
9
10
 
10
11
  const __filename = fileURLToPath(import.meta.url);
11
12
  const __dirname = path.dirname(__filename);
@@ -50,8 +51,6 @@ export async function runCreate({ name }: CreateOptions): Promise<void> {
50
51
  const spinner = ora(`Creating app "${chalk.cyan(appName)}"...`).start();
51
52
 
52
53
  try {
53
- await createApp({ appId });
54
-
55
54
  await fs.ensureDir(appDir);
56
55
 
57
56
  const templatesDir = path.join(__dirname, "..", "..", "src", "templates");
@@ -73,6 +72,9 @@ export async function runCreate({ name }: CreateOptions): Promise<void> {
73
72
 
74
73
  await fs.writeFile(path.join(appDir, "manifest.yml"), manifestContent);
75
74
  await fs.writeFile(path.join(appDir, "index.html"), htmlContent);
75
+ const manifest = await getManifest(appDir);
76
+
77
+ await createApp(manifest);
76
78
 
77
79
  spinner.succeed(`Successfully created "${chalk.cyan(appName)}" app!`);
78
80
  console.log(chalk.gray(`📁 Location: ${appDir}`));
@@ -1,3 +1,4 @@
1
+ import ora from "ora";
1
2
  import { installApp } from "../api/requests.js";
2
3
  import {
3
4
  getManifest,
@@ -5,8 +6,18 @@ import {
5
6
  } from "../utils/components.utils.js";
6
7
 
7
8
  export async function runInstall(): Promise<void> {
8
- const manifest = await getManifest();
9
- await validateManifestComponents(manifest);
10
- await installApp(manifest);
11
- console.log("App installed successfully");
9
+ const spinner = ora("Loading manifest...").start();
10
+
11
+ try {
12
+ const manifest = await getManifest();
13
+
14
+ await validateManifestComponents(manifest);
15
+
16
+ spinner.start("Installing app on Fireberry...");
17
+ await installApp(manifest);
18
+ spinner.succeed("App installed successfully");
19
+ } catch (error) {
20
+ spinner.fail("Installation failed");
21
+ throw error;
22
+ }
12
23
  }
@@ -30,7 +30,7 @@ export async function runPush(): Promise<void> {
30
30
 
31
31
  spinner.start("Uploading to Fireberry...");
32
32
 
33
- await pushComponents(manifest.app.id, zippedComponents);
33
+ await pushComponents(manifest.app.id, zippedComponents, manifest);
34
34
  spinner.succeed("Components pushed successfully");
35
35
  } else {
36
36
  spinner.succeed("No components to push");
@@ -6,3 +6,5 @@ export const COMPONENT_TYPE = {
6
6
 
7
7
  export type ComponentType =
8
8
  (typeof COMPONENT_TYPE)[keyof typeof COMPONENT_TYPE];
9
+
10
+ export const BASE_SERVICE_URL = "/services/developer/app";
@@ -14,12 +14,13 @@ import {
14
14
  } from "../api/types.js";
15
15
  import { COMPONENT_TYPE } from "../constants/component-types.js";
16
16
 
17
- export const getManifest = async (): Promise<Manifest> => {
18
- const manifestPath = path.join(process.cwd(), "manifest.yml");
17
+ export const getManifest = async (basePath?: string): Promise<Manifest> => {
18
+ const manifestPath = path.join(basePath || process.cwd(), "manifest.yml");
19
+ const searchDir = basePath || process.cwd();
19
20
 
20
21
  if (!(await fs.pathExists(manifestPath))) {
21
22
  throw new Error(
22
- `No manifest.yml found at ${chalk.yellow(process.cwd())}.\n` +
23
+ `No manifest.yml found at ${chalk.yellow(searchDir)}.\n` +
23
24
  `Please run this command from your Fireberry app directory.`
24
25
  );
25
26
  }