handoff-app 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +18 -0
- package/dist/app.js +43 -20
- package/dist/cli/eject.js +1 -1
- package/dist/cli.js +18 -212
- package/dist/commands/build/app.d.ts +6 -0
- package/dist/commands/build/app.js +64 -0
- package/dist/commands/build/integration.d.ts +6 -0
- package/dist/commands/build/integration.js +64 -0
- package/dist/commands/build/recipe.d.ts +6 -0
- package/dist/commands/build/recipe.js +64 -0
- package/dist/commands/build/snippets.d.ts +7 -0
- package/dist/commands/build/snippets.js +67 -0
- package/dist/commands/dev/index.d.ts +6 -0
- package/dist/commands/dev/index.js +64 -0
- package/dist/commands/eject/config.d.ts +6 -0
- package/dist/commands/eject/config.js +64 -0
- package/dist/commands/eject/exportables.d.ts +6 -0
- package/dist/commands/eject/exportables.js +64 -0
- package/dist/commands/eject/integration.d.ts +6 -0
- package/dist/commands/eject/integration.js +64 -0
- package/dist/commands/eject/pages.d.ts +6 -0
- package/dist/commands/eject/pages.js +64 -0
- package/dist/commands/eject/schemas.d.ts +6 -0
- package/dist/commands/eject/schemas.js +64 -0
- package/dist/commands/eject/theme.d.ts +6 -0
- package/dist/commands/eject/theme.js +64 -0
- package/dist/commands/fetch/index.d.ts +6 -0
- package/dist/commands/fetch/index.js +64 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +48 -0
- package/dist/commands/make/exportable.d.ts +8 -0
- package/dist/commands/make/exportable.js +78 -0
- package/dist/commands/make/integration.d.ts +6 -0
- package/dist/commands/make/integration.js +64 -0
- package/dist/commands/make/page.d.ts +8 -0
- package/dist/commands/make/page.js +82 -0
- package/dist/commands/make/schema.d.ts +8 -0
- package/dist/commands/make/schema.js +78 -0
- package/dist/commands/make/snippet.d.ts +7 -0
- package/dist/commands/make/snippet.js +72 -0
- package/dist/commands/make/template.d.ts +8 -0
- package/dist/commands/make/template.js +82 -0
- package/dist/commands/rename/snippet.d.ts +8 -0
- package/dist/commands/rename/snippet.js +72 -0
- package/dist/commands/start/index.d.ts +6 -0
- package/dist/commands/start/index.js +64 -0
- package/dist/commands/types.d.ts +6 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/utils.d.ts +23 -0
- package/dist/commands/utils.js +28 -0
- package/dist/config.js +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +21 -12
- package/dist/pipeline.js +1 -1
- package/dist/transformers/font/index.js +7 -6
- package/dist/transformers/integration/index.d.ts +1 -0
- package/dist/transformers/integration/index.js +2 -1
- package/dist/transformers/preview/index.js +24 -22
- package/dist/transformers/utils.d.ts +2 -8
- package/dist/utils/numbers.js +2 -2
- package/dist/utils/preview.js +6 -4
- package/dist/utils/prompt.d.ts +1 -1
- package/dist/utils/prompt.js +49 -8
- package/package.json +4 -2
- package/src/app/components/util/index.ts +2 -1
- package/src/app/next.config.mjs +2 -0
- package/src/app.ts +16 -2
- package/src/cli/eject.ts +1 -1
- package/src/cli.ts +13 -214
- package/src/commands/build/app.ts +20 -0
- package/src/commands/build/integration.ts +20 -0
- package/src/commands/build/recipe.ts +20 -0
- package/src/commands/build/snippets.ts +25 -0
- package/src/commands/dev/index.ts +20 -0
- package/src/commands/eject/config.ts +20 -0
- package/src/commands/eject/exportables.ts +20 -0
- package/src/commands/eject/integration.ts +20 -0
- package/src/commands/eject/pages.ts +20 -0
- package/src/commands/eject/schemas.ts +20 -0
- package/src/commands/eject/theme.ts +20 -0
- package/src/commands/fetch/index.ts +20 -0
- package/src/commands/index.ts +43 -0
- package/src/commands/make/exportable.ts +40 -0
- package/src/commands/make/integration.ts +20 -0
- package/src/commands/make/page.ts +46 -0
- package/src/commands/make/schema.ts +40 -0
- package/src/commands/make/snippet.ts +33 -0
- package/src/commands/make/template.ts +46 -0
- package/src/commands/rename/snippet.ts +31 -0
- package/src/commands/start/index.ts +20 -0
- package/src/commands/types.ts +7 -0
- package/src/commands/utils.ts +26 -0
- package/src/config.ts +7 -5
- package/src/index.ts +20 -10
- package/src/pipeline.ts +1 -1
- package/src/transformers/font/index.ts +1 -2
- package/src/transformers/integration/index.ts +3 -1
- package/src/transformers/preview/index.ts +3 -3
- package/src/types/config.d.ts +3 -2
- package/src/utils/numbers.ts +2 -2
- package/src/utils/preview.ts +3 -3
- package/src/utils/prompt.ts +9 -11
package/Changelog.md
CHANGED
|
@@ -6,6 +6,24 @@ 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.14.1] - 2024-10-28
|
|
10
|
+
|
|
11
|
+
This release introduces greater flexibility for custom integrations and general improvements to CLI handling.
|
|
12
|
+
|
|
13
|
+
### Changes
|
|
14
|
+
|
|
15
|
+
- Added support for custom integration paths with the `-i <path-to-integration>` CLI argument.
|
|
16
|
+
- Can be used with commands like `fetch`, `start`, `build:app`, etc.
|
|
17
|
+
- Defaults to the `integration` directory if the argument isn't specified, ensuring backward compatibility.
|
|
18
|
+
|
|
19
|
+
### Improvements
|
|
20
|
+
|
|
21
|
+
- Enhanced CLI command management:
|
|
22
|
+
- Switched to `yargs` for improved CLI parsing.
|
|
23
|
+
- Each command now has a dedicated handler file for better modularity.
|
|
24
|
+
- Improved the docs app build process:
|
|
25
|
+
- Introduced a cleanup procedure that ensures only files present in the working directory are included in the final build.
|
|
26
|
+
|
|
9
27
|
## [0.14.0] - 2024-09-26
|
|
10
28
|
|
|
11
29
|
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 (
|
|
166
|
-
switch (
|
|
178
|
+
var srcPath, appPath, handoffProjectId, handoffAppBasePath, handoffWorkingPath, handoffIntegrationPath, handoffModulePath, handoffExportPath, nextConfigPath, nextConfigContent;
|
|
179
|
+
var _a, _b, _c;
|
|
180
|
+
return __generator(this, function (_d) {
|
|
181
|
+
switch (_d.label) {
|
|
167
182
|
case 0:
|
|
168
183
|
srcPath = path_1.default.resolve(handoff.modulePath, 'src', 'app');
|
|
169
184
|
appPath = getAppPath(handoff);
|
|
@@ -171,35 +186,37 @@ 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
|
-
|
|
189
|
+
_d.sent();
|
|
175
190
|
return [4 /*yield*/, fs_extra_1.default.copy(srcPath, appPath, { overwrite: true })];
|
|
176
191
|
case 2:
|
|
177
|
-
|
|
192
|
+
_d.sent();
|
|
178
193
|
return [4 /*yield*/, mergePublicDir(handoff)];
|
|
179
194
|
case 3:
|
|
180
|
-
|
|
195
|
+
_d.sent();
|
|
181
196
|
return [4 /*yield*/, mergeMDX(handoff)];
|
|
182
197
|
case 4:
|
|
183
|
-
|
|
198
|
+
_d.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');
|
|
190
206
|
return [4 /*yield*/, fs_extra_1.default.readFile(nextConfigPath, 'utf-8')];
|
|
191
207
|
case 5:
|
|
192
|
-
nextConfigContent = (
|
|
208
|
+
nextConfigContent = (_d.sent())
|
|
193
209
|
.replace(/basePath:\s+\'\'/g, "basePath: '".concat(handoffAppBasePath, "'"))
|
|
194
210
|
.replace(/HANDOFF_PROJECT_ID:\s+\'\'/g, "HANDOFF_PROJECT_ID: '".concat(handoffProjectId, "'"))
|
|
195
211
|
.replace(/HANDOFF_APP_BASE_PATH:\s+\'\'/g, "HANDOFF_APP_BASE_PATH: '".concat(handoffAppBasePath, "'"))
|
|
196
212
|
.replace(/HANDOFF_WORKING_PATH:\s+\'\'/g, "HANDOFF_WORKING_PATH: '".concat(handoffWorkingPath, "'"))
|
|
213
|
+
.replace(/HANDOFF_INTEGRATION_PATH:\s+\'\'/g, "HANDOFF_INTEGRATION_PATH: '".concat(handoffIntegrationPath, "'"))
|
|
197
214
|
.replace(/HANDOFF_MODULE_PATH:\s+\'\'/g, "HANDOFF_MODULE_PATH: '".concat(handoffModulePath, "'"))
|
|
198
215
|
.replace(/HANDOFF_EXPORT_PATH:\s+\'\'/g, "HANDOFF_EXPORT_PATH: '".concat(handoffExportPath, "'"))
|
|
199
216
|
.replace(/%HANDOFF_MODULE_PATH%/g, handoffModulePath);
|
|
200
217
|
return [4 /*yield*/, fs_extra_1.default.writeFile(nextConfigPath, nextConfigContent)];
|
|
201
218
|
case 6:
|
|
202
|
-
|
|
219
|
+
_d.sent();
|
|
203
220
|
return [2 /*return*/, appPath];
|
|
204
221
|
}
|
|
205
222
|
});
|
|
@@ -217,9 +234,14 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
217
234
|
if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
|
|
218
235
|
throw new Error('Tokens not exported. Run `handoff-app fetch` first.');
|
|
219
236
|
}
|
|
237
|
+
// Perform cleanup
|
|
238
|
+
return [4 /*yield*/, performCleanup(handoff)];
|
|
239
|
+
case 1:
|
|
240
|
+
// Perform cleanup
|
|
241
|
+
_a.sent();
|
|
220
242
|
// If we are building the app, ensure the integration is built first
|
|
221
243
|
return [4 /*yield*/, (0, pipeline_1.buildIntegrationOnly)(handoff)];
|
|
222
|
-
case
|
|
244
|
+
case 2:
|
|
223
245
|
// If we are building the app, ensure the integration is built first
|
|
224
246
|
_a.sent();
|
|
225
247
|
// Build client preview styles
|
|
@@ -228,11 +250,11 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
228
250
|
.catch(function (error) {
|
|
229
251
|
throw new Error(error);
|
|
230
252
|
})];
|
|
231
|
-
case
|
|
253
|
+
case 3:
|
|
232
254
|
// Build client preview styles
|
|
233
255
|
_a.sent();
|
|
234
256
|
return [4 /*yield*/, prepareProjectApp(handoff)];
|
|
235
|
-
case
|
|
257
|
+
case 4:
|
|
236
258
|
appPath = _a.sent();
|
|
237
259
|
// Build app
|
|
238
260
|
return [4 /*yield*/, (0, next_build_1.nextBuild)({
|
|
@@ -243,7 +265,7 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
243
265
|
experimentalTurbo: false,
|
|
244
266
|
experimentalBuildMode: 'default',
|
|
245
267
|
}, appPath)];
|
|
246
|
-
case
|
|
268
|
+
case 5:
|
|
247
269
|
// Build app
|
|
248
270
|
_a.sent();
|
|
249
271
|
outputRoot = path_1.default.resolve(handoff.workingPath, handoff.sitesDirectory);
|
|
@@ -266,8 +288,9 @@ var buildApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
266
288
|
*/
|
|
267
289
|
var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, function () {
|
|
268
290
|
var appPath, dev, hostname, port, app, handle, moduleOutput, chokidarConfig, debounce;
|
|
269
|
-
|
|
270
|
-
|
|
291
|
+
var _a, _b;
|
|
292
|
+
return __generator(this, function (_c) {
|
|
293
|
+
switch (_c.label) {
|
|
271
294
|
case 0:
|
|
272
295
|
if (!fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.config.figma_project_id, 'tokens.json'))) {
|
|
273
296
|
throw new Error('Tokens not exported. Run `handoff-app fetch` first.');
|
|
@@ -280,10 +303,10 @@ var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
280
303
|
})];
|
|
281
304
|
case 1:
|
|
282
305
|
// Build client preview styles
|
|
283
|
-
|
|
306
|
+
_c.sent();
|
|
284
307
|
return [4 /*yield*/, prepareProjectApp(handoff)];
|
|
285
308
|
case 2:
|
|
286
|
-
appPath =
|
|
309
|
+
appPath = _c.sent();
|
|
287
310
|
// Include any changes made within the app source during watch
|
|
288
311
|
chokidar_1.default
|
|
289
312
|
.watch(path_1.default.resolve(handoff.modulePath, 'src', 'app'), {
|
|
@@ -410,8 +433,8 @@ var watchApp = function (handoff) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
410
433
|
});
|
|
411
434
|
}); });
|
|
412
435
|
}
|
|
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 () {
|
|
436
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, (_a = handoff.config.integrationPath) !== null && _a !== void 0 ? _a : 'integration'))) {
|
|
437
|
+
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 () {
|
|
415
438
|
var _a;
|
|
416
439
|
return __generator(this, function (_b) {
|
|
417
440
|
switch (_b.label) {
|
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
|
|
59
|
-
var
|
|
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
|
-
|
|
41
|
+
return 'Handoff App - 0.14.1';
|
|
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
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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,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,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:integration',
|
|
46
|
+
describe: 'Build the integration, styles and previews',
|
|
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.integration()];
|
|
57
|
+
case 1:
|
|
58
|
+
_a.sent();
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}); },
|
|
63
|
+
};
|
|
64
|
+
exports.default = command;
|