create-blocklet 0.2.18 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/.github/workflows/main.yml +5 -5
- package/common/.husky/pre-commit +4 -0
- package/common/_eslintignore +10 -0
- package/common/_eslintrc.js +1 -0
- package/common/_gitignore +15 -9
- package/common/logo.png +0 -0
- package/common/public/favicon.ico +0 -0
- package/index.js +200 -77
- package/lib/arcblock.js +11 -7
- package/lib/git.js +25 -0
- package/lib/index.js +17 -5
- package/lib/npm.js +7 -9
- package/lib/server.js +26 -20
- package/package.json +18 -16
- package/template-api/express/README.md +146 -0
- package/{template-dapp/react/server → template-api/express/api}/hooks/pre-start.js +0 -0
- package/template-api/express/api/index.js +13 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/auth.js +0 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/env.js +0 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/logger.js +0 -0
- package/template-api/express/blocklet.md +3 -0
- package/template-api/express/blocklet.yml +57 -0
- package/template-api/express/package.json +26 -0
- package/template-api/express/screenshots/.gitkeep +0 -0
- package/template-dapp/nextjs/.eslintrc.js +4 -0
- package/template-dapp/nextjs/README.md +153 -0
- package/template-dapp/{vue/server → nextjs/api}/hooks/pre-start.js +0 -0
- package/template-dapp/nextjs/api/index.js +24 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/auth.js +0 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/env.js +0 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/logger.js +0 -0
- package/template-dapp/{vue2/server → nextjs/api}/routes/index.js +1 -1
- package/template-dapp/nextjs/blocklet.md +3 -0
- package/template-dapp/nextjs/blocklet.yml +58 -0
- package/template-dapp/nextjs/next.config.js +6 -0
- package/template-dapp/nextjs/package.json +48 -0
- package/template-dapp/nextjs/pages/_app.js +21 -0
- package/template-dapp/nextjs/pages/api/hello.js +5 -0
- package/template-dapp/nextjs/pages/index.js +69 -0
- package/template-dapp/nextjs/styles/Home.module.css +116 -0
- package/template-dapp/nextjs/styles/globals.css +16 -0
- package/template-dapp/react/README.md +5 -5
- package/template-dapp/{vue2/server → react/api}/hooks/pre-start.js +0 -0
- package/template-dapp/react/{server → api}/index.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/auth.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/env.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/logger.js +0 -0
- package/template-dapp/react/{server → api}/routes/index.js +1 -1
- package/template-dapp/react/blocklet.yml +6 -6
- package/template-dapp/react/package.json +35 -23
- package/template-dapp/react/public/index.html +1 -3
- package/template-dapp/react/src/app.js +8 -8
- package/template-dapp/vue/.browserslistrc +4 -0
- package/template-dapp/vue/.eslintrc.js +25 -0
- package/template-dapp/vue/api/hooks/pre-start.js +33 -0
- package/template-dapp/vue/{server → api}/index.js +0 -0
- package/template-dapp/vue/api/libs/auth.js +22 -0
- package/template-dapp/vue/api/libs/env.js +6 -0
- package/template-dapp/vue/api/libs/logger.js +3 -0
- package/template-dapp/vue/{server → api}/routes/index.js +1 -1
- package/template-dapp/vue/blocklet.yml +6 -5
- package/template-dapp/vue/index.html +2 -3
- package/template-dapp/vue/package.json +39 -21
- package/template-dapp/vue/src/App.vue +4 -2
- package/template-dapp/vue/vite.config.js +10 -6
- package/template-dapp/vue2/.browserslistrc +4 -0
- package/template-dapp/vue2/.eslintrc.js +14 -0
- package/template-dapp/vue2/api/hooks/pre-start.js +33 -0
- package/template-dapp/vue2/{server → api}/index.js +0 -0
- package/template-dapp/vue2/api/libs/auth.js +22 -0
- package/template-dapp/vue2/api/libs/env.js +6 -0
- package/template-dapp/vue2/api/libs/logger.js +3 -0
- package/template-dapp/vue2/api/routes/index.js +6 -0
- package/template-dapp/vue2/blocklet.yml +7 -5
- package/template-dapp/vue2/jsconfig.json +19 -0
- package/template-dapp/vue2/package.json +38 -43
- package/template-dapp/vue2/public/index.html +2 -9
- package/template-dapp/vue2/src/App.vue +17 -1
- package/template-dapp/vue2/src/main.js +0 -2
- package/template-dapp/vue2/vue.config.js +0 -1
- package/template-static/blocklet-page/package.json +5 -5
- package/template-static/react/blocklet.yml +2 -2
- package/template-static/react/package.json +21 -9
- package/template-static/react/public/index.html +1 -3
- package/template-static/react/src/app.js +8 -8
- package/template-static/vue/.browserslistrc +4 -0
- package/template-static/vue/.eslintrc.js +25 -0
- package/template-static/vue/blocklet.yml +2 -2
- package/template-static/vue/index.html +2 -3
- package/template-static/vue/package.json +26 -8
- package/template-static/vue/vite.config.js +10 -6
- package/template-static/vue2/.browserslistrc +4 -0
- package/template-static/vue2/.eslintrc.js +14 -0
- package/template-static/vue2/blocklet.yml +2 -2
- package/template-static/vue2/jsconfig.json +19 -0
- package/template-static/vue2/package.json +25 -30
- package/template-static/vue2/public/index.html +2 -9
- package/template-static/vue2/src/App.vue +7 -1
- package/template-static/vue2/src/main.js +0 -2
- package/template-static/vue2/vue.config.js +0 -3
- package/common/public/favicon.svg +0 -1
- package/template-dapp/vue2/src/pages/About.vue +0 -13
- package/template-dapp/vue2/src/pages/Home.vue +0 -27
- package/template-dapp/vue2/src/router.js +0 -24
- package/template-static/vue2/src/pages/About.vue +0 -13
- package/template-static/vue2/src/pages/Home.vue +0 -20
- package/template-static/vue2/src/router.js +0 -24
|
@@ -2,42 +2,60 @@
|
|
|
2
2
|
"name": "template-vue",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"dev": "vite",
|
|
5
|
+
"dev": "vite --host",
|
|
6
6
|
"build": "vite build",
|
|
7
7
|
"serve": "vite preview",
|
|
8
8
|
"start": "npm-run-all --parallel start:*",
|
|
9
|
-
"start:client": "
|
|
10
|
-
"start:
|
|
9
|
+
"start:client": "npm run dev",
|
|
10
|
+
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
11
11
|
"clean": "rm -rf .blocklet",
|
|
12
|
-
"bundle": "npm run bundle:client && npm run bundle:
|
|
12
|
+
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
13
13
|
"bundle:client": "vite build --base /.blocklet/proxy/<%= did %>",
|
|
14
|
-
"bundle:
|
|
14
|
+
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
15
15
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
16
|
-
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
16
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
17
|
+
"lint": "eslint src api --ext .mjs,.js,.vue",
|
|
18
|
+
"prepare": "husky install"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"@arcblock/did-auth": "
|
|
20
|
-
"@arcblock/did-auth-storage-nedb": "
|
|
21
|
-
"@blocklet/sdk": "
|
|
22
|
-
"@ocap/client": "
|
|
23
|
-
"@ocap/mcrypto": "
|
|
24
|
-
"@ocap/wallet": "
|
|
25
|
-
"axios": "^0.
|
|
21
|
+
"@arcblock/did-auth": "^1.15.2",
|
|
22
|
+
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
23
|
+
"@blocklet/sdk": "^1.7.0",
|
|
24
|
+
"@ocap/client": "^1.15.2",
|
|
25
|
+
"@ocap/mcrypto": "^1.15.2",
|
|
26
|
+
"@ocap/wallet": "^1.15.2",
|
|
27
|
+
"axios": "^0.26.1",
|
|
26
28
|
"compression": "^1.7.4",
|
|
27
|
-
"cookie-parser": "^1.4.
|
|
29
|
+
"cookie-parser": "^1.4.6",
|
|
28
30
|
"cors": "^2.8.5",
|
|
29
31
|
"dotenv-flow": "^3.2.0",
|
|
30
|
-
"express": "^4.17.
|
|
32
|
+
"express": "^4.17.3",
|
|
31
33
|
"express-async-errors": "^3.1.1",
|
|
32
34
|
"express-history-api-fallback": "^2.2.1",
|
|
33
|
-
"vite-plugin-html": "^2.
|
|
34
|
-
"vue": "^3.2.
|
|
35
|
+
"vite-plugin-html": "^3.2.0",
|
|
36
|
+
"vue": "^3.2.31"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@vitejs/plugin-vue": "^
|
|
38
|
-
"
|
|
39
|
+
"@vitejs/plugin-vue": "^2.2.4",
|
|
40
|
+
"eslint": "^7.32.0",
|
|
41
|
+
"eslint-config-prettier": "^8.5.0",
|
|
42
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
43
|
+
"eslint-plugin-vue": "^8.5.0",
|
|
44
|
+
"husky": "^7.0.4",
|
|
45
|
+
"lint-staged": "^12.3.7",
|
|
46
|
+
"nodemon": "^2.0.15",
|
|
39
47
|
"npm-run-all": "^4.1.5",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
48
|
+
"prettier": "^2.6.0",
|
|
49
|
+
"vite": "^2.8.6",
|
|
50
|
+
"vite-plugin-blocklet": "^0.1.1"
|
|
51
|
+
},
|
|
52
|
+
"lint-staged": {
|
|
53
|
+
"*.{mjs,js,vue}": [
|
|
54
|
+
"prettier --write",
|
|
55
|
+
"eslint --ext .mjs,.js,.vue"
|
|
56
|
+
],
|
|
57
|
+
"*.{css,less,scss,json,graphql}": [
|
|
58
|
+
"prettier --write"
|
|
59
|
+
]
|
|
42
60
|
}
|
|
43
61
|
}
|
|
@@ -3,14 +3,16 @@ import { ref } from 'vue';
|
|
|
3
3
|
// This starter template is using Vue 3 <script setup> SFCs
|
|
4
4
|
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
|
|
5
5
|
import HelloWorld from './components/HelloWorld.vue';
|
|
6
|
+
|
|
7
|
+
const msg = ref('Hello Vue 3 + Vite');
|
|
6
8
|
</script>
|
|
7
9
|
|
|
8
10
|
<template>
|
|
9
11
|
<img alt="Vue logo" src="./assets/logo.png" />
|
|
10
|
-
<HelloWorld msg="
|
|
12
|
+
<HelloWorld :msg="msg" />
|
|
11
13
|
<div :style="{ display: 'flex', justifyContent: 'center' }">
|
|
12
14
|
<pre :style="{ textAlign: 'left' }">
|
|
13
|
-
<code>{{ JSON.stringify(window
|
|
15
|
+
<code>{{ JSON.stringify(window?.blocklet, null, 2) }}</code>
|
|
14
16
|
</pre>
|
|
15
17
|
</div>
|
|
16
18
|
</template>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineConfig, loadEnv } from 'vite';
|
|
2
2
|
import vue from '@vitejs/plugin-vue';
|
|
3
|
-
import {
|
|
3
|
+
import { createHtmlPlugin } from 'vite-plugin-html';
|
|
4
|
+
import { createBlockletPlugin } from 'vite-plugin-blocklet';
|
|
4
5
|
|
|
5
6
|
// https://vitejs.dev/config/
|
|
6
7
|
export default ({ mode }) => {
|
|
@@ -8,13 +9,16 @@ export default ({ mode }) => {
|
|
|
8
9
|
return defineConfig({
|
|
9
10
|
plugins: [
|
|
10
11
|
vue(),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
createHtmlPlugin({
|
|
13
|
+
minify: true,
|
|
14
|
+
inject: {
|
|
15
|
+
data: {
|
|
16
|
+
base: process.env.BASE_URL || '/',
|
|
17
|
+
title: envMap.VITE_APP_TITLE,
|
|
18
|
+
},
|
|
16
19
|
},
|
|
17
20
|
}),
|
|
21
|
+
createBlockletPlugin(),
|
|
18
22
|
],
|
|
19
23
|
server: {
|
|
20
24
|
port: process.env.BLOCKLET_PORT,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true,
|
|
5
|
+
},
|
|
6
|
+
extends: ['plugin:vue/essential', 'eslint:recommended', 'plugin:prettier/recommended'],
|
|
7
|
+
parserOptions: {
|
|
8
|
+
parser: '@babel/eslint-parser',
|
|
9
|
+
},
|
|
10
|
+
rules: {
|
|
11
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
12
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require('@blocklet/sdk/lib/error-handler');
|
|
2
|
+
require('dotenv-flow').config();
|
|
3
|
+
|
|
4
|
+
const Client = require('@ocap/client');
|
|
5
|
+
|
|
6
|
+
const env = require('../libs/env');
|
|
7
|
+
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
9
|
+
const { name } = require('../../package.json');
|
|
10
|
+
|
|
11
|
+
const ensureAccountDeclared = async () => {
|
|
12
|
+
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
14
|
+
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
16
|
+
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
17
|
+
if (!state) {
|
|
18
|
+
const hash = await client.declare({ moniker: name, wallet });
|
|
19
|
+
logger.log(`app account declared on chain ${env.chainHost}`, hash);
|
|
20
|
+
} else {
|
|
21
|
+
logger.log(`app account already declared on chain ${env.chainHost}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
try {
|
|
27
|
+
await ensureAccountDeclared();
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
logger.error(`${name} pre-start error`, err.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
4
|
+
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
6
|
+
|
|
7
|
+
const env = require('./env');
|
|
8
|
+
|
|
9
|
+
const wallet = getWallet();
|
|
10
|
+
const authenticator = new WalletAuthenticator();
|
|
11
|
+
const handlers = new WalletHandler({
|
|
12
|
+
authenticator,
|
|
13
|
+
tokenStorage: new AuthStorage({
|
|
14
|
+
dbPath: path.join(env.dataDir, 'auth.db'),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
authenticator,
|
|
20
|
+
handlers,
|
|
21
|
+
wallet,
|
|
22
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
name: template-vue2
|
|
2
2
|
title: Blocklet Template Vue2
|
|
3
|
-
description: A Blocklet
|
|
3
|
+
description: A Blocklet DAPP blocklet
|
|
4
4
|
keywords:
|
|
5
5
|
- blocklet
|
|
6
6
|
- vue
|
|
7
|
-
group:
|
|
7
|
+
group: dapp
|
|
8
8
|
did: ''
|
|
9
|
-
main:
|
|
9
|
+
main: api/index.js
|
|
10
10
|
author:
|
|
11
|
-
name:
|
|
12
|
-
email:
|
|
11
|
+
name: Blocklet
|
|
12
|
+
email: blocklet@arcblock.io
|
|
13
13
|
repository:
|
|
14
14
|
type: git
|
|
15
15
|
url: git+https://github.com/blocklet/create-blocklet.git
|
|
@@ -21,6 +21,7 @@ files:
|
|
|
21
21
|
- README.md
|
|
22
22
|
- blocklet.md
|
|
23
23
|
- screenshots
|
|
24
|
+
- api/hooks/pre-start.js
|
|
24
25
|
interfaces:
|
|
25
26
|
- type: web
|
|
26
27
|
name: publicUrl
|
|
@@ -43,6 +44,7 @@ requirements:
|
|
|
43
44
|
os: '*'
|
|
44
45
|
cpu: '*'
|
|
45
46
|
scripts:
|
|
47
|
+
preStart: node api/hooks/pre-start.js
|
|
46
48
|
dev: npm run start
|
|
47
49
|
environments:
|
|
48
50
|
- name: CHAIN_HOST
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"baseUrl": "./",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@/*": [
|
|
9
|
+
"src/*"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"lib": [
|
|
13
|
+
"esnext",
|
|
14
|
+
"dom",
|
|
15
|
+
"dom.iterable",
|
|
16
|
+
"scripthost"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -5,64 +5,59 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
7
7
|
"build": "vue-cli-service build",
|
|
8
|
-
"lint": "vue
|
|
8
|
+
"lint": "eslint src api --ext .mjs,.js,.vue",
|
|
9
9
|
"start": "npm-run-all --parallel start:*",
|
|
10
10
|
"start:client": "npm run serve",
|
|
11
|
-
"start:
|
|
11
|
+
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
12
12
|
"clean": "rm -rf .blocklet",
|
|
13
|
-
"bundle": "npm run bundle:client && npm run bundle:
|
|
13
|
+
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
14
14
|
"bundle:client": "PUBLIC_PATH=/.blocklet/proxy/z8ia5PYHKJaG7LxTiKK74YhN1vkVMf7N7VncW",
|
|
15
|
-
"bundle:
|
|
15
|
+
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
16
16
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
17
|
-
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
17
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
18
|
+
"prepare": "husky install"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@arcblock/did-auth": "
|
|
21
|
-
"@arcblock/did-auth-storage-nedb": "
|
|
22
|
-
"@blocklet/sdk": "
|
|
23
|
-
"@ocap/client": "
|
|
24
|
-
"@ocap/mcrypto": "
|
|
25
|
-
"@ocap/wallet": "
|
|
26
|
-
"axios": "^0.
|
|
21
|
+
"@arcblock/did-auth": "^1.15.2",
|
|
22
|
+
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
23
|
+
"@blocklet/sdk": "^1.7.0",
|
|
24
|
+
"@ocap/client": "^1.15.2",
|
|
25
|
+
"@ocap/mcrypto": "^1.15.2",
|
|
26
|
+
"@ocap/wallet": "^1.15.2",
|
|
27
|
+
"axios": "^0.26.1",
|
|
27
28
|
"compression": "^1.7.4",
|
|
28
|
-
"cookie-parser": "^1.4.
|
|
29
|
-
"core-js": "^3.
|
|
29
|
+
"cookie-parser": "^1.4.6",
|
|
30
|
+
"core-js": "^3.21.1",
|
|
30
31
|
"cors": "^2.8.5",
|
|
31
32
|
"dotenv-flow": "^3.2.0",
|
|
32
|
-
"express": "^4.17.
|
|
33
|
+
"express": "^4.17.3",
|
|
33
34
|
"express-async-errors": "^3.1.1",
|
|
34
35
|
"express-history-api-fallback": "^2.2.1",
|
|
35
|
-
"vue": "^2.6.
|
|
36
|
-
"vue-router": "^3.5.3"
|
|
36
|
+
"vue": "^2.6.14"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@vue/cli-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"eslint
|
|
45
|
-
"
|
|
39
|
+
"@babel/core": "^7.17.8",
|
|
40
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
41
|
+
"@vue/cli-plugin-babel": "~5.0.3",
|
|
42
|
+
"@vue/cli-plugin-eslint": "~5.0.3",
|
|
43
|
+
"@vue/cli-service": "~5.0.3",
|
|
44
|
+
"eslint": "^7.32.0",
|
|
45
|
+
"eslint-config-prettier": "^8.5.0",
|
|
46
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
47
|
+
"eslint-plugin-vue": "^8.5.0",
|
|
48
|
+
"husky": "^7.0.4",
|
|
49
|
+
"lint-staged": "^12.3.7",
|
|
50
|
+
"nodemon": "^2.0.15",
|
|
46
51
|
"npm-run-all": "^4.1.5",
|
|
47
|
-
"vue-template-compiler": "^2.6.
|
|
52
|
+
"vue-template-compiler": "^2.6.14"
|
|
48
53
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
},
|
|
54
|
-
"extends": [
|
|
55
|
-
"plugin:vue/essential",
|
|
56
|
-
"eslint:recommended"
|
|
54
|
+
"lint-staged": {
|
|
55
|
+
"*.{mjs,js,vue}": [
|
|
56
|
+
"prettier --write",
|
|
57
|
+
"eslint --ext .mjs,.js,.vue"
|
|
57
58
|
],
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
"browserslist": [
|
|
64
|
-
"> 1%",
|
|
65
|
-
"last 2 versions",
|
|
66
|
-
"not dead"
|
|
67
|
-
]
|
|
59
|
+
"*.{css,less,scss,json,graphql}": [
|
|
60
|
+
"prettier --write"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
68
63
|
}
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
<html lang="">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon"
|
|
6
|
-
<link rel="alternate icon" href="<%= BASE_URL %>favicon.ico" />
|
|
7
|
-
<link rel="mask-icon" href="<%= BASE_URL %>favicon.svg" color="#4F6AF5" />
|
|
5
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
|
|
8
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
9
7
|
<meta name="theme-color" content="#4F6AF5" />
|
|
10
8
|
<meta name="description" content="Web site created using create-blocklet" />
|
|
@@ -12,12 +10,7 @@
|
|
|
12
10
|
<script src="__meta__.js"></script>
|
|
13
11
|
</head>
|
|
14
12
|
<body>
|
|
15
|
-
<noscript>
|
|
16
|
-
<strong
|
|
17
|
-
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please
|
|
18
|
-
enable it to continue.</strong
|
|
19
|
-
>
|
|
20
|
-
</noscript>
|
|
13
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
21
14
|
<div id="app"></div>
|
|
22
15
|
<!-- built files will be auto injected -->
|
|
23
16
|
</body>
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="app">
|
|
3
|
-
<
|
|
3
|
+
<img alt="Vue logo" src="./assets/logo.png" />
|
|
4
|
+
<HelloWorld msg="Welcome to Your Vue.js App" />
|
|
5
|
+
<div :style="{ display: 'flex', justifyContent: 'center' }">
|
|
6
|
+
<pre :style="{ textAlign: 'left' }">
|
|
7
|
+
<code>{{ JSON.stringify(blocklet, null, 2) }}</code>
|
|
8
|
+
</pre>
|
|
9
|
+
</div>
|
|
4
10
|
</div>
|
|
5
11
|
</template>
|
|
6
12
|
|
|
7
13
|
<script>
|
|
14
|
+
import HelloWorld from './components/HelloWorld.vue';
|
|
15
|
+
|
|
8
16
|
export default {
|
|
9
17
|
name: 'App',
|
|
18
|
+
components: {
|
|
19
|
+
HelloWorld,
|
|
20
|
+
},
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
blocklet: window?.blocklet,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
10
26
|
};
|
|
11
27
|
</script>
|
|
12
28
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
+
"name": "blocklet-page",
|
|
2
3
|
"private": true,
|
|
3
4
|
"scripts": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
5
|
+
"dev": "xmark start",
|
|
6
|
+
"start": "npm run dev",
|
|
6
7
|
"build": "xmark build",
|
|
7
8
|
"clean": "rm -rf .blocklet",
|
|
8
9
|
"bundle": "npm run clean && npm run build && blocklet bundle --create-release",
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {
|
|
13
|
-
"@xmark/cli": "^2.0.
|
|
14
|
-
}
|
|
15
|
-
"name": "blocklet-page"
|
|
14
|
+
"@xmark/cli": "^2.0.28"
|
|
15
|
+
}
|
|
16
16
|
}
|
|
@@ -2,15 +2,25 @@
|
|
|
2
2
|
"name": "template-react",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
|
+
"dev": "react-scripts start",
|
|
5
6
|
"build": "react-scripts build",
|
|
6
7
|
"eject": "react-scripts eject",
|
|
7
|
-
"lint": "eslint src",
|
|
8
|
-
"dev": "react-scripts start",
|
|
8
|
+
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
9
9
|
"start": "npm run dev",
|
|
10
10
|
"clean": "rm -rf .blocklet",
|
|
11
11
|
"bundle": "npm run clean && PUBLIC_URL='/.blocklet/proxy/<%= did %>' npm run build && blocklet bundle --zip --create-release",
|
|
12
12
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
13
|
-
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
13
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
14
|
+
"prepare": "husky install"
|
|
15
|
+
},
|
|
16
|
+
"lint-staged": {
|
|
17
|
+
"*.{mjs,js,jsx,ts,tsx}": [
|
|
18
|
+
"prettier --write",
|
|
19
|
+
"eslint"
|
|
20
|
+
],
|
|
21
|
+
"*.{css,less,scss,json,graphql}": [
|
|
22
|
+
"prettier --write"
|
|
23
|
+
]
|
|
14
24
|
},
|
|
15
25
|
"browserslist": {
|
|
16
26
|
"production": [
|
|
@@ -27,21 +37,23 @@
|
|
|
27
37
|
"dependencies": {
|
|
28
38
|
"react": "^17.0.2",
|
|
29
39
|
"react-dom": "^17.0.2",
|
|
30
|
-
"react-router-dom": "^
|
|
31
|
-
"react-scripts": "
|
|
40
|
+
"react-router-dom": "^6.2.2",
|
|
41
|
+
"react-scripts": "5.0.0"
|
|
32
42
|
},
|
|
33
43
|
"devDependencies": {
|
|
34
|
-
"@arcblock/eslint-config": "
|
|
44
|
+
"@arcblock/eslint-config": "^0.1.8",
|
|
35
45
|
"babel-eslint": "^10.1.0",
|
|
36
|
-
"eslint": "^7.
|
|
46
|
+
"eslint": "^7.32.0",
|
|
37
47
|
"eslint-config-airbnb": "^18.2.1",
|
|
38
48
|
"eslint-config-prettier": "^8.3.0",
|
|
39
49
|
"eslint-plugin-import": "^2.23.4",
|
|
40
50
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
41
|
-
"eslint-plugin-prettier": "^3.4.
|
|
51
|
+
"eslint-plugin-prettier": "^3.4.1",
|
|
42
52
|
"eslint-plugin-react": "^7.24.0",
|
|
43
53
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
44
54
|
"eslint-plugin-unicorn": "^34.0.1",
|
|
45
|
-
"
|
|
55
|
+
"husky": "^7.0.4",
|
|
56
|
+
"lint-staged": "^12.3.7",
|
|
57
|
+
"prettier": "^2.6.0"
|
|
46
58
|
}
|
|
47
59
|
}
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon"
|
|
6
|
-
<link rel="alternate icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
7
|
-
<link rel="mask-icon" href="%PUBLIC_URL%/favicon.svg" color="#4F6AF5" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
8
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
9
7
|
<meta name="theme-color" content="#4F6AF5" />
|
|
10
8
|
<meta name="description" content="Web site created using create-blocklet" />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BrowserRouter as Router,
|
|
2
|
+
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
import './app.css';
|
|
5
5
|
import Home from './pages/home';
|
|
@@ -8,17 +8,17 @@ import About from './pages/about';
|
|
|
8
8
|
function App() {
|
|
9
9
|
return (
|
|
10
10
|
<div className="app">
|
|
11
|
-
<
|
|
12
|
-
<Route exact path="/"
|
|
13
|
-
<Route path="/about"
|
|
14
|
-
<Route path="/home"
|
|
15
|
-
<
|
|
16
|
-
</
|
|
11
|
+
<Routes>
|
|
12
|
+
<Route exact path="/" element={<Home />} />
|
|
13
|
+
<Route path="/about" element={<About />} />
|
|
14
|
+
<Route path="/home" element={<Home />} />
|
|
15
|
+
<Route path="*" element={<Navigate to="/" />} />
|
|
16
|
+
</Routes>
|
|
17
17
|
</div>
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const WrappedApp =
|
|
21
|
+
const WrappedApp = App;
|
|
22
22
|
|
|
23
23
|
export default () => {
|
|
24
24
|
// While the blocklet is deploy to a sub path, this will be work properly.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true,
|
|
5
|
+
},
|
|
6
|
+
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', 'plugin:prettier/recommended'],
|
|
7
|
+
globals: {
|
|
8
|
+
// Ref sugar (take 2)
|
|
9
|
+
$: 'readonly',
|
|
10
|
+
$$: 'readonly',
|
|
11
|
+
$ref: 'readonly',
|
|
12
|
+
$shallowRef: 'readonly',
|
|
13
|
+
$computed: 'readonly',
|
|
14
|
+
|
|
15
|
+
// script setup
|
|
16
|
+
defineProps: 'readonly',
|
|
17
|
+
defineEmits: 'readonly',
|
|
18
|
+
defineExpose: 'readonly',
|
|
19
|
+
withDefaults: 'readonly',
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
23
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
24
|
+
},
|
|
25
|
+
};
|