Skip to content

Commit

Permalink
refactor: add CI and refactor the unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Liendo committed Jul 14, 2023
1 parent 6476ee1 commit 387d028
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 134 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: build

on:
pull_request:
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
cache: 'npm'
node-version: '16'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint

build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
cache: 'npm'
node-version: '16'
- name: Install dependencies
run: npm ci
- name: Build
env:
NOTION_ACCESS_TOKEN: ${{ secrets.NOTION_ACCESS_TOKEN }}
NOTION_NOTES_DATABASE_ID_ES: ${{ secrets.NOTION_NOTES_DATABASE_ID_ES }}
NOTION_NOTES_DATABASE_ID_EN: ${{ secrets.NOTION_NOTES_DATABASE_ID_EN }}
NOTION_PROJECTS_DATABASE_ID: ${{ secrets.NOTION_PROJECTS_DATABASE_ID }}
run: npm run build
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "michaelliendo.com",
"version": "4.0.0",
"version": "4.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
10 changes: 5 additions & 5 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
12 changes: 5 additions & 7 deletions src/i18n/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import type { FormattersInitializer } from 'typesafe-i18n';
import type { Locales, Formatters } from './i18n-types';

export const initFormatters: FormattersInitializer<Locales, Formatters> = (
locale: Locales,
) => {
const formatters: Formatters = {
// add your formatter functions here
};
export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => {
const formatters: Formatters = {
// add your formatter functions here
};

return formatters;
return formatters;
};
15 changes: 5 additions & 10 deletions src/i18n/i18n-svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
/* eslint-disable */

import { initI18nSvelte } from 'typesafe-i18n/svelte';
import type {
Formatters,
Locales,
TranslationFunctions,
Translations,
} from './i18n-types';
import type { Formatters, Locales, TranslationFunctions, Translations } from './i18n-types';
import { loadedFormatters, loadedLocales } from './i18n-util';

const { locale, LL, setLocale } = initI18nSvelte<
Locales,
Translations,
TranslationFunctions,
Formatters
Locales,
Translations,
TranslationFunctions,
Formatters
>(loadedLocales, loadedFormatters);

export { locale, LL, setLocale };
Expand Down
68 changes: 35 additions & 33 deletions src/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,100 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
/* eslint-disable */
import type { BaseTranslation as BaseTranslationType, LocalizedString, RequiredParams } from 'typesafe-i18n'
import type {
BaseTranslation as BaseTranslationType,
LocalizedString,
RequiredParams
} from 'typesafe-i18n';

export type BaseTranslation = BaseTranslationType
export type BaseLocale = 'en'
export type BaseTranslation = BaseTranslationType;
export type BaseLocale = 'en';

export type Locales =
| 'en'
| 'es'
export type Locales = 'en' | 'es';

export type Translation = RootTranslation
export type Translation = RootTranslation;

export type Translations = RootTranslation
export type Translations = RootTranslation;

type RootTranslation = {
LAYOUT: {
NAV: {
/**
* H​o​m​e
*/
HOME: string
HOME: string;
/**
* N​o​t​e​s
*/
NOTES: string
}
NOTES: string;
};
FOOTER: {
/**
* M​a​d​e​ ​b​y​ ​M​i​c​h​a​e​l​ ​L​i​e​n​d​o​ ​©​ ​{​s​t​a​r​t​}​ ​-​ ​{​e​n​d​}
* @param {number} end
* @param {number} start
*/
COPYRGHT: RequiredParams<'end' | 'start'>
COPYRGHT: RequiredParams<'end' | 'start'>;
/**
* S​o​u​r​c​e​ ​C​o​d​e
*/
SOURCE_CODE: string
}
}
SOURCE_CODE: string;
};
};
HOMEPAGE: {
/**
* H​i​ ​I​'​m​ ​{​n​a​m​e​}​ ​{​s​u​r​n​a​m​e​}​,
* @param {string} name
* @param {string} surname
*/
HI: RequiredParams<'name' | 'surname'>
HI: RequiredParams<'name' | 'surname'>;
/**
* I​'​m​ ​a​ ​S​o​f​t​w​a​r​e​ ​D​e​v​e​l​o​p​e​r​ ​f​o​c​u​s​e​d​ ​o​n​ ​R​e​a​c​t​ ​a​n​d​ ​T​y​p​e​S​c​r​i​p​t​ ​w​i​t​h​ ​a​ ​p​a​s​s​i​o​n​ ​f​o​r​ ​W​e​b​ ​D​e​v​e​l​o​p​m​e​n​t​.​ ​I​ ​e​n​j​o​y​ ​w​o​r​k​i​n​g​ ​o​n​ ​c​h​a​l​l​e​n​g​i​n​g​ ​p​r​o​j​e​c​t​s​ ​a​n​d​ ​v​a​l​u​e​ ​c​o​l​l​a​b​o​r​a​t​i​o​n​ ​a​n​d​ ​p​r​o​b​l​e​m​-​s​o​l​v​i​n​g​.
*/
ABOUT: string
ABOUT: string;
/**
* L​a​t​e​s​t​ ​N​o​t​e​s
*/
LATEST_NOTES: string
}
}
LATEST_NOTES: string;
};
};

