Objetivos

  1. Criar um projeto javascrtipt para uma aplicação web com react e vite
  2. Compartilhar o código-fonte do projeto com o Github
  3. Ter a versão do aplicativo web instalado num servidor de aplicação

Passos

1. Criar o projeto javascript para uma aplicação web

Usa o npm com o comando create usando o script vite em sua última versão para criar um projeto javascript.

$ **npm create vite@latest**
? Project name: webapp-tarefas
? Select a framework: › - Use arrow-keys. Return to submit.
    Vanilla
    Vue
❯   React
    Preact
    Lit
    Svelte
    Others
? Select a variant: › - Use arrow-keys. Return to submit.
❯   TypeScript
    TypeScript + SWC
    JavaScript
    JavaScript + SWC

✔ Project name: … webapp-tarefas
✔ Select a framework: › React
✔ Select a variant: › TypeScript

Scaffolding project in /home/minora/src/2023-pos/webapp-tarefas...

Done. Now run:

  cd webapp-tarefas
  npm install
  npm run dev

$

2. Inicializar o repositório git para o projeto javascript

$ **cd webapp-tarefas**

[webapp-tarefas] $ **git init**
Initialized empty Git repository in /home/minora/minora/2023-pos/webapp-tarefas/.git/

[webapp-tarefas] $ **git checkout -b react**
Switched to a new branch 'react'

[webapp-tarefas] $ **git add .eslintrc.cjs .gitignore index.html package.json public src tsconfig.json tsconfig.node.json vite.config.ts** 

[webapp-tarefas] $ **git status**
On branch react
No commits yet
Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   .eslintrc.cjs
	new file:   .gitignore
	new file:   index.html
	new file:   package.json
	new file:   public/vite.svg
	new file:   src/App.css
	new file:   src/App.tsx
	new file:   src/assets/react.svg
	new file:   src/index.css
	new file:   src/main.tsx
	new file:   src/vite-env.d.ts
	new file:   tsconfig.json
	new file:   tsconfig.node.json
	new file:   vite.config.ts

[webapp-tarefas] $ **git commit -m "criado webapp react"**
[react (root-commit) 785396d] criado webapp react
 14 files changed, 279 insertions(+)
 create mode 100644 .eslintrc.cjs
 create mode 100644 .gitignore
 create mode 100644 index.html
 create mode 100644 package.json
 create mode 100644 public/vite.svg
 create mode 100644 src/App.css
 create mode 100644 src/App.tsx
 create mode 100644 src/assets/react.svg
 create mode 100644 src/index.css
 create mode 100644 src/main.tsx
 create mode 100644 src/vite-env.d.ts
 create mode 100644 tsconfig.json
 create mode 100644 tsconfig.node.json
 create mode 100644 vite.config.ts

[webapp-tarefas] $

3. Conectar o repositório local com o repositório remoto (github)

[webapp-tarefas] $ **git remote add origin <https://github.com/leonardo-minora/2023-webapp.git**>

[webapp-tarefas] $ **git pull**
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 38 (delta 4), reused 7 (delta 3), pack-reused 25
Unpacking objects: 100% (38/38), 22.02 KiB | 751.00 KiB/s, done.
From <https://github.com/leonardo-minora/2023-webapp>
 * [new branch]      main       -> origin/main
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> react

[webapp-tarefas] $ 

4. Mesclando (merge) o repositório remoto com o local

[webapp-tarefas] $ **git checkout main
branch 'main' set up to track 'origin/main'.
Switched to a new branch 'main'**

[webapp-tarefas] $ **git merge react --allow-unrelated-histories**
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Auto-merging index.html
CONFLICT (add/add): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.

****[webapp-tarefas] $ 

Precisa resolver os conflitos dos arquivos

**## verificando quais arquivos precisam ser resolvidos os conflitos**
[webapp-tarefas] $ **git status**
On branch main
Your branch is up to date with 'origin/main'.

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:
	new file:   .eslintrc.cjs
	new file:   public/vite.svg
	new file:   src/App.css
	new file:   src/App.tsx
	new file:   src/assets/react.svg
	new file:   src/index.css
	new file:   src/main.tsx
	new file:   src/vite-env.d.ts
	new file:   tsconfig.json
	new file:   tsconfig.node.json
	new file:   vite.config.ts

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both added:      .gitignore
	both added:      index.html
	both added:      package.json

[webapp-tarefas] $ 

editar os arquivos .gitignore, index.html e package.json e guarde as modificações

**## marcando resolução de conflitos**
[webapp-tarefas] $ **git add .gitignore index.html package.json**

[webapp-tarefas] $ **git status**
On branch main
Your branch is up to date with 'origin/main'.

All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:
	new file:   .eslintrc.cjs
	modified:   .gitignore
	modified:   index.html
	modified:   package.json
	new file:   public/vite.svg
	new file:   src/App.css
	new file:   src/App.tsx
	new file:   src/assets/react.svg
	new file:   src/index.css
	new file:   src/main.tsx
	new file:   src/vite-env.d.ts
	new file:   tsconfig.json
	new file:   tsconfig.node.json
	new file:   vite.config.ts

[webapp-tarefas] $ **git commit -m "mesclagem realizada de repo remoto e local"**
[main ef2d380] mesclagem realizada de repo remoto e local

[webapp-tarefas] $ 

5. Publicando no github as modificações

[webapp-tarefas] $ **git push**
Username for '<https://github.com>': leonardo-minora 
Password for '<https://leonardo-minora@github.com>': 
Enumerating objects: 26, done.
Counting objects: 100% (26/26), done.
Delta compression using up to 4 threads
Compressing objects: 100% (19/19), done.
Writing objects: 100% (22/22), 6.79 KiB | 3.40 MiB/s, done.
Total 22 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 1 local object.
To <https://github.com/leonardo-minora/2023-webapp.git>
   1447bf5..ef2d380  main -> main

[webapp-tarefas] $