@betty-blocks/cli 26.0.0-beta.14 → 26.0.0-beta.16

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 (149) hide show
  1. package/build/bb-blocks-new.js +10 -15
  2. package/build/bb-blocks-new.js.map +1 -1
  3. package/build/bb-blocks-publish.js +41 -55
  4. package/build/bb-blocks-publish.js.map +1 -1
  5. package/build/bb-blocks-release.js +6 -20
  6. package/build/bb-blocks-release.js.map +1 -1
  7. package/build/bb-blocks.js +2 -4
  8. package/build/bb-blocks.js.map +1 -1
  9. package/build/bb-bundle-init.js +15 -29
  10. package/build/bb-bundle-init.js.map +1 -1
  11. package/build/bb-bundle.js +4 -9
  12. package/build/bb-bundle.js.map +1 -1
  13. package/build/bb-components-build.js +165 -198
  14. package/build/bb-components-build.js.map +1 -1
  15. package/build/bb-components-create.js +15 -29
  16. package/build/bb-components-create.js.map +1 -1
  17. package/build/bb-components-generate.js +26 -40
  18. package/build/bb-components-generate.js.map +1 -1
  19. package/build/bb-components-publish-bundle.js +20 -34
  20. package/build/bb-components-publish-bundle.js.map +1 -1
  21. package/build/bb-components-publish.js +21 -35
  22. package/build/bb-components-publish.js.map +1 -1
  23. package/build/bb-components-serve.js +9 -14
  24. package/build/bb-components-serve.js.map +1 -1
  25. package/build/bb-components.js +3 -4
  26. package/build/bb-components.js.map +1 -1
  27. package/build/bb-functions-build.js +31 -33
  28. package/build/bb-functions-build.js.map +1 -1
  29. package/build/bb-functions-bump.js +25 -39
  30. package/build/bb-functions-bump.js.map +1 -1
  31. package/build/bb-functions-init.js +14 -19
  32. package/build/bb-functions-init.js.map +1 -1
  33. package/build/bb-functions-login.js +9 -23
  34. package/build/bb-functions-login.js.map +1 -1
  35. package/build/bb-functions-logout.js +6 -11
  36. package/build/bb-functions-logout.js.map +1 -1
  37. package/build/bb-functions-new.js +8 -13
  38. package/build/bb-functions-new.js.map +1 -1
  39. package/build/bb-functions-publish.js +26 -40
  40. package/build/bb-functions-publish.js.map +1 -1
  41. package/build/bb-functions-validate.js +18 -32
  42. package/build/bb-functions-validate.js.map +1 -1
  43. package/build/bb-functions.js +2 -4
  44. package/build/bb-functions.js.map +1 -1
  45. package/build/bb.js +7 -11
  46. package/build/bb.js.map +1 -1
  47. package/build/blocks/blockDefinitions.js +12 -21
  48. package/build/blocks/blockDefinitions.js.map +1 -1
  49. package/build/blocks/publishBlocks.js +34 -48
  50. package/build/blocks/publishBlocks.js.map +1 -1
  51. package/build/blocks/releaseBlocks.js +27 -43
  52. package/build/blocks/releaseBlocks.js.map +1 -1
  53. package/build/components/comments.js +15 -18
  54. package/build/components/comments.js.map +1 -1
  55. package/build/components/compatibility.js +13 -15
  56. package/build/components/compatibility.js.map +1 -1
  57. package/build/components/transformers/index.js +8 -14
  58. package/build/components/transformers/index.js.map +1 -1
  59. package/build/components-build/index.js +2 -18
  60. package/build/components-build/index.js.map +1 -1
  61. package/build/components-build/reportDiagnostics.js +4 -12
  62. package/build/components-build/reportDiagnostics.js.map +1 -1
  63. package/build/components-build/styles.js +35 -92
  64. package/build/components-build/styles.js.map +1 -1
  65. package/build/functions/acquireAppFunctionsProject.js +5 -10
  66. package/build/functions/acquireAppFunctionsProject.js.map +1 -1
  67. package/build/functions/acquireCustomFunctionsProject.js +5 -10
  68. package/build/functions/acquireCustomFunctionsProject.js.map +1 -1
  69. package/build/functions/bb-components-functions.js +12 -30
  70. package/build/functions/bb-components-functions.js.map +1 -1
  71. package/build/functions/config.js +88 -91
  72. package/build/functions/config.js.map +1 -1
  73. package/build/functions/functionDefinitions.js +42 -56
  74. package/build/functions/functionDefinitions.js.map +1 -1
  75. package/build/functions/icons.js +10 -16
  76. package/build/functions/icons.js.map +1 -1
  77. package/build/functions/publishAppFunctions.js +47 -63
  78. package/build/functions/publishAppFunctions.js.map +1 -1
  79. package/build/functions/publishCustomFunctions.js +53 -69
  80. package/build/functions/publishCustomFunctions.js.map +1 -1
  81. package/build/functions/publishFunctions.js +18 -33
  82. package/build/functions/publishFunctions.js.map +1 -1
  83. package/build/functions/utils.js +9 -13
  84. package/build/functions/utils.js.map +1 -1
  85. package/build/functions/validations.js +41 -59
  86. package/build/functions/validations.js.map +1 -1
  87. package/build/functions/versions.js +21 -27
  88. package/build/functions/versions.js.map +1 -1
  89. package/build/interactions/compatibility.js +8 -45
  90. package/build/interactions/compatibility.js.map +1 -1
  91. package/build/interactions/diagnostics.js +7 -10
  92. package/build/interactions/diagnostics.js.map +1 -1
  93. package/build/types.js +9 -11
  94. package/build/types.js.map +1 -1
  95. package/build/utils/arguments.js +2 -7
  96. package/build/utils/arguments.js.map +1 -1
  97. package/build/utils/checkPackageVersion.js +6 -19
  98. package/build/utils/checkPackageVersion.js.map +1 -1
  99. package/build/utils/checkUpdateAvailable.js +31 -47
  100. package/build/utils/checkUpdateAvailable.js.map +1 -1
  101. package/build/utils/fusionAuth.js +84 -108
  102. package/build/utils/fusionAuth.js.map +1 -1
  103. package/build/utils/hash.js +2 -7
  104. package/build/utils/hash.js.map +1 -1
  105. package/build/utils/ide.js +111 -133
  106. package/build/utils/ide.js.map +1 -1
  107. package/build/utils/login.js +62 -78
  108. package/build/utils/login.js.map +1 -1
  109. package/build/utils/pick.js +1 -5
  110. package/build/utils/pick.js.map +1 -1
  111. package/build/utils/readFilesByType.js +13 -27
  112. package/build/utils/readFilesByType.js.map +1 -1
  113. package/build/utils/rootDir.js +3 -8
  114. package/build/utils/rootDir.js.map +1 -1
  115. package/build/utils/serveComponentSet.js +15 -29
  116. package/build/utils/serveComponentSet.js.map +1 -1
  117. package/build/utils/transpile.js +10 -15
  118. package/build/utils/transpile.js.map +1 -1
  119. package/build/utils/uploadBlob.js +22 -36
  120. package/build/utils/uploadBlob.js.map +1 -1
  121. package/build/utils/validation.js +9 -18
  122. package/build/utils/validation.js.map +1 -1
  123. package/build/validations/component.js +32 -37
  124. package/build/validations/component.js.map +1 -1
  125. package/build/validations/constants.js +16 -19
  126. package/build/validations/constants.js.map +1 -1
  127. package/build/validations/function-block-validations/index.js +27 -44
  128. package/build/validations/function-block-validations/index.js.map +1 -1
  129. package/build/validations/interaction.js +11 -16
  130. package/build/validations/interaction.js.map +1 -1
  131. package/build/validations/prefab/action.js +54 -60
  132. package/build/validations/prefab/action.js.map +1 -1
  133. package/build/validations/prefab/component.js +97 -102
  134. package/build/validations/prefab/component.js.map +1 -1
  135. package/build/validations/prefab/componentOption.js +125 -102
  136. package/build/validations/prefab/componentOption.js.map +1 -1
  137. package/build/validations/prefab/interaction.js +22 -28
  138. package/build/validations/prefab/interaction.js.map +1 -1
  139. package/build/validations/prefab/linkedOption.js +29 -35
  140. package/build/validations/prefab/linkedOption.js.map +1 -1
  141. package/build/validations/prefab/linkedPartial.js +21 -27
  142. package/build/validations/prefab/linkedPartial.js.map +1 -1
  143. package/build/validations/prefab/variable.js +20 -26
  144. package/build/validations/prefab/variable.js.map +1 -1
  145. package/build/validations/prefab.js +34 -39
  146. package/build/validations/prefab.js.map +1 -1
  147. package/build/validations/styles.js +31 -37
  148. package/build/validations/styles.js.map +1 -1
  149. package/package.json +2 -2
