Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into writing-assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
weilirs committed Jul 31, 2024
2 parents 125865d + 152b936 commit c5aec62
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto eol=lf

36 changes: 10 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,104 +1,88 @@
name: Build and Package Electron App

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"

jobs:
build_and_package:
strategy:
matrix:
include:
- os: macos-13
# arch: x64
- os: macos-latest
# arch: arm64
- os: windows-latest
- os: ubuntu-latest
arch: x64

fail-fast: false
continue-on-error: true
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Cache TypeScript build
uses: actions/cache@v3
with:
path: ./dist
key: ${{ runner.os }}-tsc-${{ hashFiles('**/tsconfig.json') }}
restore-keys: |
${{ runner.os }}-tsc-
- name: Install dependencies
run: npm install

- name: Run Linter
run: npm run lint

- name: Run Tests
run: npm run test

- name: Set up environment for macOS build
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If you use GitHub token for auto-update
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run build
- name: Build for non-macos
- name: Build for non-macOS
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: |
npm run build
- name: Notarize macOS build
if: (matrix.os == 'macos-13' || matrix.os == 'macos-latest') && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: npm run notarize
- name: Set version as env
run: echo "APP_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: Print APP_VERSION
run: echo "APP_VERSION=${{ env.APP_VERSION }}"

- name: List output files
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: |
ls ./release/${{ env.APP_VERSION }}/
- name: Check runner architecture
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: uname -m


- name: Rename artifacts for ARM architecture
if: matrix.os == 'macos-latest'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-arm64.dmg
- name: Rename artifacts for Intel architecture
if: matrix.os == 'macos-13'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-intel.dmg
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
35 changes: 11 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,77 @@
name: Release script

on:
push:
tags:
- "v*"

jobs:
build_and_package:
runs-on: ${{ matrix.os }}

strategy:
matrix:
include:
- os: macos-13
# arch: x64
- os: macos-latest
# arch: arm64
- os: windows-latest
- os: ubuntu-latest
arch: x64
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Cache TypeScript build
uses: actions/cache@v3
with:
path: ./dist
key: ${{ runner.os }}-tsc-${{ hashFiles('**/tsconfig.json') }}
restore-keys: |
${{ runner.os }}-tsc-
- name: Install dependencies
run: npm install

- name: Run Linter
run: npm run lint

- name: Run Tests
run: npm run test

- name: Set up environment for macOS build
if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge'
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If you use GitHub token for auto-update
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run build
- name: Build for non-macos
if: matrix.os != 'macos-latest' && matrix.os != 'macos-latest-xlarge'
- name: Notarize macOS build
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: npm run notarize
- name: Build for non-macOS
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: |
npm run build
- name: Set version as env
run: echo "APP_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: Rename artifacts for ARM architecture
if: matrix.os == 'macos-latest'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-arm64.dmg
- name: Rename artifacts for Intel architecture
if: matrix.os == 'macos-13'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-intel.dmg
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -101,7 +89,6 @@ jobs:
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -110,4 +97,4 @@ jobs:
**/*.AppImage
**/*.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": true
"singleQuote": true,
"endOfLine": "lf"
}
8 changes: 5 additions & 3 deletions electron/main/electron-utils/ipcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Store from 'electron-store'

import WindowsManager from '../common/windowManager'
import { StoreKeys, StoreSchema } from '../electron-store/storeConfig'
import { ChatHistoryMetadata } from '@/components/Chat/hooks/use-chat-history'
import { FileInfoNode } from '../filesystem/types'

const electronUtilsHandlers = (
store: Store<StoreSchema>,
Expand Down Expand Up @@ -38,7 +40,7 @@ const electronUtilsHandlers = (
if (browserWindow) menu.popup({ window: browserWindow })
})

ipcMain.handle('show-context-menu-file-item', async (event, file) => {
ipcMain.handle('show-context-menu-file-item', async (event, file: FileInfoNode) => {
const menu = new Menu()

const stats = await fs.stat(file.path)
Expand Down Expand Up @@ -115,7 +117,7 @@ const electronUtilsHandlers = (
}
})

ipcMain.handle('show-chat-menu-item', (event, chatID) => {
ipcMain.handle('show-chat-menu-item', (event, chatRow: ChatHistoryMetadata) => {
const menu = new Menu()

menu.append(
Expand All @@ -130,7 +132,7 @@ const electronUtilsHandlers = (

const chatHistoriesMap = store.get(StoreKeys.ChatHistories)
const allChatHistories = chatHistoriesMap[vaultDir] || []
const filteredChatHistories = allChatHistories.filter((item) => item.id !== chatID)
const filteredChatHistories = allChatHistories.filter((item) => item.id !== chatRow.id)
chatHistoriesMap[vaultDir] = filteredChatHistories
store.set(StoreKeys.ChatHistories, chatHistoriesMap)
event.sender.send('update-chat-histories', chatHistoriesMap[vaultDir] || [])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dev": "vite",
"prebuild": "node scripts/downloadOllama.js",
"build": "tsc && vite build && electron-builder",
"postbuild": "node scripts/notarize.js",
"notarize": "node scripts/notarize.js",
"preview": "vite preview",
"pree2e": "vite build --mode=test",
"e2e": "playwright test",
Expand Down
1 change: 1 addition & 0 deletions scripts/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function printDirectoryTree(startPath, indent = "") {
}

async function notarizeApp() {
console.log("Notarizing the app...");
const productName = "Reor";

// Get the current platform
Expand Down
1 change: 0 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import IndexingProgress from './components/Common/IndexingProgress'
import MainPageComponent from './components/MainPage'
import InitialSetupSinglePage from './components/Settings/InitialSettingsSinglePage'


interface AppProps {}

const App: React.FC<AppProps> = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/File/hooks/use-file-by-filepath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const useFileByFilepath = () => {
linkify: true, // Create links from "https://..." text
breaks: true, // New lines (\n) in markdown input are converted to <br>
transformPastedText: true, // Allow to paste markdown text in the editor
transformCopiedText: true, // Copied text is transformed to markdown
transformCopiedText: false, // Copied text is transformed to markdown
}),
TaskItem.configure({
nested: true,
Expand Down

0 comments on commit c5aec62

Please sign in to comment.