Skip to content

Commit

Permalink
Merge branch 'dev' into feat/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
hientominh committed Oct 17, 2024
2 parents ac4e2b3 + a2efa35 commit cd906e2
Show file tree
Hide file tree
Showing 23 changed files with 1,019 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .github/scripts/rename-app-beta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ fi
# Use jq to transform the content
jq '
.name = "jan-beta" |
.productName = "Jan-beta" |
.build.appId = "jan-beta.ai.app" |
.build.productName = "Jan-beta" |
.build.appId = "jan-beta.ai.app" |
.build.protocols[0].name = "Jan-beta" |
Expand Down
44 changes: 30 additions & 14 deletions .github/workflows/jan-electron-build-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ jobs:
new_version: ${{ needs.get-update-version.outputs.new_version }}
beta: true

combine-latest-mac-yml:
needs: [build-macos-x64, build-macos-arm64, create-draft-release]
combine-beta-mac-yml:
needs: [build-macos-x64, build-macos-arm64, create-draft-release, build-windows-x64, build-linux-x64]
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -86,35 +86,51 @@ jobs:
- name: Download mac-x64 artifacts
uses: actions/download-artifact@v4
with:
name: latest-mac-x64
path: ./latest-mac-x64
name: beta-mac-x64
path: ./beta-mac-x64
- name: Download mac-arm artifacts
uses: actions/download-artifact@v4
with:
name: latest-mac-arm64
path: ./latest-mac-arm64
name: beta-mac-arm64
path: ./beta-mac-arm64

- name: 'Merge latest-mac.yml'
- name: 'Merge beta-mac.yml'
# unfortunately electron-builder doesn't understand that we have two different releases for mac-x64 and mac-arm, so we need to manually merge the latest files
# see https://github.com/electron-userland/electron-builder/issues/5592
run: |
ls -la .
ls -la ./latest-mac-x64
ls -la ./latest-mac-arm64
ls -la ./beta-mac-x64
ls -la ./beta-mac-arm64
ls -la ./electron
cp ./electron/merge-latest-ymls.js /tmp/merge-latest-ymls.js
cp ./electron/merge-latest-ymls.js /tmp/merge-beta-ymls.js
npm install js-yaml --prefix /tmp
node /tmp/merge-latest-ymls.js ./latest-mac-x64/latest-mac.yml ./latest-mac-arm64/latest-mac.yml ./latest-mac.yml
cat ./latest-mac.yml
node /tmp/merge-beta-ymls.js ./beta-mac-x64/beta-mac.yml ./beta-mac-arm64/beta-mac.yml ./beta-mac.yml
cat ./beta-mac.yml
- name: Yet Another Upload Release Asset Action
uses: shogo82148/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
asset_path: ./latest-mac.yml
asset_name: latest-mac.yml
asset_path: ./beta-mac.yml
asset_name: beta-mac.yml
asset_content_type: text/yaml
overwrite: true

- name: Upload beta-mac.yml
run: |
aws s3 cp ./beta-mac.yml "s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-beta/beta-mac.yml"
# sync temp-beta to beta by copy files that are different or new
aws s3 sync "s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/temp-beta/" "s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/beta/"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.DELTA_AWS_REGION }}
AWS_EC2_METADATA_DISABLED: "true"

- name: set release to prerelease
run: |
gh release edit v${{ needs.create-draft-release.outputs.version }} --draft=false --prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 15 additions & 1 deletion .github/workflows/template-build-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ jobs:
cat ./electron/package.json
echo "------------------------"
cat ./package.json
jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/beta", "channel": "beta"}, {"provider": "github", "owner": "janhq", "repo": "jan", "channel": "beta"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-beta", "channel": "beta"}]' electron/package.json > /tmp/package.json
mv /tmp/package.json electron/package.json
cat electron/package.json
- name: Update app version base on tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
Expand Down Expand Up @@ -105,14 +108,25 @@ jobs:
AWS_MAX_ATTEMPTS: "5"

- name: Build and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false
run: |
make build-and-publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ANALYTICS_ID: ${{ secrets.JAN_APP_UMAMI_PROJECT_API_KEY }}
ANALYTICS_HOST: ${{ secrets.JAN_APP_UMAMI_URL }}

- name: Build and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true
run: |
make build-and-publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: "true"
AWS_MAX_ATTEMPTS: "5"

