Skip to content

Commit

Permalink
Merge pull request #1 from woss/implement-macula.link-api
Browse files Browse the repository at this point in the history
implement macula.link api
  • Loading branch information
woss authored Sep 20, 2024
2 parents fe71c2a + 7f5ddc7 commit 73023be
Show file tree
Hide file tree
Showing 42 changed files with 7,018 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
max_line_length = 100
insert_final_newline = true
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ci

on:
merge_group:
push:
branches:
- main
pull_request:

jobs:
build:
name: build and deploy
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
env:
NODE_NO_WARNINGS: 1
BROWSERSLIST_IGNORE_OLD_DATA: 1
steps:
- uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0

- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Pnpm Install
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build
110 changes: 110 additions & 0 deletions .github/workflows/deploy-to-macula.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: deploy-to-macula
on:
workflow_dispatch:
inputs:
env:
description: 'To which env to deploy. This equals the NODE_ENV variable.'
type: choice
default: 'staging'
required: true
options:
- staging
- production
jobs:
build:
name: build and deploy
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
env:
NODE_NO_WARNINGS: 1
BROWSERSLIST_IGNORE_OLD_DATA: 1
steps:
- uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0

- run: corepack enable

- name: Download ipfsCli
run: |
echo "Downloading anagolay ipfs CLI which works with the ipfsAuthProxy."
curl https://ipfs.macula.link/ipfs/bafybeig634knkl57gqgkmh3fti6zxisfcd47swetf5lastcx2waboa4a4a > /usr/local/bin/ipfsCli
chmod +x /usr/local/bin/ipfsCli
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Pnpm Install
run: pnpm install --frozen-lockfile

- name: Build App
env:
VITE_SENTRY_RELEASE_VERSION: ${{github.sha}}
NODE_ENV: ${{inputs.env}}
run: pnpm build

- name: Upload Source Maps to Sentry
env:
SENTRY_LOG_LEVEL: ${{ secrets.SENTRY_LOG_LEVEL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_RELEASE_VERSION: ${{inputs.env}}-${{github.sha}}
SENTRY_PROJECT: woss-photo
NODE_ENV: ${{inputs.env}}
run: pnpm sentry

- name: Upload woss-photo to Macula
env:
AN_IPFS_API_URL: ${{ secrets.AN_IPFS_API_URL }}
AN_IPFS_API_KEY: ${{ secrets.AN_IPFS_API_KEY }}
run: ipfsCli add --onlyCid ./build > woss_photo_cid

- name: Create build artifact
uses: actions/upload-artifact@v4
with:
name: woss_photo_cid
path: woss_photo_cid
retention-days: 1

- name: Deployed URL
run: echo "https://$(cat woss_photo_cid).ipfs.macula.link"

- name: Publish to Macula Hosting
uses: actions/github-script@v7
with:
script: |
const { readFile } = require('node:fs/promises');
const { resolve } = require('node:path');
const filePath = resolve('./woss_photo_cid')
const contents = await readFile(filePath, { encoding: 'utf8' });
const cid = contents.toString();
const l = cid.length;
const firstChars = cid.substring(0,7);
const lastChars = cid.substring(l-7,l);
const full = `${firstChars}...${lastChars}`
let hostingUrl = '';
if('${{inputs.env}}' === 'production') {
hostingUrl = 'https://api.macula.link/hosting';
} else {
hostingUrl = 'https://api.stg.macula.link/hosting';
}
let pkgSlug = 'woss-photo';
const response = await fetch(hostingUrl, {
method: 'post',
body: JSON.stringify({slug:pkgSlug, ipfsCid: cid.trim()}),
headers: {'Content-Type': 'application/json','api-key':'${{ secrets.ACCEPT_HOSTING_API_KEY }}'}
});
const data = await response.json();
console.log('data', data)
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.eslintcache

# Sentry Config File
.sentryclirc
11 changes: 11 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
engine-strict=true
resolution-mode=highest

# registry=https://registry.npmjs.org/
registry=https://npm-registry.anagolay.io/

## macula npm-registry
# registry=http://localhost:3002/npm/

use-node-version=21.4.0
node-version=21.4.0
Empty file added .nvmrc
Empty file.
13 changes: 13 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"printWidth": 110,
"endOfLine": "auto",
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"bracketSpacing": true
}
83 changes: 83 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"workbench.sideBar.location": "right",
"files.associations": {
"*.json": "jsonc",
"package.json": "json",
".sql": "sql"
},
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "always"
},
"editor.formatOnSave": true,
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.autoIndent": "advanced"
},
"[dockercompose]": {
"editor.autoIndent": "advanced"
},
"npm.packageManager": "pnpm",
"eslint.enable": true,
"eslint.experimental.useFlatConfig": true,
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "svelte"],
"eslint.format.enable": true,
"eslint.useESLintClass": true,
"terminal.integrated.lineHeight": 1.2,
"terminal.integrated.letterSpacing": 1,
"cSpell.words": [
"Anagolay",
"cids",
"Codeowner",
"dissoc",
"dotlottie",
"Fastify",
"gpgsign",
"healthcheck",
"IPFS",
"IPFSHTTP",
"kleur",
"middlewares",
"pausable",
"pino",
"polkadot",
"rehosted",
"Roadmap",
"rushstack",
"sveltekit",
"tailwindcss",
"transpiling",
"Unilink",
"WAAT"
],
"workbench.colorCustomizations": {
"titleBar.activeBackground": "#36c2bb",
"titleBar.activeForeground": "#192222"
},
"search.exclude": {
"**/node_modules": true,
"**/*.code-search": true,
"/proc/**/*": true,
"**build*": true,
"**/lib": true,
"**rush": true,
"**dist": true,
"**/*.svelte-kit": true
},
"zenMode.fullScreen": false,
"git.autofetch": true,
"scm.defaultViewMode": "tree",
"terminal.integrated.defaultProfile.linux": "zsh"
}
66 changes: 66 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// eslint.config.cjs

import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginSvelte from 'eslint-plugin-svelte';
import globals from 'globals';
import svelteParser from 'svelte-eslint-parser';
import tsEslint from 'typescript-eslint';

export default tsEslint.config(
js.configs.recommended,
...eslintPluginSvelte.configs['flat/recommended'],
eslintConfigPrettier,
...eslintPluginSvelte.configs['flat/prettier'],
{
rules: {
semi: ['warn', 'always'],
quotes: ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'no-nested-ternary': 'error',
'linebreak-style': ['error', 'unix'],
'no-cond-assign': ['error', 'always'],
'no-console': 'error',
'sort-imports': [
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: true
}
]
}
},
{ ignores: ['build/', '.svelte-kit/', 'pnpm-lock.yaml'] },
{
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: { ...globals.node, ...globals.browser },
parser: svelteParser,
parserOptions: {
parser: tsEslint.parser,
extraFileExtensions: ['.svelte']
}
}
}
// {
// files: ['**/*.svelte'],
// languageOptions: {
// ecmaVersion: 2022,
// sourceType: 'module',
// parser: svelteParser,
// parserOptions: {
// parser: tsParser,
// extraFileExtensions: ['.svelte']
// }
// },
// rules: {
// 'svelte/no-target-blank': 'error',
// 'svelte/no-at-debug-tags': 'error',
// 'svelte/no-reactive-functions': 'error',
// 'svelte/no-reactive-literals': 'error'
// }
// }
);
Loading

0 comments on commit 73023be

Please sign in to comment.