handoff-app 1.0.6 → 1.1.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +60 -0
- package/config/config.template.js +1 -2
- package/dist/{app.d.ts → app-builder/build.d.ts} +4 -10
- package/dist/app-builder/build.js +207 -0
- package/dist/app-builder/client-config.d.ts +9 -0
- package/dist/app-builder/client-config.js +62 -0
- package/dist/app-builder/index.d.ts +2 -0
- package/dist/app-builder/index.js +12 -0
- package/dist/app-builder/paths.d.ts +19 -0
- package/dist/app-builder/paths.js +56 -0
- package/dist/app-builder/watchers.d.ts +45 -0
- package/dist/app-builder/watchers.js +302 -0
- package/dist/app-builder/websocket.d.ts +12 -0
- package/dist/app-builder/websocket.js +63 -0
- package/dist/cache/build-cache.d.ts +0 -2
- package/dist/cache/build-cache.js +6 -16
- package/dist/{create.js → cli/create.js} +2 -2
- package/dist/cli/eject.d.ts +2 -2
- package/dist/cli/eject.js +2 -2
- package/dist/cli/make.d.ts +0 -4
- package/dist/cli/make.js +14 -2
- package/dist/cli.js +1 -1
- package/dist/commands/build/components.js +1 -1
- package/dist/commands/init/index.js +1 -1
- package/dist/commands/utils.d.ts +1 -1
- package/dist/{config.d.ts → config/defaults.d.ts} +3 -4
- package/dist/{config.js → config/defaults.js} +8 -5
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.js +16 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.js +49 -0
- package/dist/config/runtime.d.ts +36 -0
- package/dist/config/runtime.js +151 -0
- package/dist/config/validator.d.ts +9 -0
- package/dist/config/validator.js +26 -0
- package/dist/index.d.ts +0 -7
- package/dist/index.js +8 -198
- package/dist/pipeline/archive.d.ts +19 -0
- package/dist/pipeline/archive.js +80 -0
- package/dist/pipeline/components.d.ts +5 -0
- package/dist/pipeline/components.js +20 -0
- package/dist/{documentation-object.d.ts → pipeline/documentation.d.ts} +1 -1
- package/dist/{documentation-object.js → pipeline/documentation.js} +3 -3
- package/dist/pipeline/figma.d.ts +11 -0
- package/dist/pipeline/figma.js +152 -0
- package/dist/pipeline/index.d.ts +15 -0
- package/dist/pipeline/index.js +53 -0
- package/dist/pipeline/styles.d.ts +10 -0
- package/dist/pipeline/styles.js +136 -0
- package/dist/pipeline/validation.d.ts +6 -0
- package/dist/pipeline/validation.js +36 -0
- package/dist/transformers/docgen/index.d.ts +19 -4
- package/dist/transformers/docgen/index.js +226 -32
- package/dist/transformers/plugins/csf-render.d.ts +5 -0
- package/dist/transformers/plugins/csf-render.js +270 -0
- package/dist/transformers/plugins/handlebars-previews.js +5 -3
- package/dist/transformers/plugins/index.d.ts +1 -0
- package/dist/transformers/plugins/index.js +3 -1
- package/dist/transformers/plugins/ssr-render.js +7 -1
- package/dist/transformers/plugins.d.ts +1 -0
- package/dist/transformers/plugins.js +3 -1
- package/dist/transformers/preview/component/api.js +2 -3
- package/dist/transformers/preview/component/builder.js +1 -4
- package/dist/transformers/preview/component/css.d.ts +3 -2
- package/dist/transformers/preview/component/css.js +7 -12
- package/dist/transformers/preview/component/html.js +7 -4
- package/dist/transformers/preview/component/javascript.d.ts +2 -2
- package/dist/transformers/preview/component/javascript.js +7 -7
- package/dist/transformers/preview/component.d.ts +6 -6
- package/dist/transformers/preview/component.js +0 -46
- package/dist/transformers/preview/types.d.ts +3 -1
- package/dist/transformers/types.d.ts +0 -18
- package/dist/transformers/utils/handlebars.d.ts +2 -0
- package/dist/transformers/utils/handlebars.js +10 -4
- package/dist/transformers/utils/schema-loader.js +2 -2
- package/dist/transformers/utils/schema.d.ts +2 -2
- package/dist/transformers/utils/schema.js +2 -2
- package/dist/types/config.d.ts +16 -1
- package/dist/{types.d.ts → types/preview.d.ts} +5 -3
- package/package.json +7 -17
- package/src/app/components/Component/BestPracticesCard.tsx +1 -1
- package/src/app/components/Component/ComponentLists.tsx +1 -1
- package/src/app/components/Component/PageSliceResolver.tsx +1 -1
- package/src/app/components/Component/Preview.tsx +410 -169
- package/src/app/components/Component/slices/BestPracticesSlice.tsx +1 -1
- package/src/app/components/Component/slices/ComponentDisplaySlice.tsx +1 -1
- package/src/app/components/Component/slices/PropertiesSlice.tsx +1 -1
- package/src/app/components/Component/slices/ValidationResultsSlice.tsx +1 -1
- package/src/app/components/Foundations/RulesSheet.tsx +10 -4
- package/src/app/components/Layout/Main.tsx +1 -1
- package/src/app/components/Markdown/CodeHighlight.tsx +20 -39
- package/src/app/components/Navigation/PrevNextNav.tsx +13 -7
- package/src/app/components/Validation/ValidationResults.tsx +1 -1
- package/src/app/components/context/PreviewContext.tsx +1 -1
- package/src/app/components/util/index.ts +1 -1
- package/src/app/next.config.mjs +0 -3
- package/src/app/pages/system/component/[component]/index.tsx +30 -15
- package/src/app/pages/system/index.tsx +1 -1
- package/src/app/pages/system/tokens/components/[component]/index.tsx +3 -3
- package/src/app/pages/system/tokens/index.tsx +1 -1
- package/src/app-builder/README.md +14 -0
- package/src/app-builder/build.ts +231 -0
- package/src/app-builder/client-config.ts +53 -0
- package/src/app-builder/index.ts +3 -0
- package/src/app-builder/paths.ts +44 -0
- package/src/app-builder/watchers.ts +278 -0
- package/src/app-builder/websocket.ts +61 -0
- package/src/cache/README.md +11 -0
- package/src/cache/build-cache.ts +1 -16
- package/src/cli/README.md +12 -0
- package/src/{create.ts → cli/create.ts} +2 -2
- package/src/cli/eject.ts +2 -2
- package/src/cli/make.ts +16 -2
- package/src/cli.ts +1 -1
- package/src/commands/README.md +23 -0
- package/src/commands/build/components.ts +1 -1
- package/src/commands/init/index.ts +1 -1
- package/src/config/README.md +23 -0
- package/src/{config.ts → config/defaults.ts} +8 -7
- package/src/config/index.ts +12 -0
- package/src/config/loader.ts +48 -0
- package/src/config/runtime.ts +176 -0
- package/src/config/validator.ts +24 -0
- package/src/index.ts +2 -221
- package/src/pipeline/README.md +20 -0
- package/src/pipeline/archive.ts +75 -0
- package/src/pipeline/components.ts +9 -0
- package/src/{documentation-object.ts → pipeline/documentation.ts} +6 -6
- package/src/pipeline/figma.ts +146 -0
- package/src/pipeline/index.ts +38 -0
- package/src/pipeline/styles.ts +152 -0
- package/src/pipeline/validation.ts +25 -0
- package/src/transformers/README.md +12 -72
- package/src/transformers/docgen/index.ts +279 -39
- package/src/transformers/plugins/csf-render.ts +315 -0
- package/src/transformers/plugins/handlebars-previews.ts +5 -3
- package/src/transformers/plugins/index.ts +1 -0
- package/src/transformers/plugins/ssr-render.ts +14 -2
- package/src/transformers/plugins.ts +1 -0
- package/src/transformers/preview/component/api.ts +1 -2
- package/src/transformers/preview/component/builder.ts +1 -5
- package/src/transformers/preview/component/css.ts +6 -9
- package/src/transformers/preview/component/html.ts +6 -3
- package/src/transformers/preview/component/javascript.ts +5 -4
- package/src/transformers/preview/component.ts +6 -45
- package/src/transformers/preview/types.ts +3 -1
- package/src/transformers/types.ts +0 -18
- package/src/transformers/utils/handlebars.ts +12 -3
- package/src/transformers/utils/schema-loader.ts +2 -2
- package/src/transformers/utils/schema.ts +2 -2
- package/src/types/README.md +11 -0
- package/src/types/config.ts +16 -1
- package/src/{types.ts → types/preview.ts} +5 -3
- package/src/utils/README.md +13 -0
- package/templates/default/handoff.config.js.tpl +6 -0
- package/templates/default/handoff.config.with-examples.js.tpl +6 -0
- package/.env.example +0 -4
- package/config/templates/integration/integration.config.json +0 -84
- package/config/templates/integration/sass/_variables-default.scss +0 -255
- package/config/templates/integration/sass/_variables.scss +0 -797
- package/config/templates/integration/sass/extended/_alert.scss +0 -20
- package/config/templates/integration/sass/extended/_button.scss +0 -73
- package/config/templates/integration/sass/extended/_checkbox.scss +0 -118
- package/config/templates/integration/sass/extended/_input.scss +0 -60
- package/config/templates/integration/sass/extended/_modal.scss +0 -46
- package/config/templates/integration/sass/extended/_pagination.scss +0 -3
- package/config/templates/integration/sass/extended/_radio.scss +0 -13
- package/config/templates/integration/sass/extended/_select.scss +0 -54
- package/config/templates/integration/sass/extended/_switch.scss +0 -22
- package/config/templates/integration/sass/extended/_tooltip.scss +0 -20
- package/config/templates/integration/sass/extended/_utilities.scss +0 -7
- package/config/templates/integration/sass/main.scss +0 -105
- package/config/templates/integration/sass/maps/_alert.scss +0 -16
- package/config/templates/integration/sass/maps/_button.scss +0 -77
- package/config/templates/integration/sass/maps/_checkbox.scss +0 -35
- package/config/templates/integration/sass/maps/_input.scss +0 -69
- package/config/templates/integration/sass/maps/_modal.scss +0 -54
- package/config/templates/integration/sass/maps/_pagination.scss +0 -27
- package/config/templates/integration/sass/maps/_radio.scss +0 -4
- package/config/templates/integration/sass/maps/_select.scss +0 -43
- package/config/templates/integration/sass/maps/_switch.scss +0 -15
- package/config/templates/integration/sass/maps/_tooltip.scss +0 -30
- package/config/templates/integration/sass/readme.md +0 -3
- package/config/templates/integration/templates/alert/default.html +0 -7
- package/config/templates/integration/templates/alert/horizontal.html +0 -12
- package/config/templates/integration/templates/alert/vertical.html +0 -12
- package/config/templates/integration/templates/alert/view.config.json +0 -10
- package/config/templates/integration/templates/button/default.html +0 -5
- package/config/templates/integration/templates/button/large.html +0 -5
- package/config/templates/integration/templates/button/medium.html +0 -5
- package/config/templates/integration/templates/button/primary/disabled.html +0 -5
- package/config/templates/integration/templates/button/small.html +0 -5
- package/config/templates/integration/templates/button/view.config.json +0 -24
- package/config/templates/integration/templates/checkbox/default/off.html +0 -10
- package/config/templates/integration/templates/checkbox/default/on.html +0 -10
- package/config/templates/integration/templates/checkbox/default.html +0 -22
- package/config/templates/integration/templates/checkbox/disabled.html +0 -16
- package/config/templates/integration/templates/checkbox/view.config.json +0 -26
- package/config/templates/integration/templates/input/complete.html +0 -14
- package/config/templates/integration/templates/input/default.html +0 -14
- package/config/templates/integration/templates/input/disabled.html +0 -14
- package/config/templates/integration/templates/input/error.html +0 -14
- package/config/templates/integration/templates/input/view.config.json +0 -33
- package/config/templates/integration/templates/main.js +0 -15
- package/config/templates/integration/templates/main.scss +0 -31
- package/config/templates/integration/templates/modal/default.html +0 -20
- package/config/templates/integration/templates/modal/view.config.json +0 -16
- package/config/templates/integration/templates/pagination/default.html +0 -31
- package/config/templates/integration/templates/pagination/lg.html +0 -31
- package/config/templates/integration/templates/pagination/sm.html +0 -31
- package/config/templates/integration/templates/pagination/view.config.json +0 -6
- package/config/templates/integration/templates/radio/default/off.html +0 -10
- package/config/templates/integration/templates/radio/default/on.html +0 -10
- package/config/templates/integration/templates/radio/default.html +0 -10
- package/config/templates/integration/templates/radio/disabled.html +0 -16
- package/config/templates/integration/templates/radio/view.config.json +0 -26
- package/config/templates/integration/templates/select/default.html +0 -10
- package/config/templates/integration/templates/select/disabled.html +0 -10
- package/config/templates/integration/templates/select/error.html +0 -10
- package/config/templates/integration/templates/select/view.config.json +0 -33
- package/config/templates/integration/templates/switch/default/off.html +0 -10
- package/config/templates/integration/templates/switch/default/on.html +0 -10
- package/config/templates/integration/templates/switch/default.html +0 -8
- package/config/templates/integration/templates/switch/disabled.html +0 -16
- package/config/templates/integration/templates/switch/view.config.json +0 -26
- package/config/templates/integration/templates/tooltip/default.html +0 -16
- package/config/templates/integration/templates/tooltip/view.config.json +0 -6
- package/dist/app.js +0 -617
- package/dist/pipeline.d.ts +0 -22
- package/dist/pipeline.js +0 -374
- package/integration/components/example/example.js +0 -70
- package/integration/components/example/style.scss +0 -1
- package/integration/components/example/template.hbs +0 -12
- package/integration/integration.config.json +0 -84
- package/integration/sass/main.scss +0 -105
- package/integration/sass/readme.md +0 -3
- package/integration/templates/alert/default.html +0 -7
- package/integration/templates/alert/horizontal.html +0 -12
- package/integration/templates/alert/vertical.html +0 -12
- package/integration/templates/alert/view.config.json +0 -10
- package/integration/templates/button/default.html +0 -5
- package/integration/templates/button/large.html +0 -5
- package/integration/templates/button/medium.html +0 -5
- package/integration/templates/button/primary/disabled.html +0 -5
- package/integration/templates/button/small.html +0 -5
- package/integration/templates/button/view.config.json +0 -24
- package/integration/templates/checkbox/default/off.html +0 -10
- package/integration/templates/checkbox/default/on.html +0 -10
- package/integration/templates/checkbox/default.html +0 -22
- package/integration/templates/checkbox/disabled.html +0 -16
- package/integration/templates/checkbox/view.config.json +0 -26
- package/integration/templates/input/complete.html +0 -14
- package/integration/templates/input/default.html +0 -14
- package/integration/templates/input/disabled.html +0 -14
- package/integration/templates/input/error.html +0 -14
- package/integration/templates/input/view.config.json +0 -33
- package/integration/templates/main.js +0 -15
- package/integration/templates/main.scss +0 -31
- package/integration/templates/modal/default.html +0 -20
- package/integration/templates/modal/view.config.json +0 -16
- package/integration/templates/pagination/default.html +0 -31
- package/integration/templates/pagination/lg.html +0 -31
- package/integration/templates/pagination/sm.html +0 -31
- package/integration/templates/pagination/view.config.json +0 -6
- package/integration/templates/radio/default/off.html +0 -10
- package/integration/templates/radio/default/on.html +0 -10
- package/integration/templates/radio/default.html +0 -10
- package/integration/templates/radio/disabled.html +0 -16
- package/integration/templates/radio/view.config.json +0 -26
- package/integration/templates/select/default.html +0 -10
- package/integration/templates/select/disabled.html +0 -10
- package/integration/templates/select/error.html +0 -10
- package/integration/templates/select/view.config.json +0 -33
- package/integration/templates/switch/default/off.html +0 -10
- package/integration/templates/switch/default/on.html +0 -10
- package/integration/templates/switch/default.html +0 -8
- package/integration/templates/switch/disabled.html +0 -16
- package/integration/templates/switch/view.config.json +0 -26
- package/integration/templates/tooltip/default.html +0 -16
- package/integration/templates/tooltip/view.config.json +0 -6
- package/src/app.ts +0 -654
- package/src/pipeline.ts +0 -413
- /package/config/templates/{integration/components/template → component}/template.hbs +0 -0
- /package/config/templates/{integration/components/template → component}/template.js +0 -0
- /package/config/templates/{integration/components/template → component}/template.json +0 -0
- /package/config/templates/{integration/components/template → component}/template.scss +0 -0
- /package/dist/{create.d.ts → cli/create.d.ts} +0 -0
- /package/dist/transformers/{config.d.ts → vite-config.d.ts} +0 -0
- /package/dist/transformers/{config.js → vite-config.js} +0 -0
- /package/dist/{types.js → types/preview.js} +0 -0
- /package/src/transformers/{config.ts → vite-config.ts} +0 -0
|
@@ -0,0 +1,302 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.watchRuntimeConfiguration = exports.watchRuntimeComponents = exports.getRuntimeComponentsPathsToWatch = exports.mapEntryTypeToSegment = exports.watchGlobalEntries = exports.watchPages = exports.watchAppSource = exports.watchPublicDirectory = void 0;
|
|
39
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
40
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
41
|
+
const path_1 = __importDefault(require("path"));
|
|
42
|
+
const css_1 = require("../transformers/preview/component/css");
|
|
43
|
+
const javascript_1 = require("../transformers/preview/component/javascript");
|
|
44
|
+
const builder_1 = __importStar(require("../transformers/preview/component/builder"));
|
|
45
|
+
const logger_1 = require("../utils/logger");
|
|
46
|
+
const client_config_1 = require("./client-config");
|
|
47
|
+
const paths_1 = require("./paths");
|
|
48
|
+
/**
|
|
49
|
+
* Watches the working public directory for changes and updates the app.
|
|
50
|
+
*/
|
|
51
|
+
const watchPublicDirectory = (handoff, wss, state, chokidarConfig) => {
|
|
52
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, 'public'))) {
|
|
53
|
+
chokidar_1.default.watch(path_1.default.resolve(handoff.workingPath, 'public'), chokidarConfig).on('all', (event, path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
switch (event) {
|
|
55
|
+
case 'add':
|
|
56
|
+
case 'change':
|
|
57
|
+
case 'unlink':
|
|
58
|
+
if (!state.debounce) {
|
|
59
|
+
state.debounce = true;
|
|
60
|
+
try {
|
|
61
|
+
logger_1.Logger.warn('Public directory changed. Handoff will ingest the new data...');
|
|
62
|
+
yield (0, paths_1.syncPublicFiles)(handoff);
|
|
63
|
+
wss(JSON.stringify({ type: 'reload' }));
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
logger_1.Logger.error('Error syncing public directory:', e);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
state.debounce = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.watchPublicDirectory = watchPublicDirectory;
|
|
78
|
+
/**
|
|
79
|
+
* Watches the application source code for changes.
|
|
80
|
+
*/
|
|
81
|
+
const watchAppSource = (handoff, initializeProjectApp) => {
|
|
82
|
+
chokidar_1.default
|
|
83
|
+
.watch(path_1.default.resolve(handoff.modulePath, 'src', 'app'), {
|
|
84
|
+
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
|
85
|
+
persistent: true,
|
|
86
|
+
ignoreInitial: true,
|
|
87
|
+
})
|
|
88
|
+
.on('all', (event, path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
switch (event) {
|
|
90
|
+
case 'add':
|
|
91
|
+
case 'change':
|
|
92
|
+
case 'unlink':
|
|
93
|
+
try {
|
|
94
|
+
yield initializeProjectApp(handoff);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
logger_1.Logger.error('Error initializing project app:', e);
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
exports.watchAppSource = watchAppSource;
|
|
104
|
+
/**
|
|
105
|
+
* Watches the user's pages directory for changes.
|
|
106
|
+
*/
|
|
107
|
+
const watchPages = (handoff, chokidarConfig) => {
|
|
108
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(handoff.workingPath, 'pages'))) {
|
|
109
|
+
chokidar_1.default.watch(path_1.default.resolve(handoff.workingPath, 'pages'), chokidarConfig).on('all', (event, path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
switch (event) {
|
|
111
|
+
case 'add':
|
|
112
|
+
case 'change':
|
|
113
|
+
case 'unlink':
|
|
114
|
+
try {
|
|
115
|
+
logger_1.Logger.warn(`Doc page ${event}ed. Please reload browser to see changes...`);
|
|
116
|
+
logger_1.Logger.debug(`Path: ${path}`);
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
logger_1.Logger.error('Error watching pages:', e);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.watchPages = watchPages;
|
|
127
|
+
/**
|
|
128
|
+
* Watches global SCSS and JS entry points for changes.
|
|
129
|
+
* Rebuilds the main bundles and all components when a global entry changes,
|
|
130
|
+
* since per-component builds may depend on these shared entries.
|
|
131
|
+
*/
|
|
132
|
+
const watchGlobalEntries = (handoff, state, chokidarConfig) => {
|
|
133
|
+
var _a, _b, _c, _d;
|
|
134
|
+
const scssEntry = (_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.scss;
|
|
135
|
+
const jsEntry = (_d = (_c = handoff.runtimeConfig) === null || _c === void 0 ? void 0 : _c.entries) === null || _d === void 0 ? void 0 : _d.js;
|
|
136
|
+
const scssPathsToWatch = [];
|
|
137
|
+
const jsPathsToWatch = [];
|
|
138
|
+
if (scssEntry && fs_extra_1.default.existsSync(scssEntry)) {
|
|
139
|
+
const stat = fs_extra_1.default.statSync(scssEntry);
|
|
140
|
+
scssPathsToWatch.push(stat.isDirectory() ? scssEntry : path_1.default.dirname(scssEntry));
|
|
141
|
+
}
|
|
142
|
+
if (jsEntry && fs_extra_1.default.existsSync(jsEntry)) {
|
|
143
|
+
jsPathsToWatch.push(path_1.default.dirname(jsEntry));
|
|
144
|
+
}
|
|
145
|
+
const pathsToWatch = [...scssPathsToWatch, ...jsPathsToWatch];
|
|
146
|
+
if (pathsToWatch.length === 0)
|
|
147
|
+
return;
|
|
148
|
+
const isPathInside = (filePath, parentPath) => {
|
|
149
|
+
const normalizedFilePath = path_1.default.resolve(filePath);
|
|
150
|
+
const normalizedParentPath = path_1.default.resolve(parentPath);
|
|
151
|
+
return normalizedFilePath === normalizedParentPath || normalizedFilePath.startsWith(`${normalizedParentPath}${path_1.default.sep}`);
|
|
152
|
+
};
|
|
153
|
+
chokidar_1.default.watch(pathsToWatch, chokidarConfig).on('all', (event, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
+
switch (event) {
|
|
155
|
+
case 'add':
|
|
156
|
+
case 'change':
|
|
157
|
+
case 'unlink':
|
|
158
|
+
if (!state.debounce) {
|
|
159
|
+
state.debounce = true;
|
|
160
|
+
try {
|
|
161
|
+
logger_1.Logger.warn('Global entry changed. Rebuilding bundles and components...');
|
|
162
|
+
const shouldRebuildMainCss = !!scssEntry && scssPathsToWatch.some((watchPath) => isPathInside(file, watchPath));
|
|
163
|
+
const shouldRebuildMainJs = !!jsEntry && jsPathsToWatch.some((watchPath) => isPathInside(file, watchPath));
|
|
164
|
+
if (shouldRebuildMainCss) {
|
|
165
|
+
yield (0, css_1.buildMainCss)(handoff);
|
|
166
|
+
}
|
|
167
|
+
if (shouldRebuildMainJs) {
|
|
168
|
+
yield (0, javascript_1.buildMainJS)(handoff);
|
|
169
|
+
}
|
|
170
|
+
yield (0, builder_1.default)(handoff);
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
logger_1.Logger.error('Error rebuilding after global entry change:', e);
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
state.debounce = false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}));
|
|
182
|
+
};
|
|
183
|
+
exports.watchGlobalEntries = watchGlobalEntries;
|
|
184
|
+
/**
|
|
185
|
+
* Maps configuration entry types to component segments.
|
|
186
|
+
*/
|
|
187
|
+
const mapEntryTypeToSegment = (type) => {
|
|
188
|
+
return {
|
|
189
|
+
js: builder_1.ComponentSegment.JavaScript,
|
|
190
|
+
scss: builder_1.ComponentSegment.Style,
|
|
191
|
+
template: builder_1.ComponentSegment.Previews,
|
|
192
|
+
templates: builder_1.ComponentSegment.Previews,
|
|
193
|
+
}[type];
|
|
194
|
+
};
|
|
195
|
+
exports.mapEntryTypeToSegment = mapEntryTypeToSegment;
|
|
196
|
+
/**
|
|
197
|
+
* Gets the paths of runtime components to watch.
|
|
198
|
+
*
|
|
199
|
+
* @returns A Map of paths to watch and their entry types
|
|
200
|
+
*/
|
|
201
|
+
const getRuntimeComponentsPathsToWatch = (handoff) => {
|
|
202
|
+
var _a, _b, _c;
|
|
203
|
+
const result = new Map();
|
|
204
|
+
for (const runtimeComponentId of Object.keys((_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries.components) !== null && _b !== void 0 ? _b : {})) {
|
|
205
|
+
const runtimeComponent = handoff.runtimeConfig.entries.components[runtimeComponentId];
|
|
206
|
+
for (const [runtimeComponentEntryType, runtimeComponentEntryPath] of Object.entries((_c = runtimeComponent.entries) !== null && _c !== void 0 ? _c : {})) {
|
|
207
|
+
const normalizedComponentEntryPath = runtimeComponentEntryPath;
|
|
208
|
+
if (fs_extra_1.default.existsSync(normalizedComponentEntryPath)) {
|
|
209
|
+
const entryType = runtimeComponentEntryType;
|
|
210
|
+
if (fs_extra_1.default.statSync(normalizedComponentEntryPath).isFile()) {
|
|
211
|
+
result.set(path_1.default.resolve(normalizedComponentEntryPath), entryType);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
result.set(normalizedComponentEntryPath, entryType);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
};
|
|
221
|
+
exports.getRuntimeComponentsPathsToWatch = getRuntimeComponentsPathsToWatch;
|
|
222
|
+
/**
|
|
223
|
+
* Watches runtime components for changes.
|
|
224
|
+
*/
|
|
225
|
+
const watchRuntimeComponents = (handoff, state, runtimeComponentPathsToWatch) => {
|
|
226
|
+
if (state.runtimeComponentsWatcher) {
|
|
227
|
+
state.runtimeComponentsWatcher.close();
|
|
228
|
+
}
|
|
229
|
+
if (runtimeComponentPathsToWatch.size > 0) {
|
|
230
|
+
const pathsToWatch = Array.from(runtimeComponentPathsToWatch.keys());
|
|
231
|
+
state.runtimeComponentsWatcher = chokidar_1.default.watch(pathsToWatch, {
|
|
232
|
+
ignoreInitial: true,
|
|
233
|
+
});
|
|
234
|
+
state.runtimeComponentsWatcher.on('all', (event, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
235
|
+
if (handoff.getConfigFilePaths().includes(file)) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
switch (event) {
|
|
239
|
+
case 'add':
|
|
240
|
+
case 'change':
|
|
241
|
+
case 'unlink':
|
|
242
|
+
if (!state.debounce) {
|
|
243
|
+
state.debounce = true;
|
|
244
|
+
try {
|
|
245
|
+
const entryType = runtimeComponentPathsToWatch.get(file);
|
|
246
|
+
const segmentToUpdate = entryType ? (0, exports.mapEntryTypeToSegment)(entryType) : undefined;
|
|
247
|
+
const componentDir = path_1.default.basename(path_1.default.dirname(file));
|
|
248
|
+
yield (0, builder_1.default)(handoff, componentDir, segmentToUpdate);
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
logger_1.Logger.error('Error processing component:', e);
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
state.debounce = false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
exports.watchRuntimeComponents = watchRuntimeComponents;
|
|
263
|
+
/**
|
|
264
|
+
* Watches the runtime configuration for changes.
|
|
265
|
+
*/
|
|
266
|
+
const watchRuntimeConfiguration = (handoff, state) => {
|
|
267
|
+
if (state.runtimeConfigurationWatcher) {
|
|
268
|
+
state.runtimeConfigurationWatcher.close();
|
|
269
|
+
}
|
|
270
|
+
if (handoff.getConfigFilePaths().length > 0) {
|
|
271
|
+
state.runtimeConfigurationWatcher = chokidar_1.default.watch(handoff.getConfigFilePaths(), { ignoreInitial: true });
|
|
272
|
+
state.runtimeConfigurationWatcher.on('all', (event, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
273
|
+
switch (event) {
|
|
274
|
+
case 'add':
|
|
275
|
+
case 'change':
|
|
276
|
+
case 'unlink':
|
|
277
|
+
if (!state.debounce) {
|
|
278
|
+
state.debounce = true;
|
|
279
|
+
try {
|
|
280
|
+
file = path_1.default.dirname(file);
|
|
281
|
+
// Reload the Handoff instance to pick up configuration changes
|
|
282
|
+
handoff.reload();
|
|
283
|
+
// After reloading, persist the updated client configuration
|
|
284
|
+
yield (0, client_config_1.persistClientConfig)(handoff);
|
|
285
|
+
// Restart the runtime components watcher to track potentially updated/added/removed components
|
|
286
|
+
(0, exports.watchRuntimeComponents)(handoff, state, (0, exports.getRuntimeComponentsPathsToWatch)(handoff));
|
|
287
|
+
// Process components based on the updated configuration and file path
|
|
288
|
+
yield (0, builder_1.default)(handoff, path_1.default.basename(file));
|
|
289
|
+
}
|
|
290
|
+
catch (e) {
|
|
291
|
+
logger_1.Logger.error('Error reloading runtime configuration:', e);
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
state.debounce = false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}));
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
exports.watchRuntimeConfiguration = watchRuntimeConfiguration;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WebSocket } from 'ws';
|
|
2
|
+
export interface HandoffWebSocket extends WebSocket {
|
|
3
|
+
isAlive: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a WebSocket server that broadcasts messages to connected clients.
|
|
7
|
+
* Designed for development mode to help with hot-reloading.
|
|
8
|
+
*
|
|
9
|
+
* @param port - Optional port number for the WebSocket server; defaults to 3001.
|
|
10
|
+
* @returns A function that accepts a message string and broadcasts it to all connected clients.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createWebSocketServer: (port?: number) => Promise<(message: string) => void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createWebSocketServer = void 0;
|
|
13
|
+
const ws_1 = require("ws");
|
|
14
|
+
const logger_1 = require("../utils/logger");
|
|
15
|
+
/**
|
|
16
|
+
* Creates a WebSocket server that broadcasts messages to connected clients.
|
|
17
|
+
* Designed for development mode to help with hot-reloading.
|
|
18
|
+
*
|
|
19
|
+
* @param port - Optional port number for the WebSocket server; defaults to 3001.
|
|
20
|
+
* @returns A function that accepts a message string and broadcasts it to all connected clients.
|
|
21
|
+
*/
|
|
22
|
+
const createWebSocketServer = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (port = 3001) {
|
|
23
|
+
const wss = new ws_1.WebSocket.Server({ port });
|
|
24
|
+
// Heartbeat function to mark a connection as alive.
|
|
25
|
+
const heartbeat = function () {
|
|
26
|
+
this.isAlive = true;
|
|
27
|
+
};
|
|
28
|
+
// Setup a new connection
|
|
29
|
+
wss.on('connection', (ws) => {
|
|
30
|
+
const extWs = ws;
|
|
31
|
+
extWs.isAlive = true;
|
|
32
|
+
extWs.send(JSON.stringify({ type: 'WELCOME' }));
|
|
33
|
+
extWs.on('error', (error) => logger_1.Logger.error('WebSocket error:', error));
|
|
34
|
+
extWs.on('pong', heartbeat);
|
|
35
|
+
});
|
|
36
|
+
// Periodically ping clients to ensure they are still connected
|
|
37
|
+
const pingInterval = setInterval(() => {
|
|
38
|
+
wss.clients.forEach((client) => {
|
|
39
|
+
const extWs = client;
|
|
40
|
+
if (!extWs.isAlive) {
|
|
41
|
+
logger_1.Logger.warn('Terminating inactive client');
|
|
42
|
+
return client.terminate();
|
|
43
|
+
}
|
|
44
|
+
extWs.isAlive = false;
|
|
45
|
+
client.ping();
|
|
46
|
+
});
|
|
47
|
+
}, 30000);
|
|
48
|
+
// Clean up the interval when the server closes
|
|
49
|
+
wss.on('close', () => {
|
|
50
|
+
clearInterval(pingInterval);
|
|
51
|
+
});
|
|
52
|
+
logger_1.Logger.success(`WebSocket server listening on ws://localhost:${port}`);
|
|
53
|
+
// Return a function to broadcast a message to all connected clients
|
|
54
|
+
return (message) => {
|
|
55
|
+
logger_1.Logger.success(`Broadcasting message to ${wss.clients.size} client(s)`);
|
|
56
|
+
wss.clients.forEach((client) => {
|
|
57
|
+
if (client.readyState === ws_1.WebSocket.OPEN) {
|
|
58
|
+
client.send(message);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
exports.createWebSocketServer = createWebSocketServer;
|
|
@@ -17,8 +17,6 @@ export interface ComponentCacheEntry {
|
|
|
17
17
|
export interface GlobalDepsState {
|
|
18
18
|
/** tokens.json file state */
|
|
19
19
|
tokens?: FileState;
|
|
20
|
-
/** shared.scss or shared.css file state */
|
|
21
|
-
sharedStyles?: FileState;
|
|
22
20
|
/** Global SCSS entry file state */
|
|
23
21
|
globalScss?: FileState;
|
|
24
22
|
/** Global JS entry file state */
|
|
@@ -94,24 +94,18 @@ function saveBuildCache(handoff, cache) {
|
|
|
94
94
|
*/
|
|
95
95
|
function computeGlobalDepsState(handoff) {
|
|
96
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
97
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
98
98
|
const result = {};
|
|
99
99
|
// tokens.json
|
|
100
100
|
const tokensPath = handoff.getTokensFilePath();
|
|
101
101
|
result.tokens = (_a = (yield (0, file_state_1.computeFileState)(tokensPath))) !== null && _a !== void 0 ? _a : undefined;
|
|
102
|
-
// shared.scss or shared.css
|
|
103
|
-
const sharedScssPath = path_1.default.resolve(handoff.workingPath, 'integration/components/shared.scss');
|
|
104
|
-
const sharedCssPath = path_1.default.resolve(handoff.workingPath, 'integration/components/shared.css');
|
|
105
|
-
const sharedScssState = yield (0, file_state_1.computeFileState)(sharedScssPath);
|
|
106
|
-
const sharedCssState = yield (0, file_state_1.computeFileState)(sharedCssPath);
|
|
107
|
-
result.sharedStyles = (_b = sharedScssState !== null && sharedScssState !== void 0 ? sharedScssState : sharedCssState) !== null && _b !== void 0 ? _b : undefined;
|
|
108
102
|
// Global SCSS entry
|
|
109
|
-
if ((
|
|
110
|
-
result.globalScss = (
|
|
103
|
+
if ((_c = (_b = handoff.runtimeConfig) === null || _b === void 0 ? void 0 : _b.entries) === null || _c === void 0 ? void 0 : _c.scss) {
|
|
104
|
+
result.globalScss = (_d = (yield (0, file_state_1.computeFileState)(handoff.runtimeConfig.entries.scss))) !== null && _d !== void 0 ? _d : undefined;
|
|
111
105
|
}
|
|
112
106
|
// Global JS entry
|
|
113
|
-
if ((
|
|
114
|
-
result.globalJs = (
|
|
107
|
+
if ((_f = (_e = handoff.runtimeConfig) === null || _e === void 0 ? void 0 : _e.entries) === null || _f === void 0 ? void 0 : _f.js) {
|
|
108
|
+
result.globalJs = (_g = (yield (0, file_state_1.computeFileState)(handoff.runtimeConfig.entries.js))) !== null && _g !== void 0 ? _g : undefined;
|
|
115
109
|
}
|
|
116
110
|
return result;
|
|
117
111
|
});
|
|
@@ -127,10 +121,6 @@ function haveGlobalDepsChanged(cached, current) {
|
|
|
127
121
|
logger_1.Logger.debug('Global dependency changed: tokens.json');
|
|
128
122
|
return true;
|
|
129
123
|
}
|
|
130
|
-
if (!(0, file_state_1.statesMatch)(cached.sharedStyles, current.sharedStyles)) {
|
|
131
|
-
logger_1.Logger.debug('Global dependency changed: shared styles');
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
124
|
if (!(0, file_state_1.statesMatch)(cached.globalScss, current.globalScss)) {
|
|
135
125
|
logger_1.Logger.debug('Global dependency changed: global SCSS entry');
|
|
136
126
|
return true;
|
|
@@ -205,7 +195,7 @@ function computeComponentFileStates(handoff, componentId) {
|
|
|
205
195
|
}
|
|
206
196
|
let templateDirFiles;
|
|
207
197
|
if (templateDir) {
|
|
208
|
-
templateDirFiles = yield (0, file_state_1.computeDirectoryState)(templateDir, ['.hbs', '.html']);
|
|
198
|
+
templateDirFiles = yield (0, file_state_1.computeDirectoryState)(templateDir, ['.hbs', '.html', '.tsx', '.ts']);
|
|
209
199
|
}
|
|
210
200
|
return { files, templateDirFiles };
|
|
211
201
|
});
|
|
@@ -45,7 +45,7 @@ const path = __importStar(require("path"));
|
|
|
45
45
|
*/
|
|
46
46
|
const getVersion = () => {
|
|
47
47
|
try {
|
|
48
|
-
const packageJsonPath = path.resolve(__dirname, '
|
|
48
|
+
const packageJsonPath = path.resolve(__dirname, '../../package.json');
|
|
49
49
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
50
50
|
return packageJson.version || 'unknown';
|
|
51
51
|
}
|
|
@@ -237,7 +237,7 @@ const create = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
237
237
|
// Create files
|
|
238
238
|
const spinner = p.spinner();
|
|
239
239
|
spinner.start('Creating project files...');
|
|
240
|
-
const templateDir = path.resolve(__dirname, '
|
|
240
|
+
const templateDir = path.resolve(__dirname, '../../templates/default');
|
|
241
241
|
if (!fs.existsSync(templateDir)) {
|
|
242
242
|
throw new CreateError(`Template directory not found at ${templateDir}. This may indicate a packaging issue.`);
|
|
243
243
|
}
|
package/dist/cli/eject.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import Handoff from '../index';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const ejectConfig: (handoff: Handoff) => Promise<Handoff>;
|
|
7
7
|
/**
|
|
8
|
-
* Eject
|
|
8
|
+
* Eject pages to the working directory
|
|
9
9
|
* @param handoff
|
|
10
10
|
*/
|
|
11
11
|
export declare const ejectPages: (handoff: Handoff) => Promise<Handoff>;
|
|
12
12
|
/**
|
|
13
|
-
* Eject
|
|
13
|
+
* Eject theme to the working directory
|
|
14
14
|
* @param handoff
|
|
15
15
|
*/
|
|
16
16
|
export declare const ejectTheme: (handoff: Handoff) => Promise<Handoff>;
|
package/dist/cli/eject.js
CHANGED
|
@@ -35,7 +35,7 @@ const ejectConfig = (handoff) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
35
35
|
});
|
|
36
36
|
exports.ejectConfig = ejectConfig;
|
|
37
37
|
/**
|
|
38
|
-
* Eject
|
|
38
|
+
* Eject pages to the working directory
|
|
39
39
|
* @param handoff
|
|
40
40
|
*/
|
|
41
41
|
const ejectPages = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -54,7 +54,7 @@ const ejectPages = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
54
54
|
});
|
|
55
55
|
exports.ejectPages = ejectPages;
|
|
56
56
|
/**
|
|
57
|
-
* Eject
|
|
57
|
+
* Eject theme to the working directory
|
|
58
58
|
* @param handoff
|
|
59
59
|
*/
|
|
60
60
|
const ejectTheme = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
package/dist/cli/make.d.ts
CHANGED
|
@@ -9,8 +9,4 @@ export declare const makeTemplate: (handoff: Handoff, component: string, state:
|
|
|
9
9
|
* @param handoff
|
|
10
10
|
*/
|
|
11
11
|
export declare const makePage: (handoff: Handoff, name: string, parent: string | undefined) => Promise<Handoff>;
|
|
12
|
-
/**
|
|
13
|
-
* Make a new component
|
|
14
|
-
* @param handoff
|
|
15
|
-
*/
|
|
16
12
|
export declare const makeComponent: (handoff: Handoff, name: string) => Promise<Handoff>;
|
package/dist/cli/make.js
CHANGED
|
@@ -134,13 +134,25 @@ exports.makePage = makePage;
|
|
|
134
134
|
* Make a new component
|
|
135
135
|
* @param handoff
|
|
136
136
|
*/
|
|
137
|
+
const DEFAULT_COMPONENTS_DIR = 'components';
|
|
137
138
|
const makeComponent = (handoff, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
+
var _a, _b, _c;
|
|
138
140
|
if (!name) {
|
|
139
141
|
logger_1.Logger.error(`Component name must be set`);
|
|
140
142
|
return;
|
|
141
143
|
}
|
|
142
144
|
name = name.replace('.html', '');
|
|
143
|
-
let
|
|
145
|
+
let componentsRoot;
|
|
146
|
+
if ((_c = (_b = (_a = handoff.config) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.length) {
|
|
147
|
+
componentsRoot = path_1.default.resolve(handoff.workingPath, handoff.config.entries.components[0]);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
componentsRoot = path_1.default.resolve(handoff.workingPath, DEFAULT_COMPONENTS_DIR);
|
|
151
|
+
logger_1.Logger.warn(`No entries.components configured in handoff.config.js. ` +
|
|
152
|
+
`Scaffolding into "${DEFAULT_COMPONENTS_DIR}/". ` +
|
|
153
|
+
`Add this path to entries.components in your config so the build picks it up.`);
|
|
154
|
+
}
|
|
155
|
+
let workingPath = path_1.default.resolve(componentsRoot, name);
|
|
144
156
|
if (!fs_extra_1.default.existsSync(workingPath)) {
|
|
145
157
|
fs_extra_1.default.mkdirSync(workingPath, { recursive: true });
|
|
146
158
|
}
|
|
@@ -151,7 +163,7 @@ const makeComponent = (handoff, name) => __awaiter(void 0, void 0, void 0, funct
|
|
|
151
163
|
return;
|
|
152
164
|
}
|
|
153
165
|
}
|
|
154
|
-
const templatePath = path_1.default.join(handoff.modulePath, 'config', 'templates/
|
|
166
|
+
const templatePath = path_1.default.join(handoff.modulePath, 'config', 'templates/component');
|
|
155
167
|
const htmlPath = path_1.default.resolve(templatePath, 'template.hbs');
|
|
156
168
|
const htmlTemplate = fs_extra_1.default.readFileSync(htmlPath, 'utf8');
|
|
157
169
|
fs_extra_1.default.writeFileSync(targetHtml, htmlTemplate);
|
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ const __1 = __importDefault(require("../.."));
|
|
|
16
16
|
const utils_1 = require("../utils");
|
|
17
17
|
const command = {
|
|
18
18
|
command: 'build:components [component]',
|
|
19
|
-
describe: 'Build the current
|
|
19
|
+
describe: 'Build the current project components. Pass a name to build a specific component.',
|
|
20
20
|
builder: (yargs) => {
|
|
21
21
|
return (0, utils_1.getSharedOptions)(yargs).positional('component', {
|
|
22
22
|
describe: 'The name of the component',
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const create_1 = __importDefault(require("../../create"));
|
|
15
|
+
const create_1 = __importDefault(require("../../cli/create"));
|
|
16
16
|
const command = {
|
|
17
17
|
command: 'init',
|
|
18
18
|
describe: 'Initialize a new Handoff project with interactive wizard',
|
package/dist/commands/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Argv } from 'yargs';
|
|
2
|
-
export declare const getSharedOptions: (yargs: Argv) => Argv<import("yargs").Omit<{}, "
|
|
2
|
+
export declare const getSharedOptions: (yargs: Argv) => Argv<import("yargs").Omit<{}, "debug" | "config" | "force"> & import("yargs").InferredOptionTypes<{
|
|
3
3
|
config: {
|
|
4
4
|
alias: string;
|
|
5
5
|
type: "string";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ClientConfig, Config } from './types/config';
|
|
1
|
+
import { ClientConfig, Config } from '../types/config';
|
|
3
2
|
export interface ImageStyle {
|
|
4
3
|
name: string;
|
|
5
4
|
style: string;
|
|
@@ -11,7 +10,7 @@ export declare const defaultConfig: () => Config;
|
|
|
11
10
|
/**
|
|
12
11
|
* Retrieves the client configuration from the provided handoff configuration.
|
|
13
12
|
*
|
|
14
|
-
* @param
|
|
13
|
+
* @param config - The full handoff Config object.
|
|
15
14
|
* @returns The client configuration object.
|
|
16
15
|
*/
|
|
17
|
-
export declare const getClientConfig: (
|
|
16
|
+
export declare const getClientConfig: (config: Config) => ClientConfig;
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getClientConfig = exports.defaultConfig = void 0;
|
|
4
4
|
const defaultConfig = () => {
|
|
5
|
-
var _a, _b, _c, _d
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
6
|
return ({
|
|
7
7
|
dev_access_token: (_a = process.env.HANDOFF_DEV_ACCESS_TOKEN) !== null && _a !== void 0 ? _a : null,
|
|
8
8
|
figma_project_id: (_b = process.env.HANDOFF_FIGMA_PROJECT_ID) !== null && _b !== void 0 ? _b : null,
|
|
9
9
|
exportsOutputDirectory: (_c = process.env.HANDOFF_OUTPUT_DIR) !== null && _c !== void 0 ? _c : 'exported',
|
|
10
10
|
sitesOutputDirectory: (_d = process.env.HANDOFF_SITES_DIR) !== null && _d !== void 0 ? _d : 'out',
|
|
11
|
-
useVariables:
|
|
11
|
+
useVariables: process.env.HANDOFF_USE_VARIABLES === 'true',
|
|
12
|
+
reactDocgen: {
|
|
13
|
+
maxDepth: 7,
|
|
14
|
+
excludeDirectories: ['dist', 'build', '.next'],
|
|
15
|
+
},
|
|
12
16
|
app: {
|
|
13
17
|
theme: 'default',
|
|
14
18
|
title: 'Convertiv Design System',
|
|
@@ -48,11 +52,10 @@ exports.defaultConfig = defaultConfig;
|
|
|
48
52
|
/**
|
|
49
53
|
* Retrieves the client configuration from the provided handoff configuration.
|
|
50
54
|
*
|
|
51
|
-
* @param
|
|
55
|
+
* @param config - The full handoff Config object.
|
|
52
56
|
* @returns The client configuration object.
|
|
53
57
|
*/
|
|
54
|
-
const getClientConfig = (
|
|
55
|
-
const config = handoff.config;
|
|
58
|
+
const getClientConfig = (config) => {
|
|
56
59
|
const { app, exportsOutputDirectory, sitesOutputDirectory, assets_zip_links = { icons: null, logos: null }, useVariables, } = Object.assign(Object.assign({}, (0, exports.defaultConfig)()), config);
|
|
57
60
|
return {
|
|
58
61
|
app,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConfig = exports.initRuntimeConfig = exports.initConfig = exports.getClientConfig = exports.defaultConfig = void 0;
|
|
4
|
+
// Config defaults and client config
|
|
5
|
+
var defaults_1 = require("./defaults");
|
|
6
|
+
Object.defineProperty(exports, "defaultConfig", { enumerable: true, get: function () { return defaults_1.defaultConfig; } });
|
|
7
|
+
Object.defineProperty(exports, "getClientConfig", { enumerable: true, get: function () { return defaults_1.getClientConfig; } });
|
|
8
|
+
// Config file loading
|
|
9
|
+
var loader_1 = require("./loader");
|
|
10
|
+
Object.defineProperty(exports, "initConfig", { enumerable: true, get: function () { return loader_1.initConfig; } });
|
|
11
|
+
// Runtime config resolution
|
|
12
|
+
var runtime_1 = require("./runtime");
|
|
13
|
+
Object.defineProperty(exports, "initRuntimeConfig", { enumerable: true, get: function () { return runtime_1.initRuntimeConfig; } });
|
|
14
|
+
// Config validation
|
|
15
|
+
var validator_1 = require("./validator");
|
|
16
|
+
Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return validator_1.validateConfig; } });
|