Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 592-rework-on-loginpa…
Browse files Browse the repository at this point in the history
…sskeys
  • Loading branch information
riccardoperra committed Apr 25, 2024
2 parents ebbf77f + e94e8a2 commit 635d0d8
Show file tree
Hide file tree
Showing 59 changed files with 632 additions and 313 deletions.
6 changes: 6 additions & 0 deletions .changeset/red-zoos-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@codeimage/api": minor
"@codeimage/app": minor
---

feat(app,api) add new border type glass option
6 changes: 6 additions & 0 deletions .changeset/slimy-dolphins-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@codeimage/api": minor
"@codeimage/app": minor
---

feat(app,api): add line number start option
5 changes: 5 additions & 0 deletions .changeset/tame-deers-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codeimage/app': minor
---

feat: allow zero padding
4 changes: 2 additions & 2 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
daysUntilStale: 120
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
daysUntilClose: 120
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
Expand Down
75 changes: 37 additions & 38 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Deploy (Production)"
name: 'Deploy (Production)'
on:
workflow_dispatch:
inputs:
Expand All @@ -22,8 +22,8 @@ jobs:
steps:
- name: Checkout PR
uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand All @@ -33,20 +33,20 @@ jobs:

lint:
name: Lint
needs: [ "install" ]
needs: ['install']
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: 📥 Monorepo install
uses: ./.github/actions/pnpm-install
- name: "[API] Generate Prisma Migration"
- name: '[API] Generate Prisma Migration'
run: |
pnpm --filter=@codeimage/api exec prisma generate
pnpm --filter=@codeimage/prisma-models build
Expand All @@ -55,25 +55,25 @@ jobs:

