A full-featured CRM built with React, shadcn/ui, and Supabase.
Feat(ops): Add CI/CD pipeline
Jonathan ARNAULTd6eb6a8e534c
diff --git a/.eslintignore b/.eslintignoreindex f729b9fb..55eed624 100644--- a/.eslintignore+++ b/.eslintignore@@ -4,3 +4,4 @@ libesmprism.jspackages/create-react-admin/templates/**+.github\ No newline at end of filediff --git a/.eslintrc b/.eslintrc.jsonsimilarity index 94%rename from .eslintrcrename to .eslintrc.jsonindex 0f80d13d..4d73b972 100644--- a/.eslintrc+++ b/.eslintrc.json@@ -1,4 +1,3 @@-{"parser": "@typescript-eslint/parser","parserOptions": {@@ -30,11 +29,11 @@],"no-redeclare": "off","import/no-anonymous-default-export": "off",- "@typescript-eslint/no-redeclare": ["error"],+ "@typescript-eslint/no-redeclare": "error","no-unused-vars": "off","@typescript-eslint/no-unused-vars": ["warn", // or "error"- {+ {"argsIgnorePattern": "^_","varsIgnorePattern": "^_","caughtErrorsIgnorePattern": "^_",diff --git a/.github/workflows/check.yml b/.github/workflows/check.ymlnew file mode 100644index 00000000..76878f49--- /dev/null+++ b/.github/workflows/check.yml@@ -0,0 +1,70 @@+name: π Deploy+on:+ push:+ branches:+ - main+ - dev+ pull_request:+ types:+ - opened+ - reopened+ - synchronize+ - ready_for_review++concurrency:+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}+ cancel-in-progress: true++permissions:+ actions: write+ contents: write+ checks: write+ pull-requests: write++jobs:+ lint:+ name: ⬣ ESLint+ runs-on: ubuntu-latest+ timeout-minutes: 10+ if: ${{ !github.event.pull_request.draft || github.event_name == 'push' }}+ steps:+ - name: β¬οΈ Checkout repo+ uses: actions/checkout@v4++ - name: β Setup node+ uses: actions/setup-node@v4+ with:+ node-version: 20+ cache: npm++ - name: π₯ Download deps+ run: npm install++ - name: π¬ Lint+ uses: wearerequired/lint-action@v2+ with:+ eslint: true+ eslint_args: "**/*.{mjs,ts,tsx}"+ prettier: true+ prettier_args: "--config ./.prettierrc.mjs --check \"**/*.{js,json,ts,tsx,css,md}\""++ build:+ name: βοΈ Build+ timeout-minutes: 10+ runs-on: ubuntu-latest+ if: ${{ !github.event.pull_request.draft || github.event_name == 'push' }}+ steps:+ - name: β¬οΈ Checkout repo+ uses: actions/checkout@v4++ - name: β Setup node+ uses: actions/setup-node@v4+ with:+ node-version: 20+ cache: npm++ - name: π₯ Download deps+ run: npm install++ - name: βοΈ Build+ run: make builddiff --git a/.prettierignore b/.prettierignoreindex 4d29bce6..c7827ed1 100644--- a/.prettierignore+++ b/.prettierignore@@ -23,4 +23,5 @@ cypress/screenshots!.yarn/plugins!.yarn/releases!.yarn/sdks-!.yarn/versions\ No newline at end of file+!.yarn/versions+.github\ No newline at end of filediff --git a/.prettierrc.mjs b/.prettierrc.mjsindex d6245821..bf30783b 100644--- a/.prettierrc.mjs+++ b/.prettierrc.mjs@@ -11,5 +11,5 @@ export default {singleQuote: true,tabWidth: 4,trailingComma: 'es5',- useTabs: false-}+ useTabs: false,+};diff --git a/makefile b/makefileindex 989ccc96..632ba567 100644--- a/makefile+++ b/makefile@@ -35,3 +35,7 @@ supabase-remote-init:supabase-deploy:npx supabase db pushnpx supabase functions deploy++lint:+ npm run lint:check+ npm run prettier:check\ No newline at end of filediff --git a/package.json b/package.jsonindex 366e42b8..3fca0560 100644--- a/package.json+++ b/package.json@@ -62,8 +62,10 @@"dev": "vite --force","build": "tsc && vite build","preview": "vite preview",- "lint": "eslint --ext .js,.ts,.tsx \"./src/**/*.{js,ts,tsx}\"",- "prettier": "prettier --config ./.prettierrc.mjs --write --list-different \"src/**/*.{js,json,ts,tsx,css,md}\"",+ "lint:apply": "eslint **/*.{mjs,ts,tsx} --fix",+ "lint:check": "eslint **/*.{mjs,ts,tsx}",+ "prettier:apply": "prettier --config ./.prettierrc.mjs --write --list-different \"**/*.{js,json,ts,tsx,css,md}\"",+ "prettier:check": "prettier --config ./.prettierrc.mjs --check \"**/*.{js,json,ts,tsx,css,md}\"","ghpages:deploy": "node ./scripts/ghpages-deploy.mjs","supabase:remote:init": "node ./scripts/supabase-remote-init.mjs"}diff --git a/scripts/seed.ts b/scripts/seed.tsdeleted file mode 100644index 2b740e1e..00000000--- a/scripts/seed.ts+++ /dev/null@@ -1,197 +0,0 @@-import { createClient } from "@supabase/supabase-js";-import dotenv from "dotenv";-import pg from "pg";--import generateData from "../src/dataGenerator/index.js";--const dataMappers = {- tags: (tag) => ({- id: tag.id,- name: tag.name,- color: tag.color,- }),- companies: (company) => ({- id: company.id,- name: company.name,- logo: company.logo,- sector: company.sector,- size: company.size,- linkedIn: company.linkedIn,- website: company.website,- phone_number: company.phone_number,- address: company.address,- zipcode: company.zipcode,- city: company.city,- stateAbbr: company.stateAbbr,- sales_id: company.sales_id,- created_at: company.created_at,- }),- contacts: (contact) => ({- id: contact.id,- first_name: contact.first_name,- last_name: contact.last_name,- gender: contact.gender,- title: contact.title,- company_id: contact.company_id,- email: contact.email,- phone_number1: contact.phone_number1,- phone_number2: contact.phone_number2,- background: contact.background,- acquisition: contact.acquisition,- avatar: contact.avatar,- first_seen: contact.first_seen,- last_seen: contact.last_seen,- has_newsletter: contact.has_newsletter,- status: contact.status,- tags: contact.tags,- sales_id: contact.sales_id,- }),- contactNotes: (contactNote) => ({- id: contactNote.id,- contact_id: contactNote.contact_id,- type: contactNote.type,- text: contactNote.text,- date: contactNote.date,- sales_id: contactNote.sales_id,- status: contactNote.status,- }),- deals: (deal) => ({- id: deal.id,- name: deal.name,- company_id: deal.company_id,- contact_ids: deal.contact_ids,- type: deal.type,- stage: deal.stage,- description: deal.description,- amount: deal.amount,- created_at: deal.created_at,- updated_at: deal.updated_at,- start_at: deal.start_at,- sales_id: deal.sales_id,- index: deal.index,- }),- dealNotes: (dealNote) => ({- id: dealNote.id,- deal_id: dealNote.deal_id,- type: dealNote.type,- text: dealNote.text,- date: dealNote.date,- sales_id: dealNote.sales_id,- }),- tasks: (task) => ({- id: task.id,- contact_id: task.contact_id,- type: task.type,- text: task.text,- due_date: task.due_date,- sales_id: task.sales_id,- }),-};--const seed = async () => {- dotenv.config();- if (process.env.VITE_SUPABASE_URL === undefined) {- throw new Error("Please set the VITE_SUPABASE_URL environment variable");- }- if (process.env.SUPABASE_SERVICE_ROLE_KEY === undefined) {- throw new Error(- "Please set the SUPABASE_SERVICE_ROLE_KEY environment variable"- );- }- if (process.env.DATABASE_URL === undefined) {- throw new Error("Please set the DATABASE_URL environment variable");- }- const supabase = createClient(- process.env.VITE_SUPABASE_URL,- process.env.SUPABASE_SERVICE_ROLE_KEY- );- const data = generateData();-- for (const sale of data.sales) {- const { data, error } = await supabase.auth.admin.createUser({- email: sale.email,- password: "Password123",- email_confirm: true,- });-- if (error) {- console.error(error);- throw new Error(`Failed to create user ${sale.email}`);- }-- const { error: errorProfile } = await supabase.from("sales").insert({- id: sale.id,- first_name: sale.first_name,- last_name: sale.last_name,- email: sale.email,- user_id: data.user.id,- });-- if (errorProfile) {- console.error(error);- throw new Error(- `Failed to create user ${sale.email}: ${errorProfile.message}`- );- }- }-- const resources = [- "tags",- "companies",- "contacts",- "contactNotes",- "deals",- "dealNotes",- "tasks",- ];- for (const resource of resources) {- const { error } = await supabase- .from(resource)- .insert(data[resource].map(dataMappers[resource]));-- if (error) {- console.error(error);- throw new Error(`Failed to insert ${resource}: ${error.message}`);- }- }-- const client = new pg.Client({- connectionString: process.env.DATABASE_URL,- });- await client.connect();- await client.query(- `SELECT setval('"sales_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"sales\"), 1), false);`- );- await client.query(- `SELECT setval('"tags_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"tags\"), 1), false);`- );- await client.query(- `SELECT setval('"companies_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"companies\"), 1), false);`- );- await client.query(- `SELECT setval('"contacts_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"contacts\"), 1), false);`- );- await client.query(- `SELECT setval('"contactNotes_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"contactNotes\"), 1), false);`- );- await client.query(- `SELECT setval('"deals_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"deals\"), 1), false);`- );- await client.query(- `SELECT setval('"dealNotes_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"dealNotes\"), 1), false);`- );- await client.query(- `SELECT setval('"tasks_id_seq\"', COALESCE((SELECT MAX(id)+1 FROM \"tasks\"), 1), false);`- );- await client.end();-};--seed()- .then(() => {- console.log("Populated database successfully");- process.exit(0);- })- .catch((error) => {- console.error(error);- process.exit(1);- });diff --git a/tsconfig.node.json b/tsconfig.node.jsonindex f48610d7..13b35d0b 100644--- a/tsconfig.node.json+++ b/tsconfig.node.json@@ -1,10 +1,9 @@{"compilerOptions": {- "composite": true,- "module": "ESNext",- "moduleResolution": "Node",- "allowSyntheticDefaultImports": true+ "composite": true,+ "module": "ESNext",+ "moduleResolution": "Node",+ "allowSyntheticDefaultImports": true},"include": ["vite.config.ts"]- }-\ No newline at end of file+}diff --git a/vite.config.ts b/vite.config.tsindex f76c9b00..3be86012 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -1,27 +1,27 @@-import { defineConfig } from "vite";-import react from "@vitejs/plugin-react";-import { visualizer } from "rollup-plugin-visualizer";+import { defineConfig } from 'vite';+import react from '@vitejs/plugin-react';+import { visualizer } from 'rollup-plugin-visualizer';// https://vitejs.dev/config/export default defineConfig({- plugins: [- react(),- visualizer({- open: process.env.NODE_ENV !== "CI",- filename: "./dist/stats.html",- }),- ],- define: {- "process.env": process.env,- },- base: "./",- esbuild: {- keepNames: true,- },- build: {- sourcemap: true,- },- resolve: {- preserveSymlinks: true,- },+ plugins: [+ react(),+ visualizer({+ open: process.env.NODE_ENV !== 'CI',+ filename: './dist/stats.html',+ }),+ ],+ define: {+ 'process.env': process.env,+ },+ base: './',+ esbuild: {+ keepNames: true,+ },+ build: {+ sourcemap: true,+ },+ resolve: {+ preserveSymlinks: true,+ },});