handoff-app 0.9.3 → 0.11.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.
Files changed (126) hide show
  1. package/Changelog.md +41 -0
  2. package/config/docs/components/button.design.json +24 -0
  3. package/config/exportables/components/button.json +4 -2
  4. package/config/exportables/components/checkbox.json +6 -0
  5. package/config/exportables/components/input.json +6 -0
  6. package/config/exportables/components/radio.json +6 -0
  7. package/config/exportables/components/select.json +6 -0
  8. package/config/exportables/components/switch.json +6 -0
  9. package/dist/api.d.ts +1 -1
  10. package/dist/app.js +22 -17
  11. package/dist/cli/eject.js +10 -13
  12. package/dist/cli.js +19 -19
  13. package/dist/config.d.ts +2 -17
  14. package/dist/config.js +17 -57
  15. package/dist/documentation-object.d.ts +2 -2
  16. package/dist/documentation-object.js +13 -15
  17. package/dist/exporters/components/extractor.d.ts +6 -13
  18. package/dist/exporters/components/extractor.js +87 -171
  19. package/dist/exporters/components/index.d.ts +3 -14
  20. package/dist/exporters/components/index.js +285 -71
  21. package/dist/exporters/components/types.d.ts +21 -1
  22. package/dist/exporters/design.d.ts +1 -2
  23. package/dist/exporters/design.js +3 -2
  24. package/dist/exporters/utils.d.ts +7 -10
  25. package/dist/exporters/utils.js +27 -15
  26. package/dist/figma/api.js +1 -1
  27. package/dist/index.d.ts +2 -4
  28. package/dist/index.js +5 -5
  29. package/dist/pipeline.js +115 -134
  30. package/dist/transformers/css/component.d.ts +4 -4
  31. package/dist/transformers/css/component.js +9 -6
  32. package/dist/transformers/css/index.d.ts +2 -2
  33. package/dist/transformers/css/index.js +2 -2
  34. package/dist/transformers/font/index.d.ts +0 -1
  35. package/dist/transformers/font/index.js +1 -1
  36. package/dist/transformers/integration/index.d.ts +0 -1
  37. package/dist/transformers/integration/index.js +3 -3
  38. package/dist/transformers/map/component.d.ts +2 -3
  39. package/dist/transformers/map/component.js +4 -3
  40. package/dist/transformers/map/index.d.ts +2 -2
  41. package/dist/transformers/map/index.js +2 -2
  42. package/dist/transformers/preview/index.d.ts +1 -2
  43. package/dist/transformers/preview/index.js +10 -6
  44. package/dist/transformers/scss/component.d.ts +4 -4
  45. package/dist/transformers/scss/component.js +12 -9
  46. package/dist/transformers/scss/index.d.ts +3 -3
  47. package/dist/transformers/scss/index.js +15 -8
  48. package/dist/transformers/sd/component.d.ts +2 -3
  49. package/dist/transformers/sd/component.js +4 -3
  50. package/dist/transformers/sd/index.d.ts +2 -2
  51. package/dist/transformers/sd/index.js +2 -2
  52. package/dist/transformers/transformer.d.ts +3 -3
  53. package/dist/transformers/types.d.ts +0 -2
  54. package/dist/transformers/utils.d.ts +8 -8
  55. package/dist/transformers/utils.js +25 -9
  56. package/dist/types/plugin.d.ts +26 -0
  57. package/dist/types/plugin.js +2 -0
  58. package/dist/types.d.ts +90 -55
  59. package/dist/utils/convertColor.d.ts +1 -2
  60. package/dist/utils/convertColor.js +3 -2
  61. package/dist/utils/index.js +1 -1
  62. package/dist/utils/preview.js +2 -2
  63. package/package.json +1 -2
  64. package/src/api.ts +1 -1
  65. package/src/app/components/ComponentDesignTokens.tsx +30 -28
  66. package/src/app/components/CopyCode.tsx +0 -1
  67. package/src/app/components/DownloadTokens.tsx +0 -1
  68. package/src/app/components/Footer.tsx +2 -2
  69. package/src/app/components/Header.tsx +2 -3
  70. package/src/app/components/Markdown/CodeHighlight.tsx +1 -1
  71. package/src/app/components/NavLink.tsx +1 -2
  72. package/src/app/components/SideNav/Custom.tsx +1 -1
  73. package/src/app/components/util/index.ts +70 -76
  74. package/src/app/next.config.js +6 -1
  75. package/src/app/pages/[level1]/[level2]/index.tsx +6 -6
  76. package/src/app/pages/[level1]/index.tsx +6 -6
  77. package/src/app/pages/_document.tsx +2 -2
  78. package/src/app/pages/assets/fonts.tsx +10 -11
  79. package/src/app/pages/assets/icons/[name]/index.tsx +5 -5
  80. package/src/app/pages/assets/icons/index.tsx +9 -9
  81. package/src/app/pages/assets/index.tsx +7 -7
  82. package/src/app/pages/assets/logos.tsx +7 -7
  83. package/src/app/pages/changelog.tsx +6 -6
  84. package/src/app/pages/components/[component]/index.tsx +207 -110
  85. package/src/app/pages/components/index.tsx +16 -23
  86. package/src/app/pages/foundations/colors.tsx +2 -2
  87. package/src/app/pages/foundations/effects.tsx +4 -4
  88. package/src/app/pages/foundations/index.tsx +2 -2
  89. package/src/app/pages/foundations/logo.tsx +3 -3
  90. package/src/app/pages/foundations/typography.tsx +6 -6
  91. package/src/app/pages/index.tsx +12 -11
  92. package/src/app/tsconfig.json +3 -2
  93. package/src/app.ts +14 -9
  94. package/src/cli/eject.ts +2 -1
  95. package/src/cli.ts +1 -1
  96. package/src/config.ts +19 -54
  97. package/src/documentation-object.ts +14 -15
  98. package/src/exporters/components/extractor.ts +143 -251
  99. package/src/exporters/components/index.ts +314 -69
  100. package/src/exporters/components/types.ts +21 -2
  101. package/src/exporters/design.ts +2 -4
  102. package/src/exporters/utils.ts +34 -19
  103. package/src/figma/api.ts +1 -1
  104. package/src/index.ts +4 -10
  105. package/src/pipeline.ts +78 -93
  106. package/src/transformers/css/component.ts +17 -10
  107. package/src/transformers/css/index.ts +3 -3
  108. package/src/transformers/font/index.ts +1 -1
  109. package/src/transformers/integration/index.ts +3 -3
  110. package/src/transformers/map/component.ts +8 -8
  111. package/src/transformers/map/index.ts +3 -3
  112. package/src/transformers/preview/index.ts +27 -17
  113. package/src/transformers/scss/component.ts +20 -16
  114. package/src/transformers/scss/index.ts +16 -9
  115. package/src/transformers/sd/component.ts +5 -5
  116. package/src/transformers/sd/index.ts +3 -3
  117. package/src/transformers/transformer.ts +4 -4
  118. package/src/transformers/types.ts +0 -3
  119. package/src/transformers/utils.ts +41 -17
  120. package/src/types/config.d.ts +8 -3
  121. package/src/types/plugin.ts +29 -0
  122. package/src/types.ts +85 -54
  123. package/src/utils/convertColor.ts +13 -12
  124. package/src/utils/index.ts +1 -1
  125. package/src/utils/preview.ts +2 -2
  126. package/tsconfig.json +3 -0
