chore: better Prettier config for easier reviews
This commit is contained in:
@ -3,30 +3,30 @@
|
||||
*/
|
||||
exports.componentGenerator = () => {
|
||||
return {
|
||||
description: 'Component Generator',
|
||||
description: "Component Generator",
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'component name'
|
||||
type: "input",
|
||||
name: "name",
|
||||
message: "component name",
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'folder',
|
||||
message: 'folder in components'
|
||||
}
|
||||
type: "input",
|
||||
name: "folder",
|
||||
message: "folder in components",
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
type: 'add',
|
||||
path: 'components/{{folder}}/{{properCase name}}/{{properCase name}}.tsx',
|
||||
templateFile: 'generators/component/Component.tsx.hbs'
|
||||
type: "add",
|
||||
path: "components/{{folder}}/{{properCase name}}/{{properCase name}}.tsx",
|
||||
templateFile: "generators/component/Component.tsx.hbs",
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'components/{{folder}}/{{properCase name}}/index.ts',
|
||||
templateFile: 'generators/component/index.ts.hbs'
|
||||
}
|
||||
]
|
||||
type: "add",
|
||||
path: "components/{{folder}}/{{properCase name}}/index.ts",
|
||||
templateFile: "generators/component/index.ts.hbs",
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
const fs = require('node:fs')
|
||||
const fs = require("node:fs")
|
||||
|
||||
const prettier = require('prettier')
|
||||
const prettier = require("prettier")
|
||||
|
||||
/**
|
||||
* @param {import('plop').NodePlopAPI} plop
|
||||
@ -8,41 +8,41 @@ const prettier = require('prettier')
|
||||
*/
|
||||
exports.languageGenerator = (plop) => {
|
||||
return {
|
||||
description: 'Add a new language for translations',
|
||||
description: "Add a new language for translations",
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'locale',
|
||||
message: 'locale'
|
||||
}
|
||||
type: "input",
|
||||
name: "locale",
|
||||
message: "locale",
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
type: 'addMany',
|
||||
base: 'locales/en',
|
||||
destination: 'locales/{{locale}}',
|
||||
templateFiles: 'locales/en/**'
|
||||
type: "addMany",
|
||||
base: "locales/en",
|
||||
destination: "locales/{{locale}}",
|
||||
templateFiles: "locales/en/**",
|
||||
},
|
||||
async (answers) => {
|
||||
process.chdir(plop.getPlopfilePath())
|
||||
const data = JSON.parse(
|
||||
await fs.promises.readFile('i18n.json', { encoding: 'utf-8' })
|
||||
await fs.promises.readFile("i18n.json", { encoding: "utf-8" }),
|
||||
)
|
||||
data.locales.push(answers.locale)
|
||||
const formatted = prettier.format(JSON.stringify(data, null, 2), {
|
||||
filepath: 'i18n.json'
|
||||
filepath: "i18n.json",
|
||||
})
|
||||
await fs.promises.writeFile('i18n.json', formatted, {
|
||||
encoding: 'utf-8'
|
||||
await fs.promises.writeFile("i18n.json", formatted, {
|
||||
encoding: "utf-8",
|
||||
})
|
||||
return plop.renderString(
|
||||
`
|
||||
Added '{{locale}}' to the 'locales' array inside 'i18n.json'
|
||||
Don't forget to add the flag at 'public/images/svg/languages/{{locale}}.svg'
|
||||
`,
|
||||
answers
|
||||
answers,
|
||||
)
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user