@futurebrand/dev-tools 2.4.0 → 2.4.2
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,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const files_1 = require("../../../../utils/files");
|
|
3
5
|
const inquirer_1 = require("inquirer");
|
|
6
|
+
const generator_1 = require("../generator");
|
|
4
7
|
const api_1 = require("./api");
|
|
5
|
-
// Limit of same variant of the same block
|
|
6
8
|
class FigmaModule {
|
|
7
9
|
state;
|
|
8
10
|
api;
|
|
@@ -20,21 +22,30 @@ class FigmaModule {
|
|
|
20
22
|
data.variants.push(variant);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
getDefaultCheckedBlocks(blocks
|
|
24
|
-
|
|
25
|
+
async getDefaultCheckedBlocks(blocks) {
|
|
26
|
+
const data = this.state.getData();
|
|
25
27
|
const defaultBlocks = [];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// )
|
|
29
|
-
// const nextProject = data.projects.find(
|
|
30
|
-
// (project) => project.type === 'next.js'
|
|
31
|
-
// )
|
|
28
|
+
const currentBlocks = data.blocks;
|
|
29
|
+
const nextProject = data.projects.find((project) => project.type === 'next.js');
|
|
32
30
|
for (const block of blocks) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const inCurrentBlocks = currentBlocks.find((b) => b.name === block.name);
|
|
32
|
+
if (inCurrentBlocks) {
|
|
33
|
+
block.hidden = inCurrentBlocks.hidden;
|
|
34
|
+
block.generated = inCurrentBlocks.generated;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const tempFolder = await (0, files_1.getTempFilePath)(generator_1.GENERATOR_FOLDER_NAME, block.name);
|
|
38
|
+
if (await (0, files_1.verifyPath)(tempFolder)) {
|
|
39
|
+
block.generated = true;
|
|
40
|
+
}
|
|
41
|
+
if (nextProject) {
|
|
42
|
+
const blockFolder = path.join(nextProject.path, 'layouts', 'blocks', block.name);
|
|
43
|
+
if (await (0, files_1.verifyPath)(blockFolder)) {
|
|
44
|
+
block.hidden = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
}
|
|
37
|
-
if (!block.hidden
|
|
48
|
+
if (!block.hidden) {
|
|
38
49
|
defaultBlocks.push(block.name);
|
|
39
50
|
}
|
|
40
51
|
}
|
|
@@ -46,8 +57,7 @@ class FigmaModule {
|
|
|
46
57
|
const figmaPageID = data.configs.figma;
|
|
47
58
|
const canvas = await this.api.getBlockCanvas(figmaPageID);
|
|
48
59
|
console.log('- Loading pages blocks');
|
|
49
|
-
const blocksData =
|
|
50
|
-
const newBlocks = [];
|
|
60
|
+
const blocksData = [];
|
|
51
61
|
const [blocks, variables] = await Promise.all([
|
|
52
62
|
this.api.getBlocks(figmaPageID, canvas),
|
|
53
63
|
this.api.getVariables(figmaPageID),
|
|
@@ -61,15 +71,14 @@ class FigmaModule {
|
|
|
61
71
|
hidden: false,
|
|
62
72
|
generated: false,
|
|
63
73
|
};
|
|
64
|
-
newBlocks.push(blockName);
|
|
65
74
|
blocksData.push(block);
|
|
66
75
|
}
|
|
67
76
|
this.addVariantsToBlock(block, blocks[blockName]);
|
|
68
77
|
});
|
|
69
|
-
console.log(`- Loaded ${blocksData.length} blocks from Figma (${newBlocks.length} new)`);
|
|
70
78
|
const blockNames = blocksData.map((block) => block.name);
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
console.log(`- Loaded ${blocksData.length} blocks from Figma (${blockNames.length} new)`);
|
|
80
|
+
const defaultCheckedBlocks = await this.getDefaultCheckedBlocks(blocksData);
|
|
81
|
+
if (blockNames.length) {
|
|
73
82
|
const query = await inquirer_1.default.prompt([
|
|
74
83
|
{
|
|
75
84
|
type: 'checkbox',
|
|
@@ -40,7 +40,7 @@ class ProjectAdder {
|
|
|
40
40
|
async createNextjsFiles(filePath, block) {
|
|
41
41
|
const project = this.data.projects.find((project) => project.type === 'next.js');
|
|
42
42
|
if (!project) {
|
|
43
|
-
throw new Error('
|
|
43
|
+
throw new Error('Nextjs project not found');
|
|
44
44
|
// return
|
|
45
45
|
}
|
|
46
46
|
const blockFolder = path.join(project.path, 'layouts', 'blocks', block.name);
|