handoff-app 0.14.0 → 0.15.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 (155) hide show
  1. package/Changelog.md +58 -0
  2. package/dist/app.js +61 -33
  3. package/dist/cli/eject.js +1 -1
  4. package/dist/cli.js +18 -212
  5. package/dist/commands/build/app.d.ts +6 -0
  6. package/dist/commands/build/app.js +64 -0
  7. package/dist/commands/build/integration.d.ts +6 -0
  8. package/dist/commands/build/integration.js +64 -0
  9. package/dist/commands/build/recipe.d.ts +6 -0
  10. package/dist/commands/build/recipe.js +64 -0
  11. package/dist/commands/build/snippets.d.ts +7 -0
  12. package/dist/commands/build/snippets.js +67 -0
  13. package/dist/commands/dev/index.d.ts +6 -0
  14. package/dist/commands/dev/index.js +64 -0
  15. package/dist/commands/eject/config.d.ts +6 -0
  16. package/dist/commands/eject/config.js +64 -0
  17. package/dist/commands/eject/exportables.d.ts +6 -0
  18. package/dist/commands/eject/exportables.js +64 -0
  19. package/dist/commands/eject/integration.d.ts +6 -0
  20. package/dist/commands/eject/integration.js +64 -0
  21. package/dist/commands/eject/pages.d.ts +6 -0
  22. package/dist/commands/eject/pages.js +64 -0
  23. package/dist/commands/eject/schemas.d.ts +6 -0
  24. package/dist/commands/eject/schemas.js +64 -0
  25. package/dist/commands/eject/theme.d.ts +6 -0
  26. package/dist/commands/eject/theme.js +64 -0
  27. package/dist/commands/fetch/index.d.ts +6 -0
  28. package/dist/commands/fetch/index.js +64 -0
  29. package/dist/commands/index.d.ts +2 -0
  30. package/dist/commands/index.js +48 -0
  31. package/dist/commands/make/exportable.d.ts +8 -0
  32. package/dist/commands/make/exportable.js +78 -0
  33. package/dist/commands/make/integration.d.ts +6 -0
  34. package/dist/commands/make/integration.js +64 -0
  35. package/dist/commands/make/page.d.ts +8 -0
  36. package/dist/commands/make/page.js +82 -0
  37. package/dist/commands/make/schema.d.ts +8 -0
  38. package/dist/commands/make/schema.js +78 -0
  39. package/dist/commands/make/snippet.d.ts +7 -0
  40. package/dist/commands/make/snippet.js +72 -0
  41. package/dist/commands/make/template.d.ts +8 -0
  42. package/dist/commands/make/template.js +82 -0
  43. package/dist/commands/rename/snippet.d.ts +8 -0
  44. package/dist/commands/rename/snippet.js +72 -0
  45. package/dist/commands/start/index.d.ts +6 -0
  46. package/dist/commands/start/index.js +64 -0
  47. package/dist/commands/types.d.ts +6 -0
  48. package/dist/commands/types.js +2 -0
  49. package/dist/commands/utils.d.ts +23 -0
  50. package/dist/commands/utils.js +28 -0
  51. package/dist/config.js +5 -3
  52. package/dist/documentation-object.js +41 -11
  53. package/dist/exporters/assets.d.ts +1 -0
  54. package/dist/exporters/components/extractor.d.ts +9 -0
  55. package/dist/exporters/components/extractor.js +95 -2
  56. package/dist/exporters/components/index.d.ts +6 -0
  57. package/dist/exporters/components/index.js +19 -0
  58. package/dist/exporters/components/types.d.ts +2 -1
  59. package/dist/exporters/design.d.ts +18 -0
  60. package/dist/exporters/design.js +51 -9
  61. package/dist/exporters/utils.d.ts +1 -0
  62. package/dist/figma/types.d.ts +9 -3
  63. package/dist/index.d.ts +9 -4
  64. package/dist/index.js +32 -20
  65. package/dist/pipeline.js +4 -4
  66. package/dist/transformers/css/component.d.ts +5 -2
  67. package/dist/transformers/css/component.js +58 -3
  68. package/dist/transformers/css/design/typography.js +7 -0
  69. package/dist/transformers/css/index.d.ts +2 -1
  70. package/dist/transformers/css/index.js +2 -2
  71. package/dist/transformers/font/index.js +7 -6
  72. package/dist/transformers/integration/index.d.ts +1 -0
  73. package/dist/transformers/integration/index.js +2 -1
  74. package/dist/transformers/preview/index.d.ts +3 -1
  75. package/dist/transformers/preview/index.js +96 -37
  76. package/dist/transformers/preview/types.d.ts +1 -0
  77. package/dist/transformers/scss/design/typography.js +7 -0
  78. package/dist/transformers/scss/index.d.ts +2 -1
  79. package/dist/transformers/scss/index.js +3 -2
  80. package/dist/transformers/sd/component.d.ts +2 -1
  81. package/dist/transformers/sd/component.js +3 -2
  82. package/dist/transformers/sd/index.d.ts +2 -1
  83. package/dist/transformers/sd/index.js +2 -2
  84. package/dist/transformers/transformer.js +5 -2
  85. package/dist/transformers/types.d.ts +2 -0
  86. package/dist/transformers/utils.d.ts +2 -8
  87. package/dist/types.d.ts +25 -0
  88. package/dist/utils/convertColor.d.ts +1 -0
  89. package/dist/utils/numbers.js +2 -2
  90. package/dist/utils/preview.js +6 -4
  91. package/dist/utils/prompt.d.ts +1 -1
  92. package/dist/utils/prompt.js +49 -8
  93. package/package.json +4 -2
  94. package/src/app/components/ComponentDesignTokens.tsx +75 -37
  95. package/src/app/components/Markdown/CodeHighlight.tsx +7 -1
  96. package/src/app/components/util/index.ts +12 -3
  97. package/src/app/components/util/token.ts +27 -0
  98. package/src/app/next-env.d.ts +1 -1
  99. package/src/app/next.config.mjs +3 -0
  100. package/src/app/pages/components/[component]/index.tsx +1 -0
  101. package/src/app/sass/components/_tokens-preview.scss +10 -0
  102. package/src/app.ts +21 -4
  103. package/src/cli/eject.ts +1 -1
  104. package/src/cli.ts +13 -214
  105. package/src/commands/build/app.ts +20 -0
  106. package/src/commands/build/integration.ts +20 -0
  107. package/src/commands/build/recipe.ts +20 -0
  108. package/src/commands/build/snippets.ts +25 -0
  109. package/src/commands/dev/index.ts +20 -0
  110. package/src/commands/eject/config.ts +20 -0
  111. package/src/commands/eject/exportables.ts +20 -0
  112. package/src/commands/eject/integration.ts +20 -0
  113. package/src/commands/eject/pages.ts +20 -0
  114. package/src/commands/eject/schemas.ts +20 -0
  115. package/src/commands/eject/theme.ts +20 -0
  116. package/src/commands/fetch/index.ts +20 -0
  117. package/src/commands/index.ts +43 -0
  118. package/src/commands/make/exportable.ts +40 -0
  119. package/src/commands/make/integration.ts +20 -0
  120. package/src/commands/make/page.ts +46 -0
  121. package/src/commands/make/schema.ts +40 -0
  122. package/src/commands/make/snippet.ts +33 -0
  123. package/src/commands/make/template.ts +46 -0
  124. package/src/commands/rename/snippet.ts +31 -0
  125. package/src/commands/start/index.ts +20 -0
  126. package/src/commands/types.ts +7 -0
  127. package/src/commands/utils.ts +26 -0
  128. package/src/config.ts +11 -6
  129. package/src/documentation-object.ts +48 -6
  130. package/src/exporters/components/extractor.ts +101 -5
  131. package/src/exporters/components/index.ts +19 -1
  132. package/src/exporters/components/types.ts +2 -1
  133. package/src/exporters/design.ts +59 -14
  134. package/src/figma/types.ts +10 -3
  135. package/src/index.ts +28 -12
  136. package/src/pipeline.ts +5 -5
  137. package/src/transformers/css/component.ts +59 -1
  138. package/src/transformers/css/design/typography.ts +7 -0
  139. package/src/transformers/css/index.ts +4 -2
  140. package/src/transformers/font/index.ts +1 -2
  141. package/src/transformers/integration/index.ts +3 -1
  142. package/src/transformers/preview/index.ts +48 -10
  143. package/src/transformers/preview/types.ts +1 -0
  144. package/src/transformers/scss/component.ts +1 -0
  145. package/src/transformers/scss/design/typography.ts +7 -0
  146. package/src/transformers/scss/index.ts +8 -2
  147. package/src/transformers/sd/component.ts +4 -1
  148. package/src/transformers/sd/index.ts +3 -1
  149. package/src/transformers/transformer.ts +10 -3
  150. package/src/transformers/types.ts +3 -0
  151. package/src/types/config.d.ts +4 -2
  152. package/src/types.ts +29 -0
  153. package/src/utils/numbers.ts +2 -2
  154. package/src/utils/preview.ts +3 -3
  155. package/src/utils/prompt.ts +9 -11
