handoff-app 0.9.2 → 0.10.0
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/Changelog.md +42 -0
- package/config/docs/components/button.design.json +24 -0
- package/config/exportables/components/button.json +4 -2
- package/config/exportables/components/checkbox.json +6 -0
- package/config/exportables/components/input.json +6 -0
- package/config/exportables/components/radio.json +6 -0
- package/config/exportables/components/select.json +6 -0
- package/config/exportables/components/switch.json +6 -0
- package/dist/api.d.ts +1 -1
- package/dist/app.js +39 -10
- package/dist/cli.js +19 -19
- package/dist/config.d.ts +2 -17
- package/dist/config.js +13 -57
- package/dist/documentation-object.d.ts +2 -2
- package/dist/documentation-object.js +13 -15
- package/dist/exporters/components/extractor.d.ts +6 -13
- package/dist/exporters/components/extractor.js +87 -140
- package/dist/exporters/components/index.d.ts +3 -14
- package/dist/exporters/components/index.js +280 -62
- package/dist/exporters/components/types.d.ts +21 -1
- package/dist/exporters/design.d.ts +1 -2
- package/dist/exporters/design.js +3 -2
- package/dist/exporters/utils.d.ts +3 -5
- package/dist/exporters/utils.js +27 -15
- package/dist/figma/api.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -2
- package/dist/pipeline.js +110 -129
- package/dist/transformers/css/component.d.ts +4 -4
- package/dist/transformers/css/component.js +9 -6
- package/dist/transformers/css/index.d.ts +2 -2
- package/dist/transformers/css/index.js +2 -2
- package/dist/transformers/map/component.d.ts +2 -3
- package/dist/transformers/map/component.js +4 -3
- package/dist/transformers/map/index.d.ts +2 -2
- package/dist/transformers/map/index.js +2 -2
- package/dist/transformers/preview/index.d.ts +1 -2
- package/dist/transformers/preview/index.js +10 -6
- package/dist/transformers/scss/component.d.ts +4 -4
- package/dist/transformers/scss/component.js +12 -9
- package/dist/transformers/scss/index.d.ts +3 -3
- package/dist/transformers/scss/index.js +15 -8
- package/dist/transformers/sd/component.d.ts +2 -3
- package/dist/transformers/sd/component.js +4 -3
- package/dist/transformers/sd/index.d.ts +2 -2
- package/dist/transformers/sd/index.js +2 -2
- package/dist/transformers/transformer.d.ts +3 -3
- package/dist/transformers/types.d.ts +0 -2
- package/dist/transformers/utils.d.ts +8 -8
- package/dist/transformers/utils.js +25 -9
- package/dist/types/plugin.d.ts +26 -0
- package/dist/types/plugin.js +2 -0
- package/dist/types.d.ts +91 -55
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/src/api.ts +1 -1
- package/src/app/components/ComponentDesignTokens.tsx +28 -26
- package/src/app/components/Footer.tsx +2 -2
- package/src/app/components/Header.tsx +2 -3
- package/src/app/components/util/index.ts +68 -74
- package/src/app/next.config.js +4 -0
- package/src/app/pages/[level1]/[level2]/index.tsx +2 -2
- package/src/app/pages/[level1]/index.tsx +2 -2
- package/src/app/pages/_document.tsx +2 -2
- package/src/app/pages/assets/fonts.tsx +3 -4
- package/src/app/pages/assets/icons/[name]/index.tsx +2 -2
- package/src/app/pages/assets/icons/index.tsx +2 -2
- package/src/app/pages/assets/index.tsx +2 -2
- package/src/app/pages/assets/logos.tsx +2 -2
- package/src/app/pages/changelog.tsx +2 -2
- package/src/app/pages/components/[component]/index.tsx +190 -110
- package/src/app/pages/components/index.tsx +9 -6
- package/src/app/pages/foundations/colors.tsx +2 -2
- package/src/app/pages/foundations/effects.tsx +2 -2
- package/src/app/pages/foundations/index.tsx +2 -2
- package/src/app/pages/foundations/logo.tsx +2 -2
- package/src/app/pages/foundations/typography.tsx +2 -2
- package/src/app/pages/index.tsx +2 -2
- package/src/app/tsconfig.json +1 -0
- package/src/app.ts +19 -0
- package/src/cli.ts +1 -1
- package/src/config.ts +12 -54
- package/src/documentation-object.ts +14 -15
- package/src/exporters/components/extractor.ts +143 -211
- package/src/exporters/components/index.ts +308 -64
- package/src/exporters/components/types.ts +21 -2
- package/src/exporters/design.ts +2 -4
- package/src/exporters/utils.ts +34 -19
- package/src/figma/api.ts +1 -1
- package/src/index.ts +0 -8
- package/src/pipeline.ts +75 -90
- package/src/transformers/css/component.ts +17 -10
- package/src/transformers/css/index.ts +3 -3
- package/src/transformers/map/component.ts +8 -8
- package/src/transformers/map/index.ts +3 -3
- package/src/transformers/preview/index.ts +27 -17
- package/src/transformers/scss/component.ts +20 -16
- package/src/transformers/scss/index.ts +16 -9
- package/src/transformers/sd/component.ts +5 -5
- package/src/transformers/sd/index.ts +3 -3
- package/src/transformers/transformer.ts +4 -4
- package/src/transformers/types.ts +0 -3
- package/src/transformers/utils.ts +41 -17
- package/src/types/config.d.ts +6 -3
- package/src/types/plugin.ts +29 -0
- package/src/types.ts +87 -55
- package/src/utils/index.ts +1 -1
package/Changelog.md
CHANGED
|
@@ -6,6 +6,48 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.10.0] - 2024-01-16
|
|
10
|
+
|
|
11
|
+
### Improvements
|
|
12
|
+
|
|
13
|
+
* Docs App:
|
|
14
|
+
* Updated docs app to present components without associated content and assets more elegantly.
|
|
15
|
+
* Improved the component pages by showing only the "Tokens" tab when no previews are detected; the "Overview" tab is hidden in such cases.
|
|
16
|
+
* Configuration Handling:
|
|
17
|
+
* Eliminated the need for `handoff.state.json` file.
|
|
18
|
+
* All required parameters are now passed to the docs app through environment variables (`process.env`), defined in the project's respective `next.config.js` file.
|
|
19
|
+
* Replaced `getConfig` with the more secure `getClientConfig` function.
|
|
20
|
+
* New function returns only configurations that can be safely exposed on the client side.
|
|
21
|
+
|
|
22
|
+
### Changes
|
|
23
|
+
|
|
24
|
+
* Handoff Figma Plugin Support:
|
|
25
|
+
* Introduced initial support for the Handoff Figma Plugin.
|
|
26
|
+
* Currently an opt-in feature as development is ongoing.
|
|
27
|
+
* Can be enabled by setting `USE_HANDOFF_PLUGIN="TRUE"` in your `.env` file.
|
|
28
|
+
* This functionality allows Handoff to extract metadata directly from the Figma file. Local JSON definitions are completely ignored in this case.
|
|
29
|
+
* Will become the default behavior in the 1.0.0 release!
|
|
30
|
+
* Deprecation Notice:
|
|
31
|
+
* Deprecated local exportable component JSON definitions.
|
|
32
|
+
* Still usable, but will be completely removed and ignored before the 1.0.0 release.
|
|
33
|
+
* Components, parts, and related definitions should be defined with the Handoff Figma Plugin prior to the 1.0.0 release.
|
|
34
|
+
|
|
35
|
+
## [0.9.3] - 2023-11-23
|
|
36
|
+
|
|
37
|
+
### Improvements
|
|
38
|
+
|
|
39
|
+
* It's now possible to declare conditions for exportable component parts. Condition dictates should the part be built based on provided condition (e.g. does a specific variant property have a certain value etc.).
|
|
40
|
+
* Handoff will now process all component sets found within the frame in which the component set that matches the search is found. Previously it was limited to process only one (first) extra component set while others were ignored.
|
|
41
|
+
|
|
42
|
+
### Changes
|
|
43
|
+
|
|
44
|
+
* Component preview title will no longer default to the value of the first variant property if no distinctive value is found. Empty value is now used instead.
|
|
45
|
+
|
|
46
|
+
### Bugfixes
|
|
47
|
+
|
|
48
|
+
* Update of the app source will now update the watched app without having to restart the watch process (issue introduced in version 0.9.0).
|
|
49
|
+
|
|
50
|
+
|
|
9
51
|
## [0.9.2] - 2023-11-21
|
|
10
52
|
|
|
11
53
|
### Improvements
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"views": {
|
|
3
|
+
"overview": {
|
|
4
|
+
"condition": {
|
|
5
|
+
"State": ["default"],
|
|
6
|
+
"Theme": ["light"]
|
|
7
|
+
},
|
|
8
|
+
"sort": ["Type", "Size"]
|
|
9
|
+
},
|
|
10
|
+
"tokens": {
|
|
11
|
+
"condition": {
|
|
12
|
+
"State": {
|
|
13
|
+
"default": {
|
|
14
|
+
"State": ["default", "hover", "disabled"],
|
|
15
|
+
"Theme": ["light"]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"Theme": ["light"],
|
|
19
|
+
"Size": [""]
|
|
20
|
+
},
|
|
21
|
+
"sort": ["Type", "Size"]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/dist/api.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { zipAssets } from './exporters/assets';
|
|
|
2
2
|
export { default as generateChangelogRecord } from './changelog';
|
|
3
3
|
export { createDocumentationObject } from './documentation-object';
|
|
4
4
|
export type { AssetObject, ColorGroup, ColorObject, DocumentationObject, RGBObject, TypographyObject } from './types';
|
|
5
|
-
export type {
|
|
5
|
+
export type { FileComponentsObject as ComponentObject } from './exporters/components/types';
|
|
6
6
|
export type { ChangelogRecord } from './changelog';
|
package/dist/app.js
CHANGED
|
@@ -92,10 +92,10 @@ var mergePublicDir = function (handoff) { return __awaiter(void 0, void 0, void
|
|
|
92
92
|
});
|
|
93
93
|
}); };
|
|
94
94
|
var prepareProjectApp = function (handoff) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
-
var srcPath, appPath, handoffAppBasePath, handoffWorkingPath, handoffExportPath, nextConfigPath, nextConfigContent;
|
|
96
|
-
var _a;
|
|
97
|
-
return __generator(this, function (
|
|
98
|
-
switch (
|
|
95
|
+
var srcPath, appPath, handoffProjectId, handoffAppBasePath, handoffWorkingPath, handoffModulePath, handoffExportPath, nextConfigPath, nextConfigContent;
|
|
96
|
+
var _a, _b;
|
|
97
|
+
return __generator(this, function (_c) {
|
|
98
|
+
switch (_c.label) {
|
|
99
99
|
case 0:
|
|
100
100
|
srcPath = path_1.default.resolve(handoff.modulePath, 'src', 'app');
|
|
101
101
|
appPath = getAppPath(handoff);
|
|
@@ -103,27 +103,31 @@ var prepareProjectApp = function (handoff) { return __awaiter(void 0, void 0, vo
|
|
|
103
103
|
return [4 /*yield*/, fs_extra_1.default.promises.mkdir(appPath, { recursive: true })];
|
|
104
104
|
case 1:
|
|
105
105
|
// Prepare project app dir
|
|
106
|
-
|
|
106
|
+
_c.sent();
|
|
107
107
|
return [4 /*yield*/, fs_extra_1.default.copy(srcPath, appPath, { overwrite: true })];
|
|
108
108
|
case 2:
|
|
109
|
-
|
|
109
|
+
_c.sent();
|
|
110
110
|
return [4 /*yield*/, mergePublicDir(handoff)];
|
|
111
111
|
case 3:
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
_c.sent();
|
|
113
|
+
handoffProjectId = (_a = handoff.config.figma_project_id) !== null && _a !== void 0 ? _a : '';
|
|
114
|
+
handoffAppBasePath = (_b = handoff.config.app.base_path) !== null && _b !== void 0 ? _b : '';
|
|
114
115
|
handoffWorkingPath = path_1.default.resolve(handoff.workingPath);
|
|
116
|
+
handoffModulePath = path_1.default.resolve(handoff.modulePath);
|
|
115
117
|
handoffExportPath = path_1.default.resolve(handoff.workingPath, handoff.outputDirectory, handoff.config.figma_project_id);
|
|
116
118
|
nextConfigPath = path_1.default.resolve(appPath, 'next.config.js');
|
|
117
119
|
return [4 /*yield*/, fs_extra_1.default.readFile(nextConfigPath, 'utf-8')];
|
|
118
120
|
case 4:
|
|
119
|
-
nextConfigContent = (
|
|
121
|
+
nextConfigContent = (_c.sent())
|
|
120
122
|
.replace(/basePath:\s+\'\'/g, "basePath: '".concat(handoffAppBasePath, "'"))
|
|
123
|
+
.replace(/HANDOFF_PROJECT_ID:\s+\'\'/g, "HANDOFF_PROJECT_ID: '".concat(handoffProjectId, "'"))
|
|
121
124
|
.replace(/HANDOFF_APP_BASE_PATH:\s+\'\'/g, "HANDOFF_APP_BASE_PATH: '".concat(handoffAppBasePath, "'"))
|
|
122
125
|
.replace(/HANDOFF_WORKING_PATH:\s+\'\'/g, "HANDOFF_WORKING_PATH: '".concat(handoffWorkingPath, "'"))
|
|
126
|
+
.replace(/HANDOFF_MODULE_PATH:\s+\'\'/g, "HANDOFF_MODULE_PATH: '".concat(handoffModulePath, "'"))
|
|
123
127
|
.replace(/HANDOFF_EXPORT_PATH:\s+\'\'/g, "HANDOFF_EXPORT_PATH: '".concat(handoffExportPath, "'"));
|
|
124
128
|
return [4 /*yield*/, fs_extra_1.default.writeFile(nextConfigPath, nextConfigContent)];
|
|
125
129
|
case 5:
|
|
126
|
-
|
|
130
|
+
_c.sent();
|
|
127
131
|
return [2 /*return*/, appPath];
|
|
128
132
|
}
|
|
129
133
|
});
|
|
@@ -179,6 +183,31 @@ var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
179
183
|
case 1:
|
|
180
184
|
appPath = _a.sent();
|
|
181
185
|
config = require(path_1.default.resolve(appPath, 'next.config.js'));
|
|
186
|
+
// Include any changes made within the app source during watch
|
|
187
|
+
chokidar_1.default.watch(path_1.default.resolve(handoff.modulePath, 'src', 'app'), {
|
|
188
|
+
ignored: /(^|[\/\\])\../,
|
|
189
|
+
persistent: true,
|
|
190
|
+
ignoreInitial: true,
|
|
191
|
+
}).on('all', function (event, path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
192
|
+
var _a;
|
|
193
|
+
return __generator(this, function (_b) {
|
|
194
|
+
switch (_b.label) {
|
|
195
|
+
case 0:
|
|
196
|
+
_a = event;
|
|
197
|
+
switch (_a) {
|
|
198
|
+
case 'add': return [3 /*break*/, 1];
|
|
199
|
+
case 'change': return [3 /*break*/, 1];
|
|
200
|
+
case 'unlink': return [3 /*break*/, 1];
|
|
201
|
+
}
|
|
202
|
+
return [3 /*break*/, 3];
|
|
203
|
+
case 1: return [4 /*yield*/, prepareProjectApp(handoff)];
|
|
204
|
+
case 2:
|
|
205
|
+
_b.sent();
|
|
206
|
+
return [3 /*break*/, 3];
|
|
207
|
+
case 3: return [2 /*return*/];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}); });
|
|
182
211
|
tsconfigPath = 'tsconfig.json';
|
|
183
212
|
config.typescript = __assign(__assign({}, config.typescript), { tsconfigPath: tsconfigPath });
|
|
184
213
|
dev = true;
|
package/dist/cli.js
CHANGED
|
@@ -80,7 +80,7 @@ var showHelp = function () {
|
|
|
80
80
|
* Show the help message
|
|
81
81
|
*/
|
|
82
82
|
var showVersion = function () {
|
|
83
|
-
cliError('Handoff App - 0.
|
|
83
|
+
cliError('Handoff App - 0.10.0', 2);
|
|
84
84
|
};
|
|
85
85
|
/**
|
|
86
86
|
* Define a CLI error
|
|
@@ -96,7 +96,7 @@ var cliError = function (msg, exitCode) {
|
|
|
96
96
|
};
|
|
97
97
|
var watching = false;
|
|
98
98
|
var run = function (argv, stdout, stderr) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
-
var args,
|
|
99
|
+
var args, handoff, _a, type, name_1, templateComponent, templateState, pageName, pageParent, e_1;
|
|
100
100
|
return __generator(this, function (_b) {
|
|
101
101
|
switch (_b.label) {
|
|
102
102
|
case 0:
|
|
@@ -122,12 +122,12 @@ var run = function (argv, stdout, stderr) { return __awaiter(void 0, void 0, voi
|
|
|
122
122
|
if (args['--version']) {
|
|
123
123
|
return [2 /*return*/, showVersion()];
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
handoff = new _1.default();
|
|
126
126
|
if (args['--debug']) {
|
|
127
|
-
|
|
127
|
+
handoff.debug = true;
|
|
128
128
|
}
|
|
129
129
|
if (args['--force']) {
|
|
130
|
-
|
|
130
|
+
handoff.force = true;
|
|
131
131
|
}
|
|
132
132
|
_a = args._[0];
|
|
133
133
|
switch (_a) {
|
|
@@ -148,26 +148,26 @@ var run = function (argv, stdout, stderr) { return __awaiter(void 0, void 0, voi
|
|
|
148
148
|
case 'make:page': return [3 /*break*/, 16];
|
|
149
149
|
}
|
|
150
150
|
return [3 /*break*/, 17];
|
|
151
|
-
case 1: return [2 /*return*/,
|
|
152
|
-
case 2: return [4 /*yield*/,
|
|
151
|
+
case 1: return [2 /*return*/, handoff.fetch()];
|
|
152
|
+
case 2: return [4 /*yield*/, handoff.build()];
|
|
153
153
|
case 3:
|
|
154
154
|
_b.sent();
|
|
155
|
-
return [2 /*return*/,
|
|
155
|
+
return [2 /*return*/, handoff];
|
|
156
156
|
case 4:
|
|
157
157
|
watching = true;
|
|
158
|
-
return [2 /*return*/,
|
|
158
|
+
return [2 /*return*/, handoff.start()];
|
|
159
159
|
case 5:
|
|
160
160
|
watching = true;
|
|
161
|
-
return [2 /*return*/,
|
|
162
|
-
case 6: return [2 /*return*/,
|
|
161
|
+
return [2 /*return*/, handoff.dev()];
|
|
162
|
+
case 6: return [2 /*return*/, handoff.integration()];
|
|
163
163
|
case 7:
|
|
164
164
|
cliError("Eject commands will eject the default configuration into the working directory so you can customize it.\n\nEject must have a subcommand. Did you mean:\n - eject:config\n - eject:exportables\n - eject:integration\n - eject:docs\n - eject:theme.", 2);
|
|
165
165
|
return [3 /*break*/, 18];
|
|
166
|
-
case 8: return [2 /*return*/,
|
|
167
|
-
case 9: return [2 /*return*/,
|
|
168
|
-
case 10: return [2 /*return*/,
|
|
169
|
-
case 11: return [2 /*return*/,
|
|
170
|
-
case 12: return [2 /*return*/,
|
|
166
|
+
case 8: return [2 /*return*/, handoff.ejectConfig()];
|
|
167
|
+
case 9: return [2 /*return*/, handoff.ejectIntegration()];
|
|
168
|
+
case 10: return [2 /*return*/, handoff.ejectExportables()];
|
|
169
|
+
case 11: return [2 /*return*/, handoff.ejectTheme()];
|
|
170
|
+
case 12: return [2 /*return*/, handoff.ejectPages()];
|
|
171
171
|
case 13:
|
|
172
172
|
cliError("Make commands create configuration files in your working root and scaffold up the appropriate folder structure if needed.\n\n Make must have a subcommand. Did you mean:\n - make:template\n - make:exportable\n - make:page", 2);
|
|
173
173
|
return [3 /*break*/, 18];
|
|
@@ -183,7 +183,7 @@ var run = function (argv, stdout, stderr) { return __awaiter(void 0, void 0, voi
|
|
|
183
183
|
if (!/^[a-z0-9]+$/i.test(name_1)) {
|
|
184
184
|
cliError("Exportable name must be alphanumeric and may contain dashes or underscores", 2);
|
|
185
185
|
}
|
|
186
|
-
return [2 /*return*/,
|
|
186
|
+
return [2 /*return*/, handoff.makeExportable(type, name_1)];
|
|
187
187
|
case 15:
|
|
188
188
|
templateComponent = args._[1];
|
|
189
189
|
if (!templateComponent) {
|
|
@@ -196,7 +196,7 @@ var run = function (argv, stdout, stderr) { return __awaiter(void 0, void 0, voi
|
|
|
196
196
|
if (templateState && !/^[a-z0-9]+$/i.test(templateComponent)) {
|
|
197
197
|
cliError("Template state must be alphanumeric and may contain dashes or underscores", 2);
|
|
198
198
|
}
|
|
199
|
-
return [2 /*return*/,
|
|
199
|
+
return [2 /*return*/, handoff.makeTemplate(templateComponent, templateState)];
|
|
200
200
|
case 16:
|
|
201
201
|
pageName = args._[1];
|
|
202
202
|
if (!pageName) {
|
|
@@ -209,7 +209,7 @@ var run = function (argv, stdout, stderr) { return __awaiter(void 0, void 0, voi
|
|
|
209
209
|
if (pageParent && !/^[a-z0-9]+$/i.test(pageParent)) {
|
|
210
210
|
cliError("Page parent must be alphanumeric and may contain dashes or underscores", 2);
|
|
211
211
|
}
|
|
212
|
-
return [2 /*return*/,
|
|
212
|
+
return [2 /*return*/, handoff.makePage(pageName, pageParent)];
|
|
213
213
|
case 17: return [2 /*return*/, showHelp()];
|
|
214
214
|
case 18: return [3 /*break*/, 20];
|
|
215
215
|
case 19:
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Handoff from '.';
|
|
2
1
|
import { Config } from './types/config';
|
|
3
2
|
export interface ImageStyle {
|
|
4
3
|
name: string;
|
|
@@ -9,21 +8,7 @@ export interface ImageStyle {
|
|
|
9
8
|
}
|
|
10
9
|
export declare const defaultConfig: () => Config;
|
|
11
10
|
/**
|
|
12
|
-
* Get the
|
|
11
|
+
* Get the configuration formatted for the client, either from the root of the project or from the default config.
|
|
13
12
|
* @returns Promise<Config>
|
|
14
13
|
*/
|
|
15
|
-
export declare const
|
|
16
|
-
/**
|
|
17
|
-
* Get the handoff from the global scope
|
|
18
|
-
* @returns Handoff
|
|
19
|
-
*/
|
|
20
|
-
export declare const getHandoff: () => Handoff;
|
|
21
|
-
/**
|
|
22
|
-
* Serialize the handoff to the working directory
|
|
23
|
-
*/
|
|
24
|
-
export declare const serializeHandoff: (handoff: Handoff) => void;
|
|
25
|
-
/**
|
|
26
|
-
* Deserialize the handoff from the working directory
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export declare const deserializeHandoff: () => any;
|
|
14
|
+
export declare const getClientConfig: (configOverride?: any) => any;
|
package/dist/config.js
CHANGED
|
@@ -14,11 +14,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.getClientConfig = exports.defaultConfig = void 0;
|
|
18
18
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
19
19
|
var path_1 = __importDefault(require("path"));
|
|
20
20
|
var defaultConfig = function () {
|
|
21
|
-
var _a, _b;
|
|
21
|
+
var _a, _b, _c;
|
|
22
22
|
return ({
|
|
23
23
|
dev_access_token: (_a = process.env.DEV_ACCESS_TOKEN) !== null && _a !== void 0 ? _a : null,
|
|
24
24
|
figma_project_id: (_b = process.env.FIGMA_PROJECT_ID) !== null && _b !== void 0 ? _b : null,
|
|
@@ -75,17 +75,15 @@ var defaultConfig = function () {
|
|
|
75
75
|
'components/switch',
|
|
76
76
|
],
|
|
77
77
|
},
|
|
78
|
+
use_legacy_definitions: ((_c = process.env.USE_HANDOFF_PLUGIN) !== null && _c !== void 0 ? _c : "").toLowerCase() !== "true"
|
|
78
79
|
});
|
|
79
80
|
};
|
|
80
81
|
exports.defaultConfig = defaultConfig;
|
|
81
82
|
/**
|
|
82
|
-
* Get the
|
|
83
|
+
* Get the configuration formatted for the client, either from the root of the project or from the default config.
|
|
83
84
|
* @returns Promise<Config>
|
|
84
85
|
*/
|
|
85
|
-
var
|
|
86
|
-
// if (global.handoff && global.handoff.config) {
|
|
87
|
-
// return global.handoff.config;
|
|
88
|
-
// }
|
|
86
|
+
var getClientConfig = function (configOverride) {
|
|
89
87
|
// Check to see if there is a config in the root of the project
|
|
90
88
|
var config = {};
|
|
91
89
|
var configPath = path_1.default.resolve(process.cwd(), 'handoff.config.json');
|
|
@@ -96,54 +94,12 @@ var getConfig = function (configOverride) {
|
|
|
96
94
|
if (configOverride) {
|
|
97
95
|
config = __assign(__assign({}, config), configOverride);
|
|
98
96
|
}
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Get the handoff from the global scope
|
|
108
|
-
* @returns Handoff
|
|
109
|
-
*/
|
|
110
|
-
var getHandoff = function () {
|
|
111
|
-
// if (global.handoff) {
|
|
112
|
-
// return global.handoff;
|
|
113
|
-
// }
|
|
114
|
-
// check for a serialized version
|
|
115
|
-
var handoff = (0, exports.deserializeHandoff)();
|
|
116
|
-
if (handoff) {
|
|
117
|
-
// global.handoff = handoff;
|
|
118
|
-
return handoff;
|
|
119
|
-
}
|
|
120
|
-
throw Error('Handoff not initialized');
|
|
121
|
-
};
|
|
122
|
-
exports.getHandoff = getHandoff;
|
|
123
|
-
/**
|
|
124
|
-
* Serialize the handoff to the working directory
|
|
125
|
-
*/
|
|
126
|
-
var serializeHandoff = function (handoff) {
|
|
127
|
-
var outputPath = path_1.default.resolve(handoff.workingPath, handoff.outputDirectory, handoff.config.figma_project_id);
|
|
128
|
-
if (!fs_extra_1.default.existsSync(outputPath)) {
|
|
129
|
-
fs_extra_1.default.mkdirSync(path_1.default.resolve(outputPath), { recursive: true });
|
|
130
|
-
}
|
|
131
|
-
var statePath = path_1.default.resolve(outputPath, 'handoff.state.json');
|
|
132
|
-
fs_extra_1.default.writeFileSync(statePath, JSON.stringify(handoff));
|
|
133
|
-
};
|
|
134
|
-
exports.serializeHandoff = serializeHandoff;
|
|
135
|
-
/**
|
|
136
|
-
* Deserialize the handoff from the working directory
|
|
137
|
-
* @returns
|
|
138
|
-
*/
|
|
139
|
-
var deserializeHandoff = function () {
|
|
140
|
-
var _a;
|
|
141
|
-
var statePath = process.env.HANDOFF_EXPORT_PATH ? path_1.default.resolve(process.env.HANDOFF_EXPORT_PATH, 'handoff.state.json') : path_1.default.resolve(process.cwd(), (_a = process.env.OUTPUT_DIR) !== null && _a !== void 0 ? _a : 'exported', 'handoff.state.json');
|
|
142
|
-
if (fs_extra_1.default.existsSync(statePath)) {
|
|
143
|
-
var stateBuffer = fs_extra_1.default.readFileSync(statePath);
|
|
144
|
-
var state = JSON.parse(stateBuffer.toString());
|
|
145
|
-
return state;
|
|
146
|
-
}
|
|
147
|
-
throw Error('Handoff cannot be deserialized');
|
|
97
|
+
var _a = __assign(__assign({}, (0, exports.defaultConfig)()), config), app = _a.app, figma = _a.figma, assets_zip_links = _a.assets_zip_links, use_legacy_definitions = _a.use_legacy_definitions;
|
|
98
|
+
return {
|
|
99
|
+
app: app,
|
|
100
|
+
figma: figma,
|
|
101
|
+
assets_zip_links: assets_zip_links !== null && assets_zip_links !== void 0 ? assets_zip_links : { icons: null, logos: null },
|
|
102
|
+
use_legacy_definitions: use_legacy_definitions
|
|
103
|
+
};
|
|
148
104
|
};
|
|
149
|
-
exports.
|
|
105
|
+
exports.getClientConfig = getClientConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DocumentationObject,
|
|
2
|
-
export declare const createDocumentationObject: (figmaFileKey: string, figmaAccessToken: string,
|
|
1
|
+
import { DocumentationObject, LegacyComponentDefinition } from './types';
|
|
2
|
+
export declare const createDocumentationObject: (figmaFileKey: string, figmaAccessToken: string, legacyDefinitions?: LegacyComponentDefinition[]) => Promise<DocumentationObject>;
|
|
@@ -41,29 +41,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.createDocumentationObject = void 0;
|
|
43
43
|
var assets_1 = __importDefault(require("./exporters/assets"));
|
|
44
|
-
var index_1 =
|
|
45
|
-
var design_1 =
|
|
44
|
+
var index_1 = require("./exporters/components/index");
|
|
45
|
+
var design_1 = require("./exporters/design");
|
|
46
46
|
var startCase_1 = __importDefault(require("lodash/startCase"));
|
|
47
47
|
var chalk_1 = __importDefault(require("chalk"));
|
|
48
|
-
var createDocumentationObject = function (figmaFileKey, figmaAccessToken,
|
|
48
|
+
var createDocumentationObject = function (figmaFileKey, figmaAccessToken, legacyDefinitions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
49
|
var components, design, icons, logos;
|
|
50
50
|
return __generator(this, function (_a) {
|
|
51
51
|
switch (_a.label) {
|
|
52
|
-
case 0: return [4 /*yield*/, (0, index_1.
|
|
52
|
+
case 0: return [4 /*yield*/, (0, index_1.getFigmaFileComponents)(figmaFileKey, figmaAccessToken, legacyDefinitions)];
|
|
53
53
|
case 1:
|
|
54
54
|
components = _a.sent();
|
|
55
55
|
// Log out components
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
return [4 /*yield*/, (0, design_1.default)(figmaFileKey, figmaAccessToken)];
|
|
56
|
+
Object.keys(components).map(function (component) {
|
|
57
|
+
if (components[component].instances.length === 0) {
|
|
58
|
+
console.error(chalk_1.default.grey("Skipping \"".concat((0, startCase_1.default)(component), "\". Reason: No matching component instances were found.")));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.log(chalk_1.default.green("".concat((0, startCase_1.default)(component), " exported:")), components[component].instances.length);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return [4 /*yield*/, (0, design_1.getFigmaFileDesignTokens)(figmaFileKey, figmaAccessToken)];
|
|
67
65
|
case 2:
|
|
68
66
|
design = _a.sent();
|
|
69
67
|
return [4 /*yield*/, (0, assets_1.default)(figmaFileKey, figmaAccessToken, 'Icons')];
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import * as ExportTypes from './types';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type: 'design' | 'layout';
|
|
9
|
-
variantProperties: [string, string][];
|
|
10
|
-
parts?: {
|
|
11
|
-
[key: string]: ExportTypes.TokenSets;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export default function extractComponents(componentSetComponentsResult: GetComponentSetComponentsResult, definition: ExportableDefinition): Component[];
|
|
2
|
+
import * as FigmaTypes from '../../figma/types';
|
|
3
|
+
import { ComponentDefinition, LegacyComponentDefinition } from '../../types';
|
|
4
|
+
export default function extractComponentInstances(components: {
|
|
5
|
+
node: FigmaTypes.Component;
|
|
6
|
+
metadata: FigmaTypes.ComponentMetadata;
|
|
7
|
+
}[], definition: ComponentDefinition, legacyDefinition?: LegacyComponentDefinition): ExportTypes.ComponentInstance[];
|