@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.
- package/dist/api/types.d.ts +2 -2
- package/dist/commands/create.js +3 -1
- package/dist/commands/push.js +1 -1
- package/dist/utils/components.utils.js +5 -5
- package/package.json +1 -1
- package/src/api/types.ts +2 -2
- package/src/commands/create.ts +3 -1
- package/src/commands/push.ts +1 -1
- package/src/templates/manifest.yml +1 -1
- package/src/utils/components.utils.ts +5 -5
package/dist/api/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ interface ManifestApp {
|
|
|
19
19
|
export interface ManifestComponent {
|
|
20
20
|
type: string;
|
|
21
21
|
title: string;
|
|
22
|
-
|
|
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
|
-
|
|
32
|
+
id: string;
|
|
33
33
|
build: Buffer;
|
|
34
34
|
}
|
|
35
35
|
export {};
|
package/dist/commands/create.js
CHANGED
|
@@ -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);
|
package/dist/commands/push.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
|
73
|
-
if (new Set(
|
|
74
|
-
throw new Error("All component
|
|
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
|
-
|
|
90
|
+
id: comp.id,
|
|
91
91
|
build: buildBuffer,
|
|
92
92
|
});
|
|
93
93
|
}
|
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
38
|
+
id: string;
|
|
39
39
|
build: Buffer;
|
|
40
40
|
}
|
package/src/commands/create.ts
CHANGED
|
@@ -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
|
|
package/src/commands/push.ts
CHANGED
|
@@ -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.
|
|
27
|
+
chalk.gray(` ${idx + 1}. ${comp.title} (${comp.id}) - ${sizeKB} KB`)
|
|
28
28
|
);
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -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.
|
|
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
|
|
113
|
-
if (new Set(
|
|
114
|
-
throw new Error("All component
|
|
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
|
-
|
|
138
|
+
id: comp.id,
|
|
139
139
|
build: buildBuffer,
|
|
140
140
|
});
|
|
141
141
|
}
|