#!/usr/bin/env ts-node import hasDirOrFile from "./scripts/helpers/hasDirOrFile"; import paths from "./scripts/helpers/paths"; import * as fs from "fs"; if (!hasDirOrFile(paths.srcDir)) { fs.mkdirSync(paths.srcDir); } if (!hasDirOrFile(paths.templates)) { fs.mkdirSync(paths.templates); } if (!hasDirOrFile(paths.scripts)) { fs.mkdirSync(paths.scripts); } if (!hasDirOrFile(paths.indexJs)) { fs.writeFileSync( paths.indexJs, `console.log('Hello world from index.js!') ` ); } if (!hasDirOrFile(paths.homeJs)) { fs.writeFileSync( paths.homeJs, `console.log('Hello world from home.js!') ` ); } if (!hasDirOrFile(paths.homeTemplate)) { fs.writeFileSync(paths.homeTemplate, `

Hello world from home.hbs!

`); } if (!hasDirOrFile(paths.dotenv)) { fs.writeFileSync( paths.dotenv, `API_URL= MEDIA_URL= LOCALES=en DEFAULT_LOCALE=en PUBLIC_URL=http://localhost:3000 HTML_EXTENSION_IN_URL=true UNCATEGORIZED_CATEGORY_SLUG=` ); } if (!hasDirOrFile(paths.publicDir)) { fs.mkdirSync(paths.publicDir); } if (!hasDirOrFile(paths.translationsConfig)) { fs.writeFileSync( paths.translationsConfig, `{ "en": { "global": {}, "single-post": {}, "category": {}, "home": {}, "archive": {} }, "hu": { "global": {}, "single-post": {}, "category": {}, "home": {}, "archive": {} } } ` ); } if (!hasDirOrFile(paths.hbsHelpersDir)) { fs.mkdirSync(paths.hbsHelpersDir); } if (!hasDirOrFile(paths.hbsTranslationHelper)) { fs.writeFileSync( paths.hbsTranslationHelper, `export default function(i18n, key, ...params) { let translated = i18n[key]; params.forEach((param, index) => { if(index+1 === params.length) return; translated = translated.replace("%", param); }); return translated; }` ); } if (!hasDirOrFile(paths.hbsEqHelper)) { fs.writeFileSync( paths.hbsEqHelper, `export default function(arg1, arg2, options) { return (arg1 == arg2) ? options.fn(this) : options.inverse(this); }` ); }