@@ -1,85 +1,27 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __rest = (this && this.__rest) || function (s, e) {
45
- var t = {};
46
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
47
- t[p] = s[p];
48
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
49
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
50
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
51
- t[p[i]] = s[p[i]];
52
- }
53
- return t;
54
- };
55
- var __importDefault = (this && this.__importDefault) || function (mod) {
56
- return (mod && mod.__esModule) ? mod : { "default": mod };
57
- };
58
- Object.defineProperty(exports, "__esModule", { value: true });
59
- const chalk_1 = __importDefault(require("chalk"));
60
- const commander_1 = require("commander");
61
- const fs_1 = __importDefault(require("fs"));
62
- const fs_extra_1 = require("fs-extra");
63
- const ora_1 = __importDefault(require("ora"));
64
- const path_1 = __importDefault(require("path"));
65
- const typescript_1 = __importStar(require("typescript"));
66
- const compatibility_1 = __importDefault(require("./components/compatibility"));
67
- const transformers_1 = require("./components/transformers");
68
- const components_build_1 = require("./components-build");
69
- const compatibility_2 = __importDefault(require("./interactions/compatibility"));
70
- const diagnostics_1 = __importDefault(require("./interactions/diagnostics"));
71
- const arguments_1 = require("./utils/arguments");
72
- const checkPackageVersion_1 = require("./utils/checkPackageVersion");
73
- const checkUpdateAvailable_1 = require("./utils/checkUpdateAvailable");
74
- const hash_1 = __importDefault(require("./utils/hash"));
75
- const readFilesByType_1 = __importDefault(require("./utils/readFilesByType"));
76
- const transpile_1 = __importDefault(require("./utils/transpile"));
77
- const validation_1 = require("./utils/validation");
78
- const component_1 = __importDefault(require("./validations/component"));
79
- const interaction_1 = __importDefault(require("./validations/interaction"));
80
- const prefab_1 = __importDefault(require("./validations/prefab"));
81
- const styles_1 = __importDefault(require("./validations/styles"));
82
- const program = new commander_1.Command();
1
+ import chalk from 'chalk';
2
+ import { Command } from 'commander';
3
+ import fs from 'fs';
4
+ import { ensureDir, outputJson, pathExists, readFile, readFileSync, remove, } from 'fs-extra';
5
+ import ora from 'ora';
6
+ import path from 'path';
7
+ import ts, { JsxEmit, ModuleKind, ScriptTarget } from 'typescript';
8
+ import extractComponentCompatibility from './components/compatibility';
9
+ import { doTranspile } from './components/transformers';
10
+ import { buildReferenceStyle, buildStyle, readStyles, reportDiagnostics, } from './components-build';
11
+ import extractInteractionCompatibility from './interactions/compatibility';
12
+ import getDiagnostics from './interactions/diagnostics';
13
+ import { parseDir } from './utils/arguments';
14
+ import { checkPackageVersion } from './utils/checkPackageVersion';
15
+ import { checkUpdateAvailableCLI } from './utils/checkUpdateAvailable';
16
+ import hash from './utils/hash';
17
+ import readFilesByType from './utils/readFilesByType';
18
+ import transpile from './utils/transpile';
19
+ import { checkNameReferences, checkOptionCategoryReferences, } from './utils/validation';
20
+ import validateComponents from './validations/component';
21
+ import validateInteractions from './validations/interaction';
22
+ import validatePrefabs from './validations/prefab';
23
+ import validateStyles from './validations/styles';
24
+ const program = new Command();
83
25
  program