build-packages:
name: Build packages/**
needs: [ "install" ]
needs: ['install']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: 📥 Monorepo install
uses: ./.github/actions/pnpm-install

- name: "[API] Generate Prisma Migration"
- name: '[API] Generate Prisma Migration'
run: |
pnpm --filter=@codeimage/api exec prisma generate
pnpm --filter=@codeimage/prisma-models build
- name: "Build packages"
- name: 'Build packages'
run: |
pnpm libs:build
Expand All @@ -84,21 +84,21 @@ jobs:
key: packages-dist-${{ github.run_id }}-${{ github.run_number }}

build-api:
name: "Build @codeimage/api"
needs: [ "install" ]
name: 'Build @codeimage/api'
needs: ['install']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: 📥 Monorepo install
uses: ./.github/actions/pnpm-install

- name: "[API] Generate Prisma Migration"
- name: '[API] Generate Prisma Migration'
run: |
pnpm --filter=@codeimage/api exec prisma generate
pnpm --filter=@codeimage/prisma-models build
Expand All @@ -118,7 +118,7 @@ jobs:

test-api:
name: Api test
needs: [ install ]
needs: [install]
runs-on: ubuntu-latest

services:
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
GRANT_TYPE_AUTH0: client_credentials
MOCK_AUTH: false
MOCK_AUTH_EMAIL: dev@example.it
ALLOWED_ORIGINS: "*"
ALLOWED_ORIGINS: '*'

steps:
- uses: actions/checkout@v3
Expand All @@ -159,7 +159,7 @@ jobs:
- name: 📥 Monorepo install
uses: ./.github/actions/pnpm-install

- name: "Run prisma DB migrations"
- name: 'Run prisma DB migrations'
run: |
cd apps/api
pnpm exec prisma migrate deploy
Expand All @@ -174,12 +174,12 @@ jobs:

typecheck-packages:
name: Type-checking packages/**
needs: [ "install", "build-packages" ]
needs: ['install', 'build-packages']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand All @@ -205,12 +205,12 @@ jobs:
deploy-highlight-package:
name: Deploy @codeimage/highlight app
environment: Production
needs: [ "install", "lint", "build-packages" ]
needs: ['install', 'lint', 'build-packages']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -239,12 +239,12 @@ jobs:
deploy-api:
name: Build and Deploy Api
environment: Production
needs: [ install, lint, typecheck-packages, test-api, build-api ]
needs: [install, lint, typecheck-packages, test-api, build-api]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -274,21 +274,21 @@ jobs:
find -type f -name '.gitignore' -delete
pnpm railway link --environment production $RAILWAY_API_PROJECT_ID
cd dist/api-bundle
pnpm railway up --detach
pnpm railway up -s codeimage
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
RAILWAY_API_PROJECT_ID: ${{ secrets.RAILWAY_API_PROJECT_ID }}

deploy-app:
name: Deploy @codeimage/app
environment: Production
needs: [ install, lint, typecheck-packages, build-packages, deploy-api ]
needs: [install, lint, typecheck-packages, build-packages, deploy-api]
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -325,23 +325,22 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
vercel-args: '--prebuilt --prod' #Optional
working-directory: apps/codeimage
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} #Required
alias-domains: | #Optional
app.codeimage.dev
deploy-website:
if: ${{ github.event.inputs.deploy-website == 'true' }}
name: Deploy @codeimage/website
environment: Production
needs: [ install, lint, typecheck-packages, build-packages ]
needs: [install, lint, typecheck-packages, build-packages]
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v3
# with:
# submodules: 'true'
# with:
# submodules: 'true'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@prisma/client": "^4.15.0",
"@sinclair/typebox": "^0.31.28",
"@teamhanko/passkeys-sdk": "^0.1.8",
"auth0": "4.2.0",
"auth0": "4.3.1",
"close-with-grace": "^1.2.0",
"dotenv": "^16.1.4",
"dotenv-cli": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "SnippetTerminal" ADD COLUMN "borderType" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "SnippetEditorTab" ADD COLUMN "lineNumberStart" INTEGER NOT NULL DEFAULT 1;
3 changes: 3 additions & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ model SnippetTerminal {
showGlassReflection Boolean @default(false)
opacity Float @default(100)
alternativeTheme Boolean @default(false)
borderType String?
}

model SnippetEditorOptions {
Expand All @@ -82,6 +83,8 @@ model SnippetEditorTab {
languageId String
tabName String @default("")
lineNumberStart Int @default(1)
@@unique([id, projectId])
}

Expand Down
9 changes: 6 additions & 3 deletions apps/api/src/common/typebox/enum.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {Type} from '@sinclair/typebox';
import {TString, Type} from '@sinclair/typebox';

export const enumLiteral = <T extends readonly string[]>(values: [...T]) => {
export const enumLiteral = <T extends string>(values: T[]): TString => {
const literals = values.map(value => Type.Literal(value));
// TODO: validation should work but type must work as a string...
return Type.Intersect([Type.Union(literals), Type.String()]);
return Type.Intersect([
Type.Union(literals),
Type.String(),
]) as unknown as TString;
};
2 changes: 2 additions & 0 deletions apps/api/src/modules/project/domain/projectUpdateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ interface EditorUpdateRequest {
code: NonNullable<SnippetEditorTab['code']>;
languageId: NonNullable<SnippetEditorTab['languageId']>;
tabName: NonNullable<SnippetEditorTab['tabName']>;
lineNumberStart: NonNullable<SnippetEditorTab['lineNumberStart']>;
}

interface EditorTabResponse {
id: NonNullable<SnippetEditorTab['id']>;
code: NonNullable<SnippetEditorTab['code']>;
languageId: NonNullable<SnippetEditorTab['languageId']>;
tabName: NonNullable<SnippetEditorTab['tabName']>;
lineNumberStart: NonNullable<SnippetEditorTab['lineNumberStart']>;
}

export interface ProjectUpdateRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function makePrismaProjectRepository(
showWatermark: data.terminal.showWatermark,
textColor: data.terminal.textColor,
type: data.terminal.type,
borderType: data.terminal.borderType,
},
},
},
Expand Down Expand Up @@ -138,20 +139,22 @@ export function makePrismaProjectRepository(
},
},
upsert: data.editors.map(editor => {
const {languageId, code, tabName} = editor;
const {languageId, code, tabName, lineNumberStart, id} = editor;
return {
where: {
id: editor.id,
id,
},
create: {
code,
tabName,
languageId,
lineNumberStart,
},
update: {
code,
tabName,
languageId,
lineNumberStart,
},
};
}),
Expand Down Expand Up @@ -186,6 +189,7 @@ export function makePrismaProjectRepository(
showWatermark: data.terminal.showWatermark,
textColor: data.terminal.textColor,
type: data.terminal.type,
borderType: data.terminal.borderType,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/modules/project/mapper/create-project-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function createProjectRequestMapper(
data.terminal.alternativeTheme ??
SnippetTerminalCreateRequestSchema.properties.alternativeTheme.default,
shadow: data.terminal.shadow ?? null,
borderType: data.terminal.borderType ?? null,
},
editorOptions: {
fontWeight: data.editorOptions.fontWeight,
Expand All @@ -62,6 +63,7 @@ export function createProjectRequestMapper(
languageId: editor.languageId,
code: editor.code,
tabName: editor.tabName,
lineNumberStart: editor.lineNumberStart,
})),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function createCompleteProjectGetByIdResponseMapper(
accentVisible: data.terminal.accentVisible,
alternativeTheme: data.terminal.alternativeTheme,
shadow: data.terminal.shadow,
borderType: data.terminal.borderType as 'glass' | null,
},
editorOptions: {
id: data.editorOptions.id,
Expand All @@ -45,6 +46,7 @@ export function createCompleteProjectGetByIdResponseMapper(
languageId: editor.languageId,
code: editor.code,
tabName: editor.tabName,
lineNumberStart: editor.lineNumberStart,
})),
isOwner: false,
};
Expand Down
Loading

0 comments on commit 635d0d8

Please sign in to comment.