diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml new file mode 100644 index 0000000..4085e3a --- /dev/null +++ b/.github/workflows/CI.yaml @@ -0,0 +1,32 @@ +name: CI +on: [push] +jobs: + Lint-and-type-check: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v6 + - name: Create .env + run: cat .env.example > .env + - name: Install pnpm + uses: pnpm/action-setup@v6 + - name: Install packages + run: pnpm install --frozen-lockfile + - name: Lint + run: pnpm lint + - name: Type check + run: pnpm check + + Build: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v6 + - name: Create .env + run: cat .env.example > .env + - name: Install pnpm + uses: pnpm/action-setup@v6 + - name: Install packages + run: pnpm install --frozen-lockfile + - name: Build + run: pnpm build diff --git a/package.json b/package.json index a423d08..1046de3 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check .", - "format": "prettier --write ." + "format": "prettier --write .", + "prepare": "svelte-kit sync" }, "devDependencies": { "@aws-sdk/client-s3": "^3.837.0", diff --git a/src/lib/components/form/ValidatedInput.svelte b/src/lib/components/form/ValidatedInput.svelte index 3bd9e31..5158af6 100644 --- a/src/lib/components/form/ValidatedInput.svelte +++ b/src/lib/components/form/ValidatedInput.svelte @@ -4,7 +4,7 @@ import type { LabelProps } from 'flowbite-svelte/Label.svelte'; import ValidatedLabel from './util/ValidatedLabel.svelte'; import ValidatedHelper from './util/ValidatedHelper.svelte'; - import { ObjectSchema, type StringSchema, ValidationError } from 'yup'; + import { type ObjectSchema, type StringSchema, ValidationError } from 'yup'; interface Props { /** diff --git a/src/lib/components/form/ValidatedInputGroup.svelte b/src/lib/components/form/ValidatedInputGroup.svelte index 548c5c2..3d847ca 100644 --- a/src/lib/components/form/ValidatedInputGroup.svelte +++ b/src/lib/components/form/ValidatedInputGroup.svelte @@ -5,7 +5,7 @@ import ValidatedLabel from './util/ValidatedLabel.svelte'; import ValidatedHelper from './util/ValidatedHelper.svelte'; import type { ButtonGroupProps } from 'flowbite-svelte/ButtonGroup.svelte'; - import { ObjectSchema, type StringSchema, ValidationError } from 'yup'; + import { type ObjectSchema, type StringSchema, ValidationError } from 'yup'; interface Props { /** diff --git a/src/lib/components/form/ValidatedSelect.svelte b/src/lib/components/form/ValidatedSelect.svelte index 7db61bc..872758b 100644 --- a/src/lib/components/form/ValidatedSelect.svelte +++ b/src/lib/components/form/ValidatedSelect.svelte @@ -4,7 +4,7 @@ import type { SelectProps } from 'flowbite-svelte/Select.svelte'; import ValidatedLabel from './util/ValidatedLabel.svelte'; import ValidatedHelper from './util/ValidatedHelper.svelte'; - import { ObjectSchema, type StringSchema, ValidationError } from 'yup'; + import { type ObjectSchema, type StringSchema, ValidationError } from 'yup'; interface Props { /** diff --git a/src/lib/components/form/ValidatedTextarea.svelte b/src/lib/components/form/ValidatedTextarea.svelte index 37929fe..6c13f2b 100644 --- a/src/lib/components/form/ValidatedTextarea.svelte +++ b/src/lib/components/form/ValidatedTextarea.svelte @@ -4,7 +4,7 @@ import type { TextareaProps } from 'flowbite-svelte/Textarea.svelte'; import ValidatedLabel from './util/ValidatedLabel.svelte'; import ValidatedHelper from './util/ValidatedHelper.svelte'; - import { ObjectSchema, type StringSchema, ValidationError } from 'yup'; + import { type ObjectSchema, type StringSchema, ValidationError } from 'yup'; interface Props { /** diff --git a/src/lib/models/basicModels.ts b/src/lib/models/basicModels.ts index 475fa93..8e3097d 100644 --- a/src/lib/models/basicModels.ts +++ b/src/lib/models/basicModels.ts @@ -1,5 +1,5 @@ import type { ISingleValue } from '$lib/types/basicTypes'; -import mongoose, { Model } from 'mongoose'; +import mongoose, { type Model } from 'mongoose'; export const singleValueSchema = new mongoose.Schema( {}, diff --git a/src/lib/models/sessionModel.ts b/src/lib/models/sessionModel.ts index 6c97a14..e26fb69 100644 --- a/src/lib/models/sessionModel.ts +++ b/src/lib/models/sessionModel.ts @@ -1,6 +1,6 @@ import { User } from '$api/users/model'; import type { ISession } from '$lib/types/session'; -import mongoose, { Model, Types } from 'mongoose'; +import mongoose, { type Model, Types } from 'mongoose'; const sessionSchema = new mongoose.Schema({ _id: { type: Buffer, required: true }, diff --git a/src/routes/api/v2/contact/validator.ts b/src/routes/api/v2/contact/validator.ts index 8890e88..8d26218 100644 --- a/src/routes/api/v2/contact/validator.ts +++ b/src/routes/api/v2/contact/validator.ts @@ -1,4 +1,4 @@ -import { object, ObjectSchema, string } from 'yup'; +import { object, type ObjectSchema, string } from 'yup'; import type { IContactUsMessage } from './types'; export const contactUsValidator: ObjectSchema = object({ diff --git a/src/routes/api/v2/page_data/announcement/validator.ts b/src/routes/api/v2/page_data/announcement/validator.ts index d76b616..d121146 100644 --- a/src/routes/api/v2/page_data/announcement/validator.ts +++ b/src/routes/api/v2/page_data/announcement/validator.ts @@ -1,4 +1,4 @@ -import { object, ObjectSchema, string } from 'yup'; +import { object, type ObjectSchema, string } from 'yup'; import type { IAnnouncement } from './types'; import type { WithoutID } from '$lib/types/basicTypes'; diff --git a/src/routes/api/v2/page_data/bellSchedule/validator.ts b/src/routes/api/v2/page_data/bellSchedule/validator.ts index 1a168dd..2b08a62 100644 --- a/src/routes/api/v2/page_data/bellSchedule/validator.ts +++ b/src/routes/api/v2/page_data/bellSchedule/validator.ts @@ -1,5 +1,5 @@ import type { WithoutID } from '$lib/types/basicTypes'; -import { string, object, boolean, array, number, ObjectSchema } from 'yup'; +import { string, object, boolean, array, number, type ObjectSchema } from 'yup'; import type { IBellSchedule, IBellScheduleDefaults, IBellScheduleOverride } from './types'; import { idArrayValidator, idValidator } from '$lib/validation/objectId'; diff --git a/src/routes/api/v2/page_data/bulletinBoard/validator.ts b/src/routes/api/v2/page_data/bulletinBoard/validator.ts index 4df21f7..9df4c7a 100644 --- a/src/routes/api/v2/page_data/bulletinBoard/validator.ts +++ b/src/routes/api/v2/page_data/bulletinBoard/validator.ts @@ -1,5 +1,5 @@ import type { WithoutID } from '$lib/types/basicTypes'; -import { object, ObjectSchema, string } from 'yup'; +import { object, type ObjectSchema, string } from 'yup'; import type { IBulletinBoardNote } from './types'; import urlRegex from '$lib/validation/url'; diff --git a/src/routes/api/v2/page_data/clubs/validator.ts b/src/routes/api/v2/page_data/clubs/validator.ts index c48fd3d..d6653c5 100644 --- a/src/routes/api/v2/page_data/clubs/validator.ts +++ b/src/routes/api/v2/page_data/clubs/validator.ts @@ -1,5 +1,5 @@ import type { WithoutID } from '$lib/types/basicTypes'; -import { object, ObjectSchema, string } from 'yup'; +import { object, type ObjectSchema, string } from 'yup'; import type { IClub } from './types'; export const INSTAGRAM_REGEX = /^[a-zA-Z0-9._]*$/; diff --git a/src/routes/api/v2/page_data/usefulLinks/validator.ts b/src/routes/api/v2/page_data/usefulLinks/validator.ts index 6410772..6dce734 100644 --- a/src/routes/api/v2/page_data/usefulLinks/validator.ts +++ b/src/routes/api/v2/page_data/usefulLinks/validator.ts @@ -1,5 +1,5 @@ import type { WithoutID } from '$lib/types/basicTypes'; -import { string, object, array, ObjectSchema } from 'yup'; +import { string, object, array, type ObjectSchema } from 'yup'; import type { ILinkCard } from './types'; export const linkCardLinkNameValidator = string().required().max(64).label('Name'); diff --git a/src/routes/api/v2/short_link/validator.ts b/src/routes/api/v2/short_link/validator.ts index 8434e91..bc1bcf7 100644 --- a/src/routes/api/v2/short_link/validator.ts +++ b/src/routes/api/v2/short_link/validator.ts @@ -1,4 +1,4 @@ -import { object, ObjectSchema, string } from 'yup'; +import { object, type ObjectSchema, string } from 'yup'; import type { IShortLinkAdminUpdate, IShortLinkCreate, diff --git a/src/routes/api/v2/users/validator.ts b/src/routes/api/v2/users/validator.ts index 9277bde..556a2ba 100644 --- a/src/routes/api/v2/users/validator.ts +++ b/src/routes/api/v2/users/validator.ts @@ -1,4 +1,4 @@ -import { object, number, ObjectSchema } from 'yup'; +import { object, number, type ObjectSchema } from 'yup'; import type { IAdminUserUpdate } from './types'; import { Permission } from '$lib/auth/permissions'; diff --git a/vite.config.ts b/vite.config.ts index 89d9026..f2abe5a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,4 +4,26 @@ import { defineConfig } from 'vite'; export default defineConfig({ plugins: [enhancedImages(), sveltekit()], + build: { + rollupOptions: { + onwarn(warning) { + throw new Error(`[Werror] ${warning.message}`); + }, + onLog(level, log, handler) { + if (level === 'warn') { + let isAllNodeModules = true; + if (log.ids && log.ids.length > 0) { + for (const id of log.ids) { + if (!id.includes('node_modules')) { + isAllNodeModules = false; + break; + } + } + } + if (!isAllNodeModules) throw new Error(`[Werror] ${log.message}`); + } + handler(level, log); + }, + }, + }, });