84
26
  .usage('[path]')
85
27
  .name('bb components build')
@@ -89,7 +31,7 @@ program
89
31
  .parse(process.argv);
90
32
  const { args } = program;
91
33
  const options = program.opts();
92
- const rootDir = (0, arguments_1.parseDir)(args);
34
+ const rootDir = parseDir(args);
93
35
  const distDir = `${rootDir}/dist`;
94
36
  const enableNewTranspile = !!options.transpile;
95
37
  const arg = process.argv.slice(2);
@@ -97,104 +39,107 @@ const startTime = Date.now();
97
39
  const buildAll = !arg.includes('--fast');
98
40
  const hasOfflineFlag = arg.includes('--offline');
99
41
  /* execute command */
100
- const readComponents = () => __awaiter(void 0, void 0, void 0, function* () {
42
+ const readComponents = async () => {
101
43
  const srcDir = `${rootDir}/src/components`;
102
- const exists = yield (0, fs_extra_1.pathExists)(srcDir);
44
+ const exists = await pathExists(srcDir);
103
45
  if (!exists) {
104
- throw new Error(chalk_1.default.red('\nComponents folder not found\n'));
46
+ throw new Error(chalk.red('\nComponents folder not found\n'));
105
47
  }
106
- const componentFiles = yield (0, readFilesByType_1.default)(srcDir, 'js', buildAll);
107
- const components = componentFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
48
+ const componentFiles = await readFilesByType(srcDir, 'js', buildAll);
49
+ const components = componentFiles.map(async (file) => {
108
50
  try {
109
- const code = yield (0, fs_extra_1.readFile)(`${srcDir}/${file}`, 'utf-8');
110
- const compatibility = (0, compatibility_1.default)(code);
111
- const transpiledFunction = Function(`return ${(0, transpile_1.default)(code, ['jsx', 'styles'])}`)();
51
+ const code = await readFile(`${srcDir}/${file}`, 'utf-8');
52
+ const compatibility = extractComponentCompatibility(code);
53
+ const transpiledFunction = Function(`return ${transpile(code, ['jsx', 'styles'])}`)();
112
54
  if (!transpiledFunction) {
113
55
  throw new Error("Component doesn't return anything");
114
56
  }
115
57
  if (enableNewTranspile) {
116
- transpiledFunction.transpiledJsx = (0, transformers_1.doTranspile)(transpiledFunction.jsx);
117
- transpiledFunction.transpiledStyles = (0, transformers_1.doTranspile)(transpiledFunction.styles);
58
+ transpiledFunction.transpiledJsx = doTranspile(transpiledFunction.jsx);
59
+ transpiledFunction.transpiledStyles = doTranspile(transpiledFunction.styles);
118
60
  }
119
61
  if (transpiledFunction.dependencies && !hasOfflineFlag) {
120
62
  const usedPackages = transpiledFunction.dependencies.map((usedDependency) => usedDependency.package);
121
- const dependencyPromises = usedPackages.map((usedPackage) => __awaiter(void 0, void 0, void 0, function* () {
122
- yield (0, checkPackageVersion_1.checkPackageVersion)(usedPackage.replace(/^npm:/g, ''));
123
- }));
124
- yield Promise.all(dependencyPromises);
63
+ const dependencyPromises = usedPackages.map(async (usedPackage) => {
64
+ await checkPackageVersion(usedPackage.replace(/^npm:/g, ''));
65
+ });
66
+ await Promise.all(dependencyPromises);
125
67
  }
126
- return Object.assign(Object.assign({}, compatibility), transpiledFunction);
68
+ return {
69
+ ...compatibility,
70
+ ...transpiledFunction,
71
+ };
127
72
  }
128
73
  catch (error) {
129
74
  throw new Error(`in ${file}: ${error}`);
130
75
  }
131
- }));
76
+ });
132
77
  return Promise.all(components);
