發表文章

使用 GitHub Actions 將 React TypeScript 項目部署到 GitHub Pages

圖片
  使用 GitHub Actions 將 React TypeScript 項目部署到 GitHub Pages 導言 將 React TypeScript 項目部署到 GitHub Pages 能夠高效地自動化過程,確保您的項目與儲存庫中的最新變更同步。這份教程將指導您如何設置 GitHub Actions 來自動將您的 React TypeScript 項目部署到 GitHub Pages。 前提條件 GitHub 帳戶 :您需要擁有一個 GitHub 帳戶以及包含您的 React TypeScript 項目的儲存庫。 Node.js 和 npm :確保已安裝 Node.js 和 npm 以處理項目依賴性。 分步指南 第一步:準備您的 React 項目 確保您的 React 項目使用 TypeScript 並配置正確構建。在您的  package.json  中,設置  homepage  字段為托管子路徑: "homepage" : "./" , 第二步:設置 GitHub Actions 生成提交權杖(Commit Token) : 前往  Settings  >  Developer Settings  >  Personal access tokens 。 選擇  Generate new token 。 為權杖選擇合適的權限,例如儲存庫(repo)訪問。 記下生成的權杖。 將提交權杖添加為密鑰(Secret) : 導航到您的儲存庫設置。 前往  Secrets and variables  >  Repository secrets  >  New repository secret 。 名稱: COMMIT_TOKEN 密鑰:貼上生成的權杖。 創建工作流文件 : 在 GitHub 上您的儲存庫中,前往  Actions  標籤並點擊 “New workflow”。 點擊 “set up a workflow yourself” 以在  .github/workflows  中創建一個新的 YAML 文件。 配置工作流 : 用以下配置替換 YAML 文件的內容: name : deploy gh - pages on : push : branches :

How to Deploy a React TypeScript Project to GitHub Pages using GitHub Actions

圖片
  How to Deploy a React TypeScript Project to GitHub Pages using GitHub Actions Introduction Deploying a React TypeScript project to GitHub Pages efficiently automates the process, ensuring your project is consistent with the latest changes in your repository. This tutorial will guide you through setting up GitHub Actions to automate the deployment of your React TypeScript project to GitHub Pages. Prerequisites GitHub Account : A GitHub account and a repository containing your React TypeScript project. Node.js and npm : Ensure Node.js and npm are installed to handle project dependencies. Step-by-Step Guide Step 1: Prepare Your React Project Make sure your React project uses TypeScript and is configured to build correctly. In your  package.json , set the  homepage  field to the hosting subpath: "homepage" : "./" , Step 2: Set Up GitHub Actions Generate a Commit Token : Go to  Settings  >  Developer Settings  >  Personal access tokens . Select  Generate new to

如何讓GPT了解你的專案

動機 在許多開發環境中,如Tabnine或GitHub Copilot提供代碼完成建議,但這些工具可能無法針對特定模型進行定制,或者需要付費使用。本教程將介紹如何通過自定義GPT模型,使其更深入地理解您的專案結構和代碼,從而提供更加精確的建議。 使用Shell腳本匯出專案所有檔案內容 以下的shell腳本可以用來將專案目錄下的所有檔案內容匯出到一個文本文件中,排除一些常見的非源代碼目錄。 #!/bin/bash # Define the output file output_file="all_files_contents.txt" # Define excluded directories in a variable as an array declare -a exclude_dirs=("bin" "build" "logs" "out" ".git" ".gradle" ".idea" "init-model" "resources") # Build the find command exclude path argument dynamically exclude_args=() for dir in "${exclude_dirs[@]}"; do exclude_args+=(! -path "*/$dir/*") done # Clear the output file if it already exists > "$output_file" # Define a function to append file details to the output file process_file() { local file_path="$1" echo "--------------" >> "$output_file" echo " ${file_path}&quo

JPA Create/Update 前修改 Entity (@PrePersist/@PreUpdate)

  JPA Create/Update 前修改 Entity (@PrePersist/@PreUpdate) 常常我們需要再寫入資料庫前,固定寫入某寫欄位 例如 創建日期 更新日期 原本操作方式 Model - Account.java import lombok . Data ; import javax . persistence . * ; @Data @Entity public class Account implements Serializable { @Id @GeneratedValue ( strategy = GenerationType . IDENTITY ) private long id ; private String username ; private String password ; private Date createAt ; private Date updateAt ; } Service - AccountService.java public class AccountService { . . . public Account createAccount ( String user , String pass ) { Account a = new Account ( ) ; . . . Date nowAt = CommUtils . nowUtc0 ( ) ; a . setCreateAt ( nowAt ) ; a . setUpdateAt ( nowAt ) ; return dao . save ( om ) ; } } 改成 @PrePersist/@PreUpdate 去寫 創建一個新的 ModelAopService.java public class ModelAopService {