Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,16 @@ const getRuntimeComponentsPathsToWatch = (handoff) => {
var _a, _b, _c;
const result = new Map();
for (const runtimeComponentId of Object.keys((_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries.components) !== null && _b !== void 0 ? _b : {})) {
for (const runtimeComponentVersion of Object.keys(handoff.runtimeConfig.entries.components[runtimeComponentId])) {
const runtimeComponent = handoff.runtimeConfig.entries.components[runtimeComponentId][runtimeComponentVersion];
for (const [runtimeComponentEntryType, runtimeComponentEntryPath,] of Object.entries((_c = runtimeComponent.entries) !== null && _c !== void 0 ? _c : {})) {
const normalizedComponentEntryPath = runtimeComponentEntryPath;
if (fs_extra_1.default.existsSync(normalizedComponentEntryPath)) {
const entryType = runtimeComponentEntryType;
if (fs_extra_1.default.statSync(normalizedComponentEntryPath).isFile()) {
result.set(path_1.default.resolve(normalizedComponentEntryPath), entryType);
}
else {
result.set(normalizedComponentEntryPath, entryType);
}
const runtimeComponent = handoff.runtimeConfig.entries.components[runtimeComponentId];
for (const [runtimeComponentEntryType, runtimeComponentEntryPath,] of Object.entries((_c = runtimeComponent.entries) !== null && _c !== void 0 ? _c : {})) {
const normalizedComponentEntryPath = runtimeComponentEntryPath;
if (fs_extra_1.default.existsSync(normalizedComponentEntryPath)) {
const entryType = runtimeComponentEntryType;
if (fs_extra_1.default.statSync(normalizedComponentEntryPath).isFile()) {
result.set(path_1.default.resolve(normalizedComponentEntryPath), entryType);
}
else {
result.set(normalizedComponentEntryPath, entryType);
}
}
}
Expand Down Expand Up @@ -563,13 +561,13 @@ const watchApp = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
stdio: 'inherit',
env: Object.assign(Object.assign({}, process.env), { NODE_ENV: 'development' }),
});
console.log(`Ready on http://${hostname}:${port}`);
logger_1.Logger.success(`Ready on http://${hostname}:${port}`);
nextProcess.on('error', (error) => {
console.error(`Next.js dev process error: ${error}`);
logger_1.Logger.error(`Next.js dev process error: ${error}`);
process.exit(1);
});
nextProcess.on('close', (code) => {
console.log(`Next.js dev process closed with code ${code}`);
logger_1.Logger.success(`Next.js dev process closed with code ${code}`);
process.exit(code);
});
const wss = yield createWebSocketServer((_d = (_c = handoff.config.app.ports) === null || _c === void 0 ? void 0 : _c.websocket) !== null && _d !== void 0 ? _d : 3001);
Expand Down
16 changes: 8 additions & 8 deletions dist/cache/build-cache.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Handoff from '../index';
import { FileState } from './file-state';
/**
* Cache entry for a single component version
* Cache entry for a single component
*/
export interface ComponentCacheEntry {
/** File states for all source files of this component */
Expand Down Expand Up @@ -32,8 +32,8 @@ export interface BuildCache {
version: string;
/** State of global dependencies at last build */
globalDeps: GlobalDepsState;
/** Per-component cache entries: componentId -> version -> entry */
components: Record<string, Record<string, ComponentCacheEntry>>;
/** Per-component cache entries: componentId -> entry */
components: Record<string, ComponentCacheEntry>;
}
/**
* Gets the path to the build cache file
Expand All @@ -60,14 +60,14 @@ export declare function haveGlobalDepsChanged(cached: GlobalDepsState | null | u
/**
* Gets all file paths that should be tracked for a component
*/
export declare function getComponentFilePaths(handoff: Handoff, componentId: string, version: string): {
export declare function getComponentFilePaths(handoff: Handoff, componentId: string): {
files: string[];
templateDir?: string;
};
/**
* Computes current file states for a component
*/
export declare function computeComponentFileStates(handoff: Handoff, componentId: string, version: string): Promise<{
export declare function computeComponentFileStates(handoff: Handoff, componentId: string): Promise<{
files: Record<string, FileState>;
templateDirFiles?: Record<string, FileState>;
}>;
Expand All @@ -81,15 +81,15 @@ export declare function hasComponentChanged(cached: ComponentCacheEntry | null |
/**
* Checks if the component output files exist
*/
export declare function checkOutputExists(handoff: Handoff, componentId: string, version: string): Promise<boolean>;
export declare function checkOutputExists(handoff: Handoff, componentId: string): Promise<boolean>;
/**
* Creates an empty cache structure
*/
export declare function createEmptyCache(): BuildCache;
/**
* Updates cache entry for a specific component version
* Updates cache entry for a specific component
*/
export declare function updateComponentCacheEntry(cache: BuildCache, componentId: string, version: string, fileStates: {
export declare function updateComponentCacheEntry(cache: BuildCache, componentId: string, fileStates: {
files: Record<string, FileState>;
templateDirFiles?: Record<string, FileState>;
}): void;
Expand Down
29 changes: 13 additions & 16 deletions dist/cache/build-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ function haveGlobalDepsChanged(cached, current) {
/**
* Gets all file paths that should be tracked for a component
*/
function getComponentFilePaths(handoff, componentId, version) {
var _a, _b, _c, _d;
const runtimeComponent = (_d = (_c = (_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c[componentId]) === null || _d === void 0 ? void 0 : _d[version];
function getComponentFilePaths(handoff, componentId) {
var _a, _b, _c;
const runtimeComponent = (_c = (_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c[componentId];
if (!runtimeComponent) {
return { files: [] };
}
Expand All @@ -155,8 +155,8 @@ function getComponentFilePaths(handoff, componentId, version) {
// Find the config file path for this component
const configPaths = handoff.getConfigFilePaths();
for (const configPath of configPaths) {
// Check if this config path belongs to this component/version
if (configPath.includes(componentId) && configPath.includes(version)) {
// Check if this config path belongs to this component
if (configPath.includes(componentId)) {
files.push(configPath);
break;
}
Expand All @@ -182,7 +182,7 @@ function getComponentFilePaths(handoff, componentId, version) {
files.push(templatePath);
}
}
catch (_e) {
catch (_d) {
// File doesn't exist, still add to track
files.push(templatePath);
}
Expand All @@ -193,9 +193,9 @@ function getComponentFilePaths(handoff, componentId, version) {
/**
* Computes current file states for a component
*/
function computeComponentFileStates(handoff, componentId, version) {
function computeComponentFileStates(handoff, componentId) {
return __awaiter(this, void 0, void 0, function* () {
const { files: filePaths, templateDir } = getComponentFilePaths(handoff, componentId, version);
const { files: filePaths, templateDir } = getComponentFilePaths(handoff, componentId);
const files = {};
for (const filePath of filePaths) {
const state = yield (0, file_state_1.computeFileState)(filePath);
Expand Down Expand Up @@ -246,9 +246,9 @@ function hasComponentChanged(cached, current) {
/**
* Checks if the component output files exist
*/
function checkOutputExists(handoff, componentId, version) {
function checkOutputExists(handoff, componentId) {
return __awaiter(this, void 0, void 0, function* () {
const outputPath = path_1.default.resolve(handoff.workingPath, 'public/api/component', componentId, `${version}.json`);
const outputPath = path_1.default.resolve(handoff.workingPath, 'public/api/component', `${componentId}.json`);
return fs_extra_1.default.pathExists(outputPath);
});
}
Expand All @@ -263,13 +263,10 @@ function createEmptyCache() {
};
}
/**
* Updates cache entry for a specific component version
* Updates cache entry for a specific component
*/
function updateComponentCacheEntry(cache, componentId, version, fileStates) {
if (!cache.components[componentId]) {
cache.components[componentId] = {};
}
cache.components[componentId][version] = {
function updateComponentCacheEntry(cache, componentId, fileStates) {
cache.components[componentId] = {
files: fileStates.files,
templateDirFiles: fileStates.templateDirFiles,
buildTimestamp: Date.now(),
Expand Down
2 changes: 1 addition & 1 deletion dist/cli/make.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export declare const makeTemplate: (handoff: Handoff, component: string, state:
*/
export declare const makePage: (handoff: Handoff, name: string, parent: string | undefined) => Promise<Handoff>;
/**
* Make a new docs page
* Make a new component
* @param handoff
*/
export declare const makeComponent: (handoff: Handoff, name: string) => Promise<Handoff>;
7 changes: 3 additions & 4 deletions dist/cli/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,16 @@ const makePage = (handoff, name, parent) => __awaiter(void 0, void 0, void 0, fu
});
exports.makePage = makePage;
/**
* Make a new docs page
* Make a new component
* @param handoff
*/
const makeComponent = (handoff, name) => __awaiter(void 0, void 0, void 0, function* () {
if (!name) {
logger_1.Logger.error(`Component name must be set`);
return;
}
const version = '1.0.0';
name = name.replace('.html', '');
let workingPath = path_1.default.resolve(path_1.default.join(handoff.workingPath, `integration/components/${name}/${version}`));
let workingPath = path_1.default.resolve(path_1.default.join(handoff.workingPath, `integration/components/${name}`));
if (!fs_extra_1.default.existsSync(workingPath)) {
fs_extra_1.default.mkdirSync(workingPath, { recursive: true });
}
Expand All @@ -152,7 +151,7 @@ const makeComponent = (handoff, name) => __awaiter(void 0, void 0, void 0, funct
return;
}
}
const templatePath = path_1.default.join(handoff.modulePath, 'config', 'templates/integration/components/template/1.0.0');
const templatePath = path_1.default.join(handoff.modulePath, 'config', 'templates/integration/components/template');
const htmlPath = path_1.default.resolve(templatePath, 'template.hbs');
const htmlTemplate = fs_extra_1.default.readFileSync(htmlPath, 'utf8');
fs_extra_1.default.writeFileSync(targetHtml, htmlTemplate);
Expand Down
2 changes: 1 addition & 1 deletion dist/commands/make/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const __1 = __importDefault(require("../.."));
const logger_1 = require("../../utils/logger");
const utils_1 = require("../utils");
const command = {
command: 'make:component <name> <version>',
command: 'make:component <name>',
describe: 'Create a new html code component that you can embed in your documentation',
builder: (yargs) => {
return (0, utils_1.getSharedOptions)(yargs).positional('name', {
Expand Down
Loading