-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: switch template from nunjucks to react rendering engine (#267)
Co-authored-by: Lukasz Gornicki <[email protected]>
- Loading branch information
1 parent
1efc15c
commit 391dd6f
Showing
26 changed files
with
11,950 additions
and
7,509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__transpiled/ | ||
node_modules | ||
test/temp | ||
template/src/lib/config.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
node_modules | ||
output | ||
test/temp | ||
__transpiled/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import _ from 'lodash'; | ||
|
||
export function camelCase(string) { | ||
return _.camelCase(string); | ||
} | ||
|
||
export function pascalCase(string) { | ||
string = _.camelCase(string); | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
|
||
export function kebabCase(string) { | ||
return _.kebabCase(string); | ||
} | ||
|
||
export function capitalize(string) { | ||
return _.capitalize(string); | ||
} | ||
|
||
export function oneLine(string) { | ||
return string.replace(/\n/g, ' ').trim(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './general'; | ||
export * from './channels-topics'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const beautify = require('js-beautify').js; | ||
|
||
const beautifyConfig = { | ||
indent_size: '2', | ||
indent_char: ' ', | ||
max_preserve_newlines: '2', | ||
preserve_newlines: true, | ||
keep_array_indentation: false, | ||
break_chained_methods: false, | ||
indent_scripts: 'normal', | ||
brace_style: 'collapse', | ||
space_before_conditional: true, | ||
unescape_strings: false, | ||
jslint_happy: false, | ||
end_with_newline: false, | ||
wrap_line_length: '0', | ||
indent_inner_html: false, | ||
comma_first: false, | ||
e4x: false, | ||
indent_empty_lines: false, | ||
}; | ||
|
||
const beautifySingleFile = (filePath) => { | ||
const fileData = fs.readFileSync(filePath); | ||
const beautifiedData = beautify(fileData.toString(), beautifyConfig); | ||
fs.writeFileSync(filePath, beautifiedData); | ||
}; | ||
|
||
/** | ||
* Recursively beautify all files in directory | ||
* | ||
* @param {string} dirPath to recursively beautify files in | ||
*/ | ||
const beautifyAllOutputFiles = function (dirPath) { | ||
const files = fs.readdirSync(dirPath); | ||
files.forEach((file) => { | ||
const filePath = path.join(dirPath, file); | ||
if (fs.statSync(filePath).isDirectory()) { | ||
beautifyAllOutputFiles(filePath); | ||
} else { | ||
beautifySingleFile(filePath); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Format all source files with indentations and new lines | ||
*/ | ||
module.exports = { | ||
'generate:after': (generator) => { | ||
const entryPointFilePath = path.resolve( | ||
generator.targetDir, | ||
'src/api/index.js' | ||
); | ||
const handlersPath = path.resolve(generator.targetDir, 'src/api/handlers'); | ||
const routesPath = path.resolve(generator.targetDir, 'src/api/routes'); | ||
|
||
beautifyAllOutputFiles(handlersPath); | ||
beautifyAllOutputFiles(routesPath); | ||
beautifySingleFile(entryPointFilePath); | ||
}, | ||
}; |
Oops, something went wrong.