diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml
index 91f21a92..83e11b5a 100644
--- a/.github/workflows/deploy-docs.yml
+++ b/.github/workflows/deploy-docs.yml
@@ -10,15 +10,15 @@ jobs:
steps:
- name: Checkout repo
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
with:
fetch-depth: 0
- # - uses: pnpm/action-setup@v2.0.1
+ # - uses: pnpm/action-setup@v3
# with:
- # version: latest
- # - uses: actions/setup-node@v2
+ # version: 9
+ # - uses: actions/setup-node@v4
# with:
- # node-version: '16'
+ # node-version: '20'
# cache: 'pnpm'
# - run: npm add -g @antfu/ni
diff --git a/.github/workflows/deploy-page.yml b/.github/workflows/deploy-page.yml
index 2fe7f12a..ba5c6a80 100644
--- a/.github/workflows/deploy-page.yml
+++ b/.github/workflows/deploy-page.yml
@@ -10,15 +10,15 @@ jobs:
steps:
- name: Checkout repo
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
with:
fetch-depth: 0
- # - uses: pnpm/action-setup@v2.0.1
+ # - uses: pnpm/action-setup@v3
# with:
- # version: latest
- # - uses: actions/setup-node@v2
+ # version: 9
+ # - uses: actions/setup-node@v4
# with:
- # node-version: '16'
+ # node-version: '20'
# cache: 'pnpm'
# - run: npm add -g @antfu/ni
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 9c02c098..e038b702 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -13,7 +13,7 @@ jobs:
changed-files: ${{ toJSON(steps.changed-files-docs.outputs) }}
bump-version: ${{ steps.changed-files-docs.outputs.only_changed == 'false' }}
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files in the docs folder
@@ -23,77 +23,22 @@ jobs:
files: |
website/**
- upload:
- if: "! contains(toJSON(github.event.commits.*.message), '[skip actions]')"
- needs: check-files
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repo
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - uses: pnpm/action-setup@v2.0.1
- with:
- version: latest
- - uses: actions/setup-node@v2
- with:
- node-version: '16'
- cache: 'pnpm'
-
- - run: npm add -g @antfu/ni
- - run: nci
-
- # - name: Deploy Page Site
- # uses: blocklet/action-workflow@v1
- # with:
- # skip-deps: false
- # skip-bundle: false
- # skip-upload: true
- # skip-deploy: false
- # skip-release: true
- # deploy-app-did: zNKkQuRidtsBVskb8oDXKVh5PpM5uD5PKxim
- # deploy-mount-point: /
- # bundle-command: nr bundle
- # working-directory: website/pages
- # server-endpoint: ${{ secrets.XMARK_NODE_ENDPOINT }}
- # server-access-key: ${{ secrets.XMARK_NODE_ACCESS_KEY }}
- # server-access-secret: ${{ secrets.XMARK_NODE_ACCESS_SECRET }}
- # slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
-
- # - name: Deploy Docs Site
- # uses: blocklet/action-workflow@v1
- # with:
- # skip-deps: true
- # skip-bundle: false
- # skip-upload: true
- # skip-deploy: false
- # skip-release: true
- # deploy-app-did: zNKkQuRidtsBVskb8oDXKVh5PpM5uD5PKxim
- # deploy-mount-point: /docs
- # bundle-command: nr bundle
- # working-directory: website/docs
- # server-endpoint: ${{ secrets.XMARK_NODE_ENDPOINT }}
- # server-access-key: ${{ secrets.XMARK_NODE_ACCESS_KEY }}
- # server-access-secret: ${{ secrets.XMARK_NODE_ACCESS_SECRET }}
- # slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
-
publish:
if: needs.check-files.outputs.bump-version == 'true'
runs-on: ubuntu-latest
needs:
- check-files
- - upload
steps:
- name: Checkout repo
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_HUB_TOKEN }}
- - uses: pnpm/action-setup@v2.0.1
+ - uses: pnpm/action-setup@v3
with:
- version: latest
- - uses: actions/setup-node@v2
+ version: 9
+ - uses: actions/setup-node@v4
with:
- node-version: '18'
+ node-version: '20'
cache: 'pnpm'
- run: npm add -g @antfu/ni
- run: nci
diff --git a/.prettierrc b/.prettierrc
index c598203c..acd189f6 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1,7 +1,7 @@
{
"printWidth": 120,
"tabWidth": 2,
- "trailingComma": "es5",
+ "trailingComma": "all",
"jsxBracketSameLine": true,
"semi": true,
"singleQuote": true
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9cdbb169..cbb1ba92 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,39 @@
+## 0.8.0 (2024-6-30)
+
+- chore: update root bump-version script
+- chore(template): update template docs link
+- chore(template): remove svelte template eslint config
+- chore(template): polish template details
+- chore(template): update blocklet specVersion
+- chore(template): update template doc link
+- chore(template): tweak template info
+- chore(create): eslint should work with create-app
+- chore(deps): update deps
+- chore(style): update prettier config
+- chore(template): update dapp bundle mode -> compact
+- chore(template): update todo-list-example template
+- chore(template): update svelte-dapp template
+- chore(template): update svelte-static template
+- chore(template): update vue-dapp template
+- chore(deps): update eslint-config-prettier version
+- chore(template): update vue-static template
+- chore(template): update solidjs-dapp template
+- chore(template): update solidjs-static template
+- chore(template): update nestjs-api template
+- chore(template): update express-api template
+- chore(remplate): update prepare scripts
+- chore(template): update react-dapp-ts templat
+- chore(template): update react-dapp template
+- chore(template): update clean script
+- chore(templace): update template html file viewport
+- chore(create): update react-static templace
+- chore(ci): update ci deps
+- chore(deps): update missing deps
+- chore(deps): update zx & bumpp
+- chore(deps): update template deps
+- chore(deps): update deps
+- chore(ci): update ci version
+
## 0.7.9 (2024-4-7)
- feat(todo-list-example): improve the todo-list template
diff --git a/package.json b/package.json
index e4827bf1..9aa336a1 100644
--- a/package.json
+++ b/package.json
@@ -1,28 +1,28 @@
{
"name": "create-blocklet",
"private": true,
- "version": "0.7.9",
+ "version": "0.8.0",
"description": "",
+ "keywords": [],
+ "author": "",
+ "license": "ISC",
"scripts": {
+ "prepare": "npx simple-git-hooks",
"debug": "node packages/create-app/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"bump-version": "zx --quiet scripts/bump-version.mjs",
- "update:deps": "pnpm -r exec taze -r -n '/arcblock|ocap|abtnode|blocklet|did-connect|did-comment|nedb/' -w",
+ "update:deps": "pnpm -r exec npx taze -r -n '/arcblock|ocap|abtnode|blocklet|did-connect|did-comment|nedb/' -w",
"preinstall": "npx only-allow pnpm",
"publish-plugins": "zx --quiet scripts/publish-plugins.mjs"
},
- "keywords": [],
- "author": "",
- "license": "ISC",
"dependencies": {
- "bumpp": "^7.2.0",
- "taze": "^0.13.0",
- "zx": "^7.2.3"
+ "bumpp": "^9.4.1",
+ "zx": "^8.1.3"
+ },
+ "devDependencies": {
+ "simple-git-hooks": "^2.11.1"
},
- "resolutions": {
- "@blocklet/sdk": "^1.16.20",
- "vite": "^5.0.10",
- "vite-plugin-blocklet": "^0.7.1",
- "vite-plugin-node-polyfills": "^0.17.0"
+ "simple-git-hooks": {
+ "pre-commit": "pnpm -r lint"
}
}
diff --git a/packages/create-app/.eslintignore b/packages/create-app/.eslintignore
new file mode 100644
index 00000000..f8a26871
--- /dev/null
+++ b/packages/create-app/.eslintignore
@@ -0,0 +1 @@
+templates
diff --git a/packages/create-app/.eslintrc.js b/packages/create-app/.eslintrc.cjs
similarity index 86%
rename from packages/create-app/.eslintrc.js
rename to packages/create-app/.eslintrc.cjs
index 86f3edfe..7671695e 100644
--- a/packages/create-app/.eslintrc.js
+++ b/packages/create-app/.eslintrc.cjs
@@ -5,6 +5,7 @@ module.exports = {
},
extends: '@arcblock/eslint-config-base',
rules: {
+ 'no-use-before-define': ['error', { functions: false }],
'import/extensions': 'off',
'no-console': 'off',
'import/no-unresolved': 'off',
diff --git a/packages/create-app/common/.github/workflows/main.yml b/packages/create-app/common/.github/workflows/main.yml
index 3fac548c..c0984cd9 100644
--- a/packages/create-app/common/.github/workflows/main.yml
+++ b/packages/create-app/common/.github/workflows/main.yml
@@ -4,6 +4,7 @@ on:
push:
branches:
- main
+ - master
jobs:
Deploy:
@@ -13,20 +14,22 @@ jobs:
steps:
- name: Checkout repo
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- - name: Set yarn cache
- uses: c-hive/gha-yarn-cache@v2
-
- - name: Install dependencies
- run: yarn
+ - uses: pnpm/action-setup@v3
+ with:
+ version: 9
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ cache: 'pnpm'
- name: Blocklet workflow
uses: blocklet/action-workflow@v1
with:
skip-upload: false
skip-deploy: false
- bundle-command: yarn bundle
+ bundle-command: pnpm bundle
store-endpoint: ${{ secrets.STORE_ENDPOINT }}
store-access-token: ${{ secrets.STORE_ACCESS_TOKEN }}
server-endpoint: ${{ secrets.SERVER_ENDPOINT }}
diff --git a/packages/create-app/common/.husky/pre-commit b/packages/create-app/common/.husky/pre-commit
deleted file mode 100755
index 36af2198..00000000
--- a/packages/create-app/common/.husky/pre-commit
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-. "$(dirname "$0")/_/husky.sh"
-
-npx lint-staged
diff --git a/packages/create-app/common/.prettierrc b/packages/create-app/common/.prettierrc
index 4d129cc9..3efd235a 100644
--- a/packages/create-app/common/.prettierrc
+++ b/packages/create-app/common/.prettierrc
@@ -2,7 +2,7 @@
"printWidth": 120,
"useTabs": false,
"tabWidth": 2,
- "trailingComma": "es5",
+ "trailingComma": "all",
"bracketSameLine": true,
"semi": true,
"singleQuote": true
diff --git a/packages/create-app/common/LICENSE b/packages/create-app/common/LICENSE
index f8393f76..c3f438c1 100644
--- a/packages/create-app/common/LICENSE
+++ b/packages/create-app/common/LICENSE
@@ -1,4 +1,4 @@
-Copyright 2018-2020 ArcBlock
+Copyright 2018-2024 ArcBlock
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/packages/create-app/common/_gitignore b/packages/create-app/common/_gitignore
index e41f4548..ac987bb5 100644
--- a/packages/create-app/common/_gitignore
+++ b/packages/create-app/common/_gitignore
@@ -14,6 +14,7 @@ build
dist
dist-ssr
.blocklet
+.next
# local env files
*.local
diff --git a/packages/create-app/common/_npmrc b/packages/create-app/common/_npmrc
deleted file mode 100644
index 6ef2a288..00000000
--- a/packages/create-app/common/_npmrc
+++ /dev/null
@@ -1,4 +0,0 @@
-## force pnpm to hoist
-shamefully-hoist=true
-strict-peer-dependencies=false
-node-linker=hoisted
diff --git a/packages/create-app/common/scripts/build-clean.js b/packages/create-app/common/scripts/build-clean.js
deleted file mode 100644
index e40180dc..00000000
--- a/packages/create-app/common/scripts/build-clean.js
+++ /dev/null
@@ -1,5 +0,0 @@
-const rimraf = require('rimraf');
-
-console.log('clean .blocklet folder');
-rimraf.sync('.blocklet');
-console.log('clean .blocklet folder done!');
diff --git a/packages/create-app/common/scripts/build-clean.mjs b/packages/create-app/common/scripts/build-clean.mjs
new file mode 100644
index 00000000..5daa6ece
--- /dev/null
+++ b/packages/create-app/common/scripts/build-clean.mjs
@@ -0,0 +1,7 @@
+/* eslint-disable no-console */
+
+import { rimrafSync } from 'rimraf';
+
+console.log('clean .blocklet folder');
+rimrafSync('.blocklet');
+console.log('clean .blocklet folder done!');
diff --git a/packages/create-app/index.js b/packages/create-app/index.js
index c11fbede..39c3679d 100755
--- a/packages/create-app/index.js
+++ b/packages/create-app/index.js
@@ -33,6 +33,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
const cwd = process.cwd();
const templates = [
+ // dapp
{
name: 'react-dapp',
display: '[dapp] react + express.js',
@@ -58,11 +59,11 @@ const templates = [
display: '[dapp] vue3 + express.js',
color: green,
},
- {
- name: 'vue2-dapp',
- display: '[dapp] vue2 + express.js',
- color: green,
- },
+ // {
+ // name: 'vue2-dapp',
+ // display: '[dapp] vue2 + express.js',
+ // color: green,
+ // },
{
name: 'svelte-dapp',
display: '[dapp] svelte + express.js',
@@ -73,11 +74,12 @@ const templates = [
display: '[dapp] next.js',
color: blue,
},
- {
- name: 'react-gun-dapp',
- display: '[dapp] react + gun.js + express.js',
- color: blue,
- },
+ // {
+ // name: 'react-gun-dapp',
+ // display: '[dapp] react + gun.js + express.js',
+ // color: blue,
+ // },
+ // static
{
name: 'react-static',
display: '[static] react',
@@ -93,11 +95,11 @@ const templates = [
display: '[static] vue3',
color: green,
},
- {
- name: 'vue2-static',
- display: '[static] vue2',
- color: green,
- },
+ // {
+ // name: 'vue2-static',
+ // display: '[static] vue2',
+ // color: green,
+ // },
{
name: 'svelte-static',
display: '[static] svelte',
@@ -108,6 +110,7 @@ const templates = [
display: '[static] html',
color: blue,
},
+ // api
{
name: 'express-api',
display: '[api] express.js',
@@ -120,7 +123,7 @@ const templates = [
},
];
-//see: https://github.com/npm/npm/issues/3763
+// see: https://github.com/npm/npm/issues/3763
const renameFiles = {
_gitignore: '.gitignore',
_npmrc: '.npmrc',
@@ -145,13 +148,14 @@ async function init() {
let targetDir = argv._[0] ? String(argv._[0]) : undefined;
const inputTemplateName = argv.template;
- const connectUrl = argv.connectUrl;
+ const connectUrl = argv?.connectUrl;
const inputDid = argv.did;
const checkRes = checkDid(inputDid);
if (typeof checkRes === 'string') {
console.error(checkRes);
return;
- } else if (checkRes !== true) {
+ }
+ if (checkRes !== true) {
console.error(`Invalid blocklet did: ${inputDid}`);
return;
}
@@ -255,7 +259,7 @@ async function init() {
onCancel: () => {
throw new Error(`${red('✖')} Operation cancelled`);
},
- }
+ },
);
} catch (cancelled) {
console.error(cancelled.message);
@@ -333,6 +337,7 @@ async function init() {
for (const file of commonFiles) {
// 如果选择多个模板,每个子 package 中 只会包含必要的 文件
if (mainBlocklet && !['screenshots', 'public', 'logo.png', '.prettierrc', 'LICENSE'].includes(file)) {
+ // eslint-disable-next-line no-continue
continue;
}
// html-staic 和 xmark 相关的模板不添加 .husky
@@ -350,7 +355,7 @@ async function init() {
// copy template files
(() => {
// 过滤掉 template-info.json 文件
- let files = fs.readdirSync(templateDir).filter((file) => file !== 'template-info.json');
+ const files = fs.readdirSync(templateDir).filter((file) => file !== 'template-info.json');
for (const file of files) {
write(file, null, templateDir, templateName);
}
@@ -365,7 +370,7 @@ async function init() {
pkg.name = mainBlocklet ? finalTemplateName : name;
},
templateDir,
- templateName
+ templateName,
);
modifyBlockletYaml(
(yamlConfig) => {
@@ -373,20 +378,21 @@ async function init() {
yamlConfig.title = mainBlocklet ? templateName : name;
},
templateDir,
- templateName
+ templateName,
);
// patch blocklet author
modifyBlockletYaml(
- async (yamlConfig) => {
+ (yamlConfig) => {
yamlConfig.author.name = authorName;
yamlConfig.author.email = authorEmail;
},
templateDir,
- templateName
+ templateName,
);
// patch did
+ // eslint-disable-next-line no-inner-declarations, require-await
async function patchDid() {
const did = didList[index];
modifyBlockletYaml(
@@ -394,7 +400,7 @@ async function init() {
yamlConfig.did = did;
},
templateDir,
- templateName
+ templateName,
);
modifyPackage(
(pkg) => {
@@ -422,12 +428,13 @@ async function init() {
}
},
templateDir,
- templateName
+ templateName,
);
// disabled random logo
// const pngIcon = toDidIcon(did, undefined, true);
// fs.writeFileSync(path.join(root, 'logo.png'), pngIcon);
}
+ // eslint-disable-next-line no-await-in-loop
await patchDid();
}
@@ -462,7 +469,7 @@ async function init() {
await initGitRepo(root);
let defaultAgent = 'npm';
- let agentList = ['npm', 'yarn', 'pnpm'];
+ const agentList = ['npm', 'yarn', 'pnpm'];
// switch (templateNames) {
// case 'react':
@@ -493,7 +500,7 @@ async function init() {
padding: 1,
margin: 1,
float: 'center',
- })
+ }),
);
hasStart = true;
execSync('blocklet dev', { stdio: 'inherit' });
@@ -540,7 +547,7 @@ async function init() {
// console.log(dim('\n start it later by:\n'));
if (root !== cwd) console.log(blue(` cd ${bold(related)}`));
if (mainBlocklet) {
- console.log(blue(`npm run init`));
+ console.log(blue('npm run init'));
} else {
console.log(blue(`${defaultAgent === 'yarn' ? 'yarn' : `${defaultAgent} install`}`));
console.log(cyan('blocklet dev'));
@@ -571,20 +578,21 @@ async function init() {
return null;
}
- function modifyPackage(modifyFn = () => {}, templateDir, templateName) {
+ function modifyPackage(modifyFn = () => {}, templateDir = '', templateName = '') {
const pkg = JSON.parse(read('package.json', templateName));
modifyFn(pkg);
write('package.json', JSON.stringify(pkg, null, 2), templateDir, templateName);
}
- function modifyBlockletYaml(modifyFn = () => {}, templateDir, templateName) {
+ function modifyBlockletYaml(modifyFn = () => {}, templateDir = '', templateName = '') {
const blockletYaml = read('blocklet.yml', templateName);
const yamlConfig = YAML.parse(blockletYaml);
modifyFn(yamlConfig);
write('blocklet.yml', YAML.stringify(yamlConfig, 2), templateDir, templateName);
}
- function modifyEnv(modifyFn = (...args) => ({ ...args }), templateDir, templateName) {
+ // eslint-disable-next-line no-unused-vars
+ function modifyEnv(modifyFn = (...args) => ({ ...args }), templateDir = '', templateName = '') {
const envContent = read('.env', templateName);
if (envContent) {
const env = envfile.parse(envContent);
diff --git a/packages/create-app/lib/arcblock.js b/packages/create-app/lib/arcblock.js
index ac23e0aa..c6bb1811 100644
--- a/packages/create-app/lib/arcblock.js
+++ b/packages/create-app/lib/arcblock.js
@@ -25,7 +25,7 @@ export function echoBrand({ version = '' }) {
});
}
export function echoDocument() {
- const url = 'https://developer.blocklet.io/docs/';
+ const url = 'https://www.arcblock.io/docs/blocklet-developer';
let msg;
if (terminalLink.isSupported) {
msg = green(terminalLink(`Documentation: ${url}`, url));
diff --git a/packages/create-app/lib/constant.js b/packages/create-app/lib/constant.js
index 217da023..bd8a2e41 100644
--- a/packages/create-app/lib/constant.js
+++ b/packages/create-app/lib/constant.js
@@ -1 +1,2 @@
+/* eslint-disable import/prefer-default-export */
export const BLOCKLET_COMMAND = 'blocklet';
diff --git a/packages/create-app/lib/did.js b/packages/create-app/lib/did.js
index cb6aeeff..9379f917 100644
--- a/packages/create-app/lib/did.js
+++ b/packages/create-app/lib/did.js
@@ -18,7 +18,7 @@ export function toDidIcon(did, size = 200, isPng = false) {
return isPng ? jdenticon.toPng(did, size) : jdenticon.toSvg(did, size);
}
-export async function getBlockletDidList(monikerList = [], connectUrl) {
+export async function getBlockletDidList(monikerList = [], connectUrl = '') {
try {
let command = `${BLOCKLET_COMMAND} init`;
if (monikerList.length > 0) {
@@ -28,6 +28,7 @@ export async function getBlockletDidList(monikerList = [], connectUrl) {
}
if (connectUrl) {
+ // eslint-disable-next-line no-unused-vars
command += ` --connectUrl=${connectUrl}`;
}
const runCommand = new Promise((resolve, reject) => {
diff --git a/packages/create-app/lib/git.js b/packages/create-app/lib/git.js
index abc9b854..57fef751 100644
--- a/packages/create-app/lib/git.js
+++ b/packages/create-app/lib/git.js
@@ -4,15 +4,6 @@ const { yellow } = chalk;
$.verbose = false;
-async function canInitGit() {
- const isInstalled = await isGitInstalled();
- const gitInfo = await getUserInfo();
- if (isInstalled && gitInfo.name && gitInfo.email) {
- return true;
- }
- return false;
-}
-
export async function isGitInstalled() {
try {
await which('git');
@@ -22,18 +13,6 @@ export async function isGitInstalled() {
}
}
-export async function initGitRepo(root) {
- const canInstalled = await canInitGit();
- if (canInstalled) {
- await cd(root);
- await $`git init`;
- await $`git add .`;
- await $`git commit -m 'init'`;
- } else {
- console.warn(`${yellow('Git is not installed')}`);
- }
-}
-
export async function getUserInfo() {
try {
const { stdout: name } = await $`git config user.name`;
@@ -46,3 +25,24 @@ export async function getUserInfo() {
};
}
}
+
+async function canInitGit() {
+ const isInstalled = await isGitInstalled();
+ const gitInfo = await getUserInfo();
+ if (isInstalled && gitInfo.name && gitInfo.email) {
+ return true;
+ }
+ return false;
+}
+
+export async function initGitRepo(root) {
+ const canInstalled = await canInitGit();
+ if (canInstalled) {
+ await cd(root);
+ await $`git init`;
+ await $`git add .`;
+ await $`git commit -m 'init'`;
+ } else {
+ console.warn(`${yellow('Git is not installed')}`);
+ }
+}
diff --git a/packages/create-app/lib/server.js b/packages/create-app/lib/server.js
index d7f52362..d12d8acc 100644
--- a/packages/create-app/lib/server.js
+++ b/packages/create-app/lib/server.js
@@ -4,7 +4,16 @@ import { BLOCKLET_COMMAND } from './constant.js';
$.verbose = false;
-export async function trimServerOutputVersion(output = '', command) {
+export async function getServerVersion() {
+ try {
+ const { stdout: output } = await $`${BLOCKLET_COMMAND} --version`;
+ return output.trim();
+ } catch (e) {
+ return '0.0.0';
+ }
+}
+
+export async function trimServerOutputVersion(output = '', command = '') {
// 调用 blocklet 命令时,都会在第一行先打印一个 blocklet [command] [version] 的信息,需要把这个信息 trim 掉
const version = await getServerVersion();
if (command) {
@@ -23,15 +32,6 @@ export async function checkServerInstalled() {
}
}
-export async function getServerVersion() {
- try {
- const { stdout: output } = await $`${BLOCKLET_COMMAND} --version`;
- return output.trim();
- } catch (e) {
- return '0.0.0';
- }
-}
-
export async function getServerStatus() {
try {
const { stdout: output } = await $`${BLOCKLET_COMMAND} server status`;
diff --git a/packages/create-app/lib/utils.js b/packages/create-app/lib/utils.js
index cd763f76..378bcb81 100644
--- a/packages/create-app/lib/utils.js
+++ b/packages/create-app/lib/utils.js
@@ -6,6 +6,7 @@ $.verbose = false;
export function copy(src, dest) {
const stat = fs.statSync(src);
if (stat.isDirectory()) {
+ // eslint-disable-next-line no-use-before-define
copyDir(src, dest);
} else {
fs.copySync(src, dest);
@@ -56,7 +57,7 @@ export function emptyDir(dir) {
export function fuzzyQuery(list = [], keyWord = '') {
const arr = [];
- for (var i = 0; i < list.length; i++) {
+ for (let i = 0; i < list.length; i++) {
if (keyWord.includes(list[i])) {
arr.push(list[i]);
}
diff --git a/packages/create-app/package.json b/packages/create-app/package.json
index b05fb860..686a13a8 100644
--- a/packages/create-app/package.json
+++ b/packages/create-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-blocklet",
- "version": "0.7.9",
+ "version": "0.8.0",
"exports": "./index.js",
"type": "module",
"repository": "git@github.com:blocklet/create-blocklet.git",
@@ -23,31 +23,31 @@
},
"homepage": "https://github.com/blocklet/create-blocklet/tree/main#readme",
"scripts": {
- "lint": "eslint .",
+ "lint": "eslint index.js lib test",
"test": "NODE_ENV=development vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run"
},
"dependencies": {
- "@arcblock/did": "^1.18.108",
- "@ocap/mcrypto": "^1.18.108",
- "@ocap/util": "^1.18.108",
- "boxen": "^6.2.1",
- "ejs": "^3.1.9",
- "envfile": "^6.22.0",
+ "@arcblock/did": "^1.18.124",
+ "@ocap/mcrypto": "^1.18.124",
+ "@ocap/util": "^1.18.124",
+ "boxen": "^7.1.1",
+ "ejs": "^3.1.10",
+ "envfile": "^7.1.0",
"figlet": "^1.7.0",
"gradient-string": "^2.0.2",
- "jdenticon": "^3.2.0",
- "ora": "^6.3.1",
+ "jdenticon": "^3.3.0",
+ "ora": "^8.0.1",
"prompts": "^2.4.2",
- "semver": "^7.5.4",
+ "semver": "^7.6.2",
"terminal-link": "^3.0.0",
- "zx": "7.2.3"
+ "zx": "^8.1.3"
},
"devDependencies": {
- "@arcblock/eslint-config-base": "0.2.4",
- "eslint": "^8.56.0",
- "prettier": "^3.1.1",
- "vitest": "^1.1.0"
+ "@arcblock/eslint-config-base": "^0.3.2",
+ "eslint": "^8.57.0",
+ "prettier": "^3.3.2",
+ "vitest": "^1.6.0"
}
}
diff --git a/packages/create-app/templates/express-api/.env b/packages/create-app/templates/express-api/.env
deleted file mode 100644
index b60a167a..00000000
--- a/packages/create-app/templates/express-api/.env
+++ /dev/null
@@ -1 +0,0 @@
-APP_TITLE=''
diff --git a/packages/create-app/templates/express-api/README.md b/packages/create-app/templates/express-api/README.md
index 1a6585de..bfed024e 100644
--- a/packages/create-app/templates/express-api/README.md
+++ b/packages/create-app/templates/express-api/README.md
@@ -31,14 +31,14 @@ This blocklet is a dapp project, which means this is a full-stack application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -138,7 +138,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/express-api/api/hooks/pre-start.js b/packages/create-app/templates/express-api/api/hooks/pre-start.js
index dff31e54..f1514a82 100644
--- a/packages/create-app/templates/express-api/api/hooks/pre-start.js
+++ b/packages/create-app/templates/express-api/api/hooks/pre-start.js
@@ -25,9 +25,10 @@ const ensureAccountDeclared = async () => {
(async () => {
try {
await ensureAccountDeclared();
+ logger.info(`${name} pre-start successfully`);
process.exit(0);
} catch (err) {
- logger.error(`${name} pre-start error`, err.message);
+ logger.error(`${name} pre-start error`, err);
process.exit(1);
}
})();
diff --git a/packages/create-app/templates/express-api/api/index.js b/packages/create-app/templates/express-api/api/index.js
index 510c0dc6..fc3d5635 100644
--- a/packages/create-app/templates/express-api/api/index.js
+++ b/packages/create-app/templates/express-api/api/index.js
@@ -1,22 +1,11 @@
const express = require('express');
-const env = require('./libs/env');
const app = express();
const port = process.env.BLOCKLET_PORT || process.env.PORT || 3030;
app.get('/', (req, res) => {
- res.send(`
-
-
- Blocklet
- + Express
-
-
-${JSON.stringify(env, null, 2)}
-
-
- `);
+ res.send('Hello Blocklet!');
});
app.listen(port, () => {
diff --git a/packages/create-app/templates/express-api/blocklet.yml b/packages/create-app/templates/express-api/blocklet.yml
index 57e2f791..56239a0b 100644
--- a/packages/create-app/templates/express-api/blocklet.yml
+++ b/packages/create-app/templates/express-api/blocklet.yml
@@ -13,7 +13,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/express-api/package.json b/packages/create-app/templates/express-api/package.json
index a8bea056..2abc2a9e 100644
--- a/packages/create-app/templates/express-api/package.json
+++ b/packages/create-app/templates/express-api/package.json
@@ -1,5 +1,5 @@
{
- "name": "express",
+ "name": "template-express-api",
"version": "0.1.0",
"description": "",
"main": "api/index.js",
@@ -8,13 +8,13 @@
"lint:fix": "npm run lint -- --fix",
"dev": "blocklet dev",
"start": "NODE_ENV=development nodemon api/index.js -w api",
- "clean": "node scripts/build-clean.js",
- "bundle": "npm run clean && blocklet bundle --zip --create-release",
+ "clean": "node scripts/build-clean.mjs",
+ "bundle": "npm run clean && blocklet bundle --compact --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
"dev:child": "blocklet dev --component --app-did=<%= did %>",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"lint-staged": {
@@ -31,20 +31,23 @@
"license": "ISC",
"dependencies": {
"@arcblock/did-auth-storage-nedb": "^1.7.1",
- "@blocklet/sdk": "^1.16.20",
- "@ocap/client": "^1.18.108",
- "dotenv-flow": "^3.3.0",
- "express": "^4.18.2"
+ "@blocklet/sdk": "^1.16.28",
+ "@ocap/client": "^1.18.124",
+ "dotenv-flow": "^4.1.0",
+ "express": "^4.19.2"
},
"devDependencies": {
- "@arcblock/eslint-config-base": "^0.2.4",
- "bumpp": "^8.2.1",
- "eslint": "^8.56.0",
- "husky": "^8.0.3",
- "lint-staged": "^12.5.0",
- "nodemon": "^3.0.2",
- "prettier": "^3.1.1",
- "rimraf": "^3.0.2",
- "zx": "^7.2.3"
+ "@arcblock/eslint-config-base": "^0.3.2",
+ "bumpp": "^9.4.1",
+ "eslint": "^8.57.0",
+ "lint-staged": "^15.2.7",
+ "nodemon": "^3.1.4",
+ "prettier": "^3.3.2",
+ "rimraf": "^5.0.7",
+ "simple-git-hooks": "^2.11.1",
+ "zx": "^8.1.3"
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/express-api/template-info.json b/packages/create-app/templates/express-api/template-info.json
index 166288b1..d1a8fe97 100644
--- a/packages/create-app/templates/express-api/template-info.json
+++ b/packages/create-app/templates/express-api/template-info.json
@@ -1,11 +1,14 @@
{
"name": "express-api",
- "desc": { "en": "A server-side API application built on Express", "zh": "一个基于 Express 构建的服务端 API 应用" },
+ "desc": {
+ "en": "A server-side API application built on Express",
+ "zh": "一个基于 Express 构建的服务端 API 应用"
+ },
"displayName": "Express API",
"blockletType": "dapp",
"composable": true,
"framework": "Express",
"languages": "JavaScript",
"useCase": "Server Side Application",
- "author": "ZhangHan"
-}
\ No newline at end of file
+ "author": "Blocklet"
+}
diff --git a/packages/create-app/templates/html-static/README.md b/packages/create-app/templates/html-static/README.md
index 19be7e99..599136df 100644
--- a/packages/create-app/templates/html-static/README.md
+++ b/packages/create-app/templates/html-static/README.md
@@ -27,14 +27,14 @@ This blocklet is a static project, which means this is a frontend application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -134,7 +134,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/html-static/app/index.html b/packages/create-app/templates/html-static/app/index.html
index 9a07b9d5..4f6b8436 100644
--- a/packages/create-app/templates/html-static/app/index.html
+++ b/packages/create-app/templates/html-static/app/index.html
@@ -1,40 +1,39 @@
-
-
-
-
-
-
- HTML Template
-
-
-
-
-
-
-
-
Get started by edit app/index.html
file
-
-
-
-
-
-
+
+
diff --git a/packages/create-app/templates/html-static/app/styles/style.css b/packages/create-app/templates/html-static/app/styles/style.css
index 45639228..1ea96f89 100644
--- a/packages/create-app/templates/html-static/app/styles/style.css
+++ b/packages/create-app/templates/html-static/app/styles/style.css
@@ -22,6 +22,7 @@ a {
}
.logo {
font-size: 18px;
+ text-align: center;
}
.footer {
@@ -55,7 +56,14 @@ a {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
- font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New,
+ font-family:
+ Menlo,
+ Monaco,
+ Lucida Console,
+ Liberation Mono,
+ DejaVu Sans Mono,
+ Bitstream Vera Sans Mono,
+ Courier New,
monospace;
}
diff --git a/packages/create-app/templates/html-static/blocklet.yml b/packages/create-app/templates/html-static/blocklet.yml
index ae26b665..4b567b6f 100644
--- a/packages/create-app/templates/html-static/blocklet.yml
+++ b/packages/create-app/templates/html-static/blocklet.yml
@@ -14,7 +14,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/html-static/package.json b/packages/create-app/templates/html-static/package.json
index a9fbf957..78699cfb 100644
--- a/packages/create-app/templates/html-static/package.json
+++ b/packages/create-app/templates/html-static/package.json
@@ -1,9 +1,9 @@
{
- "name": "template-html",
+ "name": "template-html-static",
"version": "0.1.0",
"scripts": {
"dev": "blocklet dev",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "npm run clean && blocklet bundle --zip --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
@@ -15,8 +15,9 @@
"author": "",
"license": "ISC",
"devDependencies": {
- "bumpp": "^8.2.1",
- "rimraf": "^3.0.2",
- "zx": "^7.2.3"
+ "bumpp": "^9.4.1",
+ "prettier": "^3.3.2",
+ "rimraf": "^5.0.7",
+ "zx": "^8.1.3"
}
}
diff --git a/packages/create-app/templates/html-static/template-info.json b/packages/create-app/templates/html-static/template-info.json
index fb60216d..3cdf73f9 100644
--- a/packages/create-app/templates/html-static/template-info.json
+++ b/packages/create-app/templates/html-static/template-info.json
@@ -8,5 +8,5 @@
"composable": true,
"languages": "HTML",
"useCase": "Starter",
- "author": "ZhangHan"
-}
\ No newline at end of file
+ "author": "Blocklet"
+}
diff --git a/packages/create-app/templates/monorepo/eslintrc.js b/packages/create-app/templates/monorepo/.eslintrc.js
similarity index 100%
rename from packages/create-app/templates/monorepo/eslintrc.js
rename to packages/create-app/templates/monorepo/.eslintrc.js
diff --git a/packages/create-app/templates/monorepo/.husky/pre-commit b/packages/create-app/templates/monorepo/.husky/pre-commit
deleted file mode 100755
index 36af2198..00000000
--- a/packages/create-app/templates/monorepo/.husky/pre-commit
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-. "$(dirname "$0")/_/husky.sh"
-
-npx lint-staged
diff --git a/packages/create-app/templates/monorepo/.prettierrc b/packages/create-app/templates/monorepo/.prettierrc
index 4d129cc9..3efd235a 100644
--- a/packages/create-app/templates/monorepo/.prettierrc
+++ b/packages/create-app/templates/monorepo/.prettierrc
@@ -2,7 +2,7 @@
"printWidth": 120,
"useTabs": false,
"tabWidth": 2,
- "trailingComma": "es5",
+ "trailingComma": "all",
"bracketSameLine": true,
"semi": true,
"singleQuote": true
diff --git a/packages/create-app/templates/monorepo/README.md b/packages/create-app/templates/monorepo/README.md
index 53705234..31840c50 100644
--- a/packages/create-app/templates/monorepo/README.md
+++ b/packages/create-app/templates/monorepo/README.md
@@ -27,14 +27,14 @@ This project is a monorepo project, which means that there are multiple blocklet
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. init project
diff --git a/packages/create-app/templates/monorepo/package.json b/packages/create-app/templates/monorepo/package.json
index 9180a19f..532b31cf 100644
--- a/packages/create-app/templates/monorepo/package.json
+++ b/packages/create-app/templates/monorepo/package.json
@@ -1,21 +1,17 @@
{
- "name": "root",
- "version": "0.1.1",
+ "name": "template-monorepo",
+ "version": "0.1.0",
"private": true,
"workspaces": [
"blocklets/*"
],
- "husky": {
- "hooks": {
- "pre-commit": "npm run lint"
- }
- },
"scripts": {
"init": "lerna bootstrap && lerna link",
"lint": "lerna run lint",
"lint:fix": "lerna run lint:fix",
"build": "lerna run clean && lerna run build",
"clean": "lerna clean && lerna run clean",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs",
"update:deps": "lerna exec --no-bail -- \"ncu -u -f /arcblock\\|ocap\\|abtnode\\|blocklet\\|did-connect/\" && lerna bootstrap && npx yarn-deduplicate yarn.lock && yarn"
},
@@ -23,11 +19,23 @@
"author": "",
"license": "ISC",
"devDependencies": {
- "@arcblock/eslint-config": "0.2.4",
- "bumpp": "^7.2.0",
- "eslint": "^8.56.0",
- "husky": "^4.3.8",
- "prettier": "^3.1.1",
- "zx": "^7.2.3"
+ "@arcblock/eslint-config": "^0.3.2",
+ "bumpp": "^9.4.1",
+ "eslint": "^8.57.0",
+ "prettier": "^3.3.2",
+ "simple-git-hooks": "^2.11.1",
+ "zx": "^8.1.3"
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
+ },
+ "lint-staged": {
+ "*.{mjs,js,ts}": [
+ "prettier --write",
+ "eslint"
+ ],
+ "*.{css,less,scss,json,graphql}": [
+ "prettier --write"
+ ]
}
}
diff --git a/packages/create-app/templates/monorepo/scripts/bump-version.mjs b/packages/create-app/templates/monorepo/scripts/bump-version.mjs
index 72281d01..4aeee6de 100644
--- a/packages/create-app/templates/monorepo/scripts/bump-version.mjs
+++ b/packages/create-app/templates/monorepo/scripts/bump-version.mjs
@@ -5,7 +5,7 @@ import { $, chalk, fs, path } from 'zx';
const cwd = process.cwd(); // 获取脚本执行目录
// or use pnpm to bump version: `pnpm -r --filter {packages/*, themes/*} -- pnpm version`
-execSync('bumpp package.json blocklets/*/package.json', { stdio: 'inherit' });
+execSync('bumpp --no-tag --no-commit --no-push package.json blocklets/*/package.json', { stdio: 'inherit' });
const { version } = await fs.readJSON('package.json');
await fs.writeFileSync('version', version);
diff --git a/packages/create-app/templates/nestjs-api/.eslintrc.js b/packages/create-app/templates/nestjs-api/.eslintrc.js
index 17bafcc7..81b503df 100644
--- a/packages/create-app/templates/nestjs-api/.eslintrc.js
+++ b/packages/create-app/templates/nestjs-api/.eslintrc.js
@@ -1,17 +1,20 @@
+const { join } = require('path');
+
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
- project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
+ project: [join(__dirname, 'tsconfig.eslint.json'), join(__dirname, 'tsconfig.json')],
},
- plugins: ['@typescript-eslint/eslint-plugin'],
root: true,
- extends: '@arcblock/eslint-config-base',
+ plugins: ['@typescript-eslint/eslint-plugin'],
+ extends: ['@arcblock/eslint-config-base'],
globals: {
logger: true,
},
rules: {
+ 'import/prefer-default-export': 'off',
'no-console': 'off',
'no-restricted-syntax': [
'error',
@@ -20,5 +23,26 @@ module.exports = {
message: 'Unexpected property on console object was called',
},
],
+ 'import/extensions': [
+ 'error',
+ 'ignorePackages',
+ {
+ js: 'never',
+ jsx: 'never',
+ ts: 'never',
+ tsx: 'never',
+ },
+ ],
+ },
+ settings: {
+ 'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
+ 'import/parsers': {
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
+ },
+ 'import/resolver': {
+ node: {
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
+ },
+ },
},
};
diff --git a/packages/create-app/templates/nestjs-api/README.md b/packages/create-app/templates/nestjs-api/README.md
index e4ec809b..2a7552b9 100644
--- a/packages/create-app/templates/nestjs-api/README.md
+++ b/packages/create-app/templates/nestjs-api/README.md
@@ -27,14 +27,14 @@ This blocklet is a dapp project, which means this is a full-stack application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -134,7 +134,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/nestjs-api/api/app.controller.ts b/packages/create-app/templates/nestjs-api/api/app.controller.ts
index cce879ee..f7e30b03 100644
--- a/packages/create-app/templates/nestjs-api/api/app.controller.ts
+++ b/packages/create-app/templates/nestjs-api/api/app.controller.ts
@@ -3,7 +3,9 @@ import { AppService } from './app.service';
@Controller()
export class AppController {
- constructor(private readonly appService: AppService) {}
+ constructor(private readonly appService: AppService) {
+ this.appService = appService;
+ }
@Get()
getHello(): string {
diff --git a/packages/create-app/templates/nestjs-api/api/app.service.ts b/packages/create-app/templates/nestjs-api/api/app.service.ts
index dee8e46d..81fa99d3 100644
--- a/packages/create-app/templates/nestjs-api/api/app.service.ts
+++ b/packages/create-app/templates/nestjs-api/api/app.service.ts
@@ -1,23 +1,8 @@
import { Injectable } from '@nestjs/common';
-const env = require('@blocklet/sdk/lib/env');
-const environment = {
- ...env,
- chainHost: process.env.CHAIN_HOST || '',
-};
@Injectable()
export class AppService {
getHello(): string {
- return `
-
-
- Blocklet
- + NestJS
-
-
- ${JSON.stringify(environment, null, 2)}
-
-
- `;
+ return 'Hello Blocklet!';
}
}
diff --git a/packages/create-app/templates/nestjs-api/api/hooks/pre-start.js b/packages/create-app/templates/nestjs-api/api/hooks/pre-start.js
index dff31e54..f1514a82 100644
--- a/packages/create-app/templates/nestjs-api/api/hooks/pre-start.js
+++ b/packages/create-app/templates/nestjs-api/api/hooks/pre-start.js
@@ -25,9 +25,10 @@ const ensureAccountDeclared = async () => {
(async () => {
try {
await ensureAccountDeclared();
+ logger.info(`${name} pre-start successfully`);
process.exit(0);
} catch (err) {
- logger.error(`${name} pre-start error`, err.message);
+ logger.error(`${name} pre-start error`, err);
process.exit(1);
}
})();
diff --git a/packages/create-app/templates/nestjs-api/blocklet.yml b/packages/create-app/templates/nestjs-api/blocklet.yml
index a6016aa9..6709f429 100644
--- a/packages/create-app/templates/nestjs-api/blocklet.yml
+++ b/packages/create-app/templates/nestjs-api/blocklet.yml
@@ -13,7 +13,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/nestjs-api/package.json b/packages/create-app/templates/nestjs-api/package.json
index 403501ba..dcaf9630 100644
--- a/packages/create-app/templates/nestjs-api/package.json
+++ b/packages/create-app/templates/nestjs-api/package.json
@@ -1,5 +1,5 @@
{
- "name": "nestjs",
+ "name": "template-nestjs-api",
"version": "0.1.0",
"description": "",
"main": "api/main.ts",
@@ -9,13 +9,13 @@
"build": "nest build",
"dev": "blocklet dev",
"start": "NODE_ENV=development && nest start --watch",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "npm run clean && blocklet bundle --zip --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
"dev:child": "blocklet dev --component --app-did=<%= did %>",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"lint-staged": {
@@ -32,35 +32,38 @@
"license": "ISC",
"dependencies": {
"@arcblock/did-auth-storage-nedb": "^1.7.1",
- "@blocklet/sdk": "^1.16.20",
- "@nestjs/common": "^10.3.0",
- "@nestjs/core": "^10.3.0",
- "@nestjs/platform-express": "^10.3.0",
- "@ocap/client": "^1.18.108",
- "dotenv-flow": "^3.3.0",
- "express": "^4.18.2",
- "reflect-metadata": "^0.1.14",
+ "@blocklet/sdk": "^1.16.28",
+ "@nestjs/common": "^10.3.9",
+ "@nestjs/core": "^10.3.9",
+ "@nestjs/platform-express": "^10.3.9",
+ "@ocap/client": "^1.18.124",
+ "dotenv-flow": "^4.1.0",
+ "express": "^4.19.2",
+ "reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
},
"devDependencies": {
- "@arcblock/eslint-config-base": "^0.2.4",
- "@nestjs/cli": "^10.2.1",
- "@nestjs/schematics": "^10.0.3",
+ "@arcblock/eslint-config-base": "^0.3.2",
+ "@nestjs/cli": "^10.3.2",
+ "@nestjs/schematics": "^10.1.1",
"@types/express": "^4.17.21",
- "@types/node": "^18.19.3",
- "@typescript-eslint/eslint-plugin": "^6.15.0",
- "@typescript-eslint/parser": "^6.15.0",
- "bumpp": "^8.2.1",
- "eslint": "^8.56.0",
- "husky": "^8.0.3",
- "lint-staged": "^12.5.0",
- "nodemon": "^3.0.2",
- "prettier": "^3.1.1",
- "rimraf": "^3.0.2",
+ "@types/node": "^20.14.9",
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
+ "@typescript-eslint/parser": "^7.14.1",
+ "bumpp": "^9.4.1",
+ "eslint": "^8.57.0",
+ "lint-staged": "^15.2.7",
+ "nodemon": "^3.1.4",
+ "prettier": "^3.3.2",
+ "rimraf": "^5.0.7",
+ "simple-git-hooks": "^2.11.1",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
- "typescript": "^5.3.3",
- "zx": "^7.2.3"
+ "typescript": "^5.5.2",
+ "zx": "^8.1.3"
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/nestjs-api/template-info.json b/packages/create-app/templates/nestjs-api/template-info.json
index 5dadbcb9..b34cd594 100644
--- a/packages/create-app/templates/nestjs-api/template-info.json
+++ b/packages/create-app/templates/nestjs-api/template-info.json
@@ -1,6 +1,9 @@
{
"name": "nestjs-api",
- "desc": { "en": "A server-side API application built on NestJS", "zh": "一个基于 NestJS 构建的服务端 API 应用" },
+ "desc": {
+ "en": "A server-side API application built on NestJS",
+ "zh": "一个基于 NestJS 构建的服务端 API 应用"
+ },
"displayName": "NestJS API",
"blockletType": "dapp",
"composable": true,
diff --git a/packages/create-app/templates/nestjs-api/tsconfig.build.json b/packages/create-app/templates/nestjs-api/tsconfig.build.json
index 2fe1df27..04a31572 100644
--- a/packages/create-app/templates/nestjs-api/tsconfig.build.json
+++ b/packages/create-app/templates/nestjs-api/tsconfig.build.json
@@ -1,4 +1,9 @@
{
"extends": "./tsconfig.json",
- "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
+ "exclude": [
+ "node_modules",
+ "dist",
+ "test",
+ "**/*spec.ts"
+ ]
}
diff --git a/packages/create-app/templates/nestjs-api/tsconfig.eslint.json b/packages/create-app/templates/nestjs-api/tsconfig.eslint.json
new file mode 100644
index 00000000..a3129675
--- /dev/null
+++ b/packages/create-app/templates/nestjs-api/tsconfig.eslint.json
@@ -0,0 +1,7 @@
+{
+ "extends": "./tsconfig",
+ "compilerOptions": {
+ "noEmit": true
+ },
+ "include": [".eslintrc.js"]
+}
diff --git a/packages/create-app/templates/nextjs-dapp/README.md b/packages/create-app/templates/nextjs-dapp/README.md
index a184e51d..4ccadf64 100644
--- a/packages/create-app/templates/nextjs-dapp/README.md
+++ b/packages/create-app/templates/nextjs-dapp/README.md
@@ -38,14 +38,14 @@ This blocklet is a dapp project, which means this is a full-stack application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -145,7 +145,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/nextjs-dapp/api/hooks/pre-start.js b/packages/create-app/templates/nextjs-dapp/api/hooks/pre-start.js
index dff31e54..f1514a82 100644
--- a/packages/create-app/templates/nextjs-dapp/api/hooks/pre-start.js
+++ b/packages/create-app/templates/nextjs-dapp/api/hooks/pre-start.js
@@ -25,9 +25,10 @@ const ensureAccountDeclared = async () => {
(async () => {
try {
await ensureAccountDeclared();
+ logger.info(`${name} pre-start successfully`);
process.exit(0);
} catch (err) {
- logger.error(`${name} pre-start error`, err.message);
+ logger.error(`${name} pre-start error`, err);
process.exit(1);
}
})();
diff --git a/packages/create-app/templates/nextjs-dapp/blocklet.yml b/packages/create-app/templates/nextjs-dapp/blocklet.yml
index 7dab96b9..d1e2fe9f 100644
--- a/packages/create-app/templates/nextjs-dapp/blocklet.yml
+++ b/packages/create-app/templates/nextjs-dapp/blocklet.yml
@@ -13,7 +13,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/nextjs-dapp/package.json b/packages/create-app/templates/nextjs-dapp/package.json
index 3455aff7..f55eb9bc 100644
--- a/packages/create-app/templates/nextjs-dapp/package.json
+++ b/packages/create-app/templates/nextjs-dapp/package.json
@@ -1,5 +1,5 @@
{
- "name": "nextjs",
+ "name": "template-nextjs-dapp",
"version": "0.1.0",
"private": true,
"scripts": {
@@ -7,15 +7,15 @@
"start": "nodemon -w api api/index.js",
"lint": "next lint",
"lint:fix": "npm run lint -- --fix",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "npm run bundle:client && npm run bundle:api",
"bundle:client": "PUBLIC_URL='/.blocklet/proxy/<%= did %>' next build",
- "bundle:api": "npm run clean && blocklet bundle --zip --create-release",
+ "bundle:api": "npm run clean && blocklet bundle --compact --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
"dev:child": "blocklet dev --component --app-did=<%= did %>",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"lint-staged": {
@@ -28,27 +28,30 @@
]
},
"dependencies": {
- "@arcblock/did-auth": "^1.18.108",
+ "@arcblock/did-auth": "^1.18.124",
"@arcblock/did-auth-storage-nedb": "^1.7.1",
- "@blocklet/sdk": "^1.16.20",
- "@ocap/client": "^1.18.108",
- "@ocap/mcrypto": "^1.18.108",
- "@ocap/wallet": "^1.18.108",
- "dotenv-flow": "^3.3.0",
- "express": "^4.18.2",
- "next": "14.0.4",
+ "@blocklet/sdk": "^1.16.28",
+ "@ocap/client": "^1.18.124",
+ "@ocap/mcrypto": "^1.18.124",
+ "@ocap/wallet": "^1.18.124",
+ "dotenv-flow": "^4.1.0",
+ "express": "^4.19.2",
+ "next": "14.2.4",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
- "bumpp": "^8.2.1",
- "eslint": "8.56.0",
- "eslint-config-next": "14.0.4",
- "husky": "^8.0.3",
- "lint-staged": "^12.5.0",
- "nodemon": "^3.0.2",
+ "bumpp": "^9.4.1",
+ "eslint": "8.57.0",
+ "eslint-config-next": "14.2.4",
+ "lint-staged": "^15.2.7",
+ "nodemon": "^3.1.4",
"npm-run-all": "^4.1.5",
- "rimraf": "^3.0.2",
- "zx": "^7.2.3"
+ "rimraf": "^5.0.7",
+ "simple-git-hooks": "^2.11.1",
+ "zx": "^8.1.3"
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/nextjs-dapp/pages/_app.js b/packages/create-app/templates/nextjs-dapp/pages/_app.js
index 197b6341..fedfc1e9 100644
--- a/packages/create-app/templates/nextjs-dapp/pages/_app.js
+++ b/packages/create-app/templates/nextjs-dapp/pages/_app.js
@@ -8,7 +8,7 @@ function MyApp({ Component, pageProps }) {
{process.env.APP_TITLE}
-
+
diff --git a/packages/create-app/templates/nextjs-dapp/pages/api/hello.js b/packages/create-app/templates/nextjs-dapp/pages/api/hello.js
index df63de88..d49a2572 100644
--- a/packages/create-app/templates/nextjs-dapp/pages/api/hello.js
+++ b/packages/create-app/templates/nextjs-dapp/pages/api/hello.js
@@ -1,5 +1,5 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default function handler(req, res) {
- res.status(200).json({ name: 'John Doe' })
+ res.status(200).json({ name: 'John Doe' });
}
diff --git a/packages/create-app/templates/nextjs-dapp/pages/index.js b/packages/create-app/templates/nextjs-dapp/pages/index.js
index 5d7d830b..951031d5 100644
--- a/packages/create-app/templates/nextjs-dapp/pages/index.js
+++ b/packages/create-app/templates/nextjs-dapp/pages/index.js
@@ -1,6 +1,6 @@
-import Head from 'next/head'
-import Image from 'next/image'
-import styles from '../styles/Home.module.css'
+import Head from 'next/head';
+import Image from 'next/image';
+import styles from '../styles/Home.module.css';
export default function Home() {
return (
@@ -15,8 +15,7 @@ export default function Home() {
- Get started by editing{' '}
- pages/index.js
+ Get started by editing pages/index.js
@@ -54,8 +47,7 @@ export default function Home() {
+ rel="noopener noreferrer">
Powered by{' '}
@@ -63,5 +55,5 @@ export default function Home() {
- )
+ );
}
diff --git a/packages/create-app/templates/nextjs-dapp/styles/Home.module.css b/packages/create-app/templates/nextjs-dapp/styles/Home.module.css
index 32a57d52..30d1327b 100644
--- a/packages/create-app/templates/nextjs-dapp/styles/Home.module.css
+++ b/packages/create-app/templates/nextjs-dapp/styles/Home.module.css
@@ -61,8 +61,15 @@
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
- font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
- Bitstream Vera Sans Mono, Courier New, monospace;
+ font-family:
+ Menlo,
+ Monaco,
+ Lucida Console,
+ Liberation Mono,
+ DejaVu Sans Mono,
+ Bitstream Vera Sans Mono,
+ Courier New,
+ monospace;
}
.grid {
@@ -81,7 +88,9 @@
text-decoration: none;
border: 1px solid #eaeaea;
border-radius: 10px;
- transition: color 0.15s ease, border-color 0.15s ease;
+ transition:
+ color 0.15s ease,
+ border-color 0.15s ease;
max-width: 300px;
}
diff --git a/packages/create-app/templates/nextjs-dapp/styles/globals.css b/packages/create-app/templates/nextjs-dapp/styles/globals.css
index e5e2dcc2..51a2a4ea 100644
--- a/packages/create-app/templates/nextjs-dapp/styles/globals.css
+++ b/packages/create-app/templates/nextjs-dapp/styles/globals.css
@@ -2,8 +2,18 @@ html,
body {
padding: 0;
margin: 0;
- font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
- Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
+ font-family:
+ -apple-system,
+ BlinkMacSystemFont,
+ Segoe UI,
+ Roboto,
+ Oxygen,
+ Ubuntu,
+ Cantarell,
+ Fira Sans,
+ Droid Sans,
+ Helvetica Neue,
+ sans-serif;
}
a {
diff --git a/packages/create-app/templates/nextjs-dapp/template-info.json b/packages/create-app/templates/nextjs-dapp/template-info.json
index 47d93972..d39a0db5 100644
--- a/packages/create-app/templates/nextjs-dapp/template-info.json
+++ b/packages/create-app/templates/nextjs-dapp/template-info.json
@@ -8,5 +8,5 @@
"composable": true,
"languages": "JavaScript",
"useCase": "Starter",
- "author": "ZhangHan"
-}
\ No newline at end of file
+ "author": "Blocklet"
+}
diff --git a/packages/create-app/templates/react-dapp-ts/.eslintrc.js b/packages/create-app/templates/react-dapp-ts/.eslintrc.js
index 410773ec..03d616f4 100644
--- a/packages/create-app/templates/react-dapp-ts/.eslintrc.js
+++ b/packages/create-app/templates/react-dapp-ts/.eslintrc.js
@@ -6,4 +6,7 @@ module.exports = {
parserOptions: {
project: [join(__dirname, 'tsconfig.eslint.json'), join(__dirname, 'tsconfig.json')],
},
+ rules: {
+ 'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
+ },
};
diff --git a/packages/create-app/templates/react-dapp-ts/README.md b/packages/create-app/templates/react-dapp-ts/README.md
index 29abfeb7..672182ad 100644
--- a/packages/create-app/templates/react-dapp-ts/README.md
+++ b/packages/create-app/templates/react-dapp-ts/README.md
@@ -42,14 +42,14 @@ This blocklet is a dapp project, which means this is a full-stack application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -149,7 +149,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/react-dapp-ts/api/src/hooks/pre-start.ts b/packages/create-app/templates/react-dapp-ts/api/src/hooks/pre-start.ts
index d6a0af50..22fc8a62 100644
--- a/packages/create-app/templates/react-dapp-ts/api/src/hooks/pre-start.ts
+++ b/packages/create-app/templates/react-dapp-ts/api/src/hooks/pre-start.ts
@@ -1,5 +1,4 @@
import '@blocklet/sdk/lib/error-handler';
-
import Client from '@ocap/client';
import dotenv from 'dotenv-flow';
@@ -29,9 +28,10 @@ const ensureAccountDeclared = async () => {
(async () => {
try {
await ensureAccountDeclared();
+ logger.info(`${name} pre-start successfully`);
process.exit(0);
} catch (err) {
- logger.error(`${name} pre-start error`, err.message);
+ logger.error(`${name} pre-start error`, err);
process.exit(1);
}
})();
diff --git a/packages/create-app/templates/react-dapp-ts/api/src/routes/index.ts b/packages/create-app/templates/react-dapp-ts/api/src/routes/index.ts
index 72ea0d82..54053bb8 100644
--- a/packages/create-app/templates/react-dapp-ts/api/src/routes/index.ts
+++ b/packages/create-app/templates/react-dapp-ts/api/src/routes/index.ts
@@ -5,4 +5,10 @@ const router = Router();
router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
+router.use('/data', (_, res) =>
+ res.json({
+ message: 'Hello Blocklet!',
+ }),
+);
+
export default router;
diff --git a/packages/create-app/templates/react-dapp-ts/blocklet.yml b/packages/create-app/templates/react-dapp-ts/blocklet.yml
index e8bc6b33..db963868 100644
--- a/packages/create-app/templates/react-dapp-ts/blocklet.yml
+++ b/packages/create-app/templates/react-dapp-ts/blocklet.yml
@@ -13,7 +13,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/react-dapp-ts/index.html b/packages/create-app/templates/react-dapp-ts/index.html
index db5b6420..f9784f73 100644
--- a/packages/create-app/templates/react-dapp-ts/index.html
+++ b/packages/create-app/templates/react-dapp-ts/index.html
@@ -1,14 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/create-app/templates/react-dapp-ts/package.json b/packages/create-app/templates/react-dapp-ts/package.json
index 31e54954..aaac5133 100644
--- a/packages/create-app/templates/react-dapp-ts/package.json
+++ b/packages/create-app/templates/react-dapp-ts/package.json
@@ -1,18 +1,18 @@
{
- "name": "template-react-ts",
+ "name": "template-react-dapp-ts",
"version": "0.1.0",
"scripts": {
"dev": "blocklet dev",
"lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
"lint:fix": "npm run lint -- --fix",
"start": "cross-env NODE_ENV=development nodemon api/dev.ts -w api",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "tsc --noEmit && npm run bundle:client && npm run bundle:api",
"bundle:client": "vite build",
- "bundle:api": "npm run clean && tsc -p tsconfig.api.json && blocklet bundle --zip --create-release",
+ "bundle:api": "npm run clean && tsc -p tsconfig.api.json && blocklet bundle --compact --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"lint-staged": {
@@ -37,50 +37,51 @@
]
},
"dependencies": {
- "@arcblock/did-auth": "^1.18.108",
+ "@arcblock/did-auth": "^1.18.124",
"@arcblock/did-auth-storage-nedb": "^1.7.1",
- "@blocklet/sdk": "^1.16.20",
- "@ocap/client": "^1.18.108",
- "@ocap/mcrypto": "^1.18.108",
- "@ocap/wallet": "^1.18.108",
- "axios": "^1.6.2",
+ "@blocklet/sdk": "^1.16.28",
+ "@ocap/client": "^1.18.124",
+ "@ocap/mcrypto": "^1.18.124",
+ "@ocap/wallet": "^1.18.124",
+ "axios": "^1.7.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
- "dotenv-flow": "^3.3.0",
- "express": "^4.18.2",
- "express-async-errors": "^3.1.1",
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
- "react-router-dom": "^6.21.0",
- "rimraf": "^3.0.2"
+ "dotenv-flow": "^4.1.0",
+ "express": "^4.19.2",
+ "express-async-errors": "^3.1.1"
},
"devDependencies": {
- "@arcblock/eslint-config": "^0.2.4",
- "@arcblock/eslint-config-ts": "^0.2.4",
- "@types/cookie-parser": "^1.4.6",
+ "@arcblock/eslint-config": "^0.3.2",
+ "@arcblock/eslint-config-ts": "^0.3.2",
+ "@blocklet/js-sdk": "^1.16.28",
+ "@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/dotenv-flow": "^3.3.3",
"@types/express": "^4.17.21",
- "@types/node": "^18.19.3",
- "@types/react": "^18.2.45",
- "@types/react-dom": "^18.2.18",
- "@vitejs/plugin-react": "^4.2.1",
- "bumpp": "^8.2.1",
+ "@types/node": "^20.14.9",
+ "@types/react": "^18.3.3",
+ "@types/react-dom": "^18.3.0",
+ "@vitejs/plugin-react": "^4.3.1",
+ "bumpp": "^9.4.1",
"cross-env": "^7.0.3",
- "eslint": "^8.56.0",
- "husky": "^8.0.3",
+ "eslint": "^8.57.0",
"import-sort-style-module": "^6.0.0",
- "lint-staged": "^12.5.0",
- "nodemon": "^3.0.2",
+ "lint-staged": "^15.2.7",
+ "nodemon": "^3.1.4",
"npm-run-all": "^4.1.5",
- "prettier": "^3.1.1",
+ "prettier": "^3.3.2",
"prettier-plugin-import-sort": "^0.0.7",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "react-router-dom": "^6.24.0",
+ "rimraf": "^5.0.7",
+ "simple-git-hooks": "^2.11.1",
"ts-node": "^10.9.2",
- "typescript": "^5.3.3",
- "vite": "^5.0.10",
- "vite-plugin-blocklet": "^0.7.9",
+ "typescript": "^5.5.2",
+ "vite": "^5.3.2",
+ "vite-plugin-blocklet": "^0.8.0",
"vite-plugin-svgr": "^4.2.0",
- "zx": "^7.2.3"
+ "zx": "^8.1.3"
},
"importSort": {
".js, .jsx, .mjs": {
@@ -91,5 +92,8 @@
"style": "module",
"parser": "typescript"
}
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/react-dapp-ts/src/app.css b/packages/create-app/templates/react-dapp-ts/src/app.css
deleted file mode 100644
index 492f88d4..00000000
--- a/packages/create-app/templates/react-dapp-ts/src/app.css
+++ /dev/null
@@ -1,30 +0,0 @@
-html,
-body {
- padding: 0;
- margin: 0;
-}
-.app {
- text-align: center;
-}
-
-.app-logo {
- height: 10vmin;
- pointer-events: none;
-}
-
-.app-header {
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: calc(10px + 2vmin);
-}
-
-pre {
- font-size: 0.75em;
-}
-
-.app-link {
- color: #4f6af5;
-}
diff --git a/packages/create-app/templates/react-dapp-ts/src/app.tsx b/packages/create-app/templates/react-dapp-ts/src/app.tsx
index 6b9a37e0..ac560aa1 100644
--- a/packages/create-app/templates/react-dapp-ts/src/app.tsx
+++ b/packages/create-app/templates/react-dapp-ts/src/app.tsx
@@ -1,8 +1,5 @@
-import './app.css';
+import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
-import { Navigate, Route, BrowserRouter as Router, Routes } from 'react-router-dom';
-
-import About from './pages/about';
import Home from './pages/home';
function App() {
@@ -10,8 +7,6 @@ function App() {
} />
- } />
- } />
} />
diff --git a/packages/create-app/templates/react-dapp-ts/src/assets/blocklet.svg b/packages/create-app/templates/react-dapp-ts/src/assets/blocklet.svg
new file mode 100644
index 00000000..13e63446
--- /dev/null
+++ b/packages/create-app/templates/react-dapp-ts/src/assets/blocklet.svg
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp-ts/src/assets/react.svg b/packages/create-app/templates/react-dapp-ts/src/assets/react.svg
new file mode 100644
index 00000000..6c87de9b
--- /dev/null
+++ b/packages/create-app/templates/react-dapp-ts/src/assets/react.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp-ts/src/assets/vite.svg b/packages/create-app/templates/react-dapp-ts/src/assets/vite.svg
new file mode 100644
index 00000000..e7b8dfb1
--- /dev/null
+++ b/packages/create-app/templates/react-dapp-ts/src/assets/vite.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp-ts/src/index.css b/packages/create-app/templates/react-dapp-ts/src/index.css
new file mode 100644
index 00000000..6119ad9a
--- /dev/null
+++ b/packages/create-app/templates/react-dapp-ts/src/index.css
@@ -0,0 +1,68 @@
+:root {
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
+ line-height: 1.5;
+ font-weight: 400;
+
+ color-scheme: light dark;
+ color: rgba(255, 255, 255, 0.87);
+ background-color: #242424;
+
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+a {
+ font-weight: 500;
+ color: #646cff;
+ text-decoration: inherit;
+}
+a:hover {
+ color: #535bf2;
+}
+
+body {
+ margin: 0;
+ display: flex;
+ place-items: center;
+ min-width: 320px;
+ min-height: 100vh;
+}
+
+h1 {
+ font-size: 3.2em;
+ line-height: 1.1;
+}
+
+button {
+ border-radius: 8px;
+ border: 1px solid transparent;
+ padding: 0.6em 1.2em;
+ font-size: 1em;
+ font-weight: 500;
+ font-family: inherit;
+ background-color: #1a1a1a;
+ cursor: pointer;
+ transition: border-color 0.25s;
+}
+button:hover {
+ border-color: #646cff;
+}
+button:focus,
+button:focus-visible {
+ outline: 4px auto -webkit-focus-ring-color;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ color: #213547;
+ background-color: #ffffff;
+ }
+ a:hover {
+ color: #747bff;
+ }
+ button {
+ background-color: #f9f9f9;
+ }
+}
diff --git a/packages/create-app/templates/react-dapp-ts/src/index.tsx b/packages/create-app/templates/react-dapp-ts/src/index.tsx
index ffa04516..2ed02a0c 100644
--- a/packages/create-app/templates/react-dapp-ts/src/index.tsx
+++ b/packages/create-app/templates/react-dapp-ts/src/index.tsx
@@ -1,6 +1,6 @@
import ReactDOM from 'react-dom/client';
-
import App from './app';
+import './index.css';
-const root = ReactDOM.createRoot(document.getElementById('app')!);
+const root = ReactDOM.createRoot(document.getElementById('app') as HTMLElement);
root.render();
diff --git a/packages/create-app/templates/react-dapp-ts/src/libs/api.ts b/packages/create-app/templates/react-dapp-ts/src/libs/api.ts
index 2b3e6c64..e595a8b7 100644
--- a/packages/create-app/templates/react-dapp-ts/src/libs/api.ts
+++ b/packages/create-app/templates/react-dapp-ts/src/libs/api.ts
@@ -1,14 +1,7 @@
-import axios from 'axios';
+import { createAxios } from '@blocklet/js-sdk';
-axios.interceptors.request.use(
- (config) => {
- const prefix = window.blocklet ? window.blocklet.prefix : '/';
- config.baseURL = prefix || '';
- config.timeout = 200000;
+const api = createAxios({
+ baseURL: window?.blocklet?.prefix || '/',
+});
- return config;
- },
- (error) => Promise.reject(error)
-);
-
-export default axios;
+export default api;
diff --git a/packages/create-app/templates/react-dapp-ts/src/logo.svg b/packages/create-app/templates/react-dapp-ts/src/logo.svg
deleted file mode 100644
index ec2e1d92..00000000
--- a/packages/create-app/templates/react-dapp-ts/src/logo.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp-ts/src/pages/about.tsx b/packages/create-app/templates/react-dapp-ts/src/pages/about.tsx
deleted file mode 100644
index 2e92ae8b..00000000
--- a/packages/create-app/templates/react-dapp-ts/src/pages/about.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Link } from 'react-router-dom';
-
-function About() {
- return (
-
-
-
- Back Home
-
-
- Hello, i'm a dapp blocklet
-
- );
-}
-
-export default About;
diff --git a/packages/create-app/templates/react-dapp-ts/src/pages/home.css b/packages/create-app/templates/react-dapp-ts/src/pages/home.css
new file mode 100644
index 00000000..601e2693
--- /dev/null
+++ b/packages/create-app/templates/react-dapp-ts/src/pages/home.css
@@ -0,0 +1,45 @@
+#app {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 2rem;
+ text-align: center;
+}
+
+.logo {
+ height: 6em;
+ padding: 1.5em;
+ will-change: filter;
+ transition: filter 300ms;
+}
+.logo:hover {
+ filter: drop-shadow(0 0 2em #646cffaa);
+}
+.logo.react:hover {
+ filter: drop-shadow(0 0 2em #61dafbaa);
+}
+.logo.blocklet:hover {
+ filter: drop-shadow(0 0 2em #22cdcdaa);
+}
+
+@keyframes logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ a:nth-of-type(2) .logo {
+ animation: logo-spin infinite 20s linear;
+ }
+}
+
+.card {
+ padding: 2em;
+}
+
+.read-the-docs {
+ color: #888;
+}
diff --git a/packages/create-app/templates/react-dapp-ts/src/pages/home.tsx b/packages/create-app/templates/react-dapp-ts/src/pages/home.tsx
index 8b7cba31..18882a26 100644
--- a/packages/create-app/templates/react-dapp-ts/src/pages/home.tsx
+++ b/packages/create-app/templates/react-dapp-ts/src/pages/home.tsx
@@ -1,21 +1,48 @@
-import { Link } from 'react-router-dom';
-
-import logo from '../logo.svg';
+import { useState } from 'react';
+import reactLogo from '../assets/react.svg';
+import blockletLogo from '../assets/blocklet.svg';
+import viteLogo from '../assets/vite.svg';
+import './home.css';
+import api from '../libs/api';
function Home() {
+ const [count, setCount] = useState(0);
+
+ async function getApiData() {
+ const { data } = await api.get('/api/data');
+ const { message } = data;
+ alert(`Message from api: ${message}`);
+ }
+
return (
-
+ <>
+
+ Vite + React + Blocklet
+
+
+
+
+
+
+ Edit src/app.tsx
and save to test HMR
+
+
+ Click on the Vite and React logos to learn more
+ >
);
}
diff --git a/packages/create-app/templates/react-dapp-ts/tsconfig.api.json b/packages/create-app/templates/react-dapp-ts/tsconfig.api.json
index ded8cffd..d3430112 100644
--- a/packages/create-app/templates/react-dapp-ts/tsconfig.api.json
+++ b/packages/create-app/templates/react-dapp-ts/tsconfig.api.json
@@ -5,5 +5,8 @@
"noEmit": false,
"noEmitOnError": true
},
- "include": ["api/*.d.ts", "api/src"]
+ "include": [
+ "api/*.d.ts",
+ "api/src"
+ ]
}
diff --git a/packages/create-app/templates/react-dapp-ts/tsconfig.eslint.json b/packages/create-app/templates/react-dapp-ts/tsconfig.eslint.json
index a3129675..131cc4ea 100644
--- a/packages/create-app/templates/react-dapp-ts/tsconfig.eslint.json
+++ b/packages/create-app/templates/react-dapp-ts/tsconfig.eslint.json
@@ -3,5 +3,7 @@
"compilerOptions": {
"noEmit": true
},
- "include": [".eslintrc.js"]
+ "include": [
+ ".eslintrc.js"
+ ]
}
diff --git a/packages/create-app/templates/react-dapp/README.md b/packages/create-app/templates/react-dapp/README.md
index 280e0add..b802678c 100644
--- a/packages/create-app/templates/react-dapp/README.md
+++ b/packages/create-app/templates/react-dapp/README.md
@@ -38,14 +38,14 @@ This blocklet is a dapp project, which means this is a full-stack application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -145,7 +145,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/react-dapp/api/hooks/pre-start.js b/packages/create-app/templates/react-dapp/api/hooks/pre-start.js
index dff31e54..f1514a82 100644
--- a/packages/create-app/templates/react-dapp/api/hooks/pre-start.js
+++ b/packages/create-app/templates/react-dapp/api/hooks/pre-start.js
@@ -25,9 +25,10 @@ const ensureAccountDeclared = async () => {
(async () => {
try {
await ensureAccountDeclared();
+ logger.info(`${name} pre-start successfully`);
process.exit(0);
} catch (err) {
- logger.error(`${name} pre-start error`, err.message);
+ logger.error(`${name} pre-start error`, err);
process.exit(1);
}
})();
diff --git a/packages/create-app/templates/react-dapp/api/routes/index.js b/packages/create-app/templates/react-dapp/api/routes/index.js
index 04f50432..cf8fa991 100644
--- a/packages/create-app/templates/react-dapp/api/routes/index.js
+++ b/packages/create-app/templates/react-dapp/api/routes/index.js
@@ -3,4 +3,10 @@ const router = require('express').Router();
router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
+router.use('/data', (req, res) =>
+ res.json({
+ message: 'Hello Blocklet!',
+ }),
+);
+
module.exports = router;
diff --git a/packages/create-app/templates/react-dapp/blocklet.yml b/packages/create-app/templates/react-dapp/blocklet.yml
index 625491c1..27f5ca82 100644
--- a/packages/create-app/templates/react-dapp/blocklet.yml
+++ b/packages/create-app/templates/react-dapp/blocklet.yml
@@ -13,7 +13,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/react-dapp/index.html b/packages/create-app/templates/react-dapp/index.html
index 8e678c45..13e89557 100644
--- a/packages/create-app/templates/react-dapp/index.html
+++ b/packages/create-app/templates/react-dapp/index.html
@@ -1,14 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/create-app/templates/react-dapp/package.json b/packages/create-app/templates/react-dapp/package.json
index 0b36312d..b1331ac7 100644
--- a/packages/create-app/templates/react-dapp/package.json
+++ b/packages/create-app/templates/react-dapp/package.json
@@ -1,20 +1,20 @@
{
- "name": "template-react",
+ "name": "template-react-dapp",
"version": "0.1.0",
"scripts": {
"dev": "blocklet dev",
"lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
"lint:fix": "npm run lint -- --fix",
"start": "cross-env NODE_ENV=development nodemon api/dev.js -w api",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "npm run bundle:client && npm run bundle:api",
"bundle:client": "vite build",
- "bundle:api": "npm run clean && blocklet bundle --zip --create-release",
+ "bundle:api": "npm run clean && blocklet bundle --compact --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
"dev:child": "blocklet dev --component --app-did=<%= did %>",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"lint-staged": {
@@ -39,37 +39,41 @@
]
},
"dependencies": {
- "@arcblock/did-auth": "^1.18.108",
+ "@arcblock/did-auth": "^1.18.124",
"@arcblock/did-auth-storage-nedb": "^1.7.1",
- "@blocklet/sdk": "^1.16.20",
- "@ocap/client": "^1.18.108",
- "@ocap/mcrypto": "^1.18.108",
- "@ocap/wallet": "^1.18.108",
- "axios": "^1.6.2",
+ "@blocklet/sdk": "^1.16.28",
+ "@ocap/client": "^1.18.124",
+ "@ocap/mcrypto": "^1.18.124",
+ "@ocap/wallet": "^1.18.124",
+ "axios": "^1.7.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
- "dotenv-flow": "^3.3.0",
- "express": "^4.18.2",
- "express-async-errors": "^3.1.1",
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
- "react-router-dom": "^6.21.0",
- "rimraf": "^3.0.2"
+ "dotenv-flow": "^4.1.0",
+ "express": "^4.19.2",
+ "express-async-errors": "^3.1.1"
},
"devDependencies": {
- "@arcblock/eslint-config": "^0.2.4",
- "@vitejs/plugin-react": "^4.2.1",
- "bumpp": "^8.2.1",
+ "@arcblock/eslint-config": "^0.3.2",
+ "@blocklet/js-sdk": "^1.16.28",
+ "@vitejs/plugin-react": "^4.3.1",
+ "bumpp": "^9.4.1",
"cross-env": "^7.0.3",
- "eslint": "^8.56.0",
- "husky": "^8.0.3",
- "lint-staged": "^12.5.0",
- "nodemon": "^3.0.2",
+ "eslint": "^8.57.0",
+ "lint-staged": "^15.2.7",
+ "nodemon": "^3.1.4",
"npm-run-all": "^4.1.5",
- "prettier": "^3.1.1",
- "vite": "^5.0.10",
- "vite-plugin-blocklet": "^0.7.9",
+ "prettier": "^3.3.2",
+ "rimraf": "^5.0.7",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "react-router-dom": "^6.24.0",
+ "simple-git-hooks": "^2.11.1",
+ "vite": "^5.3.2",
+ "vite-plugin-blocklet": "^0.8.0",
"vite-plugin-svgr": "^4.2.0",
- "zx": "^7.2.3"
+ "zx": "^8.1.3"
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/react-dapp/src/app.css b/packages/create-app/templates/react-dapp/src/app.css
deleted file mode 100644
index 492f88d4..00000000
--- a/packages/create-app/templates/react-dapp/src/app.css
+++ /dev/null
@@ -1,30 +0,0 @@
-html,
-body {
- padding: 0;
- margin: 0;
-}
-.app {
- text-align: center;
-}
-
-.app-logo {
- height: 10vmin;
- pointer-events: none;
-}
-
-.app-header {
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: calc(10px + 2vmin);
-}
-
-pre {
- font-size: 0.75em;
-}
-
-.app-link {
- color: #4f6af5;
-}
diff --git a/packages/create-app/templates/react-dapp/src/app.jsx b/packages/create-app/templates/react-dapp/src/app.jsx
index 05b65baa..ac560aa1 100644
--- a/packages/create-app/templates/react-dapp/src/app.jsx
+++ b/packages/create-app/templates/react-dapp/src/app.jsx
@@ -1,16 +1,12 @@
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
-import './app.css';
import Home from './pages/home';
-import About from './pages/about';
function App() {
return (
- } />
- } />
- } />
+ } />
} />
diff --git a/packages/create-app/templates/react-dapp/src/assets/blocklet.svg b/packages/create-app/templates/react-dapp/src/assets/blocklet.svg
new file mode 100644
index 00000000..13e63446
--- /dev/null
+++ b/packages/create-app/templates/react-dapp/src/assets/blocklet.svg
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp/src/assets/react.svg b/packages/create-app/templates/react-dapp/src/assets/react.svg
new file mode 100644
index 00000000..6c87de9b
--- /dev/null
+++ b/packages/create-app/templates/react-dapp/src/assets/react.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp/src/assets/vite.svg b/packages/create-app/templates/react-dapp/src/assets/vite.svg
new file mode 100644
index 00000000..e7b8dfb1
--- /dev/null
+++ b/packages/create-app/templates/react-dapp/src/assets/vite.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp/src/index.css b/packages/create-app/templates/react-dapp/src/index.css
new file mode 100644
index 00000000..6119ad9a
--- /dev/null
+++ b/packages/create-app/templates/react-dapp/src/index.css
@@ -0,0 +1,68 @@
+:root {
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
+ line-height: 1.5;
+ font-weight: 400;
+
+ color-scheme: light dark;
+ color: rgba(255, 255, 255, 0.87);
+ background-color: #242424;
+
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+a {
+ font-weight: 500;
+ color: #646cff;
+ text-decoration: inherit;
+}
+a:hover {
+ color: #535bf2;
+}
+
+body {
+ margin: 0;
+ display: flex;
+ place-items: center;
+ min-width: 320px;
+ min-height: 100vh;
+}
+
+h1 {
+ font-size: 3.2em;
+ line-height: 1.1;
+}
+
+button {
+ border-radius: 8px;
+ border: 1px solid transparent;
+ padding: 0.6em 1.2em;
+ font-size: 1em;
+ font-weight: 500;
+ font-family: inherit;
+ background-color: #1a1a1a;
+ cursor: pointer;
+ transition: border-color 0.25s;
+}
+button:hover {
+ border-color: #646cff;
+}
+button:focus,
+button:focus-visible {
+ outline: 4px auto -webkit-focus-ring-color;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ color: #213547;
+ background-color: #ffffff;
+ }
+ a:hover {
+ color: #747bff;
+ }
+ button {
+ background-color: #f9f9f9;
+ }
+}
diff --git a/packages/create-app/templates/react-dapp/src/index.jsx b/packages/create-app/templates/react-dapp/src/index.jsx
index 29816d8a..ee7d71d6 100644
--- a/packages/create-app/templates/react-dapp/src/index.jsx
+++ b/packages/create-app/templates/react-dapp/src/index.jsx
@@ -1,5 +1,6 @@
import ReactDOM from 'react-dom/client';
import App from './app';
+import './index.css';
const root = ReactDOM.createRoot(document.getElementById('app'));
root.render();
diff --git a/packages/create-app/templates/react-dapp/src/libs/api.js b/packages/create-app/templates/react-dapp/src/libs/api.js
index 2b3e6c64..e595a8b7 100644
--- a/packages/create-app/templates/react-dapp/src/libs/api.js
+++ b/packages/create-app/templates/react-dapp/src/libs/api.js
@@ -1,14 +1,7 @@
-import axios from 'axios';
+import { createAxios } from '@blocklet/js-sdk';
-axios.interceptors.request.use(
- (config) => {
- const prefix = window.blocklet ? window.blocklet.prefix : '/';
- config.baseURL = prefix || '';
- config.timeout = 200000;
+const api = createAxios({
+ baseURL: window?.blocklet?.prefix || '/',
+});
- return config;
- },
- (error) => Promise.reject(error)
-);
-
-export default axios;
+export default api;
diff --git a/packages/create-app/templates/react-dapp/src/logo.svg b/packages/create-app/templates/react-dapp/src/logo.svg
deleted file mode 100644
index ec2e1d92..00000000
--- a/packages/create-app/templates/react-dapp/src/logo.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/packages/create-app/templates/react-dapp/src/pages/about.jsx b/packages/create-app/templates/react-dapp/src/pages/about.jsx
deleted file mode 100644
index 2e92ae8b..00000000
--- a/packages/create-app/templates/react-dapp/src/pages/about.jsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Link } from 'react-router-dom';
-
-function About() {
- return (
-
-
-
- Back Home
-
-
- Hello, i'm a dapp blocklet
-
- );
-}
-
-export default About;
diff --git a/packages/create-app/templates/react-dapp/src/pages/home.css b/packages/create-app/templates/react-dapp/src/pages/home.css
new file mode 100644
index 00000000..601e2693
--- /dev/null
+++ b/packages/create-app/templates/react-dapp/src/pages/home.css
@@ -0,0 +1,45 @@
+#app {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 2rem;
+ text-align: center;
+}
+
+.logo {
+ height: 6em;
+ padding: 1.5em;
+ will-change: filter;
+ transition: filter 300ms;
+}
+.logo:hover {
+ filter: drop-shadow(0 0 2em #646cffaa);
+}
+.logo.react:hover {
+ filter: drop-shadow(0 0 2em #61dafbaa);
+}
+.logo.blocklet:hover {
+ filter: drop-shadow(0 0 2em #22cdcdaa);
+}
+
+@keyframes logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ a:nth-of-type(2) .logo {
+ animation: logo-spin infinite 20s linear;
+ }
+}
+
+.card {
+ padding: 2em;
+}
+
+.read-the-docs {
+ color: #888;
+}
diff --git a/packages/create-app/templates/react-dapp/src/pages/home.jsx b/packages/create-app/templates/react-dapp/src/pages/home.jsx
index 8b7cba31..27134e93 100644
--- a/packages/create-app/templates/react-dapp/src/pages/home.jsx
+++ b/packages/create-app/templates/react-dapp/src/pages/home.jsx
@@ -1,21 +1,48 @@
-import { Link } from 'react-router-dom';
-
-import logo from '../logo.svg';
+import { useState } from 'react';
+import reactLogo from '../assets/react.svg';
+import blockletLogo from '../assets/blocklet.svg';
+import viteLogo from '../assets/vite.svg';
+import './home.css';
+import api from '../libs/api';
function Home() {
+ const [count, setCount] = useState(0);
+
+ async function getApiData() {
+ const { data } = await api.get('/api/data');
+ const { message } = data;
+ alert(`Message from api: ${message}`);
+ }
+
return (
-
+ <>
+
+ Vite + React + Blocklet
+
+
+
+
+
+
+ Edit src/app.jsx
and save to test HMR
+
+
+ Click on the Vite and React logos to learn more
+ >
);
}
diff --git a/packages/create-app/templates/react-dapp/template-info.json b/packages/create-app/templates/react-dapp/template-info.json
index 17378946..a12c9ea8 100644
--- a/packages/create-app/templates/react-dapp/template-info.json
+++ b/packages/create-app/templates/react-dapp/template-info.json
@@ -8,5 +8,5 @@
"composable": true,
"languages": "JavaScript",
"useCase": "Starter",
- "author": "ZhangHan"
-}
\ No newline at end of file
+ "author": "Blocklet"
+}
diff --git a/packages/create-app/templates/react-gun-dapp/README.md b/packages/create-app/templates/react-gun-dapp/README.md
index b1167270..39c00320 100644
--- a/packages/create-app/templates/react-gun-dapp/README.md
+++ b/packages/create-app/templates/react-gun-dapp/README.md
@@ -38,14 +38,14 @@ This blocklet is a dapp project, which means this is a full-stack application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -145,7 +145,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/react-gun-dapp/api/hooks/pre-start.js b/packages/create-app/templates/react-gun-dapp/api/hooks/pre-start.js
index dff31e54..f1514a82 100644
--- a/packages/create-app/templates/react-gun-dapp/api/hooks/pre-start.js
+++ b/packages/create-app/templates/react-gun-dapp/api/hooks/pre-start.js
@@ -25,9 +25,10 @@ const ensureAccountDeclared = async () => {
(async () => {
try {
await ensureAccountDeclared();
+ logger.info(`${name} pre-start successfully`);
process.exit(0);
} catch (err) {
- logger.error(`${name} pre-start error`, err.message);
+ logger.error(`${name} pre-start error`, err);
process.exit(1);
}
})();
diff --git a/packages/create-app/templates/react-gun-dapp/blocklet.yml b/packages/create-app/templates/react-gun-dapp/blocklet.yml
index 1e8d04f8..2ab50d98 100644
--- a/packages/create-app/templates/react-gun-dapp/blocklet.yml
+++ b/packages/create-app/templates/react-gun-dapp/blocklet.yml
@@ -13,7 +13,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/react-gun-dapp/index.html b/packages/create-app/templates/react-gun-dapp/index.html
index 8e678c45..13e89557 100644
--- a/packages/create-app/templates/react-gun-dapp/index.html
+++ b/packages/create-app/templates/react-gun-dapp/index.html
@@ -1,14 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/create-app/templates/react-gun-dapp/package.json b/packages/create-app/templates/react-gun-dapp/package.json
index 4ca73ef0..c52bebed 100644
--- a/packages/create-app/templates/react-gun-dapp/package.json
+++ b/packages/create-app/templates/react-gun-dapp/package.json
@@ -1,20 +1,20 @@
{
- "name": "react-gun",
+ "name": "template-react-gun-dapp",
"version": "0.1.0",
"scripts": {
"dev": "blocklet dev",
"lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
"lint:fix": "npm run lint -- --fix",
"start": "cross-env NODE_ENV=development nodemon api/dev.js -w api",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "npm run bundle:client && npm run bundle:api",
"bundle:client": "vite build",
- "bundle:api": "npm run clean && blocklet bundle --zip --create-release",
+ "bundle:api": "npm run clean && blocklet bundle --compact --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
"dev:child": "blocklet dev --component --app-did=<%= did %>",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"lint-staged": {
@@ -39,38 +39,41 @@
]
},
"dependencies": {
- "@arcblock/did-auth": "^1.18.108",
+ "@arcblock/did-auth": "^1.18.124",
"@arcblock/did-auth-storage-nedb": "^1.7.1",
- "@blocklet/sdk": "^1.16.20",
- "@ocap/client": "^1.18.108",
- "@ocap/mcrypto": "^1.18.108",
- "@ocap/wallet": "^1.18.108",
- "axios": "^1.6.2",
+ "@blocklet/sdk": "^1.16.28",
+ "@ocap/client": "^1.18.124",
+ "@ocap/mcrypto": "^1.18.124",
+ "@ocap/wallet": "^1.18.124",
+ "axios": "^1.7.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
- "dotenv-flow": "^3.3.0",
- "express": "^4.18.2",
+ "dotenv-flow": "^4.1.0",
+ "express": "^4.19.2",
"express-async-errors": "^3.1.1",
- "gun": "^0.2020.1239",
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
- "react-router-dom": "^6.21.0"
+ "gun": "^0.2020.1240"
},
"devDependencies": {
- "@arcblock/eslint-config": "^0.2.4",
- "@vitejs/plugin-react": "^4.2.1",
- "bumpp": "^8.2.1",
+ "@arcblock/eslint-config": "^0.3.2",
+ "@vitejs/plugin-react": "^4.3.1",
+ "bumpp": "^9.4.1",
"cross-env": "^7.0.3",
- "eslint": "^8.56.0",
- "husky": "^8.0.3",
- "lint-staged": "^12.5.0",
- "nodemon": "^3.0.2",
+ "eslint": "^8.57.0",
+ "lint-staged": "^15.2.7",
+ "nodemon": "^3.1.4",
"npm-run-all": "^4.1.5",
- "prettier": "^3.1.1",
- "rimraf": "^3.0.2",
- "vite": "^5.0.10",
- "vite-plugin-blocklet": "^0.7.9",
+ "prettier": "^3.3.2",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "react-router-dom": "^6.24.0",
+ "rimraf": "^5.0.7",
+ "simple-git-hooks": "^2.11.1",
+ "vite": "^5.3.2",
+ "vite-plugin-blocklet": "^0.8.0",
"vite-plugin-svgr": "^4.2.0",
- "zx": "^7.2.3"
+ "zx": "^8.1.3"
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/react-gun-dapp/src/app.jsx b/packages/create-app/templates/react-gun-dapp/src/app.jsx
index 05b65baa..d2bea45b 100644
--- a/packages/create-app/templates/react-gun-dapp/src/app.jsx
+++ b/packages/create-app/templates/react-gun-dapp/src/app.jsx
@@ -8,7 +8,7 @@ function App() {
return (
- } />
+ } />
} />
} />
} />
diff --git a/packages/create-app/templates/react-gun-dapp/src/libs/api.js b/packages/create-app/templates/react-gun-dapp/src/libs/api.js
index 2b3e6c64..12b0d1b4 100644
--- a/packages/create-app/templates/react-gun-dapp/src/libs/api.js
+++ b/packages/create-app/templates/react-gun-dapp/src/libs/api.js
@@ -8,7 +8,7 @@ axios.interceptors.request.use(
return config;
},
- (error) => Promise.reject(error)
+ (error) => Promise.reject(error),
);
export default axios;
diff --git a/packages/create-app/templates/react-gun-dapp/src/pages/about.jsx b/packages/create-app/templates/react-gun-dapp/src/pages/about.jsx
index 18e28245..308a4f7d 100644
--- a/packages/create-app/templates/react-gun-dapp/src/pages/about.jsx
+++ b/packages/create-app/templates/react-gun-dapp/src/pages/about.jsx
@@ -12,7 +12,11 @@ function About() {
Home
-
+
Learn Blocklet
diff --git a/packages/create-app/templates/react-gun-dapp/src/pages/home.jsx b/packages/create-app/templates/react-gun-dapp/src/pages/home.jsx
index 71478c06..562a07e4 100644
--- a/packages/create-app/templates/react-gun-dapp/src/pages/home.jsx
+++ b/packages/create-app/templates/react-gun-dapp/src/pages/home.jsx
@@ -49,7 +49,11 @@ export default function Home() {
Home
-
+
Learn Blocklet
diff --git a/packages/create-app/templates/react-static/README.md b/packages/create-app/templates/react-static/README.md
index 46d5bf1e..4fae611e 100644
--- a/packages/create-app/templates/react-static/README.md
+++ b/packages/create-app/templates/react-static/README.md
@@ -32,14 +32,14 @@ This blocklet is a static project, which means this is a frontend application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -139,7 +139,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/react-static/blocklet.yml b/packages/create-app/templates/react-static/blocklet.yml
index 4697bfb3..2540e841 100644
--- a/packages/create-app/templates/react-static/blocklet.yml
+++ b/packages/create-app/templates/react-static/blocklet.yml
@@ -13,7 +13,7 @@ author:
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
diff --git a/packages/create-app/templates/react-static/index.html b/packages/create-app/templates/react-static/index.html
index 8e678c45..13e89557 100644
--- a/packages/create-app/templates/react-static/index.html
+++ b/packages/create-app/templates/react-static/index.html
@@ -1,14 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/create-app/templates/react-static/package.json b/packages/create-app/templates/react-static/package.json
index 97134792..c9aa9768 100644
--- a/packages/create-app/templates/react-static/package.json
+++ b/packages/create-app/templates/react-static/package.json
@@ -1,5 +1,6 @@
{
- "name": "template-react",
+ "name": "template-react-static",
+ "private": true,
"version": "0.1.0",
"scripts": {
"dev": "blocklet dev",
@@ -7,13 +8,13 @@
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
"lint:fix": "npm run lint -- --fix",
"start": "vite --host",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "npm run clean && vite build && blocklet bundle --zip --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
"dev:child": "blocklet dev --component --app-did=<%= did %>",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"lint-staged": {
@@ -37,23 +38,24 @@
"last 1 safari version"
]
},
- "dependencies": {
+ "devDependencies": {
+ "@arcblock/eslint-config": "^0.3.2",
+ "@vitejs/plugin-react": "^4.3.1",
+ "bumpp": "^9.4.1",
+ "eslint": "^8.57.0",
+ "lint-staged": "^15.2.7",
+ "prettier": "^3.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-router-dom": "^6.21.0"
- },
- "devDependencies": {
- "@arcblock/eslint-config": "^0.2.4",
- "@vitejs/plugin-react": "^4.2.1",
- "bumpp": "^8.2.1",
- "eslint": "^8.56.0",
- "husky": "^8.0.3",
- "lint-staged": "^12.5.0",
- "prettier": "^3.1.1",
- "rimraf": "^3.0.2",
- "vite": "^5.0.10",
- "vite-plugin-blocklet": "^0.7.9",
+ "react-router-dom": "^6.24.0",
+ "rimraf": "^5.0.7",
+ "simple-git-hooks": "^2.11.1",
+ "vite": "^5.3.2",
+ "vite-plugin-blocklet": "^0.8.0",
"vite-plugin-svgr": "^4.2.0",
- "zx": "^7.2.3"
+ "zx": "^8.1.3"
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/react-static/src/app.css b/packages/create-app/templates/react-static/src/app.css
deleted file mode 100644
index 492f88d4..00000000
--- a/packages/create-app/templates/react-static/src/app.css
+++ /dev/null
@@ -1,30 +0,0 @@
-html,
-body {
- padding: 0;
- margin: 0;
-}
-.app {
- text-align: center;
-}
-
-.app-logo {
- height: 10vmin;
- pointer-events: none;
-}
-
-.app-header {
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: calc(10px + 2vmin);
-}
-
-pre {
- font-size: 0.75em;
-}
-
-.app-link {
- color: #4f6af5;
-}
diff --git a/packages/create-app/templates/react-static/src/app.jsx b/packages/create-app/templates/react-static/src/app.jsx
index 05b65baa..ac560aa1 100644
--- a/packages/create-app/templates/react-static/src/app.jsx
+++ b/packages/create-app/templates/react-static/src/app.jsx
@@ -1,16 +1,12 @@
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
-import './app.css';
import Home from './pages/home';
-import About from './pages/about';
function App() {
return (
- } />
- } />
- } />
+ } />
} />
diff --git a/packages/create-app/templates/react-static/src/assets/blocklet.svg b/packages/create-app/templates/react-static/src/assets/blocklet.svg
new file mode 100644
index 00000000..13e63446
--- /dev/null
+++ b/packages/create-app/templates/react-static/src/assets/blocklet.svg
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-static/src/assets/react.svg b/packages/create-app/templates/react-static/src/assets/react.svg
new file mode 100644
index 00000000..6c87de9b
--- /dev/null
+++ b/packages/create-app/templates/react-static/src/assets/react.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-static/src/assets/vite.svg b/packages/create-app/templates/react-static/src/assets/vite.svg
new file mode 100644
index 00000000..e7b8dfb1
--- /dev/null
+++ b/packages/create-app/templates/react-static/src/assets/vite.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/create-app/templates/react-static/src/index.css b/packages/create-app/templates/react-static/src/index.css
new file mode 100644
index 00000000..6119ad9a
--- /dev/null
+++ b/packages/create-app/templates/react-static/src/index.css
@@ -0,0 +1,68 @@
+:root {
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
+ line-height: 1.5;
+ font-weight: 400;
+
+ color-scheme: light dark;
+ color: rgba(255, 255, 255, 0.87);
+ background-color: #242424;
+
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+a {
+ font-weight: 500;
+ color: #646cff;
+ text-decoration: inherit;
+}
+a:hover {
+ color: #535bf2;
+}
+
+body {
+ margin: 0;
+ display: flex;
+ place-items: center;
+ min-width: 320px;
+ min-height: 100vh;
+}
+
+h1 {
+ font-size: 3.2em;
+ line-height: 1.1;
+}
+
+button {
+ border-radius: 8px;
+ border: 1px solid transparent;
+ padding: 0.6em 1.2em;
+ font-size: 1em;
+ font-weight: 500;
+ font-family: inherit;
+ background-color: #1a1a1a;
+ cursor: pointer;
+ transition: border-color 0.25s;
+}
+button:hover {
+ border-color: #646cff;
+}
+button:focus,
+button:focus-visible {
+ outline: 4px auto -webkit-focus-ring-color;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ color: #213547;
+ background-color: #ffffff;
+ }
+ a:hover {
+ color: #747bff;
+ }
+ button {
+ background-color: #f9f9f9;
+ }
+}
diff --git a/packages/create-app/templates/react-static/src/index.jsx b/packages/create-app/templates/react-static/src/index.jsx
index 29816d8a..ee7d71d6 100644
--- a/packages/create-app/templates/react-static/src/index.jsx
+++ b/packages/create-app/templates/react-static/src/index.jsx
@@ -1,5 +1,6 @@
import ReactDOM from 'react-dom/client';
import App from './app';
+import './index.css';
const root = ReactDOM.createRoot(document.getElementById('app'));
root.render();
diff --git a/packages/create-app/templates/react-static/src/logo.svg b/packages/create-app/templates/react-static/src/logo.svg
deleted file mode 100644
index 133db0d6..00000000
--- a/packages/create-app/templates/react-static/src/logo.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/packages/create-app/templates/react-static/src/pages/about.jsx b/packages/create-app/templates/react-static/src/pages/about.jsx
deleted file mode 100644
index 1a906922..00000000
--- a/packages/create-app/templates/react-static/src/pages/about.jsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Link } from 'react-router-dom';
-
-function About() {
- return (
-
-
-
- Back Home
-
-
- Hello, i'm a static blocklet
-
- );
-}
-
-export default About;
diff --git a/packages/create-app/templates/react-static/src/pages/home.css b/packages/create-app/templates/react-static/src/pages/home.css
new file mode 100644
index 00000000..601e2693
--- /dev/null
+++ b/packages/create-app/templates/react-static/src/pages/home.css
@@ -0,0 +1,45 @@
+#app {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 2rem;
+ text-align: center;
+}
+
+.logo {
+ height: 6em;
+ padding: 1.5em;
+ will-change: filter;
+ transition: filter 300ms;
+}
+.logo:hover {
+ filter: drop-shadow(0 0 2em #646cffaa);
+}
+.logo.react:hover {
+ filter: drop-shadow(0 0 2em #61dafbaa);
+}
+.logo.blocklet:hover {
+ filter: drop-shadow(0 0 2em #22cdcdaa);
+}
+
+@keyframes logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ a:nth-of-type(2) .logo {
+ animation: logo-spin infinite 20s linear;
+ }
+}
+
+.card {
+ padding: 2em;
+}
+
+.read-the-docs {
+ color: #888;
+}
diff --git a/packages/create-app/templates/react-static/src/pages/home.jsx b/packages/create-app/templates/react-static/src/pages/home.jsx
index 8b7cba31..ec5e8b4d 100644
--- a/packages/create-app/templates/react-static/src/pages/home.jsx
+++ b/packages/create-app/templates/react-static/src/pages/home.jsx
@@ -1,21 +1,36 @@
-import { Link } from 'react-router-dom';
-
-import logo from '../logo.svg';
+import { useState } from 'react';
+import reactLogo from '../assets/react.svg';
+import blockletLogo from '../assets/blocklet.svg';
+import viteLogo from '../assets/vite.svg';
+import './home.css';
function Home() {
+ const [count, setCount] = useState(0);
+
return (
-
+ <>
+
+ Vite + React + Blocklet
+
+
+
+ Edit src/app.jsx
and save to test HMR
+
+
+ Click on the Vite and React logos to learn more
+ >
);
}
diff --git a/packages/create-app/templates/react-static/template-info.json b/packages/create-app/templates/react-static/template-info.json
index 68e6a377..343324ce 100644
--- a/packages/create-app/templates/react-static/template-info.json
+++ b/packages/create-app/templates/react-static/template-info.json
@@ -1,9 +1,12 @@
{
"name": "react-static",
- "desc": { "en": "A front-end application skeleton built with React", "zh": "一个基于 React 构建的前端应用骨架" },
+ "desc": {
+ "en": "A front-end application skeleton built with React",
+ "zh": "一个基于 React 构建的前端应用骨架"
+ },
"blockletType": "static",
"composable": true,
"languages": "JavaScript",
"useCase": "Starter",
- "author": "ZhangHan"
-}
\ No newline at end of file
+ "author": "Blocklet"
+}
diff --git a/packages/create-app/templates/solidjs-dapp/.eslintrc.js b/packages/create-app/templates/solidjs-dapp/.eslintrc.js
index 17f43072..518224fb 100644
--- a/packages/create-app/templates/solidjs-dapp/.eslintrc.js
+++ b/packages/create-app/templates/solidjs-dapp/.eslintrc.js
@@ -6,7 +6,8 @@ module.exports = {
es6: true,
},
parserOptions: {
- ecmaVersion: 2018,
+ ecmaVersion: 'latest',
+ sourceType: 'module',
},
plugins: ['solid'],
extends: ['eslint:recommended', 'plugin:prettier/recommended', 'plugin:solid/recommended'],
diff --git a/packages/create-app/templates/solidjs-dapp/README.md b/packages/create-app/templates/solidjs-dapp/README.md
index 8f9d5640..dc2f5fc9 100644
--- a/packages/create-app/templates/solidjs-dapp/README.md
+++ b/packages/create-app/templates/solidjs-dapp/README.md
@@ -32,14 +32,14 @@ This blocklet is a static project, which means this is a frontend application. I
Blocklet needs blocklet server as a dependency. So you need to install it first.
`npm install -g @blocklet/cli`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
2. Init blocklet server & start blocklet server
Before starting an blocklet server, you need to init blocklet server.
`blocklet server init --mode=debug`
`blocklet server start`
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
3. Go to the project directory `cd [name]`
4. Install dependencies: `npm install` or `yarn`
@@ -139,7 +139,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
## Learn More
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
-- Full document of Blocklet Server & blocklet development: [https://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
+- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
## License
diff --git a/packages/create-app/templates/solidjs-dapp/api/hooks/pre-start.js b/packages/create-app/templates/solidjs-dapp/api/hooks/pre-start.js
index dff31e54..f1514a82 100644
--- a/packages/create-app/templates/solidjs-dapp/api/hooks/pre-start.js
+++ b/packages/create-app/templates/solidjs-dapp/api/hooks/pre-start.js
@@ -25,9 +25,10 @@ const ensureAccountDeclared = async () => {
(async () => {
try {
await ensureAccountDeclared();
+ logger.info(`${name} pre-start successfully`);
process.exit(0);
} catch (err) {
- logger.error(`${name} pre-start error`, err.message);
+ logger.error(`${name} pre-start error`, err);
process.exit(1);
}
})();
diff --git a/packages/create-app/templates/solidjs-dapp/api/routes/index.js b/packages/create-app/templates/solidjs-dapp/api/routes/index.js
index 04f50432..cf8fa991 100644
--- a/packages/create-app/templates/solidjs-dapp/api/routes/index.js
+++ b/packages/create-app/templates/solidjs-dapp/api/routes/index.js
@@ -3,4 +3,10 @@ const router = require('express').Router();
router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
+router.use('/data', (req, res) =>
+ res.json({
+ message: 'Hello Blocklet!',
+ }),
+);
+
module.exports = router;
diff --git a/packages/create-app/templates/solidjs-dapp/blocklet.yml b/packages/create-app/templates/solidjs-dapp/blocklet.yml
index b4fe121a..c6e800e6 100644
--- a/packages/create-app/templates/solidjs-dapp/blocklet.yml
+++ b/packages/create-app/templates/solidjs-dapp/blocklet.yml
@@ -6,19 +6,21 @@ keywords:
- solidjs
group: dapp
did: ''
-main: dist
+main: api/index.js
author:
name: Blocklet
email: blocklet@arcblock.io
repository:
type: git
url: 'git+https://github.com/blocklet/create-blocklet.git'
-specVersion: 1.1.1
+specVersion: 1.2.8
version: 0.1.0
logo: logo.png
files:
- logo.png
- screenshots
+ - dist
+ - api/hooks/pre-start.js
interfaces:
- type: web
name: publicUrl
diff --git a/packages/create-app/templates/solidjs-dapp/index.html b/packages/create-app/templates/solidjs-dapp/index.html
index 6a68895c..0e0e475c 100644
--- a/packages/create-app/templates/solidjs-dapp/index.html
+++ b/packages/create-app/templates/solidjs-dapp/index.html
@@ -1,15 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/create-app/templates/solidjs-dapp/package.json b/packages/create-app/templates/solidjs-dapp/package.json
index 00e27827..64ad979f 100644
--- a/packages/create-app/templates/solidjs-dapp/package.json
+++ b/packages/create-app/templates/solidjs-dapp/package.json
@@ -1,64 +1,68 @@
{
- "name": "vite-template-solid",
+ "name": "template-solid-dapp",
"version": "0.0.0",
"description": "",
"scripts": {
"dev": "blocklet dev",
"start": "cross-env NODE_ENV=development nodemon api/dev.js -w api",
- "clean": "node scripts/build-clean.js",
+ "clean": "node scripts/build-clean.mjs",
"bundle": "npm run bundle:client && npm run bundle:api",
"bundle:client": "vite build",
- "bundle:api": "npm run clean && blocklet bundle --zip --create-release",
+ "bundle:api": "npm run clean && blocklet bundle --compact --create-release",
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
- "lint": "eslint src --ext .mjs,.js,.jsx",
+ "lint": "eslint src --ext .mjs,.js,.jsx,.tsx",
"lint:fix": "npm run lint -- --fix",
"deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
"dev:child": "blocklet dev --component --app-did=<%= did %>",
- "prepare": "husky install",
+ "prepare": "npx simple-git-hooks",
"bump-version": "zx --quiet scripts/bump-version.mjs"
},
"license": "MIT",
"devDependencies": {
- "bumpp": "^8.2.1",
+ "@blocklet/js-sdk": "^1.16.28",
+ "bumpp": "^9.4.1",
"cross-env": "^7.0.3",
- "eslint": "^8.56.0",
- "eslint-config-prettier": "^8.10.0",
- "eslint-plugin-prettier": "^4.2.1",
- "eslint-plugin-solid": "0.13.0",
- "husky": "^8.0.3",
- "lint-staged": "^12.5.0",
- "nodemon": "^3.0.2",
+ "eslint": "^8.57.0",
+ "eslint-config-prettier": "^9.1.0",
+ "eslint-plugin-prettier": "^5.1.3",
+ "eslint-plugin-solid": "0.14.1",
+ "lint-staged": "^15.2.7",
+ "nodemon": "^3.1.4",
"npm-run-all": "^4.1.5",
- "prettier": "^3.1.1",
- "rimraf": "^3.0.2",
- "vite": "^5.0.10",
- "vite-plugin-blocklet": "^0.7.9",
- "vite-plugin-solid": "^2.8.0",
- "zx": "^7.2.3"
+ "prettier": "^3.3.2",
+ "rimraf": "^5.0.7",
+ "simple-git-hooks": "^2.11.1",
+ "vite": "^5.3.2",
+ "vite-plugin-blocklet": "^0.8.0",
+ "vite-plugin-solid": "^2.10.2",
+ "zx": "^8.1.3"
},
"dependencies": {
- "@arcblock/did-auth": "^1.18.108",
+ "@arcblock/did-auth": "^1.18.124",
"@arcblock/did-auth-storage-nedb": "^1.7.1",
- "@blocklet/sdk": "^1.16.20",
- "@ocap/client": "^1.18.108",
- "@ocap/mcrypto": "^1.18.108",
- "@ocap/wallet": "^1.18.108",
- "axios": "^1.6.2",
+ "@blocklet/sdk": "^1.16.28",
+ "@ocap/client": "^1.18.124",
+ "@ocap/mcrypto": "^1.18.124",
+ "@ocap/wallet": "^1.18.124",
+ "axios": "^1.7.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
- "dotenv-flow": "^3.3.0",
- "express": "^4.18.2",
+ "dotenv-flow": "^4.1.0",
+ "express": "^4.19.2",
"express-async-errors": "^3.1.1",
- "solid-js": "^1.8.7"
+ "solid-js": "^1.8.18"
},
"lint-staged": {
- "*.{mjs,js,vue}": [
+ "*.{mjs,js,jsx,tsx}": [
"prettier --write",
- "eslint --ext .js,.vue,.mjs"
+ "eslint --ext .js,.mjs,.jsx,.tsx"
],
"*.{css,less,scss,json,graphql}": [
"prettier --write"
]
+ },
+ "simple-git-hooks": {
+ "pre-commit": "npx lint-staged"
}
}
diff --git a/packages/create-app/templates/solidjs-dapp/src/App.jsx b/packages/create-app/templates/solidjs-dapp/src/App.jsx
index 2b1e9182..1e23b3cd 100644
--- a/packages/create-app/templates/solidjs-dapp/src/App.jsx
+++ b/packages/create-app/templates/solidjs-dapp/src/App.jsx
@@ -1,17 +1,29 @@
-import logo from './logo.svg';
+import solidjsLogo from './assets/solidjs.svg';
+import blockletLogo from './assets/blocklet.svg';
import styles from './App.module.css';
+import api from './libs/api';
function App() {
+ async function getApiData() {
+ const { data } = await api.get('/api/data');
+ const { message } = data;
+ alert(`Message from api: ${message}`);
+ }
+
return (