export type TranslationFunctions = {
LAYOUT: {
NAV: {
/**
* Home
*/
HOME: () => LocalizedString
HOME: () => LocalizedString;
/**
* Notes
*/
NOTES: () => LocalizedString
}
NOTES: () => LocalizedString;
};
FOOTER: {
/**
* Made by Michael Liendo © {start} - {end}
*/
COPYRGHT: (arg: { end: number, start: number }) => LocalizedString
COPYRGHT: (arg: { end: number; start: number }) => LocalizedString;
/**
* Source Code
*/
SOURCE_CODE: () => LocalizedString
}
}
SOURCE_CODE: () => LocalizedString;
};
};
HOMEPAGE: {
/**
* Hi I'm {name} {surname},
*/
HI: (arg: { name: string, surname: string }) => LocalizedString
HI: (arg: { name: string; surname: string }) => LocalizedString;
/**
* I'm a Software Developer focused on React and TypeScript with a passion for Web Development. I enjoy working on challenging projects and value collaboration and problem-solving.
*/
ABOUT: () => LocalizedString
ABOUT: () => LocalizedString;
/**
* Latest Notes
*/
LATEST_NOTES: () => LocalizedString
}
}
LATEST_NOTES: () => LocalizedString;
};
};

export type Formatters = {}
export type Formatters = {};
24 changes: 12 additions & 12 deletions src/i18n/i18n-util.async.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
/* eslint-disable */

import { initFormatters } from './formatters'
import type { Locales, Translations } from './i18n-types'
import { loadedFormatters, loadedLocales, locales } from './i18n-util'
import { initFormatters } from './formatters';
import type { Locales, Translations } from './i18n-types';
import { loadedFormatters, loadedLocales, locales } from './i18n-util';

const localeTranslationLoaders = {
en: () => import('./en'),
es: () => import('./es'),
}
es: () => import('./es')
};

const updateDictionary = (locale: Locales, dictionary: Partial<Translations>): Translations =>
loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary }
(loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary });

export const importLocaleAsync = async (locale: Locales): Promise<Translations> =>
(await localeTranslationLoaders[locale]()).default as unknown as Translations
(await localeTranslationLoaders[locale]()).default as unknown as Translations;

export const loadLocaleAsync = async (locale: Locales): Promise<void> => {
updateDictionary(locale, await importLocaleAsync(locale))
loadFormatters(locale)
}
updateDictionary(locale, await importLocaleAsync(locale));
loadFormatters(locale);
};

export const loadAllLocalesAsync = (): Promise<void[]> => Promise.all(locales.map(loadLocaleAsync))
export const loadAllLocalesAsync = (): Promise<void[]> => Promise.all(locales.map(loadLocaleAsync));

export const loadFormatters = (locale: Locales): void =>
void (loadedFormatters[locale] = initFormatters(locale))
void (loadedFormatters[locale] = initFormatters(locale));
26 changes: 13 additions & 13 deletions src/i18n/i18n-util.sync.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
/* eslint-disable */

