Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Commit cc9f557

Browse files
authored
Merge pull request #5 from quantmind/ls-v2
v2
2 parents ba43042 + 293f208 commit cc9f557

18 files changed

Lines changed: 3535 additions & 595 deletions

.github/workflows/test.yml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
name: test
22

3-
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
branches:
9-
- master
3+
on: push
104

115
jobs:
126
build:
137
runs-on: ubuntu-latest
148
env:
159
METABLOCK_API_TOKEN: ${{ secrets.METABLOCK_API_TOKEN }}
16-
METABLOCK_BLOCK_ID: 7ccced109e374e0ebdcb4d8bb9b8d61e
17-
BUNDLE_LOCATION: example/public
10+
METABLOCK_BLOCK_ID: 9f15b0a7a60e4f528e573444cc5af7e0
1811

1912
steps:
2013
- name: checkout repo
21-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
2215
- name: build example
23-
uses: actions/setup-node@v1
16+
uses: actions/setup-node@v2
2417
with:
25-
node-version: 12.x
18+
node-version: 18.x
2619
- name: build example
27-
run: cd example && yarn && yarn build
28-
- uses: quantmind/metablock-action@master
29-
id: metablock-deployment-stage
30-
if: github.event_name == 'pull_request'
31-
- uses: quantmind/metablock-action@master
32-
id: metablock-deployment-prod
33-
if: github.event_name == 'push'
20+
run: make build-example
21+
- name: stage deployment
22+
uses: ./
23+
if: github.ref != 'refs/heads/main'
24+
with:
25+
env: stage
26+
bundle: example/dist
27+
- name: prod deployment
28+
uses: ./
29+
if: github.ref == 'refs/heads/main'
3430
with:
3531
env: prod
32+
bundle: example/dist

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM node:12-slim
1+
FROM node:16-slim
22

33
WORKDIR /action
44

55
ENV DOCKER=yes NODE_ENV=production
6-
RUN npm i --global @metablock/cli@0.1.9
6+
RUN npm i --global @metablock/cli@0.23.2

Makefile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
.PHONY: help update
22

3+
.PHONY: help
34
help:
45
@echo ======================================================================================
56
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
67
@echo ======================================================================================
78

89

9-
image: ## Build image
10+
.PHONY: image
11+
image: ## Build image
1012
@docker build -t metablock-action .
1113

12-
terminal: ## Terminal
14+
.PHONY: terminal
15+
terminal: ## Terminal
1316
@docker run -it --rm metablock-action bash
1417

1518

16-
update: ## Update dependencies
17-
@yarn upgrade --latest
19+
.PHONY: build-example
20+
build-example: ## Build example
21+
@cd example && yarn && yarn build
22+
23+
.PHONY: outdated-example
24+
outdated-example: ## Outdated example dependencies
25+
@cd example && yarn outdated
26+
27+
.PHONY: update-example
28+
update-example: ## Update example dependencies
29+
@cd example && yarn upgrade --latest

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ inputs:
55
description: "Metablock API token - can be set as METABLOCK_API_TOKEN env variable"
66
block:
77
description: "Metablock Block ID - can be set as METABLOCK_BLOCK_ID env variable"
8+
bundle:
9+
description: "Filesystem location of the bundle to deploy"
10+
default: "./dist"
811
env:
912
description: "Metablock environment to deploy"
1013
default: "stage"
@@ -18,5 +21,7 @@ runs:
1821
- ${{ inputs.token }}
1922
- "--block"
2023
- ${{ inputs.block }}
24+
- "--bundle"
25+
- ${{ inputs.bundle }}
2126
- "--env"
2227
- ${{ inputs.env }}

example/.eslintrc.cjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
env: { browser: true, es2020: true },
3+
extends: [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"plugin:react-hooks/recommended",
7+
],
8+
parser: "@typescript-eslint/parser",
9+
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
10+
plugins: ["react-refresh"],
11+
rules: {
12+
"react-refresh/only-export-components": "warn",
13+
},
14+
};

example/README.md

Lines changed: 0 additions & 93 deletions
This file was deleted.

example/app/App.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from "react";
2+
import BlockInfo from "./Info";
3+
4+
const App = () => {
5+
return (
6+
<div>
7+
<h1>Metablock Deployment Starter</h1>
8+
<BlockInfo />
9+
</div>
10+
);
11+
};
12+
13+
export default App;

example/app/Info.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { getBlock } from "@metablock/core";
2+
import React from "react";
3+
import ReactJson from "react-json-view";
4+
5+
const BlockInfo = () => {
6+
const [state, setState] = React.useState<any>();
7+
const [height, setHeight] = React.useState<number>(0);
8+
9+
const style: any = {};
10+
if (height > 0) style.minHeight = `${height}px`;
11+
12+
const block = getBlock();
13+
const shouldSetHeight = (el: any) => {
14+
if (el && el.offsetHeight > height) setHeight(el.offsetHeight);
15+
};
16+
17+
return (
18+
<div ref={shouldSetHeight}>
19+
<ReactJson src={block} theme="monokai" style={style} />
20+
</div>
21+
);
22+
};
23+
24+
export default BlockInfo;

example/app/main.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from "react";
2+
import { hydrateRoot } from "react-dom/client";
3+
import App from "./App";
4+
5+
const root: HTMLElement = document.getElementById("__metablock") as HTMLElement;
6+
7+
hydrateRoot(root, <App />);

example/package.json

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,33 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"build": "rollup -c",
7-
"dev": "rollup -c -w",
8-
"start": "sirv public"
6+
"lint": "eslint 'app/**/*'",
7+
"fix": "eslint 'app/**/*' --fix",
8+
"build": "export NODE_ENV=production && webpack",
9+
"watch": "export NODE_ENV=development && webpack serve --progress",
10+
"dev": "export NODE_ENV=production && webpack serve"
911
},
1012
"devDependencies": {
11-
"@rollup/plugin-commonjs": "^12.0.0",
12-
"@rollup/plugin-node-resolve": "^8.0.0",
13-
"rollup": "^2.3.4",
14-
"rollup-plugin-livereload": "^1.0.0",
15-
"rollup-plugin-svelte": "^5.0.3",
16-
"rollup-plugin-terser": "^5.1.2",
17-
"svelte": "^3.0.0"
13+
"@metablock/server": "^0.23.2",
14+
"@types/react": "^18.2.7",
15+
"@types/react-dom": "^18.2.4",
16+
"@typescript-eslint/eslint-plugin": "^5.59.7",
17+
"@typescript-eslint/parser": "^5.59.7",
18+
"eslint": "^8.41.0",
19+
"source-map-loader": "^4.0.1",
20+
"style-loader": "^3.3.3",
21+
"ts-loader": "^9.4.3",
22+
"typescript": "^5.0.4",
23+
"webpack": "^5.84.1",
24+
"webpack-cli": "^5.1.1",
25+
"webpack-dev-server": "^4.15.0",
26+
"webpack-hot-middleware": "^2.25.3",
27+
"webpack-require-from": "^1.8.6"
1828
},
1929
"dependencies": {
20-
"sirv-cli": "^0.4.4"
30+
"@metablock/core": "^0.23.2",
31+
"react": "^18.2.0",
32+
"react-dom": "^18.2.0",
33+
"react-json-view": "^1.21.3"
2134
}
2235
}

0 commit comments

Comments
 (0)