@fireberry/cli 0.0.5-beta.12 → 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.
@@ -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 {};
@@ -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);
@@ -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);
@@ -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
  };
@@ -69,9 +69,9 @@ export const validateManifestComponents = async (manifest) => {
69
69
  if (!components || components.length === 0) {
70
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
76
  for (const comp of components) {
77
77
  const componentPath = path.join(process.cwd(), comp.path);
@@ -87,7 +87,7 @@ export const handleComponents = async (manifest) => {
87
87
  const buildBuffer = await zipComponentBuild(componentPath, comp.title);
88
88
  zippedComponents.push({
89
89
  title: comp.title,
90
- key: comp.key,
90
+ id: comp.id,
91
91
  build: buildBuffer,
92
92
  });
93
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireberry/cli",
3
- "version": "0.0.5-beta.12",
3
+ "version": "0.0.5-beta.13",
4
4
  "description": "Fireberry CLI tool",
5
5
  "type": "module",
6
6
  "author": "",
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
  }
@@ -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
 
@@ -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,7 +5,7 @@ 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
10
  settings:
11
11
  iconName: "related-single"
@@ -51,7 +51,7 @@ export const validateComponentBuild = async (
51
51
  const files = await fs.readdir(componentPath);
52
52
 
53
53
  if (files.length === 0) {
54
- throw new Error(`Component <${comp.key}> at: /${comp.path} not found`);
54
+ throw new Error(`Component <${comp.id}> at: /${comp.path} not found`);
55
55
  }
56
56
  }
57
57
  };
@@ -109,9 +109,9 @@ export const validateManifestComponents = async (manifest: Manifest) => {
109
109
  throw new Error("No components found in manifest");
110
110
  }
111
111
 
112
- const keys = components.map((comp) => comp.key);
113
- if (new Set(keys).size !== keys.length) {
114
- 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
115
  }
116
116
 
117
117
  for (const comp of components) {
@@ -135,7 +135,7 @@ export const handleComponents = async (
135
135
 
136
136
  zippedComponents.push({
137
137
  title: comp.title,
138
- key: comp.key,
138
+ id: comp.id,
139
139
  build: buildBuffer,
140
140
  });
141
141
  }