package/Changelog.md CHANGED
@@ -6,6 +6,47 @@ 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.11.0] - 2024-05-23
10
+
11
+ ### Bugfixes
12
+
13
+ * Issue that was causing the `handoff-app start` command to malfunction has been fixed.
14
+ * The `Reference error: name is not defined` issue that occurred when a component specified in the schema was missing from the Figma file has been resolved. The `name` reference has been replaced with a correct identifier.
15
+ * Icon sizes have been corrected.
16
+
17
+ ### Changes
18
+
19
+ * **Integration with Handoff Figma Plugin**: This release now seamlessly integrates with the Handoff Figma Plugin by default.
20
+ * As a result, the local schema will not be used by default.
21
+ * If you prefer to continue using local schemas, set `USE_HANDOFF_PLUGIN="FALSE"` in your `.env` file.
22
+ * Internal module working directory has been relocated from `./src` to `./.handoff`
23
+
24
+ ## [0.10.0] - 2024-01-16
25
+
26
+ ### Improvements
27
+
28
+ * Docs App:
29
+ * Updated docs app to present components without associated content and assets more elegantly.
30
+ * Improved the component pages by showing only the "Tokens" tab when no previews are detected; the "Overview" tab is hidden in such cases.
31
+ * Configuration Handling:
32
+ * Eliminated the need for `handoff.state.json` file.
33
+ * 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.
34
+ * Replaced `getConfig` with the more secure `getClientConfig` function.
35
+ * New function returns only configurations that can be safely exposed on the client side.
36
+
37
+ ### Changes
38
+
39
+ * Handoff Figma Plugin Support:
40
+ * Introduced initial support for the Handoff Figma Plugin.
41
+ * Currently an opt-in feature as development is ongoing.
42
+ * Can be enabled by setting `USE_HANDOFF_PLUGIN="TRUE"` in your `.env` file.
43
+ * This functionality allows Handoff to extract metadata directly from the Figma file. Local JSON definitions are completely ignored in this case.
44
+ * Will become the default behavior in the 1.0.0 release!
45
+ * Deprecation Notice:
46
+ * Deprecated local exportable component JSON definitions.
47
+ * Still usable, but will be completely removed and ignored before the 1.0.0 release.
48
+ * Components, parts, and related definitions should be defined with the Handoff Figma Plugin prior to the 1.0.0 release.
49
+
9
50
  ## [0.9.3] - 2023-11-23
