chore: minimize build output

This commit is contained in:
Rotimi Best
2024-09-23 01:21:05 +01:00
parent 25b010ebf2
commit 877b514a7b
21 changed files with 672 additions and 660 deletions
+21 -9
View File
@@ -1,6 +1,6 @@
FROM node:18
FROM node:18-alpine AS builder
WORKDIR "/app"
WORKDIR /app
RUN npm install -g pnpm
@@ -18,19 +18,31 @@ ENV UNSPLASH_API_KEY=$UNSPLASH_API_KEY
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ENV PUBLIC_SERVER_URL=$PUBLIC_SERVER_URL
ENV PUBLIC_IP_REGISTRY_KEY=$PUBLIC_IP_REGISTRY_KEY
ENV NODE_OPTIONS="--max-old-space-size=2048"
ENV NODE_OPTIONS="--max-old-space-size=8192"
RUN pnpm i --frozen-lockfile
RUN pnpm i
COPY . /app/
COPY . .
WORKDIR "/app/apps/dashboard"
WORKDIR /app/apps/dashboard
RUN pnpm i --frozen-lockfile
RUN pnpm prepare
RUN pnpm i
RUN pnpm build
RUN pnpm prune --production
FROM node:18-alpine
WORKDIR /app/apps/dashboard
COPY --from=builder /app/apps/dashboard/build build/
COPY --from=builder /app/apps/dashboard/node_modules node_modules/
COPY package.json .
EXPOSE 5000
CMD ["pnpm", "start"]
ENV NODE_ENV=production
CMD [ "node", "build" ]
# EXPOSE 5000
# CMD ["pnpm", "start"]
# CMD [ "sh", "-c", "ls -la && cd apps/dashboard && pnpm build && pnpm start" ]
+1 -4
View File
@@ -20,19 +20,17 @@
"script:translate": "node ./scripts/translate.cjs"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.386.0",
"@carbon/charts-svelte": "^1.13.6",
"@defer/client": "^2.2.0",
"@lemonsqueezy/lemonsqueezy.js": "^2.2.0",
"@sentry/browser": "^7.61.0",
"@sentry/integrations": "^7.61.0",
"@sentry/vite-plugin": "^2.6.2",
"@supabase/supabase-js": "^2.31.0",
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/adapter-node": "^5.2.4",
"@sveltejs/adapter-vercel": "^3.0.3",
"@tailwindcss/forms": "^0.5.4",
"@types/pluralize": "0.0.30",
"@vercel/speed-insights": "^1.0.1",
"ai": "^2.1.31",
"axios": "^1.5.1",
"body-parser": "^1.20.2",
@@ -43,7 +41,6 @@
"d3-cloud": "^1.2.7",
"d3-sankey": "^0.12.3",
"dayjs": "^1.11.10",
"form-data": "^4.0.0",
"hotkeys-js": "^3.11.2",
"html-to-image": "^1.11.11",
"is-valid-domain": "^0.1.6",
@@ -1,4 +1,5 @@
<script lang="ts">
import { onMount } from 'svelte';
import { browser } from '$app/environment';
import Modal from '$lib/components/Modal/index.svelte';
import TextField from '$lib/components/Form/TextField.svelte';
@@ -7,7 +8,7 @@
import CheckmarkOutlineIcon from 'carbon-icons-svelte/lib/CheckmarkOutline.svelte';
import ComingSoon from '$lib/components/ComingSoon/index.svelte';
import { Tag } from 'carbon-components-svelte';
import { TEMPLATES, TAGS } from '$lib/mocks';
import { type GeneratedTemplates, getAllTemplates, TAGS } from '$lib/mocks';
import type { ExerciseTemplate } from '$lib/utils/types';
import { lesson, lessonByTranslation } from '../store/lessons';
import { useCompletion } from 'ai/svelte';
@@ -39,6 +40,7 @@
let isLoading = writable(false);
let isAIStarted = false;
let note = '';
let allTemplates: GeneratedTemplates;
const options = [
{
@@ -106,6 +108,10 @@
}, 500);
}
onMount(async () => {
allTemplates = await getAllTemplates();
});
$: content = lessonFallbackNote(
$lesson.materials.note,
$lessonByTranslation[$lesson.id || ''],
@@ -208,7 +214,7 @@
</div>
{:else if type === Type.TEMPLATE}
<div>
<h2 class="text-2xl font-medium my-5">
<h2 class="text-2xl font-medium mb-2 m-0">
{$t('course.navItem.lessons.exercises.new_exercise_modal.select_template')}
</h2>
@@ -228,32 +234,34 @@
</div>
<div class="flex flex-wrap items-start gap-2">
{#each TEMPLATES[selectedTag] as template}
<button
class="w-[161px] h-[140px] hover:scale-95 p-5 rounded-md dark:bg-neutral-700 border-2 {template.id ===
selectedTemplateId
? 'border-primary-400'
: `border-gray-200 dark:border-neutral-600 `} flex flex-col transition-all ease-in-out"
type="button"
on:click={() => (selectedTemplateId = template.id)}
>
<div class="flex flex-col justify-evenly h-full">
<p class="font-bold text-sm text-start flex items-center">
{template.title}
</p>
<div class="flex flex-col items-start justify-between gap-1">
<p class="text-xs font-normal">
{template.questions}
{$t('course.navItem.lessons.exercises.new_exercise_modal.questions')}
</p>
<p class="text-xs font-normal text-start">
{template.points}
{$t('course.navItem.lessons.exercises.new_exercise_modal.points')}
{#if allTemplates}
{#each allTemplates[selectedTag] as template}
<button
class="w-[161px] h-[140px] hover:scale-95 p-5 rounded-md dark:bg-neutral-700 border-2 {template.id ===
selectedTemplateId
? 'border-primary-400'
: `border-gray-200 dark:border-neutral-600 `} flex flex-col transition-all ease-in-out"
type="button"
on:click={() => (selectedTemplateId = template.id)}
>
<div class="flex flex-col justify-evenly h-full">
<p class="font-bold text-sm text-start flex items-center">
{template.title}
</p>
<div class="flex flex-col items-start justify-between gap-1">
<p class="text-xs font-normal">
{template.questions}
{$t('course.navItem.lessons.exercises.new_exercise_modal.questions')}
</p>
<p class="text-xs font-normal text-start">
{template.points}
{$t('course.navItem.lessons.exercises.new_exercise_modal.points')}
</p>
</div>
</div>
</div>
</button>
{/each}
</button>
{/each}
{/if}
</div>
<div class="mt-5 flex items-center justify-between">
@@ -264,13 +272,13 @@
onClick={handleBack}
/>
<PrimaryButton
isDisabled={!selectedTemplateId}
isDisabled={!selectedTemplateId || !allTemplates}
className="px-6 py-3"
label={$t('course.navItem.lessons.exercises.new_exercise_modal.finish')}
isLoading={isTemplateFinishedLoading}
onClick={async () => {
isTemplateFinishedLoading = true;
const template = TEMPLATES[selectedTag].find((t) => t.id === selectedTemplateId);
const template = allTemplates[selectedTag].find((t) => t.id === selectedTemplateId);
if (!template) return;
console.log('Selected template', template);
@@ -2,7 +2,7 @@
import isEmpty from 'lodash/isEmpty';
import { fade } from 'svelte/transition';
import { useCompletion } from 'ai/svelte';
import MODES from '$lib/utils/constants/mode.js';
import MODES from '$lib/utils/constants/mode';
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
import IconButton from '$lib/components/IconButton/index.svelte';
import { formatYoutubeVideo } from '$lib/utils/functions/formatYoutubeVideo';
+20 -41
View File
@@ -1,24 +1,3 @@
import cssSyntax from './001_css_syntax';
import cssSelectors from './002_css_selectors';
import cssHowTo from './003_css_howTo';
import cssComments from './004_css_comments';
import cssColors from './005_css_colors';
import cssBackgounds from './006_css_backgrounds';
import cssBorders from './007_css_borders';
import cssMargin from './008_css_margin';
import cssPadding from './009_css_padding';
import cssDimensions from './010_css_dimentions';
import cssBoxModel from './011_css_boxModel';
import cssOutline from './012_css_outline';
import cssText from './013_css_text';
import cssFonts from './014_css_fonts';
import cssIcons from './015_css_icons';
import cssLinks from './016_css_links';
import cssLists from './017_css_lists';
import cssTables from './018_css_tables';
import cssDisplay from './019_css_display';
import cssMaxWidth from './020_css_maxWidth';
export const CSS_IDS: { [key: string]: string } = {
CSS_SYNTAX: 'CSS_SYNTAX',
CSS_SELECTORS: 'CSS_SELECTORS',
@@ -43,24 +22,24 @@ export const CSS_IDS: { [key: string]: string } = {
};
export const CSS_TEMPLATES = {
[CSS_IDS.CSS_SYNTAX]: cssSyntax,
[CSS_IDS.CSS_SELECTORS]: cssSelectors,
[CSS_IDS.CSS_HOWTO]: cssHowTo,
[CSS_IDS.CSS_COMMENTS]: cssComments,
[CSS_IDS.CSS_COLORS]: cssColors,
[CSS_IDS.CSS_BACKGROUNDS]: cssBackgounds,
[CSS_IDS.CSS_BORDERS]: cssBorders,
[CSS_IDS.CSS_MARGIN]: cssMargin,
[CSS_IDS.CSS_PADDING]: cssPadding,
[CSS_IDS.CSS_DIMENTIONS]: cssDimensions,
[CSS_IDS.CSS_BOXMODEL]: cssBoxModel,
[CSS_IDS.CSS_OUTLINE]: cssOutline,
[CSS_IDS.CSS_TEXT]: cssText,
[CSS_IDS.CSS_FONTS]: cssFonts,
[CSS_IDS.CSS_ICONS]: cssIcons,
[CSS_IDS.CSS_LINKS]: cssLinks,
[CSS_IDS.CSS_LISTS]: cssLists,
[CSS_IDS.CSS_TABLES]: cssTables,
[CSS_IDS.CSS_DISPLAY]: cssDisplay,
[CSS_IDS.CSS_MAXWIDTH]: cssMaxWidth
[CSS_IDS.CSS_SYNTAX]: async () => (await import('./001_css_syntax')).default,
[CSS_IDS.CSS_SELECTORS]: async () => (await import('./002_css_selectors')).default,
[CSS_IDS.CSS_HOWTO]: async () => (await import('./003_css_howTo')).default,
[CSS_IDS.CSS_COMMENTS]: async () => (await import('./004_css_comments')).default,
[CSS_IDS.CSS_COLORS]: async () => (await import('./005_css_colors')).default,
[CSS_IDS.CSS_BACKGROUNDS]: async () => (await import('./006_css_backgrounds')).default,
[CSS_IDS.CSS_BORDERS]: async () => (await import('./007_css_borders')).default,
[CSS_IDS.CSS_MARGIN]: async () => (await import('./008_css_margin')).default,
[CSS_IDS.CSS_PADDING]: async () => (await import('./009_css_padding')).default,
[CSS_IDS.CSS_DIMENTIONS]: async () => (await import('./010_css_dimentions')).default,
[CSS_IDS.CSS_BOXMODEL]: async () => (await import('./011_css_boxModel')).default,
[CSS_IDS.CSS_OUTLINE]: async () => (await import('./012_css_outline')).default,
[CSS_IDS.CSS_TEXT]: async () => (await import('./013_css_text')).default,
[CSS_IDS.CSS_FONTS]: async () => (await import('./014_css_fonts')).default,
[CSS_IDS.CSS_ICONS]: async () => (await import('./015_css_icons')).default,
[CSS_IDS.CSS_LINKS]: async () => (await import('./016_css_links')).default,
[CSS_IDS.CSS_LISTS]: async () => (await import('./017_css_lists')).default,
[CSS_IDS.CSS_TABLES]: async () => (await import('./018_css_tables')).default,
[CSS_IDS.CSS_DISPLAY]: async () => (await import('./019_css_display')).default,
[CSS_IDS.CSS_MAXWIDTH]: async () => (await import('./020_css_maxWidth')).default
};
+20 -41
View File
@@ -1,24 +1,3 @@
import gitNewFiles from './001_git_newFiles';
import gitStaging from './002_git_staging';
import gitCommit from './003_git_commit';
import gitAmend from './004_git_amend';
import gitBranch from './005_git_branch';
import gitBranchMerge from './006_git_branchMerge';
import gitPull from './007_git_pull';
import gitPush from './008_git_push';
import gitGithubBranch from './009_git_githubBranch';
import gitBranchPull from './010_git_branchPull';
import gitBranchPush from './011_git_branchPush';
import gitGithubFlow from './012_git_githubFlow';
import gitGithubPages from './013_git_githubPages';
import gitGithubFork from './014_git_githubFork';
import gitClone from './015_git_clone';
import gitPullRequest from './016_git_pullRequest';
import gitIgnore from './017_git_ignore';
import gitSsh from './018_gitSsh';
import gitRevert from './019_git_revert';
import gitReset from './020_git_reset';
export const GIT_IDS: { [key: string]: string } = {
GIT_NEWFILES: 'GIT_NEWFILES',
GIT_STAGING: 'GIT_STAGING',
@@ -43,24 +22,24 @@ export const GIT_IDS: { [key: string]: string } = {
};
export const GIT_TEMPLATES = {
[GIT_IDS.GIT_NEWFILES]: gitNewFiles,
[GIT_IDS.GIT_STAGING]: gitStaging,
[GIT_IDS.GIT_COMMIT]: gitCommit,
[GIT_IDS.GIT_AMEND]: gitAmend,
[GIT_IDS.GIT_BRANCH]: gitBranch,
[GIT_IDS.GIT_BRANCHMERGE]: gitBranchMerge,
[GIT_IDS.GIT_PULL]: gitPull,
[GIT_IDS.GIT_PUSH]: gitPush,
[GIT_IDS.GIT_GITHUBBRANCH]: gitGithubBranch,
[GIT_IDS.GIT_BRANCHPULL]: gitBranchPull,
[GIT_IDS.GIT_BRANCHPUSH]: gitBranchPush,
[GIT_IDS.GIT_GITHUBFLOW]: gitGithubFlow,
[GIT_IDS.GIT_GITHUBPAGES]: gitGithubPages,
[GIT_IDS.GIT_GITHUBFORK]: gitGithubFork,
[GIT_IDS.GIT_CLONE]: gitClone,
[GIT_IDS.GIT_PULLREQUEST]: gitPullRequest,
[GIT_IDS.GIT_IGNORE]: gitIgnore,
[GIT_IDS.GIT_SSH]: gitSsh,
[GIT_IDS.GIT_REVERT]: gitRevert,
[GIT_IDS.GIT_RESET]: gitReset
[GIT_IDS.GIT_NEWFILES]: async () => (await import('./001_git_newFiles')).default,
[GIT_IDS.GIT_STAGING]: async () => (await import('./002_git_staging')).default,
[GIT_IDS.GIT_COMMIT]: async () => (await import('./003_git_commit')).default,
[GIT_IDS.GIT_AMEND]: async () => (await import('./004_git_amend')).default,
[GIT_IDS.GIT_BRANCH]: async () => (await import('./005_git_branch')).default,
[GIT_IDS.GIT_BRANCHMERGE]: async () => (await import('./006_git_branchMerge')).default,
[GIT_IDS.GIT_PULL]: async () => (await import('./007_git_pull')).default,
[GIT_IDS.GIT_PUSH]: async () => (await import('./008_git_push')).default,
[GIT_IDS.GIT_GITHUBBRANCH]: async () => (await import('./009_git_githubBranch')).default,
[GIT_IDS.GIT_BRANCHPULL]: async () => (await import('./010_git_branchPull')).default,
[GIT_IDS.GIT_BRANCHPUSH]: async () => (await import('./011_git_branchPush')).default,
[GIT_IDS.GIT_GITHUBFLOW]: async () => (await import('./012_git_githubFlow')).default,
[GIT_IDS.GIT_GITHUBPAGES]: async () => (await import('./013_git_githubPages')).default,
[GIT_IDS.GIT_GITHUBFORK]: async () => (await import('./014_git_githubFork')).default,
[GIT_IDS.GIT_CLONE]: async () => (await import('./015_git_clone')).default,
[GIT_IDS.GIT_PULLREQUEST]: async () => (await import('./016_git_pullRequest')).default,
[GIT_IDS.GIT_IGNORE]: async () => (await import('./017_git_ignore')).default,
[GIT_IDS.GIT_SSH]: async () => (await import('./018_gitSsh')).default,
[GIT_IDS.GIT_REVERT]: async () => (await import('./019_git_revert')).default,
[GIT_IDS.GIT_RESET]: async () => (await import('./020_git_reset')).default
};
+20 -41
View File
@@ -1,24 +1,3 @@
import htmlElements from './001_html_elements';
import htmlAttributes from './002_html_attributes';
import htmlHeadings from './003_html_headings';
import htmlPharagraphs from './004_html_paragraph';
import htmlStyles from './005_html_styles';
import htmlFormatting from './006_html_formatting';
import htmlQuotations from './007_html_quotations';
import htmlComments from './008_html_comments';
import htmlColors from './009_html_colors';
import htmlCss from './010_html_css';
import htmlLinks from './011_html_links';
import htmlImages from './012_html_images';
import htmlFavicon from './013_html_favicon';
import htmlPagetitle from './014_html_pageTitle';
import htmlTables from './015_html_tables';
import htmlLists from './016_html_lists';
import htmlBlocks from './017_html_blocks';
import htmlClasses from './018_html_classes';
import htmlId from './019_html_id';
import htmlIframes from './020_html_iframes';
export const HTML_IDS: { [key: string]: string } = {
HTML_ELEMENTS: 'HTML_ELEMENTS',
HTML_ATTRIBUTES: 'HTML_ATTRIBUTES',
@@ -43,24 +22,24 @@ export const HTML_IDS: { [key: string]: string } = {
};
export const HTML_TEMPLATES = {
[HTML_IDS.HTML_ELEMENTS]: htmlElements,
[HTML_IDS.HTML_ATTRIBUTES]: htmlAttributes,
[HTML_IDS.HTML_HEADINGS]: htmlHeadings,
[HTML_IDS.HTML_PARAGRAPH]: htmlPharagraphs,
[HTML_IDS.HTML_STYLES]: htmlStyles,
[HTML_IDS.HTML_FORMATTING]: htmlFormatting,
[HTML_IDS.HTML_QUOTATIONS]: htmlQuotations,
[HTML_IDS.HTML_COMMENTS]: htmlComments,
[HTML_IDS.HTML_COLORS]: htmlColors,
[HTML_IDS.HTML_CSS]: htmlCss,
[HTML_IDS.HTML_LINKS]: htmlLinks,
[HTML_IDS.HTML_IMAGES]: htmlImages,
[HTML_IDS.HTML_FAVICON]: htmlFavicon,
[HTML_IDS.HTML_PAGETITLE]: htmlPagetitle,
[HTML_IDS.HTML_TABLES]: htmlTables,
[HTML_IDS.HTML_LISTS]: htmlLists,
[HTML_IDS.HTML_BLOCKS]: htmlBlocks,
[HTML_IDS.HTML_CLASSES]: htmlClasses,
[HTML_IDS.HTML_ID]: htmlId,
[HTML_IDS.HTML_IFRAMES]: htmlIframes
[HTML_IDS.HTML_ELEMENTS]: async () => (await import('./001_html_elements')).default,
[HTML_IDS.HTML_ATTRIBUTES]: async () => (await import('./002_html_attributes')).default,
[HTML_IDS.HTML_HEADINGS]: async () => (await import('./003_html_headings')).default,
[HTML_IDS.HTML_PARAGRAPH]: async () => (await import('./004_html_paragraph')).default,
[HTML_IDS.HTML_STYLES]: async () => (await import('./005_html_styles')).default,
[HTML_IDS.HTML_FORMATTING]: async () => (await import('./006_html_formatting')).default,
[HTML_IDS.HTML_QUOTATIONS]: async () => (await import('./007_html_quotations')).default,
[HTML_IDS.HTML_COMMENTS]: async () => (await import('./008_html_comments')).default,
[HTML_IDS.HTML_COLORS]: async () => (await import('./009_html_colors')).default,
[HTML_IDS.HTML_CSS]: async () => (await import('./010_html_css')).default,
[HTML_IDS.HTML_LINKS]: async () => (await import('./011_html_links')).default,
[HTML_IDS.HTML_IMAGES]: async () => (await import('./012_html_images')).default,
[HTML_IDS.HTML_FAVICON]: async () => (await import('./013_html_favicon')).default,
[HTML_IDS.HTML_PAGETITLE]: async () => (await import('./014_html_pageTitle')).default,
[HTML_IDS.HTML_TABLES]: async () => (await import('./015_html_tables')).default,
[HTML_IDS.HTML_LISTS]: async () => (await import('./016_html_lists')).default,
[HTML_IDS.HTML_BLOCKS]: async () => (await import('./017_html_blocks')).default,
[HTML_IDS.HTML_CLASSES]: async () => (await import('./018_html_classes')).default,
[HTML_IDS.HTML_ID]: async () => (await import('./019_html_id')).default,
[HTML_IDS.HTML_IFRAMES]: async () => (await import('./020_html_iframes')).default
};
+59 -32
View File
@@ -1,16 +1,9 @@
import { HTML_IDS, HTML_TEMPLATES } from './html';
import { CSS_IDS, CSS_TEMPLATES } from './css';
import { calculateTotalPoints, shuffleOptions } from './utils';
import type { ExerciseTemplate } from '$lib/utils/types';
import { JS_IDS, JS_TEMPLATES } from './js';
import { NODE_IDS, NODE_TEMPLATES } from './node';
import { REACT_IDS, REACT_TEMPLATES } from './react';
import { TS_IDS, TS_TEMPLATES } from './typescript';
import { PHP_IDS, PHP_TEMPLATES } from './php';
import { VUE_IDS, VUE_TEMPLATES } from './vue';
import { GIT_IDS, GIT_TEMPLATES } from './git';
import { PYTHON_IDS, PYTHON_TEMPLATES } from './python';
// Rule to add new template
// The key and value must match
// The template should have both `{VALUE}_IDS` and `{VALUE}_TEMPLATES`
export const TAGS = {
HTML: 'HTML',
CSS: 'CSS',
@@ -24,41 +17,75 @@ export const TAGS = {
GIT: 'GIT'
};
function generateTemplateForTag(
export interface GeneratedTemplates {
[key: string]: LangTemplate[];
}
interface LangTemplate {
id: string;
title: string;
questions: number;
points: number;
data: ExerciseTemplate;
}
async function generateTemplateForTag(
keys: { [key: string]: string },
templates: {
[x: string]: ExerciseTemplate;
template: {
[x: string]: () => ExerciseTemplate;
}
) {
const template = [];
const templates: LangTemplate[] = [];
for (const key in keys) {
const id = keys[key];
templates[id].questionnaire.questions = templates[id].questionnaire.questions.map((q) => {
const data = await template[id]();
data.questionnaire.questions = data.questionnaire.questions.map((q) => {
q.options = shuffleOptions(q.options);
return q;
});
template.push({
templates.push({
id,
title: templates[id].title,
questions: templates[id].questionnaire.questions.length,
points: calculateTotalPoints(templates[id]),
data: templates[id]
title: data.title,
questions: data.questionnaire.questions.length,
points: calculateTotalPoints(data),
data: data
});
}
return template;
return templates;
}
export const TEMPLATES = {
[TAGS.HTML]: generateTemplateForTag(HTML_IDS, HTML_TEMPLATES),
[TAGS.CSS]: generateTemplateForTag(CSS_IDS, CSS_TEMPLATES),
[TAGS.JS]: generateTemplateForTag(JS_IDS, JS_TEMPLATES),
[TAGS.Typescript]: generateTemplateForTag(TS_IDS, TS_TEMPLATES),
[TAGS.ReactJS]: generateTemplateForTag(REACT_IDS, REACT_TEMPLATES),
[TAGS.VueJS]: generateTemplateForTag(VUE_IDS, VUE_TEMPLATES),
[TAGS.NodeJS]: generateTemplateForTag(NODE_IDS, NODE_TEMPLATES),
[TAGS.Python]: generateTemplateForTag(PYTHON_IDS, PYTHON_TEMPLATES),
[TAGS.PHP]: generateTemplateForTag(PHP_IDS, PHP_TEMPLATES),
[TAGS.GIT]: generateTemplateForTag(GIT_IDS, GIT_TEMPLATES)
export const getAllTemplates = async (): Promise<GeneratedTemplates> => {
const templateModules = {
HTML: await import('./html'),
CSS: await import('./css'),
JS: await import('./js'),
Typescript: await import('./typescript'),
ReactJS: await import('./react'),
VueJS: await import('./vue'),
NodeJS: await import('./node'),
Python: await import('./python'),
PHP: await import('./php'),
GIT: await import('./git')
};
const templates: GeneratedTemplates = {};
for (const tag in templateModules) {
try {
const module = templateModules[tag];
const ids = module[`${tag.toUpperCase()}_IDS`];
const templatesData = module[`${tag.toUpperCase()}_TEMPLATES`];
if (!templatesData) {
throw 'Templates not found';
}
templates[tag] = await generateTemplateForTag(ids, templatesData);
} catch (error) {
console.error('error finding template', error);
}
}
return templates;
};
+20 -41
View File
@@ -1,24 +1,3 @@
import jsStatement from './001_js_statements';
import jsSyntax from './002_js_syntax';
import jsComment from './003_js_comments';
import jsVariables from './004_js_variables';
import jsLet from './005_js_let';
import jsConst from './006_js_const';
import jsOperator from './007_js_operators';
import jsArithmetic from './008_js_arithmetic';
import jsAssignment from './009_js_assignment';
import jsDataTypes from './010_js_dataTypes';
import jsFunctions from './011_js_functions';
import jsObjects from './012_js_objects';
import jsEvents from './013_js_events';
import jsStrings from './014_js_strings';
import jsStringMethods from './015_js_stringMethods';
import jsStringSearch from './016_stringSearch';
import jsStringTemplates from './017_js_stringTemplates';
import jsNumbers from './018_js_numbers';
import jsBigInt from './019_js_bigInt';
import jsNumberMethods from './020_js_numberMethods';
export const JS_IDS: { [key: string]: string } = {
JS_OUTPUT: 'JS_OUTPUT',
JS_SYNTAX: 'JS_SYNTAX',
@@ -43,24 +22,24 @@ export const JS_IDS: { [key: string]: string } = {
};
export const JS_TEMPLATES = {
[JS_IDS.JS_OUTPUT]: jsStatement,
[JS_IDS.JS_SYNTAX]: jsSyntax,
[JS_IDS.JS_COMMENT]: jsComment,
[JS_IDS.JS_VARIABLES]: jsVariables,
[JS_IDS.JS_LET]: jsLet,
[JS_IDS.JS_CONST]: jsConst,
[JS_IDS.JS_OPERATOR]: jsOperator,
[JS_IDS.JS_ARITHMETIC]: jsArithmetic,
[JS_IDS.JS_ASSIGNMENT]: jsAssignment,
[JS_IDS.JS_DATATYPES]: jsDataTypes,
[JS_IDS.JS_FUNCTIONS]: jsFunctions,
[JS_IDS.JS_OBJECTS]: jsObjects,
[JS_IDS.JS_EVENTS]: jsEvents,
[JS_IDS.JS_STRINGS]: jsStrings,
[JS_IDS.JS_STRINGMETHODS]: jsStringMethods,
[JS_IDS.JS_STRINGSEARCH]: jsStringSearch,
[JS_IDS.JS_STRINGTEMPLATES]: jsStringTemplates,
[JS_IDS.JS_NUMBERS]: jsNumbers,
[JS_IDS.JS_BIGINT]: jsBigInt,
[JS_IDS.JS_NUMBERMETHODS]: jsNumberMethods
[JS_IDS.JS_OUTPUT]: async () => (await import('./001_js_statements')).default,
[JS_IDS.JS_SYNTAX]: async () => (await import('./002_js_syntax')).default,
[JS_IDS.JS_COMMENT]: async () => (await import('./003_js_comments')).default,
[JS_IDS.JS_VARIABLES]: async () => (await import('./004_js_variables')).default,
[JS_IDS.JS_LET]: async () => (await import('./005_js_let')).default,
[JS_IDS.JS_CONST]: async () => (await import('./006_js_const')).default,
[JS_IDS.JS_OPERATOR]: async () => (await import('./007_js_operators')).default,
[JS_IDS.JS_ARITHMETIC]: async () => (await import('./008_js_arithmetic')).default,
[JS_IDS.JS_ASSIGNMENT]: async () => (await import('./009_js_assignment')).default,
[JS_IDS.JS_DATATYPES]: async () => (await import('./010_js_dataTypes')).default,
[JS_IDS.JS_FUNCTIONS]: async () => (await import('./011_js_functions')).default,
[JS_IDS.JS_OBJECTS]: async () => (await import('./012_js_objects')).default,
[JS_IDS.JS_EVENTS]: async () => (await import('./013_js_events')).default,
[JS_IDS.JS_STRINGS]: async () => (await import('./014_js_strings')).default,
[JS_IDS.JS_STRINGMETHODS]: async () => (await import('./015_js_stringMethods')).default,
[JS_IDS.JS_STRINGSEARCH]: async () => (await import('./016_stringSearch')).default,
[JS_IDS.JS_STRINGTEMPLATES]: async () => (await import('./017_js_stringTemplates')).default,
[JS_IDS.JS_NUMBERS]: async () => (await import('./018_js_numbers')).default,
[JS_IDS.JS_BIGINT]: async () => (await import('./019_js_bigInt')).default,
[JS_IDS.JS_NUMBERMETHODS]: async () => (await import('./020_js_numberMethods')).default
};
+23 -43
View File
@@ -1,25 +1,4 @@
import nodeModule from './001_node_module';
import nodeHttpModule from './002_node_httpModule';
import nodeFileSystem from './003_node_fileSystem';
import nodeUrlModule from './004_node_urlModule';
import nodeNpm from './005_node_npm';
import nodeEvents from './006_node_events';
import nodeUploadFiles from './007_node_uploadFiles';
import nodeEmail from './008_node_email';
import nodeSqlDatabase from './009_node_sqlDatabase';
import nodeSqlCreateTable from './010_node_sqlCreateTable';
import nodeSqlInertInto from './011_node_sqlInsertInto';
import nodeSqlSelectForm from './012_node_sqlSelectForm';
import nodeSqlWhere from './013_node_sqlWhere';
import nodeSqlOrderBy from './014_node_sqlOrderBy';
import nodeSqlDelete from './015_node_sqlDelete';
import nodeSqlDropTable from './016_node_sqlDropTable';
import nodeSqlUpdate from './017_node_sqlUpdate';
import nodeSqlLimit from './018_node_sqlLimit';
import nodeSqlJoin from './019_node_sqlJoin';
import nodeMongoDBDatabase from './020_node_mongodbDatabase';
export const NODE_IDS: { [key: string]: string } = {
export const NODEJS_IDS: { [key: string]: string } = {
NODE_MODULE: 'NODE_MODULE',
NODE_HTTPMODULE: 'NODE_HTTPMODULE',
NODE_FILESYSTEM: 'NODE_FILESYSTEM',
@@ -42,25 +21,26 @@ export const NODE_IDS: { [key: string]: string } = {
NODE_MONGODBDATABASE: 'NODE_MONGODBDATABASE'
};
export const NODE_TEMPLATES = {
[NODE_IDS.NODE_MODULE]: nodeModule,
[NODE_IDS.NODE_HTTPMODULE]: nodeHttpModule,
[NODE_IDS.NODE_FILESYSTEM]: nodeFileSystem,
[NODE_IDS.NODE_URLMODULE]: nodeUrlModule,
[NODE_IDS.NODE_NPM]: nodeNpm,
[NODE_IDS.NODE_EVENTS]: nodeEvents,
[NODE_IDS.NODE_UPLOADFILES]: nodeUploadFiles,
[NODE_IDS.NODE_EMAIL]: nodeEmail,
[NODE_IDS.NODE_SQLDATABASE]: nodeSqlDatabase,
[NODE_IDS.NODE_SQLCREATETABLE]: nodeSqlCreateTable,
[NODE_IDS.NODE_SQLINSERTINTO]: nodeSqlInertInto,
[NODE_IDS.NODE_SQLSELECTFORM]: nodeSqlSelectForm,
[NODE_IDS.NODE_SQLWHERE]: nodeSqlWhere,
[NODE_IDS.NODE_SQLORDERBY]: nodeSqlOrderBy,
[NODE_IDS.NODE_SQLDELETE]: nodeSqlDelete,
[NODE_IDS.NODE_SQLDROPTABLE]: nodeSqlDropTable,
[NODE_IDS.NODE_SQLUPDATE]: nodeSqlUpdate,
[NODE_IDS.NODE_SQLLIMIT]: nodeSqlLimit,
[NODE_IDS.NODE_SQLJOIN]: nodeSqlJoin,
[NODE_IDS.NODE_MONGODBDATABASE]: nodeMongoDBDatabase
export const NODEJS_TEMPLATES = {
[NODEJS_IDS.NODE_MODULE]: async () => (await import('./001_node_module')).default,
[NODEJS_IDS.NODE_HTTPMODULE]: async () => (await import('./002_node_httpModule')).default,
[NODEJS_IDS.NODE_FILESYSTEM]: async () => (await import('./003_node_fileSystem')).default,
[NODEJS_IDS.NODE_URLMODULE]: async () => (await import('./004_node_urlModule')).default,
[NODEJS_IDS.NODE_NPM]: async () => (await import('./005_node_npm')).default,
[NODEJS_IDS.NODE_EVENTS]: async () => (await import('./006_node_events')).default,
[NODEJS_IDS.NODE_UPLOADFILES]: async () => (await import('./007_node_uploadFiles')).default,
[NODEJS_IDS.NODE_EMAIL]: async () => (await import('./008_node_email')).default,
[NODEJS_IDS.NODE_SQLDATABASE]: async () => (await import('./009_node_sqlDatabase')).default,
[NODEJS_IDS.NODE_SQLCREATETABLE]: async () => (await import('./010_node_sqlCreateTable')).default,
[NODEJS_IDS.NODE_SQLINSERTINTO]: async () => (await import('./011_node_sqlInsertInto')).default,
[NODEJS_IDS.NODE_SQLSELECTFORM]: async () => (await import('./012_node_sqlSelectForm')).default,
[NODEJS_IDS.NODE_SQLWHERE]: async () => (await import('./013_node_sqlWhere')).default,
[NODEJS_IDS.NODE_SQLORDERBY]: async () => (await import('./014_node_sqlOrderBy')).default,
[NODEJS_IDS.NODE_SQLDELETE]: async () => (await import('./015_node_sqlDelete')).default,
[NODEJS_IDS.NODE_SQLDROPTABLE]: async () => (await import('./016_node_sqlDropTable')).default,
[NODEJS_IDS.NODE_SQLUPDATE]: async () => (await import('./017_node_sqlUpdate')).default,
[NODEJS_IDS.NODE_SQLLIMIT]: async () => (await import('./018_node_sqlLimit')).default,
[NODEJS_IDS.NODE_SQLJOIN]: async () => (await import('./019_node_sqlJoin')).default,
[NODEJS_IDS.NODE_MONGODBDATABASE]: async () =>
(await import('./020_node_mongodbDatabase')).default
};
+20 -41
View File
@@ -1,24 +1,3 @@
import phpSyntax from './001_php_syntax';
import phpComments from './002_php_comments';
import phpVariables from './003_php_variables';
import phpEcho from './004_php_echo';
import phpDataTypes from './005_php_dataTypes';
import phpString from './006_php_string';
import phpNumbers from './007_php_numbers';
import phpMath from './008_php_math';
import phpConstants from './009_php_constants';
import phpOperators from './010_php_operators';
import phpConditionals from './011_php_conditionals';
import phpSwitch from './012_php_switch';
import phpLoops from './013_php_loops';
import phpFunctions from './014_php_functions';
import phpArrays from './015_php_arrays';
import phpSuperglobal from './016_php_superGlobal';
import phpRegex from './017_php_regex';
import phpForms from './018_php_forms';
import phpFormValidation from './019_php_formValidation';
import phpFormRequired from './020_php_formRequired';
export const PHP_IDS: { [key: string]: string } = {
PHP_SYNTAX: 'PHP_SYNTAX',
PHP_COMMENTS: 'PHP_COMMENTS',
@@ -43,24 +22,24 @@ export const PHP_IDS: { [key: string]: string } = {
};
export const PHP_TEMPLATES = {
[PHP_IDS.PHP_SYNTAX]: phpSyntax,
[PHP_IDS.PHP_COMMENTS]: phpComments,
[PHP_IDS.PHP_VARIABLES]: phpVariables,
[PHP_IDS.PHP_ECHO]: phpEcho,
[PHP_IDS.PHP_DATATYPES]: phpDataTypes,
[PHP_IDS.PHP_STRING]: phpString,
[PHP_IDS.PHP_NUMBERS]: phpNumbers,
[PHP_IDS.PHP_MATH]: phpMath,
[PHP_IDS.PHP_CONSTANTS]: phpConstants,
[PHP_IDS.PHP_OPERATORS]: phpOperators,
[PHP_IDS.PHP_CONDITIONALS]: phpConditionals,
[PHP_IDS.PHP_SWITCH]: phpSwitch,
[PHP_IDS.PHP_LOOPS]: phpLoops,
[PHP_IDS.PHP_FUNCTIONS]: phpFunctions,
[PHP_IDS.PHP_ARRAYS]: phpArrays,
[PHP_IDS.PHP_SUPERGLOBAL]: phpSuperglobal,
[PHP_IDS.PHP_REGEX]: phpRegex,
[PHP_IDS.PHP_FORMS]: phpForms,
[PHP_IDS.PHP_FORMVALIDATION]: phpFormValidation,
[PHP_IDS.PHP_FORMREQUIRED]: phpFormRequired
[PHP_IDS.PHP_SYNTAX]: async () => (await import('./001_php_syntax')).default,
[PHP_IDS.PHP_COMMENTS]: async () => (await import('./002_php_comments')).default,
[PHP_IDS.PHP_VARIABLES]: async () => (await import('./003_php_variables')).default,
[PHP_IDS.PHP_ECHO]: async () => (await import('./004_php_echo')).default,
[PHP_IDS.PHP_DATATYPES]: async () => (await import('./005_php_dataTypes')).default,
[PHP_IDS.PHP_STRING]: async () => (await import('./006_php_string')).default,
[PHP_IDS.PHP_NUMBERS]: async () => (await import('./007_php_numbers')).default,
[PHP_IDS.PHP_MATH]: async () => (await import('./008_php_math')).default,
[PHP_IDS.PHP_CONSTANTS]: async () => (await import('./009_php_constants')).default,
[PHP_IDS.PHP_OPERATORS]: async () => (await import('./010_php_operators')).default,
[PHP_IDS.PHP_CONDITIONALS]: async () => (await import('./011_php_conditionals')).default,
[PHP_IDS.PHP_SWITCH]: async () => (await import('./012_php_switch')).default,
[PHP_IDS.PHP_LOOPS]: async () => (await import('./013_php_loops')).default,
[PHP_IDS.PHP_FUNCTIONS]: async () => (await import('./014_php_functions')).default,
[PHP_IDS.PHP_ARRAYS]: async () => (await import('./015_php_arrays')).default,
[PHP_IDS.PHP_SUPERGLOBAL]: async () => (await import('./016_php_superGlobal')).default,
[PHP_IDS.PHP_REGEX]: async () => (await import('./017_php_regex')).default,
[PHP_IDS.PHP_FORMS]: async () => (await import('./018_php_forms')).default,
[PHP_IDS.PHP_FORMVALIDATION]: async () => (await import('./019_php_formValidation')).default,
[PHP_IDS.PHP_FORMREQUIRED]: async () => (await import('./020_php_formRequired')).default
};
+20 -41
View File
@@ -1,24 +1,3 @@
import pythonSyntax from './001_python_syntax';
import pythonComments from './002_python_comments';
import pythonVariables from './003_python_variables';
import pythonDataTypes from './004_python_dataTypes';
import pythonNumbers from './005_python_numbers';
import pythonCasting from './006_python_casting';
import pythonStrings from './007_python_strings';
import pythonBooleans from './008_python_booleans';
import pythonOperators from './009_python_operators';
import pythonLists from './010_python_lists';
import pythonTuples from './011_python_tuples';
import pythonSets from './012_python_sets';
import pythonDictionaries from './013_python_dictionaries';
import pythonConditionals from './014_python_conditionals';
import pythonWhileLoops from './015_python_whileLoops';
import pythonForLoops from './016_python_forLoops';
import pythonFunctions from './017_python_functions';
import pythonLambda from './018_python_lambda';
import pythonArrays from './019_python_arrays';
import pythonClasses from './020_python_classes';
export const PYTHON_IDS: { [key: string]: string } = {
PYTHON_SYNTAX: 'PYTHON_SYNTAX',
PYTHON_COMMENTS: 'PYTHON_COMMENTS',
@@ -43,24 +22,24 @@ export const PYTHON_IDS: { [key: string]: string } = {
};
export const PYTHON_TEMPLATES = {
[PYTHON_IDS.PYTHON_SYNTAX]: pythonSyntax,
[PYTHON_IDS.PYTHON_COMMENTS]: pythonComments,
[PYTHON_IDS.PYTHON_VARIABLES]: pythonVariables,
[PYTHON_IDS.PYTHON_DATATYPES]: pythonDataTypes,
[PYTHON_IDS.PYTHON_NUMBERS]: pythonNumbers,
[PYTHON_IDS.PYTHON_CASTING]: pythonCasting,
[PYTHON_IDS.PYTHON_STRINGS]: pythonStrings,
[PYTHON_IDS.PYTHON_BOOLEANS]: pythonBooleans,
[PYTHON_IDS.PYTHON_OPERATORS]: pythonOperators,
[PYTHON_IDS.PYTHON_LISTS]: pythonLists,
[PYTHON_IDS.PYTHON_TUPLES]: pythonTuples,
[PYTHON_IDS.PYTHON_SETS]: pythonSets,
[PYTHON_IDS.PYTHON_DICTIONARIES]: pythonDictionaries,
[PYTHON_IDS.PYTHON_CONDITIONALS]: pythonConditionals,
[PYTHON_IDS.PYTHON_WHILELOOPS]: pythonWhileLoops,
[PYTHON_IDS.PYTHON_FORLOOPS]: pythonForLoops,
[PYTHON_IDS.PYTHON_FUNCTIONS]: pythonFunctions,
[PYTHON_IDS.PYTHON_LAMBDA]: pythonLambda,
[PYTHON_IDS.PYTHON_ARRAYS]: pythonArrays,
[PYTHON_IDS.PYTHON_CLASSES]: pythonClasses
[PYTHON_IDS.PYTHON_SYNTAX]: async () => (await import('./001_python_syntax')).default,
[PYTHON_IDS.PYTHON_COMMENTS]: async () => (await import('./002_python_comments')).default,
[PYTHON_IDS.PYTHON_VARIABLES]: async () => (await import('./003_python_variables')).default,
[PYTHON_IDS.PYTHON_DATATYPES]: async () => (await import('./004_python_dataTypes')).default,
[PYTHON_IDS.PYTHON_NUMBERS]: async () => (await import('./005_python_numbers')).default,
[PYTHON_IDS.PYTHON_CASTING]: async () => (await import('./006_python_casting')).default,
[PYTHON_IDS.PYTHON_STRINGS]: async () => (await import('./007_python_strings')).default,
[PYTHON_IDS.PYTHON_BOOLEANS]: async () => (await import('./008_python_booleans')).default,
[PYTHON_IDS.PYTHON_OPERATORS]: async () => (await import('./009_python_operators')).default,
[PYTHON_IDS.PYTHON_LISTS]: async () => (await import('./010_python_lists')).default,
[PYTHON_IDS.PYTHON_TUPLES]: async () => (await import('./011_python_tuples')).default,
[PYTHON_IDS.PYTHON_SETS]: async () => (await import('./012_python_sets')).default,
[PYTHON_IDS.PYTHON_DICTIONARIES]: async () => (await import('./013_python_dictionaries')).default,
[PYTHON_IDS.PYTHON_CONDITIONALS]: async () => (await import('./014_python_conditionals')).default,
[PYTHON_IDS.PYTHON_WHILELOOPS]: async () => (await import('./015_python_whileLoops')).default,
[PYTHON_IDS.PYTHON_FORLOOPS]: async () => (await import('./016_python_forLoops')).default,
[PYTHON_IDS.PYTHON_FUNCTIONS]: async () => (await import('./017_python_functions')).default,
[PYTHON_IDS.PYTHON_LAMBDA]: async () => (await import('./018_python_lambda')).default,
[PYTHON_IDS.PYTHON_ARRAYS]: async () => (await import('./019_python_arrays')).default,
[PYTHON_IDS.PYTHON_CLASSES]: async () => (await import('./020_python_classes')).default
};
+45 -69
View File
@@ -1,38 +1,4 @@
import reactEs6 from './001_react_es6';
import reactEs6ArrowFunction from './002_react_es6ArrowFunctions';
import reactEs6Variables from './003_react_es6Variables';
import reactEs6ArrayMethods from './004_react_es6ArrayMethods';
import reactEs6Destructuring from './005_react_es6Destructuring';
import reactEs6SpreadOperator from './006_react_es6SpreadOperator';
import reactEs6Modules from './007_react_es6Modules';
import reactEs6TenaryOperator from './008_react_es6TenaryOperator';
import reactJsx from './009_react_jsx';
import reactComponents from './010_react_components';
import reactClassComponents from './011_react_classComponents';
import reactProps from './012_react_props';
import reactEvents from './013_react_events';
import reactConditionals from './014_react_conditionals';
import reactLists from './015_react_lists';
import reactForms from './016_react_forms';
import reactRouter from './017_react_router';
import reactMemo from './018_react_memo';
import reactCssStyling from './019_react_cssStyling';
import reactSassStyling from './020_react_sassStyling';
import reactImportExport from './021_react_importingAndExporting';
import reactExtractingStateLogic from './022_react_extractingStateLogic';
import reactSharingState from './023_react_sharingState';
import reactUpdatingObjects from './024_react_updatingObjects';
import reactUpdatingArrays from './025_react_updatingArrays';
import reactUseState from './026_react_useState';
import reactUseContext from './027_react_useContext';
import reactUseEffect from './028_react_useEffect';
import reactUseReducer from './029_react_useReducer';
import reactUseRef from './030_react_useRef';
import reactUseCallback from './031_react_useCallBack';
import reactCustomHooks from './032_react_customHooks';
import reactUseMemo from './033_react_useMemo';
export const REACT_IDS: { [key: string]: string } = {
export const REACTJS_IDS: { [key: string]: string } = {
REACT_ES6: 'REACT_ES6',
REACT_ES6ARROWFUNCTION: 'REACT_ES6ARROWFUNCTION',
REACT_ES6VARIABLES: 'REACT_ES6VARIABLES',
@@ -68,38 +34,48 @@ export const REACT_IDS: { [key: string]: string } = {
REACT_USEMEMO: 'REACT_USEMEMO'
};
export const REACT_TEMPLATES = {
[REACT_IDS.REACT_ES6]: reactEs6,
[REACT_IDS.REACT_ES6ARROWFUNCTION]: reactEs6ArrowFunction,
[REACT_IDS.REACT_ES6VARIABLES]: reactEs6Variables,
[REACT_IDS.REACT_ES6ARRAYMETHODS]: reactEs6ArrayMethods,
[REACT_IDS.REACT_ES6DESTRUCTURING]: reactEs6Destructuring,
[REACT_IDS.REACT_ES6SPREADOPERATOR]: reactEs6SpreadOperator,
[REACT_IDS.REACT_ES6MODULES]: reactEs6Modules,
[REACT_IDS.REACT_ES6TENARYOPERATOR]: reactEs6TenaryOperator,
[REACT_IDS.REACT_JSX]: reactJsx,
[REACT_IDS.REACT_COMPONENTS]: reactComponents,
[REACT_IDS.REACT_CLASSCOMPONENTS]: reactClassComponents,
[REACT_IDS.REACT_PROPS]: reactProps,
[REACT_IDS.REACT_EVENTS]: reactEvents,
[REACT_IDS.REACT_CONDITIONALS]: reactConditionals,
[REACT_IDS.REACT_LISTS]: reactLists,
[REACT_IDS.REACT_FORMS]: reactForms,
[REACT_IDS.REACT_ROUTER]: reactRouter,
[REACT_IDS.REACT_MEMO]: reactMemo,
[REACT_IDS.REACT_CSSSTYLING]: reactCssStyling,
[REACT_IDS.REACT_SASSSTYLING]: reactSassStyling,
[REACT_IDS.REACT_IMPORTEXPORT]: reactImportExport,
[REACT_IDS.REACT_EXTRACTSTATELOGIC]: reactExtractingStateLogic,
[REACT_IDS.REACT_SHARINGSTATE]: reactSharingState,
[REACT_IDS.REACT_UPDATINGOBJECTS]: reactUpdatingObjects,
[REACT_IDS.REACT_UPDATINGARRAYS]: reactUpdatingArrays,
[REACT_IDS.REACT_USESTATE]: reactUseState,
[REACT_IDS.REACT_USEEFFECT]: reactUseEffect,
[REACT_IDS.REACT_USECONTEXT]: reactUseContext,
[REACT_IDS.REACT_USEREF]: reactUseRef,
[REACT_IDS.REACT_USEREDUCER]: reactUseReducer,
[REACT_IDS.REACT_USECALLBACK]: reactUseCallback,
[REACT_IDS.REACT_CUSTOMHOOKS]: reactCustomHooks,
[REACT_IDS.REACT_USEMEMO]: reactUseMemo
export const REACTJS_TEMPLATES = {
[REACTJS_IDS.REACT_ES6]: async () => (await import('./001_react_es6')).default,
[REACTJS_IDS.REACT_ES6ARROWFUNCTION]: async () =>
(await import('./002_react_es6ArrowFunctions')).default,
[REACTJS_IDS.REACT_ES6VARIABLES]: async () => (await import('./003_react_es6Variables')).default,
[REACTJS_IDS.REACT_ES6ARRAYMETHODS]: async () =>
(await import('./004_react_es6ArrayMethods')).default,
[REACTJS_IDS.REACT_ES6DESTRUCTURING]: async () =>
(await import('./005_react_es6Destructuring')).default,
[REACTJS_IDS.REACT_ES6SPREADOPERATOR]: async () =>
(await import('./006_react_es6SpreadOperator')).default,
[REACTJS_IDS.REACT_ES6MODULES]: async () => (await import('./007_react_es6Modules')).default,
[REACTJS_IDS.REACT_ES6TENARYOPERATOR]: async () =>
(await import('./008_react_es6TenaryOperator')).default,
[REACTJS_IDS.REACT_JSX]: async () => (await import('./009_react_jsx')).default,
[REACTJS_IDS.REACT_COMPONENTS]: async () => (await import('./010_react_components')).default,
[REACTJS_IDS.REACT_CLASSCOMPONENTS]: async () =>
(await import('./011_react_classComponents')).default,
[REACTJS_IDS.REACT_PROPS]: async () => (await import('./012_react_props')).default,
[REACTJS_IDS.REACT_EVENTS]: async () => (await import('./013_react_events')).default,
[REACTJS_IDS.REACT_CONDITIONALS]: async () => (await import('./014_react_conditionals')).default,
[REACTJS_IDS.REACT_LISTS]: async () => (await import('./015_react_lists')).default,
[REACTJS_IDS.REACT_FORMS]: async () => (await import('./016_react_forms')).default,
[REACTJS_IDS.REACT_ROUTER]: async () => (await import('./017_react_router')).default,
[REACTJS_IDS.REACT_MEMO]: async () => (await import('./018_react_memo')).default,
[REACTJS_IDS.REACT_CSSSTYLING]: async () => (await import('./019_react_cssStyling')).default,
[REACTJS_IDS.REACT_SASSSTYLING]: async () => (await import('./020_react_sassStyling')).default,
[REACTJS_IDS.REACT_IMPORTEXPORT]: async () =>
(await import('./021_react_importingAndExporting')).default,
[REACTJS_IDS.REACT_EXTRACTSTATELOGIC]: async () =>
(await import('./022_react_extractingStateLogic')).default,
[REACTJS_IDS.REACT_SHARINGSTATE]: async () => (await import('./023_react_sharingState')).default,
[REACTJS_IDS.REACT_UPDATINGOBJECTS]: async () =>
(await import('./024_react_updatingObjects')).default,
[REACTJS_IDS.REACT_UPDATINGARRAYS]: async () =>
(await import('./025_react_updatingArrays')).default,
[REACTJS_IDS.REACT_USESTATE]: async () => (await import('./026_react_useState')).default,
[REACTJS_IDS.REACT_USEEFFECT]: async () => (await import('./028_react_useEffect')).default,
[REACTJS_IDS.REACT_USECONTEXT]: async () => (await import('./027_react_useContext')).default,
[REACTJS_IDS.REACT_USEREF]: async () => (await import('./030_react_useRef')).default,
[REACTJS_IDS.REACT_USEREDUCER]: async () => (await import('./029_react_useReducer')).default,
[REACTJS_IDS.REACT_USECALLBACK]: async () => (await import('./031_react_useCallBack')).default,
[REACTJS_IDS.REACT_CUSTOMHOOKS]: async () => (await import('./032_react_customHooks')).default,
[REACTJS_IDS.REACT_USEMEMO]: async () => (await import('./033_react_useMemo')).default
};
@@ -1,21 +1,4 @@
import tsSimpleTypes from './001_ts_simpleTypes';
import tsSpecialTypes from './002_ts_specialTypes';
import tsArrays from './003_ts_arrays';
import tsTuples from './004_ts_tuples';
import tsObjectTypes from './005_ts_objectTypes';
import tsEnums from './006_ts_enums';
import tsInterfaces from './007_ts_interfaces';
import tsUnionTypes from './008_ts_unionTypes';
import tsFunctions from './009_ts_functions';
import tsCasting from './010_ts_casting';
import tsClasses from './011_ts_classes';
import tsBasicGenerics from './012_ts_basicGenerics';
import tsUtilityTypes from './013_ts_utilityTypes';
import tsKeyOf from './014_ts_keyOf';
import tsNull from './015_ts_null';
import tsDefinitelyTyped from './016_ts_definitelyTyped';
export const TS_IDS: { [key: string]: string } = {
export const TYPESCRIPT_IDS: { [key: string]: string } = {
TS_SIMPLETYPES: 'TS_SIMPLETYPES',
TS_SPECIALTYPES: 'TS_SPECIALTYPES',
TS_ARRAYS: 'TS_ARRAYS',
@@ -34,21 +17,22 @@ export const TS_IDS: { [key: string]: string } = {
TS_DEFINITELYTYPED: 'TS_DEFINITELYTYPED'
};
export const TS_TEMPLATES = {
[TS_IDS.TS_SIMPLETYPES]: tsSimpleTypes,
[TS_IDS.TS_SPECIALTYPES]: tsSpecialTypes,
[TS_IDS.TS_ARRAYS]: tsArrays,
[TS_IDS.TS_TUPLES]: tsTuples,
[TS_IDS.TS_OBJECTTYPES]: tsObjectTypes,
[TS_IDS.TS_ENUMS]: tsEnums,
[TS_IDS.TS_INTERFACES]: tsInterfaces,
[TS_IDS.TS_UNIONTYPES]: tsUnionTypes,
[TS_IDS.TS_FUNCTIONS]: tsFunctions,
[TS_IDS.TS_CASTING]: tsCasting,
[TS_IDS.TS_CLASSES]: tsClasses,
[TS_IDS.TS_BASICGENERICS]: tsBasicGenerics,
[TS_IDS.TS_UTILITYTYPES]: tsUtilityTypes,
[TS_IDS.TS_KEYOF]: tsKeyOf,
[TS_IDS.TS_NULL]: tsNull,
[TS_IDS.TS_DEFINITELYTYPED]: tsDefinitelyTyped
export const TYPESCRIPT_TEMPLATES = {
[TYPESCRIPT_IDS.TS_SIMPLETYPES]: async () => (await import('./001_ts_simpleTypes')).default,
[TYPESCRIPT_IDS.TS_SPECIALTYPES]: async () => (await import('./002_ts_specialTypes')).default,
[TYPESCRIPT_IDS.TS_ARRAYS]: async () => (await import('./003_ts_arrays')).default,
[TYPESCRIPT_IDS.TS_TUPLES]: async () => (await import('./004_ts_tuples')).default,
[TYPESCRIPT_IDS.TS_OBJECTTYPES]: async () => (await import('./005_ts_objectTypes')).default,
[TYPESCRIPT_IDS.TS_ENUMS]: async () => (await import('./006_ts_enums')).default,
[TYPESCRIPT_IDS.TS_INTERFACES]: async () => (await import('./007_ts_interfaces')).default,
[TYPESCRIPT_IDS.TS_UNIONTYPES]: async () => (await import('./008_ts_unionTypes')).default,
[TYPESCRIPT_IDS.TS_FUNCTIONS]: async () => (await import('./009_ts_functions')).default,
[TYPESCRIPT_IDS.TS_CASTING]: async () => (await import('./010_ts_casting')).default,
[TYPESCRIPT_IDS.TS_CLASSES]: async () => (await import('./011_ts_classes')).default,
[TYPESCRIPT_IDS.TS_BASICGENERICS]: async () => (await import('./012_ts_basicGenerics')).default,
[TYPESCRIPT_IDS.TS_UTILITYTYPES]: async () => (await import('./013_ts_utilityTypes')).default,
[TYPESCRIPT_IDS.TS_KEYOF]: async () => (await import('./014_ts_keyOf')).default,
[TYPESCRIPT_IDS.TS_NULL]: async () => (await import('./015_ts_null')).default,
[TYPESCRIPT_IDS.TS_DEFINITELYTYPED]: async () =>
(await import('./016_ts_definitelyTyped')).default
};
+24 -43
View File
@@ -1,25 +1,4 @@
import vueDirectives from './001_vue_directives';
import vueVBind from './002_vue_vBind';
import vueVIf from './003_vue_vIf';
import vueVShow from './004_vue_vShow';
import vueVFor from './005_vue_vFor';
import vueEvents from './006_vue-vEvents';
import vueVOn from './007_vue_vOn';
import vueMethods from './008_vue_methods';
import vueEventModifiers from './009_vue_eventModifiers';
import vueForms from './010_vue_forms';
import vueVModel from './011_vue_vModel';
import vueCssBinding from './012_vue_cssBinding';
import vueComputedProperties from './013_vue_computedProperties';
import vueWatchers from './014_vue_watchers';
import vueTemplates from './015_vue_templates';
import vueComponents from './016_vue_components';
import vueProps from './017_vue_props';
import vueVForComp from './018_vue_vForComp';
import vueEmit from './019_vue_emit';
import vueFallThroughAttribute from './020_vue_fallThroughAttribute';
export const VUE_IDS: { [key: string]: string } = {
export const VUEJS_IDS: { [key: string]: string } = {
VUE_DIRECTIVES: 'VUE_DIRECTIVES',
VUE_VBIND: 'VUE_VBIND',
VUE_VIF: 'VUE_VIF',
@@ -42,25 +21,27 @@ export const VUE_IDS: { [key: string]: string } = {
VUE_FALLTHROUGHATTRIBUTE: 'VUE_FALLTHROUGHATTRIBUTE'
};
export const VUE_TEMPLATES = {
[VUE_IDS.VUE_DIRECTIVES]: vueDirectives,
[VUE_IDS.VUE_VBIND]: vueVBind,
[VUE_IDS.VUE_VIF]: vueVIf,
[VUE_IDS.VUE_VSHOW]: vueVShow,
[VUE_IDS.VUE_VFOR]: vueVFor,
[VUE_IDS.VUE_VEVENTS]: vueEvents,
[VUE_IDS.VUE_VON]: vueVOn,
[VUE_IDS.VUE_METHODS]: vueMethods,
[VUE_IDS.VUE_EVENTMODIFIERS]: vueEventModifiers,
[VUE_IDS.VUE_FORMS]: vueForms,
[VUE_IDS.VUE_VMODEL]: vueVModel,
[VUE_IDS.VUE_CSSBINDING]: vueCssBinding,
[VUE_IDS.VUE_COMPUTEDPROPERTIES]: vueComputedProperties,
[VUE_IDS.VUE_WATCHERS]: vueWatchers,
[VUE_IDS.VUE_TEMPLATES]: vueTemplates,
[VUE_IDS.VUE_COMPONENTS]: vueComponents,
[VUE_IDS.VUE_PROPS]: vueProps,
[VUE_IDS.VUE_VFORCOMP]: vueVForComp,
[VUE_IDS.VUE_EMIT]: vueEmit,
[VUE_IDS.VUE_FALLTHROUGHATTRIBUTE]: vueFallThroughAttribute
export const VUEJS_TEMPLATES = {
[VUEJS_IDS.VUE_DIRECTIVES]: async () => (await import('./001_vue_directives')).default,
[VUEJS_IDS.VUE_VBIND]: async () => (await import('./002_vue_vBind')).default,
[VUEJS_IDS.VUE_VIF]: async () => (await import('./003_vue_vIf')).default,
[VUEJS_IDS.VUE_VSHOW]: async () => (await import('./004_vue_vShow')).default,
[VUEJS_IDS.VUE_VFOR]: async () => (await import('./005_vue_vFor')).default,
[VUEJS_IDS.VUE_VEVENTS]: async () => (await import('./006_vue-vEvents')).default,
[VUEJS_IDS.VUE_VON]: async () => (await import('./007_vue_vOn')).default,
[VUEJS_IDS.VUE_METHODS]: async () => (await import('./008_vue_methods')).default,
[VUEJS_IDS.VUE_EVENTMODIFIERS]: async () => (await import('./009_vue_eventModifiers')).default,
[VUEJS_IDS.VUE_FORMS]: async () => (await import('./010_vue_forms')).default,
[VUEJS_IDS.VUE_VMODEL]: async () => (await import('./011_vue_vModel')).default,
[VUEJS_IDS.VUE_CSSBINDING]: async () => (await import('./012_vue_cssBinding')).default,
[VUEJS_IDS.VUE_COMPUTEDPROPERTIES]: async () =>
(await import('./013_vue_computedProperties')).default,
[VUEJS_IDS.VUE_WATCHERS]: async () => (await import('./014_vue_watchers')).default,
[VUEJS_IDS.VUE_TEMPLATES]: async () => (await import('./015_vue_templates')).default,
[VUEJS_IDS.VUE_COMPONENTS]: async () => (await import('./016_vue_components')).default,
[VUEJS_IDS.VUE_PROPS]: async () => (await import('./017_vue_props')).default,
[VUEJS_IDS.VUE_VFORCOMP]: async () => (await import('./018_vue_vForComp')).default,
[VUEJS_IDS.VUE_EMIT]: async () => (await import('./019_vue_emit')).default,
[VUEJS_IDS.VUE_FALLTHROUGHATTRIBUTE]: async () =>
(await import('./020_vue_fallThroughAttribute')).default
};
-5
View File
@@ -1,6 +1,5 @@
<script lang="ts">
import { onMount } from 'svelte';
import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit';
import { MetaTags } from 'svelte-meta-tags';
import { fly } from 'svelte/transition';
import { derived } from 'svelte/store';
@@ -60,10 +59,6 @@
// Set up posthog
initPosthog();
if (!dev) {
injectSpeedInsights();
}
}
function setAnalyticsUser() {
+8 -1
View File
@@ -1,7 +1,14 @@
import { vitePreprocess } from '@sveltejs/kit/vite';
import adapter from '@sveltejs/adapter-auto';
import adapterNode from '@sveltejs/adapter-node';
import path from 'path';
import 'dotenv/config';
console.log('\n\n=======config: ', process.env.IS_SELFHOSTED);
const useNodeAdapter = process.env.IS_SELFHOSTED === 'true';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
@@ -9,7 +16,7 @@ const config = {
preprocess: [vitePreprocess({})],
kit: {
adapter: adapter(),
adapter: useNodeAdapter ? adapterNode() : adapter(),
alias: {
$lib: path.resolve('./src/lib'),
$mail: path.resolve('./src/mail')
+7
View File
@@ -7,6 +7,13 @@ export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: ['legacy-js-api'],
},
},
},
plugins: [sveltekit(), sentryVitePlugin(getSentryConfig(process.env))],
server: getServer(process.env),
build: {