@fireberry/cli 0.0.5-beta.10 → 0.0.5-beta.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Fireberry LTD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,4 +1,5 @@
1
1
  import "../config/env.js";
2
- import type { CreateAppRequest, ZippedComponent } from "./types.js";
2
+ import type { CreateAppRequest, Manifest, ZippedComponent } from "./types.js";
3
3
  export declare const createApp: (data: CreateAppRequest) => Promise<void>;
4
4
  export declare const pushComponents: (appId: string, components: ZippedComponent[]) => Promise<void>;
5
+ export declare const installApp: (manifest: Manifest) => Promise<void>;
@@ -18,3 +18,12 @@ export const pushComponents = async (appId, components) => {
18
18
  throw new Error(error instanceof Error ? error.message : "Unknown error");
19
19
  }
20
20
  };
21
+ export const installApp = async (manifest) => {
22
+ const url = `/services/developer/install`;
23
+ try {
24
+ await api.post(url, { manifest });
25
+ }
26
+ catch (error) {
27
+ throw new Error(error instanceof Error ? error.message : "Unknown error");
28
+ }
29
+ };
@@ -19,7 +19,7 @@ interface ManifestApp {
19
19
  export interface ManifestComponent {
20
20
  type: string;
21
21
  title: string;
22
- key: string;
22
+ id: string;
23
23
  path: string;
24
24
  settings?: Record<string, unknown>;
25
25
  }
@@ -29,7 +29,7 @@ export interface Manifest {
29
29
  }
30
30
  export interface ZippedComponent {
31
31
  title: string;
32
- key: string;
32
+ id: string;
33
33
  build: Buffer;
34
34
  }
35
35
  export {};
@@ -5,6 +5,7 @@ import { runInit } from "../commands/init.js";
5
5
  import { runCreate } from "../commands/create.js";
6
6
  import packageJson from "../../package.json" with { type: "json" };
7
7
  import { runPush } from "../commands/push.js";
8
+ import { runInstall } from "../commands/install.js";
8
9
  const program = new Command();
9
10
  program
10
11
  .name("fireberry")
@@ -31,6 +32,11 @@ program
31
32
  .action(async () => {
32
33
  await runPush();
33
34
  });
35
+ program.command("install")
36
+ .description("Install app on your Fireberry account")
37
+ .action(async () => {
38
+ await runInstall();
39
+ });
34
40
  program.parseAsync(process.argv).catch((err) => {
35
41
  const errorMessage = err instanceof Error
36
42
  ? err.message
@@ -28,6 +28,7 @@ export async function runCreate({ name }) {
28
28
  }
29
29
  const slug = slugifyName(appName);
30
30
  const appId = uuidv4();
31
+ const componentId = uuidv4();
31
32
  const appDir = path.resolve(process.cwd(), slug);
32
33
  if (await fs.pathExists(appDir)) {
33
34
  throw new Error(`Already exists. ${chalk.yellow(slug)}`);
@@ -41,7 +42,8 @@ export async function runCreate({ name }) {
41
42
  const htmlTemplate = await fs.readFile(path.join(templatesDir, "index.html"), "utf-8");
42
43
  const manifestContent = manifestTemplate
43
44
  .replace(/{{appName}}/g, appName)
44
- .replace(/{{appId}}/g, appId);
45
+ .replace(/{{appId}}/g, appId)
46
+ .replace(/{{componentId}}/g, componentId);
45
47
  const htmlContent = htmlTemplate.replace(/{{appName}}/g, appName);
46
48
  await fs.writeFile(path.join(appDir, "manifest.yml"), manifestContent);
47
49
  await fs.writeFile(path.join(appDir, "index.html"), htmlContent);
@@ -0,0 +1 @@
1
+ export declare function runInstall(): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { installApp } from "../api/requests.js";
2
+ import { getManifest, validateManifestComponents, } from "../utils/components.utils.js";
3
+ export async function runInstall() {
4
+ const manifest = await getManifest();
5
+ await validateManifestComponents(manifest);
6
+ await installApp(manifest);
7
+ console.log("App installed successfully");
8
+ }
@@ -15,7 +15,7 @@ export async function runPush() {
15
15
  console.log(chalk.cyan("\nComponents ready to push:"));
16
16
  zippedComponents.forEach((comp, idx) => {
17
17
  const sizeKB = (comp.build.length / 1024).toFixed(2);
18
- console.log(chalk.gray(` ${idx + 1}. ${comp.title} (${comp.key}) - ${sizeKB} KB`));
18
+ console.log(chalk.gray(` ${idx + 1}. ${comp.title} (${comp.id}) - ${sizeKB} KB`));
19
19
  });
20
20
  spinner.start("Uploading to Fireberry...");
21
21
  await pushComponents(manifest.app.id, zippedComponents);
@@ -2,4 +2,5 @@ import { Manifest, ManifestComponent, ZippedComponent } from "../api/types.js";
2
2
  export declare const getManifest: () => Promise<Manifest>;
3
3
  export declare const validateComponentBuild: (componentPath: string, comp: ManifestComponent) => Promise<void>;
4
4
  export declare const zipComponentBuild: (componentPath: string, title: string) => Promise<Buffer>;
5
+ export declare const validateManifestComponents: (manifest: Manifest) => Promise<void>;
5
6
  export declare const handleComponents: (manifest: Manifest) => Promise<ZippedComponent[]>;
@@ -28,7 +28,7 @@ export const validateComponentBuild = async (componentPath, comp) => {
28
28
  if (stats.isDirectory()) {
29
29
  const files = await fs.readdir(componentPath);
30
30
  if (files.length === 0) {
31
- throw new Error(`Component <${comp.key}> at: /${comp.path} not found`);
31
+ throw new Error(`Component <${comp.id}> at: /${comp.path} not found`);
32
32
  }
33
33
  }
34
34
  };
@@ -64,23 +64,30 @@ export const zipComponentBuild = async (componentPath, title) => {
64
64
  throw error;
65
65
  }
66
66
  };
67
- export const handleComponents = async (manifest) => {
67
+ export const validateManifestComponents = async (manifest) => {
68
68
  const components = manifest.components;
69
69
  if (!components || components.length === 0) {
70
- return [];
70
+ throw new Error("No components found in manifest");
71
71
  }
72
- const keys = components.map((comp) => comp.key);
73
- if (new Set(keys).size !== keys.length) {
74
- throw new Error("All component keys must be unique");
72
+ const ids = components.map((comp) => comp.id);
73
+ if (new Set(ids).size !== ids.length) {
74
+ throw new Error("All component ids must be unique");
75
75
  }
76
- const zippedComponents = [];
77
76
  for (const comp of components) {
78
77
  const componentPath = path.join(process.cwd(), comp.path);
79
78
  await validateComponentBuild(componentPath, comp);
79
+ }
80
+ };
81
+ export const handleComponents = async (manifest) => {
82
+ await validateManifestComponents(manifest);
83
+ const components = manifest.components;
84
+ const zippedComponents = [];
85
+ for (const comp of components) {
86
+ const componentPath = path.join(process.cwd(), comp.path);
80
87
  const buildBuffer = await zipComponentBuild(componentPath, comp.title);
81
88
  zippedComponents.push({
82
89
  title: comp.title,
83
- key: comp.key,
90
+ id: comp.id,
84
91
  build: buildBuffer,
85
92
  });
86
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireberry/cli",
3
- "version": "0.0.5-beta.10",
3
+ "version": "0.0.5-beta.13",
4
4
  "description": "Fireberry CLI tool",
5
5
  "type": "module",
6
6
  "author": "",
@@ -1,6 +1,6 @@
1
1
  import "../config/env.js";
2
2
  import { api } from "./axios.js";
3
- import type { CreateAppRequest, ZippedComponent } from "./types.js";
3
+ import type { CreateAppRequest, Manifest, ZippedComponent } from "./types.js";
4
4
 
5
5
  export const createApp = async (data: CreateAppRequest): Promise<void> => {
6
6
  const url = "/services/developer/create";
@@ -22,3 +22,12 @@ export const pushComponents = async (
22
22
  throw new Error(error instanceof Error ? error.message : "Unknown error");
23
23
  }
24
24
  };
25
+
26
+ export const installApp = async (manifest: Manifest): Promise<void> => {
27
+ const url = `/services/developer/install`;
28
+ try {
29
+ await api.post<void>(url, { manifest });
30
+ } catch (error) {
31
+ throw new Error(error instanceof Error ? error.message : "Unknown error");
32
+ }
33
+ };
package/src/api/types.ts CHANGED
@@ -23,7 +23,7 @@ interface ManifestApp {
23
23
  export interface ManifestComponent {
24
24
  type: string;
25
25
  title: string;
26
- key: string;
26
+ id: string;
27
27
  path: string;
28
28
  settings?: Record<string, unknown>;
29
29
  }
@@ -35,6 +35,6 @@ export interface Manifest {
35
35
 
36
36
  export interface ZippedComponent {
37
37
  title: string;
38
- key: string;
38
+ id: string;
39
39
  build: Buffer;
40
40
  }
@@ -5,6 +5,7 @@ import { runInit } from "../commands/init.js";
5
5
  import { runCreate } from "../commands/create.js";
6
6
  import packageJson from "../../package.json" with { type: "json" };
7
7
  import { runPush } from "../commands/push.js";
8
+ import { runInstall } from "../commands/install.js";
8
9
 
9
10
  const program = new Command();
10
11
 
@@ -37,6 +38,12 @@ program
37
38
  await runPush();
38
39
  });
39
40
 
41
+ program.command("install")
42
+ .description("Install app on your Fireberry account")
43
+ .action(async () => {
44
+ await runInstall();
45
+ });
46
+
40
47
  program.parseAsync(process.argv).catch((err: unknown) => {
41
48
  const errorMessage = err instanceof Error
42
49
  ? err.message
@@ -40,6 +40,7 @@ export async function runCreate({ name }: CreateOptions): Promise<void> {
40
40
 
41
41
  const slug = slugifyName(appName);
42
42
  const appId = uuidv4();
43
+ const componentId = uuidv4();
43
44
  const appDir = path.resolve(process.cwd(), slug);
44
45
 
45
46
  if (await fs.pathExists(appDir)) {
@@ -65,7 +66,8 @@ export async function runCreate({ name }: CreateOptions): Promise<void> {
65
66
 
66
67
  const manifestContent = manifestTemplate
67
68
  .replace(/{{appName}}/g, appName)
68
- .replace(/{{appId}}/g, appId);
69
+ .replace(/{{appId}}/g, appId)
70
+ .replace(/{{componentId}}/g, componentId);
69
71
 
70
72
  const htmlContent = htmlTemplate.replace(/{{appName}}/g, appName);
71
73
 
@@ -0,0 +1,12 @@
1
+ import { installApp } from "../api/requests.js";
2
+ import {
3
+ getManifest,
4
+ validateManifestComponents,
5
+ } from "../utils/components.utils.js";
6
+
7
+ 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");
12
+ }
@@ -24,7 +24,7 @@ export async function runPush(): Promise<void> {
24
24
  zippedComponents.forEach((comp, idx) => {
25
25
  const sizeKB = (comp.build.length / 1024).toFixed(2);
26
26
  console.log(
27
- chalk.gray(` ${idx + 1}. ${comp.title} (${comp.key}) - ${sizeKB} KB`)
27
+ chalk.gray(` ${idx + 1}. ${comp.title} (${comp.id}) - ${sizeKB} KB`)
28
28
  );
29
29
  });
30
30
 
@@ -5,6 +5,9 @@ app:
5
5
  components:
6
6
  - type: record
7
7
  title: my-first-component
8
- key: comp
8
+ id: "{{componentId}}"
9
9
  path: static/comp/build
10
- settings: {}
10
+ settings:
11
+ iconName: "related-single"
12
+ iconColor: "#7aae7f"
13
+ objectType: 0
@@ -49,8 +49,9 @@ export const validateComponentBuild = async (
49
49
 
50
50
  if (stats.isDirectory()) {
51
51
  const files = await fs.readdir(componentPath);
52
+
52
53
  if (files.length === 0) {
53
- throw new Error(`Component <${comp.key}> at: /${comp.path} not found`);
54
+ throw new Error(`Component <${comp.id}> at: /${comp.path} not found`);
54
55
  }
55
56
  }
56
57
  };
@@ -102,31 +103,39 @@ export const zipComponentBuild = async (
102
103
  }
103
104
  };
104
105
 
105
- export const handleComponents = async (
106
- manifest: Manifest
107
- ): Promise<ZippedComponent[]> => {
106
+ export const validateManifestComponents = async (manifest: Manifest) => {
108
107
  const components = manifest.components;
109
108
  if (!components || components.length === 0) {
110
- return [];
109
+ throw new Error("No components found in manifest");
111
110
  }
112
111
 
113
- const keys = components.map((comp) => comp.key);
114
- if (new Set(keys).size !== keys.length) {
115
- throw new Error("All component keys must be unique");
112
+ const ids = components.map((comp) => comp.id);
113
+ if (new Set(ids).size !== ids.length) {
114
+ throw new Error("All component ids must be unique");
115
+ }
116
+
117
+ for (const comp of components) {
118
+ const componentPath = path.join(process.cwd(), comp.path);
119
+ await validateComponentBuild(componentPath, comp);
116
120
  }
121
+ };
122
+
123
+ export const handleComponents = async (
124
+ manifest: Manifest
125
+ ): Promise<ZippedComponent[]> => {
126
+ await validateManifestComponents(manifest);
127
+ const components = manifest.components!;
117
128
 
118
129
  const zippedComponents: ZippedComponent[] = [];
119
130
 
120
131
  for (const comp of components) {
121
132
  const componentPath = path.join(process.cwd(), comp.path);
122
133
 
123
- await validateComponentBuild(componentPath, comp);
124
-
125
134
  const buildBuffer = await zipComponentBuild(componentPath, comp.title);
126
135
 
127
136
  zippedComponents.push({
128
137
  title: comp.title,
129
- key: comp.key,
138
+ id: comp.id,
130
139
  build: buildBuffer,
131
140
  });
132
141
  }