10
51
 
11
52
  ### 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
+ }
@@ -33,8 +33,7 @@
33
33
  "design": {
34
34
  "State": "default",
35
35
  "Theme": "light"
36
- },
37
- "layout": {}
36
+ }
38
37
  },
39
38
  "designTokens": {
40
39
  "design": {
@@ -49,6 +48,9 @@
49
48
  }
50
49
  },
51
50
  "Theme": "light"
51
+ },
52
+ "layout": {
53
+ "Size": ""
52
54
  }
53
55
  }
54
56
  }
@@ -36,6 +36,9 @@
36
36
  ],
37
37
  "Activity": "off",
38
38
  "Theme": "light"
39
+ },
40
+ "layout": {
41
+ "Size": ""
39
42
  }
40
43
  },
41
44
  "designTokens": {
@@ -51,6 +54,9 @@
51
54
  }
52
55
  },
53
56
  "Theme": "light"
57
+ },
58
+ "layout": {
59
+ "Size": ""
54
60
  }
55
61
  }
56
62
  }
@@ -34,6 +34,9 @@
34
34
  "disabled"
35
35
  ],
36
36
  "Theme": "light"
37
+ },
38
+ "layout": {
39
+ "Size": ""
37
40
  }
38
41
  },
39
42
  "designTokens": {
@@ -64,6 +67,9 @@
64
67
  }
65
68
  },
66
69
  "Theme": "light"
70
+ },
71
+ "layout": {
72
+ "Size": ""
67
73
  }
68
74
  }
69
75
  }
@@ -36,6 +36,9 @@
36
36
  ],
37
37
  "Activity": "off",
38
38
  "Theme": "light"
39
+ },
40
+ "layout": {
41
+ "Size": ""
39
42
  }
40
43
  },
41
44
  "designTokens": {
@@ -51,6 +54,9 @@
51
54
  }
52
55
  },
53
56
  "Theme": "light"
57
+ },
58
+ "layout": {
59
+ "Size": ""
54
60
  }
55
61
  }
56
62
  }
@@ -34,6 +34,9 @@
34
34
  "disabled"
35
35
  ],
36
36
  "Theme": "light"
37
+ },
38
+ "layout": {
39
+ "Size": ""
37
40
  }
38
41
  },
39
42
  "designTokens": {
@@ -62,6 +65,9 @@
62
65
  }
63
66
  },
64
67
  "Theme": "light"
68
+ },
69
+ "layout": {
70
+ "Size": ""
65
71
  }
66
72
  }
67
73
  }
@@ -36,6 +36,9 @@
36
36
  ],
37
37
  "Activity": "off",
38
38
  "Theme": "light"
39
+ },
40
+ "layout": {
41
+ "Size": ""
39
42
  }
40
43
  },