133
- });
134
- const readtsPrefabs = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (isPartial = false) {
135
- var _a;
136
- const absoluteRootDir = path_1.default.resolve(process.cwd(), rootDir);
78
+ };
79
+ const readtsPrefabs = async (isPartial = false) => {
80
+ const absoluteRootDir = path.resolve(process.cwd(), rootDir);
137
81
  const srcDir = `${absoluteRootDir}/src/prefabs`;
138
82
  const outDir = `${absoluteRootDir}/tmp/${Math.floor(Date.now() / 1000)}`;
139
- const exists = yield (0, fs_extra_1.pathExists)(srcDir);
83
+ const exists = await pathExists(srcDir);
140
84
  if (!exists) {
141
- throw new Error(chalk_1.default.red('\nPrefabs folder not found\n'));
85
+ throw new Error(chalk.red('\nPrefabs folder not found\n'));
142
86
  }
143
87
  let prefabTsFiles = [];
144
88
  let prefabTsxFiles = [];
145
89
  let partialTsxFiles = [];
146
90
  if (isPartial) {
147
- partialTsxFiles = yield (0, readFilesByType_1.default)(`${srcDir}/partials`, 'tsx', buildAll);
91
+ partialTsxFiles = await readFilesByType(`${srcDir}/partials`, 'tsx', buildAll);
148
92
  }
149
93
  else {
150
- prefabTsFiles = yield (0, readFilesByType_1.default)(srcDir, 'ts', buildAll);
151
- prefabTsxFiles = yield (0, readFilesByType_1.default)(srcDir, 'tsx', buildAll);
94
+ prefabTsFiles = await readFilesByType(srcDir, 'ts', buildAll);
95
+ prefabTsxFiles = await readFilesByType(srcDir, 'tsx', buildAll);
152
96
  }
153
97
  const prefabFiles = [...prefabTsFiles, ...prefabTsxFiles];
154
98
  const files = isPartial ? partialTsxFiles : prefabFiles;
155
99
  const basePath = isPartial ? `${srcDir}/partials/` : `${srcDir}/`;
156
- const prefabProgram = typescript_1.default.createProgram(files.map((file) => `${basePath}/${file}`), {
100
+ const prefabProgram = ts.createProgram(files.map((file) => `${basePath}/${file}`), {
157
101
  allowSyntheticDefaultImports: false,
158
102
  esModuleInterop: true,
159
- jsx: typescript_1.JsxEmit.React,
103
+ jsx: JsxEmit.React,
160
104
  listEmittedFiles: true,
161
- module: typescript_1.ModuleKind.CommonJS,
105
+ module: ModuleKind.CommonJS,
162
106
  outDir,
163
- target: typescript_1.ScriptTarget.ESNext,
107
+ target: ScriptTarget.ESNext,
164
108
  });
165
- const diagnostics = [...typescript_1.default.getPreEmitDiagnostics(prefabProgram)];
109
+ const diagnostics = [...ts.getPreEmitDiagnostics(prefabProgram)];
166
110
  if (diagnostics.length > 0) {
167
- (0, components_build_1.reportDiagnostics)(diagnostics);
111
+ reportDiagnostics(diagnostics);
168
112
  process.exit(1);
169
113
  }
170
114
  const results = prefabProgram.emit();
171
115
  if (results.diagnostics.length > 0) {
172
- (0, components_build_1.reportDiagnostics)([...results.diagnostics]);
116
+ reportDiagnostics([...results.diagnostics]);
173
117
  process.exit(1);
174
118
  }
175
119
  const globalDiagnostics = [...prefabProgram.getGlobalDiagnostics()];
176
120
  if (globalDiagnostics.length > 0) {
177
- (0, components_build_1.reportDiagnostics)(globalDiagnostics);
121
+ reportDiagnostics(globalDiagnostics);
178
122
  process.exit(1);
179
123
  }
180
124
  const declarationDiagnostics = [...prefabProgram.getDeclarationDiagnostics()];
181
125
  if (declarationDiagnostics.length > 0) {
182
- (0, components_build_1.reportDiagnostics)(declarationDiagnostics);
126
+ reportDiagnostics(declarationDiagnostics);
183
127
  process.exit(1);
184
128
  }
185
129
  const configDiagnostics = [
186
130
  ...prefabProgram.getConfigFileParsingDiagnostics(),
187
131
  ];
188
132
  if (configDiagnostics.length > 0) {
189
- (0, components_build_1.reportDiagnostics)(configDiagnostics);
133
+ reportDiagnostics(configDiagnostics);
190
134
  process.exit(1);
191
135
  }
192
- const prefabs = ((_a = results.emittedFiles) !== null && _a !== void 0 ? _a : [])
136
+ const prefabs = (results.emittedFiles ?? [])
193
137
  .filter((filename) => isPartial
194
138
  ? /prefabs\/partials\/\w+\.js$/.test(filename)
195
139
  : /prefabs\/\w+\.js$/.test(filename))
196
140
  .map((filename) => new Promise((resolve) => {
197
- Promise.resolve(`${filename}`).then(s => __importStar(require(s))).then((prefab) => {
141
+ import(filename)
142
+ .then((prefab) => {
198
143
  // JSON schema validation
199
144
  resolve(prefab.default);
200
145
  })
@@ -203,18 +148,18 @@ const readtsPrefabs = (...args_1) => __awaiter(void 0, [...args_1], void 0, func
203
148
  });
204
149
  }));
205
150
  return Promise.all(prefabs);
206
- });
207
- const readPrefabs = () => __awaiter(void 0, void 0, void 0, function* () {
151
+ };
152
+ const readPrefabs = async () => {
208
153
  const srcDir = `${rootDir}/src/prefabs`;
209
- const exists = yield (0, fs_extra_1.pathExists)(srcDir);
154
+ const exists = await pathExists(srcDir);
210
155
  if (!exists) {
211
- throw new Error(chalk_1.default.red('\nPrefabs folder not found\n'));
156
+ throw new Error(chalk.red('\nPrefabs folder not found\n'));
212
157
  }
213
- const prefabFiles = yield (0, readFilesByType_1.default)(srcDir, 'js', buildAll);
214
- const prefabs = prefabFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
158
+ const prefabFiles = await readFilesByType(srcDir, 'js', buildAll);
159
+ const prefabs = prefabFiles.map(async (file) => {
215
160
  try {
216
- const code = yield (0, fs_extra_1.readFile)(`${srcDir}/${file}`, 'utf-8');
217
- const transpiledFunction = Function(`return ${(0, transpile_1.default)(code, ['beforeCreate'])}`)();
161
+ const code = await readFile(`${srcDir}/${file}`, 'utf-8');
162
+ const transpiledFunction = Function(`return ${transpile(code, ['beforeCreate'])}`)();
218
163
  if (!transpiledFunction) {
219
164
  throw new Error("Prefab doesn't return anything");
220
165
  }
@@ -223,20 +168,20 @@ const readPrefabs = () => __awaiter(void 0, void 0, void 0, function* () {
223
168
  catch (error) {
224
169
  throw new Error(`in ${file}: ${error}`);
225
170
  }
226
- }));
171
+ });
227
172
  return Promise.all(prefabs);
228
- });
229
- const readPartialPrefabs = () => __awaiter(void 0, void 0, void 0, function* () {
173
+ };
174
+ const readPartialPrefabs = async () => {
230
175
  const srcDir = `${rootDir}/src/prefabs/partials`;
231
- const exists = yield (0, fs_extra_1.pathExists)(srcDir);
176
+ const exists = await pathExists(srcDir);
232
177
  if (!exists) {
233
- yield (0, fs_extra_1.ensureDir)(srcDir);
178
+ await ensureDir(srcDir);
234
179
  }
235
- const partialPrefabFiles = yield (0, readFilesByType_1.default)(srcDir, 'js', buildAll);
236
- const partialPrefabs = partialPrefabFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
180
+ const partialPrefabFiles = await readFilesByType(srcDir, 'js', buildAll);
181
+ const partialPrefabs = partialPrefabFiles.map(async (file) => {
237
182
  try {
238
- const code = yield (0, fs_extra_1.readFile)(`${srcDir}/${file}`, 'utf-8');
239
- const transpiledFunction = Function(`return ${(0, transpile_1.default)(code, ['beforeCreate'])}`)();
183
+ const code = await readFile(`${srcDir}/${file}`, 'utf-8');
184
+ const transpiledFunction = Function(`return ${transpile(code, ['beforeCreate'])}`)();
240
185
  if (!transpiledFunction) {
241
186
  throw new Error("Prefab doesn't return anything");
242
187
  }
@@ -245,36 +190,38 @@ const readPartialPrefabs = () => __awaiter(void 0, void 0, void 0, function* ()
245
190
  catch (error) {
246
191
  throw new Error(`in ${file}: ${error}`);
247
192
  }
248
- }));
193
+ });
249
194
  return Promise.all(partialPrefabs);
250
- });
251
- const readInteractions = () => __awaiter(void 0, void 0, void 0, function* () {
195
+ };
196
+ const readInteractions = async () => {
252
197
  const srcDir = `${rootDir}/src/interactions`;
253
- const exists = yield (0, fs_extra_1.pathExists)(srcDir);
198
+ const exists = await pathExists(srcDir);
254
199
  if (!exists) {
255
200
  return new Promise((resolve) => {
256
201
  resolve([]);
257
202
  });
258
203
  }
259
- const interactionFiles = yield (0, readFilesByType_1.default)(srcDir, 'ts', buildAll);
260
- return Promise.all(interactionFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
204
+ const interactionFiles = await readFilesByType(srcDir, 'ts', buildAll);
205
+ return Promise.all(interactionFiles.map(async (file) => {
261
206
  try {
262
- (0, diagnostics_1.default)(`${srcDir}/${file}`);
263
- return Object.assign({}, (0, compatibility_2.default)(`${srcDir}/${file}`));
207
+ getDiagnostics(`${srcDir}/${file}`);
208
+ return {
209
+ ...extractInteractionCompatibility(`${srcDir}/${file}`),
210
+ };
264
211
  }
265
212
  catch (error) {
266
213
  throw new Error(`in ${file}: ${error}`);
267
214
  }
268
- })));
269
- });
270
- void (() => __awaiter(void 0, void 0, void 0, function* () {
215
+ }));
216
+ };
217
+ void (async () => {
271
218
  if (!hasOfflineFlag) {
272
- yield (0, checkUpdateAvailable_1.checkUpdateAvailableCLI)();
219
+ await checkUpdateAvailableCLI();
273
220
  }
274
- const buildStart = (0, ora_1.default)(`Building component set...`).start();
221
+ const buildStart = ora(`Building component set...`).start();
275
222
  try {
276
- const [styles, tsxPrefabs, jsPrefabs, components, interactions, tsxPartialPrefabs, partialprefabs,] = yield Promise.all([
277
- (0, components_build_1.readStyles)(rootDir),
223
+ const [styles, tsxPrefabs, jsPrefabs, components, interactions, tsxPartialPrefabs, partialprefabs,] = await Promise.all([
224
+ readStyles(rootDir),
278
225
  readtsPrefabs(),
279
226
  readPrefabs(),
280
227
  readComponents(),
@@ -282,10 +229,10 @@ void (() => __awaiter(void 0, void 0, void 0, function* () {
282
229
  readPartialPrefabs(),
283
230
  readtsPrefabs(true),
284
231
  ]);
285
- const templatesPath = path_1.default.join(distDir, 'templates.json');
232
+ const templatesPath = path.join(distDir, 'templates.json');
286
233
  let existingComponents = [];
287
- if (fs_1.default.existsSync(templatesPath)) {
288
- const templatesData = fs_1.default.readFileSync(templatesPath, 'utf8');
234
+ if (fs.existsSync(templatesPath)) {
235
+ const templatesData = fs.readFileSync(templatesPath, 'utf8');
289
236
  existingComponents = JSON.parse(templatesData);
290
237
  }
291
238
  else {
@@ -302,11 +249,17 @@ void (() => __awaiter(void 0, void 0, void 0, function* () {
302
249
  const stylesGroupedByTypeAndName = styles.reduce((object, e) => {
303
250
  const { name, type } = e;
304
251
  const byType = object[type] || {};
305
- return Object.assign(Object.assign({}, object), { [type]: Object.assign(Object.assign({}, byType), { [name]: e }) });
252
+ return {
253
+ ...object,
254
+ [type]: {
255
+ ...byType,
256
+ [name]: e,
257
+ },
258
+ };
306
259
  }, {});
307
260
  let finalComponents;
308
- if (fs_1.default.existsSync(templatesPath)) {
309
- const templatesData = fs_1.default.readFileSync(templatesPath, 'utf8');
261
+ if (fs.existsSync(templatesPath)) {
262
+ const templatesData = fs.readFileSync(templatesPath, 'utf8');
310
263
  finalComponents = JSON.parse(templatesData);
311
264
  }
312
265
  else {
@@ -314,7 +267,7 @@ void (() => __awaiter(void 0, void 0, void 0, function* () {
314
267
  finalComponents = components;
315
268
  }
316
269
  const componentNames = finalComponents.map(({ name }) => name);
317
- (0, validation_1.checkNameReferences)(prefabs, finalComponents);
270
+ checkNameReferences(prefabs, finalComponents);
318
271
  const { availableNames: availableComponentNames, styleMap: componentStyleMap, } = components.reduce(({ availableNames, styleMap }, component) => {
319
272
  const newNames = availableNames.includes(component.name)
320
273
  ? availableNames
@@ -326,71 +279,85 @@ void (() => __awaiter(void 0, void 0, void 0, function* () {
326
279
  : styleMap;
327
280
  return { availableNames: newNames, styleMap: newStyleMap };
328
281
  }, { availableNames: [], styleMap: {} });
329
- yield Promise.all([
330
- (0, styles_1.default)(styles, componentNames),
331
- (0, component_1.default)(components, validStyleTypes),
332
- (0, prefab_1.default)({
282
+ await Promise.all([
283
+ validateStyles(styles, componentNames),
284
+ validateComponents(components, validStyleTypes),
285
+ validatePrefabs({
333
286
  availableComponentNames,
334
287
  componentStyleMap,
335
288
  prefabs,
336
289
  styles: stylesGroupedByTypeAndName,
337
290
  }),
338
- (0, prefab_1.default)({
291
+ validatePrefabs({
339
292
  availableComponentNames,
340
293
  componentStyleMap,
341
294
  prefabType: 'partial',
342
295
  prefabs: allPartialPrefabs,
343
296
  styles: stylesGroupedByTypeAndName,
344
297
  }),
345
- interactions && (0, interaction_1.default)(interactions),
298
+ interactions && validateInteractions(interactions),
346
299
  ]);
347
- (0, validation_1.checkOptionCategoryReferences)(prefabs);
348
- const componentsWithHash = components.map((component) => (Object.assign(Object.assign({}, component), { componentHash: (0, hash_1.default)(component) })));
300
+ checkOptionCategoryReferences(prefabs);
301
+ const componentsWithHash = components.map((component) => ({
302
+ ...component,
303
+ componentHash: hash(component),
304
+ }));
349
305
  const buildPrefab = (prefab) => {
350
306
  const buildStructure = (structure) => {
351
307
  if (structure.type === 'PARTIAL') {
352
308
  return structure;
353
309
  }
354
310
  if (structure.type === 'WRAPPER') {
355
- const { descendants = [] } = structure, rest = __rest(structure, ["descendants"]);
356
- const wrapperStructure = Object.assign(Object.assign({}, rest), { descendants: descendants.map(buildStructure) });
311
+ const { descendants = [], ...rest } = structure;
312
+ const wrapperStructure = {
313
+ ...rest,
314
+ descendants: descendants.map(buildStructure),
315
+ };
357
316
  return wrapperStructure;
358
317
  }
359
- const { style, descendants } = structure, rest = __rest(structure, ["style", "descendants"]);
360
- const styleReference = (0, components_build_1.buildReferenceStyle)(style);
361
- const newStructure = Object.assign(Object.assign(Object.assign({}, rest), (styleReference ? { style: styleReference } : {})), { descendants: descendants.map(buildStructure), hash: (0, hash_1.default)(structure.options) });
318
+ const { style, descendants, ...rest } = structure;
319
+ const styleReference = buildReferenceStyle(style);
320
+ const newStructure = {
321
+ ...rest,
322
+ ...(styleReference ? { style: styleReference } : {}),
323
+ descendants: descendants.map(buildStructure),
324
+ hash: hash(structure.options),
325
+ };
362
326
  return newStructure;
363
327
  };
364
- return Object.assign(Object.assign({}, prefab), { structure: prefab.structure.map(buildStructure) });
328
+ return {
329
+ ...prefab,
330
+ structure: prefab.structure.map(buildStructure),
331
+ };
365
332
  };
366
- const buildStyles = styles.map(components_build_1.buildStyle);
333
+ const buildStyles = styles.map(buildStyle);
367
334
  const buildPrefabs = prefabs.map(buildPrefab);
368
335
  const buildPartialprefabs = allPartialPrefabs.map(buildPrefab);
369
- yield (0, fs_extra_1.ensureDir)(distDir);
336
+ await ensureDir(distDir);
370
337
  const defaultPrefabs = buildPrefabs.filter((prefab) => prefab.type !== 'page');
371
338
  const pagePrefabs = prefabs.filter((prefab) => prefab.type === 'page');
372
- const existingPath = yield (0, fs_extra_1.pathExists)(`${distDir}/pagePrefabs.json`);
373
- const existingPartialPath = yield (0, fs_extra_1.pathExists)(`${distDir}/partials.json`);
339
+ const existingPath = await pathExists(`${distDir}/pagePrefabs.json`);
340
+ const existingPartialPath = await pathExists(`${distDir}/partials.json`);
374
341
  if (buildAll) {
375
342
  const outputPromises = [
376
- (0, fs_extra_1.outputJson)(`${distDir}/prefabs.json`, defaultPrefabs),
377
- (0, fs_extra_1.outputJson)(`${distDir}/templates.json`, componentsWithHash),
343
+ outputJson(`${distDir}/prefabs.json`, defaultPrefabs),
344
+ outputJson(`${distDir}/templates.json`, componentsWithHash),
378
345
  interactions &&
379
- (0, fs_extra_1.outputJson)(`${distDir}/interactions.json`, interactions),
346
+ outputJson(`${distDir}/interactions.json`, interactions),
380
347
  ];
381
348
  if (buildStyles.length > 0) {
382
- outputPromises.push((0, fs_extra_1.outputJson)(`${distDir}/styles.json`, buildStyles));
349
+ outputPromises.push(outputJson(`${distDir}/styles.json`, buildStyles));
383
350
  }
384
351
  if (pagePrefabs.length > 0) {
385
- outputPromises.push((0, fs_extra_1.outputJson)(`${distDir}/pagePrefabs.json`, pagePrefabs));
352
+ outputPromises.push(outputJson(`${distDir}/pagePrefabs.json`, pagePrefabs));
386
353
  }
387
354
  if (buildPartialprefabs.length > 0) {
388
- outputPromises.push((0, fs_extra_1.outputJson)(`${distDir}/partials.json`, buildPartialprefabs));
355
+ outputPromises.push(outputJson(`${distDir}/partials.json`, buildPartialprefabs));
389
356
  }
390
- yield Promise.all(outputPromises);
357
+ await Promise.all(outputPromises);
391
358
  }
392
359
  else {
393
- const existingPrefabs = JSON.parse((0, fs_extra_1.readFileSync)(`${distDir}/prefabs.json`, 'utf8'));
360
+ const existingPrefabs = JSON.parse(readFileSync(`${distDir}/prefabs.json`, 'utf8'));
394
361
  const replaceInSet = (existingElements, newElements) => existingElements.map((existingElement) => {
395
362
  if (newElements.length > 0 &&
396
363
  existingElement.name === newElements[0].name) {
@@ -400,34 +367,34 @@ void (() => __awaiter(void 0, void 0, void 0, function* () {
400
367
  });
401
368
  const updatedPrefabs = replaceInSet(existingPrefabs, prefabs);
402
369
  const updatedComponents = replaceInSet(existingComponents, componentsWithHash);
403
- const existingInteractions = JSON.parse((0, fs_extra_1.readFileSync)(`${distDir}/interactions.json`, 'utf8'));
370
+ const existingInteractions = JSON.parse(readFileSync(`${distDir}/interactions.json`, 'utf8'));
404
371
  const updatedInteractions = replaceInSet(existingInteractions, interactions);
405
372
  const newOutputPromises = [
406
- (0, fs_extra_1.outputJson)(`${distDir}/prefabs.json`, updatedPrefabs),
407
- (0, fs_extra_1.outputJson)(`${distDir}/templates.json`, updatedComponents),
373
+ outputJson(`${distDir}/prefabs.json`, updatedPrefabs),
374
+ outputJson(`${distDir}/templates.json`, updatedComponents),
408
375
  interactions &&
409
- (0, fs_extra_1.outputJson)(`${distDir}/interactions.json`, updatedInteractions),
376
+ outputJson(`${distDir}/interactions.json`, updatedInteractions),
410
377
  ];
411
- const existingPagePrefabs = JSON.parse((0, fs_extra_1.readFileSync)(`${distDir}/pagePrefabs.json`, 'utf8'));
378
+ const existingPagePrefabs = JSON.parse(readFileSync(`${distDir}/pagePrefabs.json`, 'utf8'));
412
379
  const updatedPagePrefabs = replaceInSet(existingPagePrefabs, pagePrefabs);
413
380
  if (existingPath && pagePrefabs.length > 0) {
414
- newOutputPromises.push((0, fs_extra_1.outputJson)(`${distDir}/pagePrefabs.json`, updatedPagePrefabs));
381
+ newOutputPromises.push(outputJson(`${distDir}/pagePrefabs.json`, updatedPagePrefabs));
415
382
  }
416
- const existingPartials = JSON.parse((0, fs_extra_1.readFileSync)(`${distDir}/partials.json`, 'utf8'));
383
+ const existingPartials = JSON.parse(readFileSync(`${distDir}/partials.json`, 'utf8'));
417
384
  const updatedPartials = replaceInSet(existingPartials, buildPartialprefabs);
418
385
  if (existingPartialPath && buildPartialprefabs.length > 0) {
419
- newOutputPromises.push((0, fs_extra_1.outputJson)(`${distDir}/partials.json`, updatedPartials));
386
+ newOutputPromises.push(outputJson(`${distDir}/partials.json`, updatedPartials));
420
387
  }
421
- yield Promise.all(newOutputPromises);
388
+ await Promise.all(newOutputPromises);
422
389
  }
423
390
  if (buildPartialprefabs.length === 0 && existingPartialPath && buildAll) {
424
- yield (0, fs_extra_1.remove)(`${distDir}/partials.json`);
391
+ await remove(`${distDir}/partials.json`);
425
392
  }
426
393
  if (pagePrefabs.length === 0 && existingPath && buildAll) {
427
- yield (0, fs_extra_1.remove)(`${distDir}/pagePrefabs.json`);
394
+ await remove(`${distDir}/pagePrefabs.json`);
428
395
  }
429
396
  buildStart.succeed();
430
- console.info(chalk_1.default.green('Success, the component set has been built'));
397
+ console.info(chalk.green('Success, the component set has been built'));
431
398
  }
432
399
  catch (error) {
433
400
  // Handle both Error objects and custom error objects
@@ -445,5 +412,5 @@ void (() => __awaiter(void 0, void 0, void 0, function* () {
445
412
  throw new Error(`An unknown error occurred: ${error}`);
446
413
  }
447
414
  console.info(`Total time: ${(Date.now() - startTime) / 1000} seconds`);
448
- }))();
415
+ })();
449
416
  //# sourceMappingURL=bb-components-build.js.map