首页 > 其他分享 >[Tools] Automate Creating a Local React Project, GitHub Repository, and Live Hosted Demo in a Single

[Tools] Automate Creating a Local React Project, GitHub Repository, and Live Hosted Demo in a Single

时间:2024-12-23 16:21:19浏览次数:8  
标签:project GitHub Creating md echo Project github README name

It's fairly trivial to create a React project, but there's always a big hurdle between creating it locally and making it shareable so that someone else can run it. This lesson walks you through the process of automating creating a React project locally, creating the repository where it's going to be hosted, and creating shareable links where it can be run so that you can quickly and easily create single one-off demos and shoot them over to your friends and coworkers for sharing your code ideas in a working environment.

share-react-project() {
  if [[ -z "$1" ]]; then
    echo "Usage: share-react-project <project_name>"
    return 1
  fi

  local project_name="$1"
  local github_username=$(gh api /user --jq '.login')

  echo "Creating Vite project: $project_name"
  pnpm create vite "$project_name" --template react

  cd "$project_name"

  echo "Initializing Git repository"
  git init

  echo "Adding all files to Git"
  git add .

  echo "Creating initial commit"
  git commit -m "Initial commit"

  local codesandbox_link="https://codesandbox.io/p/github/${github_username}/${project_name}"

  echo "Adding CodeSandbox link to README.md"
  echo "" >> README.md
  echo "## CodeSandbox" >> README.md
  echo "[![Open in CodeSandbox](https://assets.codesandbox.io/github/button-edit-blue.svg)](${codesandbox_link})" >> README.md

  echo "Adding README.md to Git"
  git add README.md

  echo "Committing README.md changes"
  git commit -m "Add CodeSandbox link"

  echo "Creating GitHub repository: $github_username/$project_name"
  gh repo create "$github_username/$project_name" --public

  echo "Pushing to remote 'origin'"
  git push -u origin main

  echo "Project '$project_name' created successfully!"
  echo "GitHub repository: https://github.com/$github_username/$project_name"
  echo "CodeSandbox link: $codesandbox_link"
}

 

Usage:

share-react-project demo-project

 

标签:project,GitHub,Creating,md,echo,Project,github,README,name
From: https://www.cnblogs.com/Answer1215/p/18624324

相关文章

  • 向github仓库上传代码报错的处理
    remote:PermissiontoBROtao233/socket_study.gitdeniedtoMasterTao2233.fatal:unabletoaccess'https://github.com/BROtao233/socket_study.git/':TherequestedURLreturnederror:403在通过push命令向github仓库上传代码时,遇到了上面的报错仔细读,意思是,对于用户......
  • 使用canvas画一个github的LOGO图案
    使用HTML5<canvas>元素来绘制GitHub的LOGO需要一些细致的工作,因为GitHub的LOGO并不是一个简单的几何图形。但是,为了简化,我们可以尝试绘制一个简化的版本,比如一个类似于GitHubLOGO的八边形图案。以下是一个简化的示例,展示如何使用<canvas>来绘制一个类似GitHubL......
  • 好消息,在 Visual Studio 中可以免费使用 GitHub Copilot 了!
    前言今天大姚给大家分享一个好消息,GitHubCopilot可以免费使用了!在此之前若开发者要使用GitHubCopilot需要付费订阅,每月订阅费用起步价为10美元,而经过验证的学生、教师和开源项目维护者则可以申请免费使用。今天咱们一起来看看在VisualStudio使用GitHubCopilot......
  • 好消息,在 Visual Studio 中可以免费使用 GitHub Copilot 了!
     思维导航前言GitHubCopilot介绍GitHubCopilotFree包含哪些功能?GitHubCopilot支持语言安装最新版本的VisualStudio2022激活GitHubCopilotFreeVisualStudio中开始免费使用CopilotVisualStudio中Copilot的相关设置VisualStudio中使用Copilot代码补全Vi......
  • 2024年12月20日Github流行趋势
    项目名称:EbookFoundation/free-programming-books项目维护者:vhf,eshellman,davorpa,MHM5000,kadhirash等项目介绍:免费的编程书籍集合项目star数:342,145项目fork数:62,055项目名称:microsoft/PowerToys项目维护者:crutkas,bao-qian,qianlifeng,jaimecbernardo,......
  • https://github.com/mvysny/vok-helloworld-app修改内容
    build.gradle.kts:importorg.gradle.api.tasks.testing.logging.TestExceptionFormatimportorg.jetbrains.kotlin.gradle.dsl.JvmTargetimportorg.jetbrains.kotlin.gradle.tasks.KotlinCompileplugins{kotlin("jvm")version"2.1.0"......
  • github pbft代码问题
    最近在做毕设,参考github相关代码时发现一些问题,这里给自己做个笔记提醒。(github总是犯神经,报错超时无语)链接为https://github.com/kenzarh/SG-PBFT代码中间进行视图切换的消息类型操作时,有一句逻辑为给全部节点发送new-view类型消息的代码,直接修改main.py的timer_limit_befor......
  • GitHub 推出免费版 GitHub Copilot:提供每月2,000次代码补全和50条聊天消息,支持多种主
    ❤️如果你也关注AI的发展现状,且对AI应用开发非常感兴趣,我会每日跟你分享最新的AI资讯和开源应用,也会不定期分享自己的想法和开源实例,欢迎关注我哦!......
  • idea构建Build Project项目时一直卡在解析阶段解决办法
    可能是内存不足,修改以下三个地方1、help->EditCustomVMOptions-Xmx4096m2、file->settings->Build,Execution,Deployment->BuildTools->Maven->Importing的VMoptionsforimporter写入参数-Xmx4096m3、file->settings->Build,Execution,Deployment->Compiler的Sh......
  • Github博客搭建指南(1)
    不要怕,万里长征从今始,路是一步一步踏出去的序我是近期才开始搭建Github博客的,写这篇博客的目的是把我的搭建方法分享出来,如果有对搭建博客有兴趣,但是不知从何开始的小白,可以使用这篇作为参考。该篇文章仅作为大佬搭建步骤的归纳和总结,如有不足之处还望指正注:本篇仅限于win......