41
44
  "designTokens": {
@@ -51,6 +54,9 @@
51
54
  }
52
55
  },
53
56
  "Theme": "light"
57
+ },
58
+ "layout": {
59
+ "Size": ""
54
60
  }
55
61
  }
56
62
  }
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 { DocumentComponentsObject as ComponentObject } from './exporters/components/index';
5
+ export type { FileComponentsObject as ComponentObject } from './exporters/components/types';
6
6
  export type { ChangelogRecord } from './changelog';
package/dist/app.js CHANGED
@@ -74,7 +74,7 @@ var getWorkingPublicPath = function (handoff) {
74
74
  return null;
75
75
  };
76
76
  var getAppPath = function (handoff) {
77
- return path_1.default.resolve(handoff.modulePath, 'src', "~app-".concat(handoff.config.figma_project_id));
77
+ return path_1.default.resolve(handoff.modulePath, '.handoff', "".concat(handoff.config.figma_project_id));
78
78
  };
79
79
  /**
80
80
  * Copy the public dir from the working dir to the module dir
@@ -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 (_b) {
98
- switch (_b.label) {
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,32 @@ 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
- _b.sent();
106
+ _c.sent();
107
107
  return [4 /*yield*/, fs_extra_1.default.copy(srcPath, appPath, { overwrite: true })];
108
108
  case 2:
109
- _b.sent();
109
+ _c.sent();
110
110
  return [4 /*yield*/, mergePublicDir(handoff)];
111
111
  case 3:
112
- _b.sent();
113
- handoffAppBasePath = (_a = handoff.config.app.base_path) !== null && _a !== void 0 ? _a : '';
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);
115
- handoffExportPath = path_1.default.resolve(handoff.workingPath, handoff.outputDirectory, handoff.config.figma_project_id);
116
+ handoffModulePath = path_1.default.resolve(handoff.modulePath);
117
+ handoffExportPath = path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, 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 = (_b.sent())
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, "'"))
123
- .replace(/HANDOFF_EXPORT_PATH:\s+\'\'/g, "HANDOFF_EXPORT_PATH: '".concat(handoffExportPath, "'"));
126
+ .replace(/HANDOFF_MODULE_PATH:\s+\'\'/g, "HANDOFF_MODULE_PATH: '".concat(handoffModulePath, "'"))
127
+ .replace(/HANDOFF_EXPORT_PATH:\s+\'\'/g, "HANDOFF_EXPORT_PATH: '".concat(handoffExportPath, "'"))
128
+ .replace(/%HANDOFF_MODULE_PATH%/g, handoffModulePath);
124
129
  return [4 /*yield*/, fs_extra_1.default.writeFile(nextConfigPath, nextConfigContent)];
125
130
  case 5:
126
- _b.sent();
131
+ _c.sent();
127
132
  return [2 /*return*/, appPath];
128
133
  }
129
134
  });
