diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..fffa63a9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "typedoc"] + path = typedoc + url = https://github.com/TypeStrong/typedoc diff --git a/.prettierrc.json b/.prettierrc.json index 0967ef42..9fcfde7a 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1 +1,3 @@ -{} +{ + "printWidth": 120 +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..fd0ffd8b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, +} diff --git a/convert.ts b/convert.ts new file mode 100644 index 00000000..da908c6e --- /dev/null +++ b/convert.ts @@ -0,0 +1,21 @@ +import {readFileSync, writeFileSync} from 'fs'; +import { compile } from 'handlebars-to-jsx'; +import {sync as globSync} from 'glob'; +import {outdent} from 'outdent'; + +for(const file of globSync('src/**/*.hbs')) { + console.dir(file); + try { + const converted = compile(readFileSync(file, 'utf8')); + writeFileSync(file.replace(/.hbs$/, '.tsx'), outdent ` + import React from 'react'; + export const component = ${ converted } + + `); + } catch(e) { + // if(e.message.includes('block may only')) { + console.log(e.message); + console.log(`${file}:${e.location?.start?.line}:${e.location?.start?.column}`); + // } + } +} diff --git a/package.json b/package.json index cb318329..8c39386d 100644 --- a/package.json +++ b/package.json @@ -47,5 +47,15 @@ "typescript", "documentation", "generator" - ] + ], + "dependencies": { + "@types/react": "^17.0.14", + "@types/react-dom": "^17.0.9", + "glob": "^7.1.7", + "handlebars-to-jsx": "^0.1.4", + "outdent": "^0.8.0", + "react": "^17.0.2", + "react-dom": "^17.0.2", + "ts-node": "^10.1.0" + } } diff --git a/src/default/layouts/default.hbs b/src/default/layouts/default.hbs index 87722a78..34ef5dfa 100644 --- a/src/default/layouts/default.hbs +++ b/src/default/layouts/default.hbs @@ -3,7 +3,7 @@
-