-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Rafaelfferreira/pages-structure
Main update with CI/CD
- Loading branch information
Showing
55 changed files
with
9,499 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = { | ||
parser: "@typescript-eslint/parser", | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
node: true, | ||
}, | ||
// plugins: ["react", "prettier", "@typescript-eslint"], | ||
plugins: ["react", "@typescript-eslint"], | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:react/recommended", | ||
"plugin:prettier/recommended", | ||
], | ||
overrides: [], | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
}, | ||
settings: { | ||
react: { | ||
version: "detect", | ||
}, | ||
}, | ||
ignorePatterns: ["node_modules/", "cypress/"], | ||
// Cherry of the Cake | ||
rules: { | ||
"prettier/prettier": 0, | ||
"nonblock-statement-body-position": "off", | ||
// "no-console": "error", | ||
"react/no-unknown-property": ["error", { ignore: ["jsx", "global"] }], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: "CD- Continuous Delivery" | ||
|
||
# on: | ||
# push: | ||
# branches: [ main ] | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
## [Common_CI_Steps] | ||
- uses: actions/checkout@v3 | ||
## =========================== | ||
- name: "Debug" | ||
run: | | ||
ls -la | ||
- name: "Install Dependencies" | ||
run: "npm install" | ||
- name: "Deploy" | ||
run: "npx vercel --prod --token=${{ secrets.VERCEL_TOKEN }} " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: "CI - Continuous Integration" | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
## [Common_CI_Steps] | ||
- uses: actions/checkout@v3 | ||
## =========================== | ||
- name: "Debug" | ||
run: | | ||
ls -la | ||
echo "Second command line!" | ||
- name: "Install Dependencies" | ||
run: "npm install" | ||
- name: "Lint" | ||
run: "npm run lint" | ||
test: | ||
runs-on: ubuntu-22.04 | ||
container: | ||
image: "cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1" | ||
options: --user 1001 | ||
steps: | ||
## [Common_CI_Steps] | ||
- uses: actions/checkout@v3 | ||
|
||
- name: "Install Dependencies" | ||
run: "npm install " | ||
## =========================== | ||
- name: "Test" | ||
run: "npm run test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,4 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.github | ||
.vscode | ||
core | ||
cypress | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"EditorConfig.EditorConfig", | ||
"dbaeumer.vscode-eslint", | ||
"github.vscode-github-actions" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import fs from "fs"; | ||
import { v4 as uuid } from "uuid"; | ||
|
||
// MARK: - CONSTANTS | ||
const DB_FILE_PATH = "./core/db"; | ||
|
||
// MARK: - TYPES | ||
type UUID = string; | ||
|
||
type Todo = { | ||
id: UUID; | ||
date: string; | ||
content: string; | ||
done: boolean; | ||
}; | ||
|
||
// MARK: - CRUD FUNCTIONS | ||
export function create(content: string): Todo { | ||
const todo: Todo = { | ||
id: uuid(), | ||
date: new Date().toISOString(), | ||
content: content, | ||
done: false, | ||
}; | ||
|
||
const todos: Array<Todo> = [ | ||
...read(), | ||
todo, | ||
]; | ||
|
||
// salvar o content no sistema | ||
fs.writeFileSync(DB_FILE_PATH, JSON.stringify({ | ||
todos, | ||
"dogs": [] | ||
}, null, 2)); // Sync -> synchronous | ||
return todo; | ||
} | ||
|
||
export function read(): Array<Todo> { | ||
const dbString = fs.readFileSync(DB_FILE_PATH, "utf-8"); | ||
const db = JSON.parse(dbString || "{}"); | ||
if (!db.todos) { | ||
return []; | ||
} | ||
return db.todos; | ||
} | ||
|
||
export function update(id: UUID, partialTodo: Partial<Todo>): Todo { // Partial<Todo> -> Partial is a built-in type that makes all properties of Todo optional | ||
let updatedTodo; | ||
|
||
const todos = read(); | ||
todos.forEach((currentItem) => { | ||
const isToUpdate = currentItem.id === id; | ||
if(isToUpdate) { | ||
updatedTodo = Object.assign(currentItem, partialTodo); // Object.assign -> built-in function that copies all properties from the second object to the first object | ||
} | ||
}); | ||
|
||
fs.writeFileSync(DB_FILE_PATH, JSON.stringify({ | ||
todos, | ||
}, null, 2)); | ||
|
||
if(!updatedTodo) { | ||
throw new Error("Please provide another ID!") | ||
} | ||
|
||
return updatedTodo; | ||
} | ||
|
||
export function deleteById(id: UUID) { | ||
const todos = read(); | ||
|
||
const todosWithoutDeleted = todos.filter((todo) => { | ||
if(todo.id === id) { return false; } | ||
return true; | ||
}); | ||
|
||
fs.writeFileSync(DB_FILE_PATH, JSON.stringify({ todos: todosWithoutDeleted }, null, 2)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"todos": [ | ||
{ | ||
"id": "30c08ad9-cd30-4e5f-8fb9-b84cb358b9a5", | ||
"date": "2024-04-27T22:31:07.560Z", | ||
"content": "Primeira TODO", | ||
"done": true | ||
}, | ||
{ | ||
"id": "a49eb7da-9586-4646-b2d9-c365e84b261d", | ||
"date": "2024-04-27T22:31:07.561Z", | ||
"content": "Terceira TODO com novo content!", | ||
"done": false | ||
}, | ||
{ | ||
"id": "4613fcbf-2561-47c8-9021-30cb0a4e226f", | ||
"date": "2024-05-16T01:36:18.008Z", | ||
"content": "Next day task", | ||
"done": true | ||
}, | ||
{ | ||
"id": "c733e23e-37f7-4cc0-b765-a3de7a157345", | ||
"date": "2024-05-19T20:32:49.395Z", | ||
"content": "alo alo w brazil", | ||
"done": false | ||
} | ||
], | ||
"dogs": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents() { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.