package/Changelog.md CHANGED
@@ -6,6 +6,64 @@ 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.15.0] - 2024-11-05
10
+
11
+ This release allows Figma foundation styles - Colors, Typography, and Effects
12
+ to create variable references in component styles in CSS, SASS, and Style
13
+ Dictionaries. It also adds shared style support in snippets to make it easier
14
+ to structure and reuse styles across multiple large components.
15
+
16
+ ### Features
17
+
18
+ - Figma foundation styles - Colors, Typography, and Effects - are now linked to
19
+ component styles in the tokens export. This allows you to use foundation styles
20
+ as variables in component styles in CSS, SASS, and Style Dictionaries.
21
+ - To enable, set `useVariables` to `true` in the `handoff.config.json` file.
22
+ - You can also enable variable support via the `.env` var
23
+ `HANDOFF_USE_VARIABLES`. You can use a boolean or string ("true"/"false")
24
+ - When enabled, Handoff will create variable references in the component styles
25
+ for the foundation styles wherever possible instead of using the string value.
26
+ - For example a color foundation style `Blue` in the `Primary` color group
27
+ with value `#FF0000` will be referenced as `var(--color-primary-blue)` in
28
+ the component styles instead of `#FF0000`.
29
+ - This feature is disabled by default.
30
+ - Added support for shared styles in snippets. Shared Styles exist to allow users
31
+ to separate styles used across multiple components from the styles unique to
32
+ each component.
33
+ - To use a shared style in a snippet, add a `{{ sharedStyles }}` to your snippet
34
+ HTML file. Handoff will replace this with the shared styles from the Figma
35
+ file.
36
+ - Created a `shared.scss` or `shared.css` file in the `integration/snippets`
37
+ directory to define the shared styles.
38
+ - If the shared styles are defined in a `shared.scss` file, Handoff will compile
39
+ the shared styles to CSS and include them in the snippet.
40
+
41
+ ### Changes
42
+
43
+ - The default configuration now has a `useVariables` property set to `false` to
44
+ maintain backward compatibility.
45
+ - The default snippets.html file now includes a `{{ sharedStyles }}` token to
46
+ support shared styles in snippets. This value will be empty if no shared styles
47
+ exists.
48
+
49
+ ## [0.14.1] - 2024-10-28
50
+
51
+ This release introduces greater flexibility for custom integrations and general improvements to CLI handling.
52
+
53
+ ### Changes
54
+
55
+ - Added support for custom integration paths with the `-i <path-to-integration>` CLI argument.
56
+ - Can be used with commands like `fetch`, `start`, `build:app`, etc.
57
+ - Defaults to the `integration` directory if the argument isn't specified, ensuring backward compatibility.
58
+
59
+ ### Improvements
60
+
61
+ - Enhanced CLI command management:
62
+ - Switched to `yargs` for improved CLI parsing.
63
+ - Each command now has a dedicated handler file for better modularity.
64
+ - Improved the docs app build process:
65
+ - Introduced a cleanup procedure that ensures only files present in the working directory are included in the final build.
66
+
9
67
  ## [0.14.0] - 2024-09-26