@@ -138,7 +143,7 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
138
143
  return __generator(this, function (_a) {
139
144
  switch (_a.label) {
140
145
  case 0:
141
- if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.outputDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
146
+ if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
142
147
  throw new Error('Tokens not exported. Run `handoff-app fetch` first.');
143
148
  }
144
149
  return [4 /*yield*/, prepareProjectApp(handoff)];
@@ -149,7 +154,7 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
149
154
  case 2:
150
155
  // Build app
151
156
  _a.sent();
152
- outputRoot = path_1.default.resolve(handoff.workingPath, 'out');
157
+ outputRoot = path_1.default.resolve(handoff.workingPath, handoff.sitesDirectory);
153
158
  if (!fs_extra_1.default.existsSync(outputRoot)) {
154
159
  fs_extra_1.default.mkdirSync(outputRoot, { recursive: true });
155
160
  }
@@ -172,7 +177,7 @@ var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
172
177
  return __generator(this, function (_a) {
173
178
  switch (_a.label) {
174
179
  case 0:
175
- if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.outputDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
180
+ if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
176
181
  throw new Error('Tokens not exported. Run `handoff-app fetch` first.');
177
182
  }
178
183
  return [4 /*yield*/, prepareProjectApp(handoff)];
@@ -363,7 +368,7 @@ var devApp = function (handoff) { return __awaiter(void 0, void 0, void 0, funct
363
368
  return __generator(this, function (_a) {
364
369
  switch (_a.label) {
365
370
  case 0:
366
- if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.outputDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
371
+ if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
367
372
  throw new Error('Tokens not exported. Run `handoff-app fetch` first.');
368
373
  }
369
374
  return [4 /*yield*/, prepareProjectApp(handoff)];
package/dist/cli/eject.js CHANGED
@@ -44,6 +44,7 @@ var path_1 = __importDefault(require("path"));
44
44
  var fs_extra_1 = __importDefault(require("fs-extra"));
45
45
  var chalk_1 = __importDefault(require("chalk"));
46
46
  var integration_1 = require("../transformers/integration");
47
+ var config_1 = require("../config");
47
48
  /**
48
49
  * Eject the config to the working directory
49
50
  * @param handoff
@@ -51,20 +52,16 @@ var integration_1 = require("../transformers/integration");
51
52
  var ejectConfig = function (handoff) { return __awaiter(void 0, void 0, void 0, function () {
52
53
  var config, configPath;
53
54
  return __generator(this, function (_a) {
54
- switch (_a.label) {
55
- case 0: return [4 /*yield*/, handoff.config];
56
- case 1:
57
- config = _a.sent();
58
- configPath = path_1.default.resolve(path_1.default.join(handoff.workingPath, 'handoff.config.json'));
59
- if (fs_extra_1.default.existsSync(configPath)) {
60
- if (!handoff.force) {
61
- console.log(chalk_1.default.red("A config already exists in the working directory. Use the --force flag to overwrite."));
62
- }
63
- }
64
- fs_extra_1.default.writeFileSync(configPath, "".concat(JSON.stringify(config, null, 2)));
65
- console.log(chalk_1.default.green("Config ejected to ".concat(configPath)));
66
- return [2 /*return*/, handoff];
55
+ config = (0, config_1.getClientConfig)(handoff.config);
56
+ configPath = path_1.default.resolve(path_1.default.join(handoff.workingPath, 'handoff.config.json'));
57
+ if (fs_extra_1.default.existsSync(configPath)) {
58
+ if (!handoff.force) {
59
+ console.log(chalk_1.default.red("A config already exists in the working directory. Use the --force flag to overwrite."));
60
+ }
67
61
  }
62
+ fs_extra_1.default.writeFileSync(configPath, "".concat(JSON.stringify(config, null, 2)));
63
+ console.log(chalk_1.default.green("Config ejected to ".concat(configPath)));
64
+ return [2 /*return*/, handoff];
68
65
  });
69
66
  }); };
70
67
  exports.ejectConfig = ejectConfig;
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.9.3', 2);
83
+ cliError('Handoff App - 0.11.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, handoff_1, _a, type, name_1, templateComponent, templateState, pageName, pageParent, e_1;
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
- handoff_1 = new _1.default();
125
+ handoff = new _1.default();
126
126
  if (args['--debug']) {
127
- handoff_1.debug = true;
127
+ handoff.debug = true;
128
128
  }
129
129
  if (args['--force']) {
130
- handoff_1.force = true;
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*/, handoff_1.fetch()];
152
- case 2: return [4 /*yield*/, handoff_1.build()];
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*/, handoff_1];
155
+ return [2 /*return*/, handoff];
156
156
  case 4:
157
157
  watching = true;
158
- return [2 /*return*/, handoff_1.start()];
158
+ return [2 /*return*/, handoff.start()];
159
159
  case 5:
160
160
  watching = true;
161
- return [2 /*return*/, handoff_1.dev()];
162
- case 6: return [2 /*return*/, handoff_1.integration()];
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*/, handoff_1.ejectConfig()];
167
- case 9: return [2 /*return*/, handoff_1.ejectIntegration()];
168
- case 10: return [2 /*return*/, handoff_1.ejectExportables()];
169
- case 11: return [2 /*return*/, handoff_1.ejectTheme()];
170
- case 12: return [2 /*return*/, handoff_1.ejectPages()];
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*/, handoff_1.makeExportable(type, name_1)];
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*/, handoff_1.makeTemplate(templateComponent, templateState)];
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*/, handoff_1.makePage(pageName, pageParent)];
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 config, either from the root of the project or from the default config
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 getConfig: (configOverride?: any) => Config;
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,14 +14,16 @@ 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.deserializeHandoff = exports.serializeHandoff = exports.getHandoff = exports.getConfig = exports.defaultConfig = void 0;
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, _d, _e;
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,
25
+ exportsOutputDirectory: (_c = process.env.OUTPUT_DIR) !== null && _c !== void 0 ? _c : "exported",
26
+ sitesOutputDirectory: (_d = process.env.SITES_DIR) !== null && _d !== void 0 ? _d : "out",
25
27
  integration: {
26
28
  name: 'bootstrap',
27
29
  version: '5.3',
@@ -75,17 +77,15 @@ var defaultConfig = function () {
75
77
  'components/switch',
76
78
  ],
77
79
  },