- name: Upload Artifact .deb file
if: inputs.public_provider != 'github'
uses: actions/upload-artifact@v4
Expand Down
34 changes: 32 additions & 2 deletions .github/workflows/template-build-macos-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ jobs:
cat ./electron/package.json
echo "------------------------"
cat ./package.json
jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/beta", "channel": "beta"}, {"provider": "github", "owner": "janhq", "repo": "jan", "channel": "beta"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-beta", "channel": "beta"}]' electron/package.json > /tmp/package.json
mv /tmp/package.json electron/package.json
cat electron/package.json
- name: Update app version base on tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
Expand Down Expand Up @@ -144,7 +147,7 @@ jobs:
AWS_MAX_ATTEMPTS: "5"

- name: Build and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false
run: |
make build-and-publish
env:
Expand All @@ -159,6 +162,25 @@ jobs:
ANALYTICS_ID: ${{ secrets.JAN_APP_UMAMI_PROJECT_API_KEY }}
ANALYTICS_HOST: ${{ secrets.JAN_APP_UMAMI_URL }}

- name: Build and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true
run: |
make build-and-publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_LINK: "/tmp/codesign.p12"
CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
CSC_IDENTITY_AUTO_DISCOVERY: "true"
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APP_PATH: "."
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
AWS_EC2_METADATA_DISABLED: "true"
AWS_MAX_ATTEMPTS: "5"

- name: Upload Artifact
if: inputs.public_provider != 'github'
uses: actions/upload-artifact@v4
Expand All @@ -167,7 +189,15 @@ jobs:
path: ./electron/dist/jan-mac-arm64-${{ inputs.new_version }}.dmg

- name: Upload Artifact
if: inputs.beta == false
uses: actions/upload-artifact@v4
with:
name: latest-mac-arm64
path: ./electron/dist/latest-mac.yml
path: ./electron/dist/latest-mac.yml

- name: Upload Artifact
if: inputs.beta == true
uses: actions/upload-artifact@v4
with:
name: beta-mac-arm64
path: ./electron/dist/beta-mac.yml
34 changes: 32 additions & 2 deletions .github/workflows/template-build-macos-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ jobs:
cat ./electron/package.json
echo "------------------------"
cat ./package.json
jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/beta", "channel": "beta"}, {"provider": "github", "owner": "janhq", "repo": "jan", "channel": "beta"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-beta", "channel": "beta"}]' electron/package.json > /tmp/package.json
mv /tmp/package.json electron/package.json
cat electron/package.json
- name: Update app version base on tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
Expand Down Expand Up @@ -144,7 +147,7 @@ jobs:
AWS_MAX_ATTEMPTS: "5"

- name: Build and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false
run: |
make build-and-publish
env:
Expand All @@ -159,6 +162,25 @@ jobs:
ANALYTICS_ID: ${{ secrets.JAN_APP_UMAMI_PROJECT_API_KEY }}
ANALYTICS_HOST: ${{ secrets.JAN_APP_UMAMI_URL }}

- name: Build and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true
run: |
make build-and-publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_LINK: "/tmp/codesign.p12"
CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
CSC_IDENTITY_AUTO_DISCOVERY: "true"
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APP_PATH: "."
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
AWS_EC2_METADATA_DISABLED: "true"
AWS_MAX_ATTEMPTS: "5"

- name: Upload Artifact
if: inputs.public_provider != 'github'
uses: actions/upload-artifact@v4
Expand All @@ -167,7 +189,15 @@ jobs:
path: ./electron/dist/jan-mac-x64-${{ inputs.new_version }}.dmg

- name: Upload Artifact
if: inputs.beta == false
uses: actions/upload-artifact@v4
with:
name: latest-mac-x64
path: ./electron/dist/latest-mac.yml
path: ./electron/dist/latest-mac.yml

- name: Upload Artifact
if: inputs.beta == true
uses: actions/upload-artifact@v4
with:
name: beta-mac-x64
path: ./electron/dist/beta-mac.yml
23 changes: 22 additions & 1 deletion .github/workflows/template-build-windows-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jobs:
cat ./package.json
echo "------------------------"
cat ./electron/scripts/uninstaller.nsh
jq '.build.publish = [{"provider": "generic", "url": "https://delta.jan.ai/beta", "channel": "beta"}, {"provider": "github", "owner": "janhq", "repo": "jan", "channel": "beta"}, {"provider": "s3", "acl": null, "bucket": "${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}", "region": "${{ secrets.DELTA_AWS_REGION}}", "path": "temp-beta", "channel": "beta"}]' electron/package.json > /tmp/package.json
mv /tmp/package.json electron/package.json
cat electron/package.json
- name: Update app version base on tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
Expand Down Expand Up @@ -138,7 +141,7 @@ jobs:
AWS_MAX_ATTEMPTS: "5"