10
68
 
11
69
  This release enables creation of complex documentation pages, with storybook
package/dist/app.js CHANGED
@@ -159,11 +159,26 @@ var transformMdx = function (src, dest, id) {
159
159
  mdx = "\n\n\n".concat(mdx, "\n\n\nimport {staticBuildMenu, getCurrentSection} from \"handoff-app/src/app/components/util\";\nimport { getClientConfig } from '@handoff/config';\nimport { getPreview } from \"handoff-app/src/app/components/util\";\n\nexport const getStaticProps = async () => {\n // get previews for components on this page\n const previews = getPreview();\n const menu = staticBuildMenu();\n const config = getClientConfig();\n return {\n props: {\n previews,\n menu,\n config,\n current: getCurrentSection(menu, \"/").concat(id, "\") ?? [],\n title: \"").concat(title, "\",\n description: \"").concat(description, "\",\n image: \"").concat(image, "\",\n },\n };\n};\n\nexport const preview = (name) => {\n return previews.components[name];\n};\n\nimport MarkdownLayout from \"handoff-app/src/app/components/MarkdownLayout\";\nexport default function Layout(props) {\n return (\n <MarkdownLayout\n menu={props.menu}\n metadata={{\n metaDescription: \"").concat(metaDescription, "\",\n metaTitle: \"").concat(metaTitle, "\",\n title: \"").concat(title, "\",\n weight: ").concat(weight, ",\n image: \"").concat(image, "\",\n menuTitle: \"").concat(menuTitle, "\",\n enabled: ").concat(enabled, ",\n }}\n wide={").concat(wide, "}\n allPreviews={props.previews}\n config={props.config}\n current={props.current}\n >\n {props.children}\n </MarkdownLayout>\n );\n\n}");
160
160
  fs_extra_1.default.writeFileSync(dest, mdx, 'utf-8');
161
161
  };