80
+ use_legacy_definitions: ((_e = process.env.USE_HANDOFF_PLUGIN) !== null && _e !== void 0 ? _e : "").toLowerCase() === "false"
78
81
  });
79
82
  };
80
83
  exports.defaultConfig = defaultConfig;
81
84
  /**
82
- * Get the config, either from the root of the project or from the default config
85
+ * Get the configuration formatted for the client, either from the root of the project or from the default config.
83
86
  * @returns Promise<Config>
84
87
  */
85
- var getConfig = function (configOverride) {
86
- // if (global.handoff && global.handoff.config) {
87
- // return global.handoff.config;
88
- // }
88
+ var getClientConfig = function (configOverride) {
89
89
  // Check to see if there is a config in the root of the project
90
90
  var config = {};
91
91
  var configPath = path_1.default.resolve(process.cwd(), 'handoff.config.json');
@@ -96,54 +96,14 @@ var getConfig = function (configOverride) {
96
96
  if (configOverride) {
97
97
  config = __assign(__assign({}, config), configOverride);
98
98
  }
99
- var result = __assign(__assign({}, (0, exports.defaultConfig)()), config);
100
- // Anonymize the configuration!
101
- delete result.figma_project_id;
102
- delete result.dev_access_token;
103
- return result;
104
- };
105
- exports.getConfig = getConfig;
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');
99
+ var _a = __assign(__assign({}, (0, exports.defaultConfig)()), config), app = _a.app, figma = _a.figma, exportsOutputDirectory = _a.exportsOutputDirectory, sitesOutputDirectory = _a.sitesOutputDirectory, assets_zip_links = _a.assets_zip_links, use_legacy_definitions = _a.use_legacy_definitions;
100
+ return {
101
+ app: app,
102
+ figma: figma,
103
+ exportsOutputDirectory: exportsOutputDirectory,
104
+ sitesOutputDirectory: sitesOutputDirectory,
105
+ assets_zip_links: assets_zip_links !== null && assets_zip_links !== void 0 ? assets_zip_links : { icons: null, logos: null },
106
+ use_legacy_definitions: use_legacy_definitions
107
+ };
148
108
  };
149
- exports.deserializeHandoff = deserializeHandoff;
109
+ exports.getClientConfig = getClientConfig;
@@ -1,2 +1,2 @@
1
- import { DocumentationObject, ExportableDefinition } from './types';
2
- export declare const createDocumentationObject: (figmaFileKey: string, figmaAccessToken: string, exportables: ExportableDefinition[]) => Promise<DocumentationObject>;
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 = __importDefault(require("./exporters/components/index"));
45
- var design_1 = __importDefault(require("./exporters/design"));
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, exportables) { return __awaiter(void 0, void 0, void 0, function () {
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.default)(figmaFileKey, figmaAccessToken, exportables)];
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
- if (Object.keys(components).filter(function (component) { return components[component].length > 0; }).length > 0) {
57
- Object.keys(components).map(function (component) {
58
- if (components[component].length === 0) {
59
- console.error(chalk_1.default.grey("".concat((0, startCase_1.default)(component), " could not be located in the figma file")));
60
- }
61
- else {
62
- console.log(chalk_1.default.green("".concat((0, startCase_1.default)(component), " exported:")), components[component].length);
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 { ExportableDefinition } from '../../types';
3
- import { GetComponentSetComponentsResult } from '.';
4
- export interface Component {
5
- id: string;
6
- name: string;
7
- description?: string;
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[];