Skip to content

Commit

Permalink
feat(core): initial stable commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Plopix committed May 18, 2024
0 parents commit 817859c
Show file tree
Hide file tree
Showing 49 changed files with 9,616 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
.git
.idea/
.editorconfig
.gitattributes
.github/
.vscode
bin/
tests/
.dockerignore
.env
.env.dist
.gitignore
.prettierignore
.prettierrc.json
Dockerfile
jest.config
/node_modules
.env
.cache
build
3 changes: 3 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CRYSTALLIZE_SIGNING_SECRET=xxx
CRYSTALLIZE_ACCESS_TOKEN_ID=xxx
CRYSTALLIZE_ACCESS_TOKEN_SECRET=xxx
80 changes: 80 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* This is intended to be a basic starting point for linting in your app.
* It relies on recommended configs out of the box for simplicity, but you can
* and should modify this configuration to best suit your team's needs.
*/

/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
commonjs: true,
es6: true,
},
ignorePatterns: ['!**/.server', '!**/.client'],

// Base config
extends: ['eslint:recommended'],

overrides: [
// React
{
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: ['react', 'jsx-a11y'],
extends: [
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
settings: {
react: {
version: 'detect',
},
formComponents: ['Form'],
linkComponents: [
{ name: 'Link', linkAttribute: 'to' },
{ name: 'NavLink', linkAttribute: 'to' },
],
'import/resolver': {
typescript: {},
},
},
},

// Typescript
{
files: ['**/*.{ts,tsx}'],
plugins: ['@typescript-eslint', 'import'],
parser: '@typescript-eslint/parser',
settings: {
'import/internal-regex': '^~/',
'import/resolver': {
node: {
extensions: ['.ts', '.tsx'],
},
typescript: {
alwaysTryTypes: true,
},
},
},
extends: ['plugin:@typescript-eslint/recommended', 'plugin:import/recommended', 'plugin:import/typescript'],
},

// Node
{
files: ['.eslintrc.cjs'],
env: {
node: true,
},
},
],
};
77 changes: 77 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI

on:
push:
branches: ['main']
pull_request:
types: [opened, synchronize, reopened]

jobs:
lint:
name: 💄 Lint
runs-on: blacksmith-2vcpu-ubuntu-2204
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: ⎔ Set up pnpm
uses: pnpm/action-setup@v3
with:
version: 9.1.1

- name: 📥 Download deps
run: pnpm install

- name: 💄 Prettier Check
run: pnpm prettier:check

- name: 🔬 Lint Check
run: pnpm lint:check

test:
name: 🧪 Tests
runs-on: blacksmith-2vcpu-ubuntu-2204
needs: [lint]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: ⎔ Set up pnpm
uses: pnpm/action-setup@v3
with:
version: 9.1.1

- name: 📥 Download deps
run: |
pnpm install
pnpm run build
- name: 🏄 Run the tests
run: pnpm test

deploy:
name: 🍿 Deploy
if: github.event_name == 'push' && ( github.ref_name == 'main' )
runs-on: blacksmith-2vcpu-ubuntu-2204
needs: [lint, test]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🍔 Install Flyctl
uses: superfly/flyctl-actions/setup-flyctl@master

- name: 🚀 Push to Fly.io
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: flyctl deploy --remote-only --config fly-${{ github.ref_name }}.toml
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules

/.cache
/build
.env

*.pid
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
public/build
api
pnpm-lock.yaml
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tabWidth": 4,
"semi": true,
"useTabs": false,
"bracketSpacing": true,
"bracketSameLine": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
}
39 changes: 39 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"typescript.suggest.paths": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/node_modules": true,
"**/build": true,
"**/.cache": true
},
"todo-tree.general.tags": ["@todo:", "@fixme:", "@bug:"],
"todo-tree.general.statusBar": "top three",
"todo-tree.tree.groupedByTag": true,
"todo-tree.general.statusBarClickBehaviour": "reveal",
"todo-tree.general.tagGroups": {
"TODOs": ["@todo:"],
"BUGs": ["@fixme:", "@bug:"]
},
"todo-tree.highlights.customHighlight": {
"TODOs": {
"icon": "flame",
"foreground": "#ff9900"
},
"BUGs": {
"icon": "bug",
"foreground": "#ff0000"
}
},
"files.associations": {
"**/*.css": "tailwindcss"
}
}
3 changes: 3 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bulk-edit-import.app.crystallize.app.local {
reverse_proxy 127.0.0.1:3080
}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-slim as base
LABEL fly_launch_runtime="Remix"
RUN mkdir /app
WORKDIR /app
ARG PNPM_VERSION=9.1.1
RUN npm install -g pnpm@$PNPM_VERSION
COPY . .
RUN pnpm install --frozen-lockfile --prod=false
RUN pnpm build
ENV NODE_ENV=production
ENV PORT=80
EXPOSE 80
CMD [ "pnpm", "start" ]
73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Styles
YELLOW := $(shell echo "\033[00;33m")
RED := $(shell echo "\033[00;31m")
RESTORE := $(shell echo "\033[0m")