import { initFormatters } from './formatters'
import type { Locales, Translations } from './i18n-types'
import { loadedFormatters, loadedLocales, locales } from './i18n-util'
import { initFormatters } from './formatters';
import type { Locales, Translations } from './i18n-types';
import { loadedFormatters, loadedLocales, locales } from './i18n-util';

import en from './en'
import es from './es'
import en from './en';
import es from './es';

const localeTranslations = {
en,
es,
}
es
};

export const loadLocale = (locale: Locales): void => {
if (loadedLocales[locale]) return
if (loadedLocales[locale]) return;

loadedLocales[locale] = localeTranslations[locale] as unknown as Translations
loadFormatters(locale)
}
loadedLocales[locale] = localeTranslations[locale] as unknown as Translations;
loadFormatters(locale);
};

export const loadAllLocales = (): void => locales.forEach(loadLocale)
export const loadAllLocales = (): void => locales.forEach(loadLocale);

export const loadFormatters = (locale: Locales): void =>
void (loadedFormatters[locale] = initFormatters(locale))
void (loadedFormatters[locale] = initFormatters(locale));
44 changes: 25 additions & 19 deletions src/i18n/i18n-util.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
/* eslint-disable */

import { i18n as initI18n, i18nObject as initI18nObject, i18nString as initI18nString } from 'typesafe-i18n'
import type { LocaleDetector } from 'typesafe-i18n/detectors'
import type { LocaleTranslationFunctions, TranslateByString } from 'typesafe-i18n'
import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors'
import { initExtendDictionary } from 'typesafe-i18n/utils'
import type { Formatters, Locales, Translations, TranslationFunctions } from './i18n-types'
import {
i18n as initI18n,
i18nObject as initI18nObject,
i18nString as initI18nString
} from 'typesafe-i18n';
import type { LocaleDetector } from 'typesafe-i18n/detectors';
import type { LocaleTranslationFunctions, TranslateByString } from 'typesafe-i18n';
import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors';
import { initExtendDictionary } from 'typesafe-i18n/utils';
import type { Formatters, Locales, Translations, TranslationFunctions } from './i18n-types';

export const baseLocale: Locales = 'en'
export const baseLocale: Locales = 'en';

export const locales: Locales[] = [
'en',
'es'
]
export const locales: Locales[] = ['en', 'es'];

export const isLocale = (locale: string): locale is Locales => locales.includes(locale as Locales)
export const isLocale = (locale: string): locale is Locales => locales.includes(locale as Locales);

export const loadedLocales: Record<Locales, Translations> = {} as Record<Locales, Translations>
export const loadedLocales: Record<Locales, Translations> = {} as Record<Locales, Translations>;

export const loadedFormatters: Record<Locales, Formatters> = {} as Record<Locales, Formatters>
export const loadedFormatters: Record<Locales, Formatters> = {} as Record<Locales, Formatters>;

export const extendDictionary = initExtendDictionary<Translations>()
export const extendDictionary = initExtendDictionary<Translations>();

export const i18nString = (locale: Locales): TranslateByString => initI18nString<Locales, Formatters>(locale, loadedFormatters[locale])
export const i18nString = (locale: Locales): TranslateByString =>
initI18nString<Locales, Formatters>(locale, loadedFormatters[locale]);

export const i18nObject = (locale: Locales): TranslationFunctions =>
initI18nObject<Locales, Translations, TranslationFunctions, Formatters>(
locale,
loadedLocales[locale],
loadedFormatters[locale]
)
);

export const i18n = (): LocaleTranslationFunctions<Locales, Translations, TranslationFunctions> =>
initI18n<Locales, Translations, TranslationFunctions, Formatters>(loadedLocales, loadedFormatters)
initI18n<Locales, Translations, TranslationFunctions, Formatters>(
loadedLocales,
loadedFormatters
);

export const detectLocale = (...detectors: LocaleDetector[]): Locales => detectLocaleFn<Locales>(baseLocale, locales, ...detectors)
export const detectLocale = (...detectors: LocaleDetector[]): Locales =>
detectLocaleFn<Locales>(baseLocale, locales, ...detectors);
Loading

0 comments on commit 387d028

Please sign in to comment.