- name: Build app and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false
run: |
make build-and-publish
env:
Expand All @@ -151,6 +154,24 @@ jobs:
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }}

- name: Build app and publish app to github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == true
run: |
make build-and-publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
AWS_EC2_METADATA_DISABLED: "true"
AWS_MAX_ATTEMPTS: "5"
AZURE_KEY_VAULT_URI: ${{ secrets.AZURE_KEY_VAULT_URI }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }}
# AZURE_CERT_NAME: homebrewltd

- name: Upload Artifact
if: inputs.public_provider != 'github'
uses: actions/upload-artifact@v4
Expand Down
39 changes: 34 additions & 5 deletions electron/utils/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app } from 'electron'
import { app, screen } from 'electron'
import Store from 'electron-store'

const DEFAULT_WIDTH = 1000
Expand All @@ -22,13 +22,42 @@ export const getBounds = async () => {
height: DEFAULT_HEIGHT,
}

const bounds = await storage.get('windowBounds')
if (bounds) {
return bounds as Electron.Rectangle
} else {
const bounds = (await storage.get('windowBounds')) as
| Electron.Rectangle
| undefined

// If no bounds are saved, use the defaults
if (!bounds) {
storage.set('windowBounds', defaultBounds)
return defaultBounds
}

// Validate that the bounds are on a valid display
const displays = screen.getAllDisplays()
const isValid = displays.some((display) => {
const { x, y, width, height } = display.bounds
return (
bounds.x >= x &&
bounds.x < x + width &&
bounds.y >= y &&
bounds.y < y + height
)
})

// If the position is valid, return the saved bounds, otherwise return default bounds
if (isValid) {
return bounds
} else {
const primaryDisplay = screen.getPrimaryDisplay()
const resetBounds = {
x: primaryDisplay.bounds.x,
y: primaryDisplay.bounds.y,
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
}
storage.set('windowBounds', resetBounds)
return resetBounds
}
}

export const saveBounds = (bounds: Electron.Rectangle | undefined) => {
Expand Down
2 changes: 1 addition & 1 deletion joi/src/core/Modal/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fieldset,

&__content {
color: hsla(var(--modal-fg));
overflow: hidden;
overflow: auto;
background-color: hsla(var(--modal-bg));
border-radius: 8px;
font-size: 14px;
Expand Down
43 changes: 43 additions & 0 deletions web/containers/AutoLink/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import AutoLink from './index'

describe('AutoLink Component', () => {
it('renders text without links correctly', () => {
const text = 'This is a test without links.'
render(<AutoLink text={text} />)
expect(screen.getByText(text)).toBeInTheDocument()
})

it('renders text with a single link correctly', () => {
const text = 'Check this link: https://example.com'
render(<AutoLink text={text} />)
const link = screen.getByText('https://example.com')
expect(link).toBeInTheDocument()
expect(link).toHaveAttribute('href', 'https://example.com')
expect(link).toHaveAttribute('target', 'blank')
})

it('renders text with multiple links correctly', () => {
const text = 'Visit https://example.com and http://test.com'
render(<AutoLink text={text} />)
const link1 = screen.getByText('https://example.com')
const link2 = screen.getByText('http://test.com')
expect(link1).toBeInTheDocument()
expect(link1).toHaveAttribute('href', 'https://example.com')
expect(link1).toHaveAttribute('target', 'blank')
expect(link2).toBeInTheDocument()
expect(link2).toHaveAttribute('href', 'http://test.com')
expect(link2).toHaveAttribute('target', 'blank')
})

it('renders text with a link without protocol correctly', () => {
const text = 'Visit example.com for more info.'
render(<AutoLink text={text} />)
const link = screen.getByText('example.com')
expect(link).toBeInTheDocument()
expect(link).toHaveAttribute('href', 'http://example.com')
expect(link).toHaveAttribute('target', 'blank')
})
})
Loading

0 comments on commit cd906e2

Please sign in to comment.