# Variables
.DEFAULT_GOAL := list
PACKAGE_MANAGER := pnpm
CURRENT_DIR := $(shell pwd)
DEPENDENCIES := node pnpm git
NODE := node -r dotenv/config
CADDY_PID_FILE := caddy.dev.pid
CADDY = caddy

.PHONY: list
list:
@echo "${YELLOW}***${RED}***${RESTORE}***${YELLOW}***${RED}***${RESTORE}***${YELLOW}***${RED}***${RESTORE}***${YELLOW}***${RED}***${RESTORE}"
@echo "${RED}Bulk Edit Import App: ${YELLOW}Available targets${RESTORE}:"
@grep -E '^[a-zA-Z-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " ${YELLOW}%-15s${RESTORE} > %s\n", $$1, $$2}'
@echo "${RED}=================================${RESTORE}"

.PHONY: check-dependencies
check-dependencies:
@for dependency in $(DEPENDENCIES); do \
if ! command -v $$dependency &> /dev/null; then \
echo "${RED}Error:${RESTORE} ${YELLOW}$$dependency${RESTORE} is not installed."; \
exit 1; \
fi; \
done
@echo "All ${YELLOW}dependencies are installed.${RESTORE}"

.PHONY: install
install: check-dependencies update ## Install the Application and reset the database

.PHONY: update
update: check-dependencies ## Update the Repo
@$(PACKAGE_MANAGER) install

.PHONY: codeclean
codeclean: ## Code Clean
@$(PACKAGE_MANAGER) run lint:fix
@$(PACKAGE_MANAGER) run prettier:fix
@$(PACKAGE_MANAGER) run lint:check
@$(PACKAGE_MANAGER) run prettier:check

.PHONY: strict-codeclean
strict-codeclean: codeclean
@$(PACKAGE_MANAGER) run typecheck

.PHONY: build
build: ## Build All
@$(PACKAGE_MANAGER) run build

.PHONY: start-services
start-services: stop-services ## Start Services
@touch $(CADDY_PID_FILE)
@$(CADDY) start --pidfile $(CADDY_PID_FILE)

.PHONY: stop-services
stop-services: ## Stop Services
-@$(CADDY) stop > /dev/null 2>&1 &
-@if [ -f $(CADDY_PID_FILE) ]; then \
kill -9 `cat $(CADDY_PID_FILE)`; \
rm -f $(CADDY_PID_FILE); \
fi

.PHONY: serve
serve: ## Serve the application
@$(PACKAGE_MANAGER) run dev --host

.PHONY: tests
tests: ## Run All the Tests
@$(PACKAGE_MANAGER) run test
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Crystallize Bulk Edit Import App

> Import app that provides a UI for importing and mapping datasets to Crystallize.
## Requirements

You need:

- Caddy Server
- Node 20
- PNPM 9.1.1

## Install

```bash
make install
```

## Run the project

HTTPS locally, if you want to simplify authentication you should run the project and inject the local url in Crystallize.
Make sure to update your `.env` file.

> Pro tip: Once the Cookie is created you can reach the https url directly.
First you need to start the services, Caddy server is the only service for now. This is non-blocking.

```bash
make start-services
```

Then you can run the webserver:

```bash
make serve
```

> https://bulk-edit-import.app.crystallize.app.local
Caddy can generate the HTTPS Certificates on its own if the domain is `.local` so you should be covered.
However, `bulk-edit-import.app.crystallize.app.local` must resolve to `127.0.0.1`

## Contributing

```make codeclean`
Loading

0 comments on commit 817859c

Please sign in to comment.