HubSpot / cms-react

A repo to expose CMS react examples, React defaults modules, and more to CMS devs
http://github.hubspot.com/cms-react/
Apache License 2.0
25 stars 15 forks source link

Hubspot CMS Dev Server doesn't generate types #77

Open webcodavic opened 1 month ago

webcodavic commented 1 month ago

There's a bug on hubspot-cms-dev server that cause hs-cms-dev-server --generateFieldTypes to not generate field types automatically. the slashes are different on projectRoot and id in getEntryPathFromId function

image

Currently to (temporarily) fix it I have to change the isInModulesFolder function on

var isInModulesFolder = (filePath, _projectRoot) => {
    const projectRoot = path8.normalize(_projectRoot);
  const getEntryPathFromId = (id) => {
    return id.startsWith(projectRoot) ? id.replace(path8.normalize(`${projectRoot}/`), "") : "";
  };
  const currentModuleId = path8.normalize(filePath);
  const moduleEntryPath = getEntryPathFromId(currentModuleId);
  const subFolderTokens = moduleEntryPath.split(path8.sep);
  return {
    inModuleFolder: subFolderTokens[0] === "components" && subFolderTokens[1] === "modules",
    isRootModuleFile: subFolderTokens.length === 3
  };
};