162
+ var performCleanup = function (handoff) { return __awaiter(void 0, void 0, void 0, function () {
163
+ var appPath;
164
+ return __generator(this, function (_a) {
165
+ switch (_a.label) {
166
+ case 0:
167
+ appPath = getAppPath(handoff);
168
+ if (!fs_extra_1.default.existsSync(appPath)) return [3 /*break*/, 2];
169
+ return [4 /*yield*/, fs_extra_1.default.rm(appPath, { recursive: true })];
170
+ case 1:
171
+ _a.sent();
172
+ _a.label = 2;
173
+ case 2: return [2 /*return*/];
174
+ }
175
+ });
176
+ }); };
162
177
  var prepareProjectApp = function (handoff) { return __awaiter(void 0, void 0, void 0, function () {
163
- var srcPath, appPath, handoffProjectId, handoffAppBasePath, handoffWorkingPath, handoffModulePath, handoffExportPath, nextConfigPath, nextConfigContent;
164
- var _a, _b;
165
- return __generator(this, function (_c) {
166
- switch (_c.label) {
178
+ var srcPath, appPath, handoffProjectId, handoffAppBasePath, handoffWorkingPath, handoffIntegrationPath, handoffModulePath, handoffExportPath, nextConfigPath, handoffUseReferences, nextConfigContent;
179
+ var _a, _b, _c, _d;
180
+ return __generator(this, function (_e) {
181
+ switch (_e.label) {
167
182
  case 0:
168
183
  srcPath = path_1.default.resolve(handoff.modulePath, 'src', 'app');
169
184
  appPath = getAppPath(handoff);
@@ -171,35 +186,39 @@ var prepareProjectApp = function (handoff) { return __awaiter(void 0, void 0, vo
171
186
  return [4 /*yield*/, fs_extra_1.default.promises.mkdir(appPath, { recursive: true })];
172
187
  case 1:
173
188
  // Prepare project app dir
174
- _c.sent();
189
+ _e.sent();
175
190
  return [4 /*yield*/, fs_extra_1.default.copy(srcPath, appPath, { overwrite: true })];
176
191
  case 2:
177
- _c.sent();
192
+ _e.sent();
178
193
  return [4 /*yield*/, mergePublicDir(handoff)];
179
194
  case 3:
180
- _c.sent();
195
+ _e.sent();
181
196
  return [4 /*yield*/, mergeMDX(handoff)];
182
197
  case 4:
183
- _c.sent();
198
+ _e.sent();
184
199
  handoffProjectId = (_a = handoff.config.figma_project_id) !== null && _a !== void 0 ? _a : '';
185
200
  handoffAppBasePath = (_b = handoff.config.app.base_path) !== null && _b !== void 0 ? _b : '';
186
201
  handoffWorkingPath = path_1.default.resolve(handoff.workingPath);
202
+ handoffIntegrationPath = path_1.default.resolve(handoff.workingPath, (_c = handoff.config.integrationPath) !== null && _c !== void 0 ? _c : 'integration');
187
203
  handoffModulePath = path_1.default.resolve(handoff.modulePath);
188
204
  handoffExportPath = path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id);
189
205
  nextConfigPath = path_1.default.resolve(appPath, 'next.config.mjs');
206
+ handoffUseReferences = (_d = handoff.config.useVariables) !== null && _d !== void 0 ? _d : false;
190
207
  return [4 /*yield*/, fs_extra_1.default.readFile(nextConfigPath, 'utf-8')];
191
208
  case 5:
192
- nextConfigContent = (_c.sent())
209
+ nextConfigContent = (_e.sent())
193
210
  .replace(/basePath:\s+\'\'/g, "basePath: '".concat(handoffAppBasePath, "'"))
194
211
  .replace(/HANDOFF_PROJECT_ID:\s+\'\'/g, "HANDOFF_PROJECT_ID: '".concat(handoffProjectId, "'"))
195
212
  .replace(/HANDOFF_APP_BASE_PATH:\s+\'\'/g, "HANDOFF_APP_BASE_PATH: '".concat(handoffAppBasePath, "'"))
196
213
  .replace(/HANDOFF_WORKING_PATH:\s+\'\'/g, "HANDOFF_WORKING_PATH: '".concat(handoffWorkingPath, "'"))
214
+ .replace(/HANDOFF_INTEGRATION_PATH:\s+\'\'/g, "HANDOFF_INTEGRATION_PATH: '".concat(handoffIntegrationPath, "'"))
197
215
  .replace(/HANDOFF_MODULE_PATH:\s+\'\'/g, "HANDOFF_MODULE_PATH: '".concat(handoffModulePath, "'"))
198
216
  .replace(/HANDOFF_EXPORT_PATH:\s+\'\'/g, "HANDOFF_EXPORT_PATH: '".concat(handoffExportPath, "'"))
217
+ .replace(/HANDOFF_USE_REFERENCES:\s+\'\'/g, "HANDOFF_USE_REFERENCES: '".concat(handoffUseReferences, "'"))
199
218
  .replace(/%HANDOFF_MODULE_PATH%/g, handoffModulePath);
200
219
  return [4 /*yield*/, fs_extra_1.default.writeFile(nextConfigPath, nextConfigContent)];
201
220
  case 6:
202
- _c.sent();
221
+ _e.sent();
203
222
  return [2 /*return*/, appPath];
204
223
  }
205
224
  });
@@ -217,9 +236,14 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
217
236
  if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
218
237
  throw new Error('Tokens not exported. Run `handoff-app fetch` first.');
219
238
  }
239
+ // Perform cleanup
240
+ return [4 /*yield*/, performCleanup(handoff)];
241
+ case 1:
242
+ // Perform cleanup
243
+ _a.sent();
220
244
  // If we are building the app, ensure the integration is built first
221
245
  return [4 /*yield*/, (0, pipeline_1.buildIntegrationOnly)(handoff)];
222
- case 1:
246
+ case 2:
223
247
  // If we are building the app, ensure the integration is built first
224
248
  _a.sent();
225
249
  // Build client preview styles
@@ -228,11 +252,11 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
228
252
  .catch(function (error) {
229
253
  throw new Error(error);
230
254
  })];
231
- case 2:
255
+ case 3:
232
256
  // Build client preview styles
233
257
  _a.sent();
234
258
  return [4 /*yield*/, prepareProjectApp(handoff)];
235
- case 3:
259
+ case 4:
236
260
  appPath = _a.sent();
237
261
  // Build app
238
262
  return [4 /*yield*/, (0, next_build_1.nextBuild)({
@@ -243,7 +267,7 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
243
267
  experimentalTurbo: false,
244
268
  experimentalBuildMode: 'default',
245
269
  }, appPath)];
246
- case 4:
270
+ case 5:
247
271
  // Build app
248
272
  _a.sent();
249
273
  outputRoot = path_1.default.resolve(handoff.workingPath, handoff.sitesDirectory);
@@ -266,8 +290,9 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
266
290
  */
267
291
  var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, function () {
268
292
  var appPath, dev, hostname, port, app, handle, moduleOutput, chokidarConfig, debounce;
269
- return __generator(this, function (_a) {
270
- switch (_a.label) {
293
+ var _a, _b;
294
+ return __generator(this, function (_c) {
295
+ switch (_c.label) {
271
296
  case 0:
272
297
  if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
273
298
  throw new Error('Tokens not exported. Run `handoff-app fetch` first.');
@@ -280,10 +305,10 @@ var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
280
305
  })];
281
306
  case 1:
282
307
  // Build client preview styles
283
- _a.sent();
308
+ _c.sent();
284
309
  return [4 /*yield*/, prepareProjectApp(handoff)];
285
310
  case 2:
286
- appPath = _a.sent();
311
+ appPath = _c.sent();
287
312
  // Include any changes made within the app source during watch
288
313
  chokidar_1.default
289
314
  .watch(path_1.default.resolve(handoff.modulePath, 'src', 'app'), {
@@ -410,9 +435,9 @@ var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
410
435
  });
411
436
  }); });
412
437
  }
413
- if (fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, 'integration'))) {
414
- chokidar_1.default.watch(path_1.default.resolve(handoff.workingPath, 'integration'), chokidarConfig).on('all', function (event, file) { return __awaiter(void 0, void 0, void 0, function () {
415
- var _a;
438
+ if (fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, (_a = handoff.config.integrationPath) !== null && _a !== void 0 ? _a : 'integration'))) {
439
+ chokidar_1.default.watch(path_1.default.resolve(handoff.workingPath, (_b = handoff.config.integrationPath) !== null && _b !== void 0 ? _b : 'integration'), chokidarConfig).on('all', function (event, file) { return __awaiter(void 0, void 0, void 0, function () {
440
+ var _a, sharedStyles;
416
441
  return __generator(this, function (_b) {
417
442
  switch (_b.label) {
418
443
  case 0:
@@ -422,25 +447,28 @@ var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
422
447
  case 'change': return [3 /*break*/, 1];
423
448
  case 'unlink': return [3 /*break*/, 1];
424
449
  }
425
- return [3 /*break*/, 7];
450
+ return [3 /*break*/, 8];
426
451
  case 1:
427
- if (!((file.includes('json') || file.includes('html') || file.includes('js') || file.includes('scss')) && !debounce)) return [3 /*break*/, 6];
452
+ if (!((file.includes('json') || file.includes('html') || file.includes('js') || file.includes('scss')) && !debounce)) return [3 /*break*/, 7];
428
453
  console.log(chalk_1.default.yellow("Integration ".concat(event, "ed. Handoff will rerender the integrations...")), file);
429
454
  debounce = true;
430
- if (!file.includes('snippet')) return [3 /*break*/, 3];
431
- return [4 /*yield*/, (0, preview_2.processSnippet)(handoff, path_1.default.basename(file))];
455
+ if (!file.includes('snippet')) return [3 /*break*/, 4];
456
+ return [4 /*yield*/, (0, preview_2.processSharedStyles)(handoff)];
432
457
  case 2:
458
+ sharedStyles = _b.sent();
459
+ return [4 /*yield*/, (0, preview_2.processSnippet)(handoff, path_1.default.basename(file), sharedStyles)];
460
+ case 3:
433
461
  _b.sent();
434
- return [3 /*break*/, 5];
435
- case 3: return [4 /*yield*/, handoff.integration()];
436
- case 4:
437
- _b.sent();
438
- _b.label = 5;
462
+ return [3 /*break*/, 6];
463
+ case 4: return [4 /*yield*/, handoff.integration()];
439
464
  case 5:
440
- debounce = false;
465
+ _b.sent();
441
466
  _b.label = 6;
442
- case 6: return [3 /*break*/, 7];
443
- case 7: return [2 /*return*/];
467
+ case 6:
468
+ debounce = false;
469
+ _b.label = 7;
470
+ case 7: return [3 /*break*/, 8];
471
+ case 8: return [2 /*return*/];
444
472
  }
445
473
  });
446
474
  }); });
package/dist/cli/eject.js CHANGED
@@ -87,10 +87,10 @@ var makeIntegration = function (handoff) { return __awaiter(void 0, void 0, void
87
87
  fs_extra_1.default.copySync(integrationPath, workingPath, { overwrite: handoff.force ? true : false });
88
88
  if (handoff.force)
89
89
  handoff.force = false;
90
+ console.log(chalk_1.default.green("Integration has been successfully created! Path: ".concat(workingPath)));
90
91
  return [4 /*yield*/, (0, pipeline_1.buildIntegrationOnly)(handoff)];
91
92
  case 1:
92
93
  _a.sent();
93
- console.log(chalk_1.default.green("Integration has been successfully created! Path: ".concat(workingPath)));
94
94
  return [2 /*return*/, handoff];
95
95
  }
96
96
  });
package/dist/cli.js CHANGED
@@ -15,48 +15,13 @@ var __extends = (this && this.__extends) || (function () {
15
15
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16
16
  };
17
17
  })();
18
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
19
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
- return new (P || (P = Promise))(function (resolve, reject) {
21
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
- step((generator = generator.apply(thisArg, _arguments || [])).next());
25
- });
26
- };
27
- var __generator = (this && this.__generator) || function (thisArg, body) {
28
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
29
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
30
- function verb(n) { return function (v) { return step([n, v]); }; }
31
- function step(op) {
32
- if (f) throw new TypeError("Generator is already executing.");
33
- while (_) try {
34
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
35
- if (y = 0, t) op = [op[0] & 2, t.value];
36
- switch (op[0]) {
37
- case 0: case 1: t = op; break;
38
- case 4: _.label++; return { value: op[1], done: false };
39
- case 5: _.label++; y = op[1]; op = [0]; continue;
40
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
41
- default:
42
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
43
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
44
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
45
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
46
- if (t[2]) _.ops.pop();
47
- _.trys.pop(); continue;
48
- }
49
- op = body.call(thisArg, _);
50
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
51
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
52
- }
53
- };
54
18
  var __importDefault = (this && this.__importDefault) || function (mod) {
55
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
56
20
  };
57
21
  Object.defineProperty(exports, "__esModule", { value: true });
58
- var arg_1 = __importDefault(require("arg"));
59
- var _1 = __importDefault(require("."));
22
+ var yargs_1 = __importDefault(require("yargs/yargs"));
23
+ var helpers_1 = require("yargs/helpers");
24
+ var commands_1 = require("./commands");
60
25
  var HandoffCliError = /** @class */ (function (_super) {
61
26
  __extends(HandoffCliError, _super);
62
27
  function HandoffCliError(message) {
@@ -69,18 +34,11 @@ var HandoffCliError = /** @class */ (function (_super) {
69
34
  }
70
35
  return HandoffCliError;
71
36
  }(Error));
72
- var usage = "Usage: handoff-app <cmd> <opts>\n\nCommands:\n fetch [opts] - Fetches the design tokens from the design system\n\n build - Using the current tokens, build various outputs\n build:app [opts] - Builds the design system static application\n build:integration [opts] - Builds current selected integration, styles and previews\n build:recipe - Builds a recipe file based on the integration that is curretnly used (if any)\n build:snippets <name> [opts] - Builds the snippets for the current integration. Pass a name to build a specific snippet.\n\n start [opts] - Starts the design system in development mode\n\n make\n make:exportable <type> <name> [opts] - Creates a new schema\n make:template <component> <state> [opts] - Creates a new template\n make:page <name> <parent> [opts] - Creates a new custom page\n make:integration - Creates a new integration based on the provided Bootstrap 5.3 template\n make:snippet - <name> Creates a new html code snippet that you can embed in your documentation\n\n eject - Ejects the default entire configuration to the current directory\n eject:config [opts] - Ejects the default configuration to the current directory\n eject:integration [opts] - Ejects the default integration to the current directory\n eject:exportables [opts] - Ejects the default exportables to the current directory\n eject:pages [opts] - Ejects the default pages to the current directory\n eject:theme [opts] - Ejects the currently selected theme to theme/main.scss\n\n rename:snippet <source> <destination> [opts] - Renames a snippet from source to destination and update any references.\n\nOptions:\n -c, --config [file] Define the path to the config file\n -d, --debug Show debug logs\n -h, --help Show this help message\n -v, --version Show the version number\n";
73
- /**
74
- * Show the help message
75
- */
76
- var showHelp = function () {
77
- cliError(usage, 2);
78
- };
79
37
  /**
80
38
  * Show the help message
81
39
  */
82
40
  var showVersion = function () {
83
- cliError('Handoff App - 0.14.0', 2);
41
+ return 'Handoff App - 0.15.0';
84
42
  };
85
43
  /**
86
44
  * Define a CLI error
@@ -94,170 +52,18 @@ var cliError = function (msg, exitCode) {
94
52
  err.exitCode = exitCode;
95
53
  throw err;
96
54
  };
97
- var watching = false;
98
- var run = function (argv, stdout, stderr) { return __awaiter(void 0, void 0, void 0, function () {
99
- var args, handoff, _a, snippet, source, destination, type, name_1, templateComponent, templateState, pageName, pageParent, snippetName, e_1;
100
- return __generator(this, function (_b) {
101
- switch (_b.label) {
102
- case 0:
103
- _b.trys.push([0, 24, , 25]);
104
- args = (0, arg_1.default)({
105
- '--help': Boolean,
106
- '-h': '--help',
107
- '--version': Boolean,
108
- '-v': '--version',
109
- '--config': String,
110
- '-c': '--config',
111
- '--debug': Boolean,
112
- '-d': '--debug',
113
- '--force': Boolean,
114
- '-f': '--force',
115
- }, {
116
- permissive: false,
117
- argv: argv,
118
- });
119
- if (args['--help']) {
120
- return [2 /*return*/, showHelp()];
121
- }
122
- if (args['--version']) {
123
- return [2 /*return*/, showVersion()];
124
- }
125
- handoff = new _1.default();
126
- if (args['--debug']) {
127
- handoff.debug = true;
128
- }
129
- if (args['--force']) {
130
- handoff.force = true;
131
- }
132
- _a = args._[0];
133
- switch (_a) {
134
- case 'fetch': return [3 /*break*/, 1];
135
- case 'build:app': return [3 /*break*/, 2];
136
- case 'start': return [3 /*break*/, 4];
137
- case 'dev': return [3 /*break*/, 5];
138
- case 'build:integration': return [3 /*break*/, 6];
139
- case 'build:snippets': return [3 /*break*/, 7];
140
- case 'rename:snippet': return [3 /*break*/, 8];
141
- case 'build:recipe': return [3 /*break*/, 9];
142
- case 'eject': return [3 /*break*/, 10];
143
- case 'eject:config': return [3 /*break*/, 11];
144
- case 'eject:integration': return [3 /*break*/, 12];
145
- case 'eject:exportables': return [3 /*break*/, 13];
146
- case 'eject:theme': return [3 /*break*/, 14];
147
- case 'eject:pages': return [3 /*break*/, 15];
148
- case 'make': return [3 /*break*/, 16];
149
- case 'make:exportable': return [3 /*break*/, 17];
150
- case 'make:template': return [3 /*break*/, 18];
151
- case 'make:page': return [3 /*break*/, 19];
152
- case 'make:snippet': return [3 /*break*/, 20];
153
- case 'make:integration': return [3 /*break*/, 21];
154
- }
155
- return [3 /*break*/, 22];
156
- case 1: return [2 /*return*/, handoff.fetch()];
157
- case 2: return [4 /*yield*/, handoff.build()];
158
- case 3:
159
- _b.sent();
160
- return [2 /*return*/, handoff];
161
- case 4:
162
- watching = true;
163
- return [2 /*return*/, handoff.start()];
164
- case 5:
165
- watching = true;
166
- return [2 /*return*/, handoff.dev()];
167
- case 6: return [2 /*return*/, handoff.integration()];
168
- case 7:
169
- snippet = args._[1];
170
- return [2 /*return*/, handoff.snippet(snippet)];
171
- case 8:
172
- source = args._[1];
173
- if (!source) {
174
- cliError("You must specify a source snippet name", 2);
175
- }
176
- destination = args._[2];
177
- if (!destination) {
178
- cliError("You must specify a destination snippet name", 2);
179
- }
180
- return [2 /*return*/, handoff.renameSnippet(source, destination)];
181
- case 9: return [2 /*return*/, handoff.recipe()];
182
- case 10:
183
- 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);
184
- return [3 /*break*/, 23];
185
- case 11: return [2 /*return*/, handoff.ejectConfig()];
186
- case 12: return [2 /*return*/, handoff.ejectIntegration()];
187
- case 13: return [2 /*return*/, handoff.ejectExportables()];
188
- case 14: return [2 /*return*/, handoff.ejectTheme()];
189
- case 15: return [2 /*return*/, handoff.ejectPages()];
190
- case 16:
191
- 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\n - make:integration\n - make:snippet", 2);
192
- return [3 /*break*/, 23];
193
- case 17:
194
- type = args._[1];
195
- if (!type) {
196
- cliError("You must specify a type of 'component' or 'foundation'", 2);
197
- }
198
- name_1 = args._[2];
199
- if (!name_1) {
200
- cliError("You must specify a name for the exportable", 2);
201
- }
202
- if (!/^[a-z0-9]+$/i.test(name_1)) {
203
- cliError("Exportable name must be alphanumeric and may contain dashes or underscores", 2);
204
- }
205
- return [2 /*return*/, handoff.makeExportable(type, name_1)];
206
- case 18:
207
- templateComponent = args._[1];
208
- if (!templateComponent) {
209
- cliError("You must supply a component name", 2);
210
- }
211
- if (!/^[a-z0-9]+$/i.test(templateComponent)) {
212
- cliError("Template component must be alphanumeric and may contain dashes or underscores", 2);
213
- }
214
- templateState = args._[2];
215
- if (templateState && !/^[a-z0-9]+$/i.test(templateComponent)) {
216
- cliError("Template state must be alphanumeric and may contain dashes or underscores", 2);
217
- }
218
- return [2 /*return*/, handoff.makeTemplate(templateComponent, templateState)];
219
- case 19:
220
- pageName = args._[1];
221
- if (!pageName) {
222
- cliError("You must supply a page name", 2);
223
- }
224
- if (!/^[a-z0-9]+$/i.test(pageName)) {
225
- cliError("Page name must be alphanumeric and may contain dashes or underscores", 2);
226
- }
227
- pageParent = args._[2];
228
- if (pageParent && !/^[a-z0-9]+$/i.test(pageParent)) {
229
- cliError("Page parent must be alphanumeric and may contain dashes or underscores", 2);
230
- }
231
- return [2 /*return*/, handoff.makePage(pageName, pageParent)];
232
- case 20:
233
- snippetName = args._[1];
234
- if (!snippetName) {
235
- cliError("You must supply a snippet name", 2);
236
- }
237
- if (!/^[a-z0-9]+$/i.test(snippetName)) {
238
- cliError("Snippet name must be alphanumeric and may contain dashes or underscores", 2);
239
- }
240
- return [2 /*return*/, handoff.makeSnippet(snippetName)];
241
- case 21: return [2 /*return*/, handoff.makeIntegration()];
242
- case 22: return [2 /*return*/, showHelp()];
243
- case 23: return [3 /*break*/, 25];
244
- case 24:
245
- e_1 = _b.sent();
246
- if (e_1.message.indexOf('Unknown or unexpected option') === -1)
247
- throw e_1;
248
- return [2 /*return*/, cliError(e_1.message + "\n".concat(usage), 2)];
249
- case 25: return [2 /*return*/];
250
- }
251
- });
252
- }); };
253
- run(process.argv.slice(2), process.stdout, process.stderr)
254
- .then(function () {
255
- if (!watching) {
256
- process.exit(0);
55
+ var run = function () {
56
+ try {
57
+ var yargsInstance_1 = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv));
58
+ commands_1.commands.forEach(function (command) {
59
+ yargsInstance_1.command(command);
60
+ });
61
+ yargsInstance_1.help().version(showVersion()).strict().parse();
257
62
  }
258
- })
259
- .catch(function (e) {
260
- if (!e.silent)
261
- console.error(e.messageOnly ? e.message : e);
262
- process.exit(e.exitCode || 1);
263
- });
63
+ catch (e) {
64
+ if (e.message.indexOf('Unknown or unexpected option') === -1)
65
+ throw e;
66
+ return cliError(e.message, 2);
67
+ }
68
+ };
69
+ run();
@@ -0,0 +1,6 @@
1
+ import { CommandModule } from 'yargs';
2
+ import { SharedArgs } from '../types';
3
+ export interface BuildAppArgs extends SharedArgs {
4
+ }
5
+ declare const command: CommandModule<{}, BuildAppArgs>;
6
+ export default command;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var utils_1 = require("../utils");
43
+ var __1 = __importDefault(require("../../"));
44
+ var command = {
45
+ command: 'build:app',
46
+ describe: 'Build the documentation application',
47
+ builder: function (yargs) {
48
+ return (0, utils_1.getSharedOptions)(yargs);
49
+ },
50
+ handler: function (args) { return __awaiter(void 0, void 0, void 0, function () {
51
+ var handoff;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ handoff = new __1.default(args.debug, args.force, { integrationPath: args.integration });
56
+ return [4 /*yield*/, handoff.build()];
57
+ case 1:
58
+ _a.sent();
59
+ return [2 /*return*/];
60
+ }
61
+ });
62
+ }); },
63
+ };
64
+ exports.default = command;
@@ -0,0 +1,6 @@
1
+ import { CommandModule } from 'yargs';
2
+ import { SharedArgs } from '../types';
3
+ export interface BuildIntegrationArgs extends SharedArgs {
4
+ }
5
+ declare const command: CommandModule<{}, BuildIntegrationArgs>;
6
+ export default command;