Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejVukosav authored Oct 29, 2024
0 parents commit 115e106
Show file tree
Hide file tree
Showing 48 changed files with 26,317 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: setup
description: "Setup - Cache dependencies ⚡ - Install dependencies 🔧"
runs:
using: "composite"
steps:
- name: Install pnpm
shell: bash
run: npm install -g pnpm

- name: Install dependencies
shell: bash
run: |
cd ${{ inputs.working-directory }}
pnpm install
- name: Build
shell: bash
run: |
cd ${{ inputs.working-directory }}
pnpm build
inputs:
working-directory:
description: "Working directory"
default: "./app"
76 changes: 76 additions & 0 deletions .github/workflows/deploy-react.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Deploy Next.js site to Pages

on:
push:
branches: ["master"]
workflow_dispatch:

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

permissions:
id-token: write
contents: write
pages: write

defaults:
run:
working-directory: ./app

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Setup Pages
uses: actions/configure-pages@v5
with:
static_site_generator: next

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: ./app/build

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
needs: build

steps:
- name: Download artifact
uses: actions/download-artifact@v4

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

notify-slack-on-failure:
runs-on: ubuntu-latest
needs: [build, deploy]
if: failure()
steps:
- name: Notify failure
uses: "ravsamhq/[email protected]"
with:
status: failure
notification_title: "Deploy failed on ${{ github.ref_name }} - <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Failure>"
message_format: ":fire: *Deploy Core App Template site to Pages* in <${{ github.server_url }}/${{ github.repository }}/${{ github.ref_name }}|${{ github.repository }}>"
footer: "Linked Repo <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}> | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Failure>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.DEPLOY_FAIL_SLACK }}
36 changes: 36 additions & 0 deletions .github/workflows/release-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release WASM app to registry
on:
push:
branches:
- master
paths:
- "logic/**"
jobs:
metadata:
name: Build and release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build application
run: |
./logic/build.sh
- name: Install near CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.15.1/near-cli-rs-installer.sh | sh
- name: Release application
env:
NEAR_NETWORK: testnet
NEAR_CREDENTIALS_JSON: ${{ secrets.NEAR_TESTNET_CREDENTIALS_JSON }}
NEAR_CONTRACT_ACCOUNT_ID: "calimero-package-manager.testnet"
run: |
credentials_file="./near-credentials.json"
printf "$NEAR_CREDENTIALS_JSON" > "$credentials_file"
./logic/release.sh \
"$NEAR_NETWORK" \
"$(realpath "$credentials_file")" \
"$NEAR_CONTRACT_ACCOUNT_ID"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/node_modules
.DS_Store

.idea/
res/
data/
target/
14 changes: 14 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Check for changes in the 'app' directory
if git diff --cached --name-only | grep -q '^app/'; then
echo "Running checks for the React app..."
(cd app && pnpm prettier && pnpm lint:fix)
fi

# Check for changes in the 'logic' directory
if git diff --cached --name-only | grep -q '^logic/'; then
echo "Running checks for the Rust logic..."
(cd logic && cargo test && cargo fmt -- --check)
fi
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Core App Template

## Logic

```bash title="Terminal"
cd logic
```

```bash title="Terminal"
chmod +x ./build.sh
```

```bash title="Terminal"
./build.sh
```

```bash title="Terminal"
./release.sh ./res/logic.wasm "Test Name123" "0.0.1" "-" "-" "-" calimero-package-manager.testnet
```

## App

```bash title="Terminal"
cd app
```

```bash title="Terminal"
pnpm install
```

```bash title="Terminal"
pnpm build
```

```bash title="Terminal"
pnpm dev
```

Open app in browser and connect to running node.

For more information how to build app check our docs:
https://calimero-network.github.io/build/quickstart
5 changes: 5 additions & 0 deletions app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VITE_APPLICATION_ID="bafa0e4f0794a67bfb8a4c6eca5da2760555a8e0ed889a39b522131b57b7010e"
VITE_NEAR_ENVIRONMENT=testnet
VITE_NODE_URL=http://localhost:2428
VITE_RPC_PATH=/jsonrpc
VITE_CONTEXT_ID=GSouksxYcyCNS3z3axxoh3YSSzbCoMU84TYxr43Df2DU
40 changes: 40 additions & 0 deletions app/.eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { defineConfig } from 'eslint-define-config';

export default defineConfig({
root: true,
env: {
browser: true,
es2020: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'react-app',
'plugin:prettier/recommended',
],
ignorePatterns: ['build', '.eslint.config.mjs'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json'],
},
settings: {
react: {
version: '18.2',
},
},
plugins: ['@typescript-eslint', 'react-refresh'],
rules: {
'react/jsx-no-target-blank': 'off',
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
});
4 changes: 4 additions & 0 deletions app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
build
coverage
node_modules
23 changes: 23 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
4 changes: 4 additions & 0 deletions app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
build
coverage
node_modules
46 changes: 46 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
4 changes: 4 additions & 0 deletions app/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.svg' {
const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
export default content;
}
43 changes: 43 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>App</title>

<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script checks to see if a redirect is present in the query string,
// converts it back into the correct url and adds it to the
// browser's history using window.history.replaceState(...),
// which won't cause the browser to attempt to load the new url.
// When the single page app is loaded further down in this file,
// the correct url will be waiting in the browser's history for
// the single page app to route accordingly.
(function (l) {
if (l.search[1] === '/') {
var decoded = l.search
.slice(1)
.split('&')
.map(function (s) {
return s.replace(/~and~/g, '&');
})
.join('?');
window.history.replaceState(
null,
null,
l.pathname.slice(0, -1) + decoded + l.hash,
);
}
})(window.location);
</script>
<!-- End Single Page Apps for GitHub Pages -->
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
Loading

0 comments on commit 115e106

Please sign in to comment.