diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..2b9b79e2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto eol=lf + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f196a07b..12533b5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,4 @@ name: Build and Package Electron App - on: push: branches: @@ -7,31 +6,26 @@ on: 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: @@ -39,7 +33,6 @@ jobs: key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- - - name: Cache TypeScript build uses: actions/cache@v3 with: @@ -47,58 +40,49 @@ jobs: 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: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67ce83e3..fba272c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,27 @@ 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: @@ -37,7 +29,6 @@ jobs: key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- - - name: Cache TypeScript build uses: actions/cache@v3 with: @@ -45,45 +36,42 @@ jobs: 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: @@ -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: @@ -110,4 +97,4 @@ jobs: **/*.AppImage **/*.dmg env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index 30fdbfad..27b6c818 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,5 +4,6 @@ "trailingComma": "all", "tabWidth": 2, "semi": false, - "singleQuote": true + "singleQuote": true, + "endOfLine": "lf" } \ No newline at end of file diff --git a/electron/main/electron-utils/ipcHandlers.ts b/electron/main/electron-utils/ipcHandlers.ts index e40d2731..036b89e0 100644 --- a/electron/main/electron-utils/ipcHandlers.ts +++ b/electron/main/electron-utils/ipcHandlers.ts @@ -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, @@ -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) @@ -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( @@ -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] || []) diff --git a/package.json b/package.json index 8f1be2fc..b8d48019 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/notarize.js b/scripts/notarize.js index 85638272..487d7207 100644 --- a/scripts/notarize.js +++ b/scripts/notarize.js @@ -25,6 +25,7 @@ function printDirectoryTree(startPath, indent = "") { } async function notarizeApp() { + console.log("Notarizing the app..."); const productName = "Reor"; // Get the current platform diff --git a/src/App.tsx b/src/App.tsx index 4ff63f5f..71d85fea 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 = () => { diff --git a/src/components/File/hooks/use-file-by-filepath.ts b/src/components/File/hooks/use-file-by-filepath.ts index f951d97e..a6dd513c 100644 --- a/src/components/File/hooks/use-file-by-filepath.ts +++ b/src/components/File/hooks/use-file-by-filepath.ts @@ -166,7 +166,7 @@ const useFileByFilepath = () => { linkify: true, // Create links from "https://..." text breaks: true, // New lines (\n) in markdown input are converted to
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,