create-blocklet 0.2.14 → 0.2.17
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/README.md +8 -3
- package/common/_npmrc +2 -0
- package/index.js +14 -4
- package/package.json +1 -1
- package/template-static/blocklet-page/README.md +143 -0
- package/template-static/blocklet-page/blocklet.md +3 -0
- package/template-static/blocklet-page/blocklet.yml +50 -0
- package/template-static/blocklet-page/package.json +16 -0
- package/template-static/blocklet-page/site/blocks/CustomBlock.mdx +3 -0
- package/template-static/blocklet-page/site/composes/MyLayout.mdx +5 -0
- package/template-static/blocklet-page/site/pages/index.mdx +5 -0
- package/template-static/blocklet-page/xmark.yml +4 -0
package/README.md
CHANGED
|
@@ -17,16 +17,16 @@ With NPM:
|
|
|
17
17
|
npm init blocklet@latest [blocklet-name]
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
With Yarn:
|
|
20
|
+
With Yarn: (recommend)
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
yarn create blocklet [blocklet-name]
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
With PNPM:
|
|
26
|
+
With PNPM: (recommend)
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
|
|
29
|
+
pnpm create blocklet [blocklet-name]
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Currently supported template presets include:
|
|
@@ -34,10 +34,15 @@ Currently supported template presets include:
|
|
|
34
34
|
**dapp**
|
|
35
35
|
|
|
36
36
|
- `react`
|
|
37
|
+
- `vue3 + vite`
|
|
38
|
+
- `vue2 + @vue/cli`
|
|
37
39
|
|
|
38
40
|
**static**
|
|
39
41
|
|
|
40
42
|
- `react`
|
|
43
|
+
- `vue3 + vite`
|
|
44
|
+
- `vue2 + @vue/cli`
|
|
45
|
+
- `blocklet page`
|
|
41
46
|
|
|
42
47
|
## Community Templates
|
|
43
48
|
|
package/common/_npmrc
ADDED
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import YAML from 'yaml';
|
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import minimist from 'minimist';
|
|
9
9
|
import prompts from 'prompts';
|
|
10
|
-
import { yellow, red, green, cyan } from 'kolorist';
|
|
10
|
+
import { yellow, red, green, cyan, blue, lightYellow } from 'kolorist';
|
|
11
11
|
import * as envfile from 'envfile';
|
|
12
12
|
|
|
13
13
|
import { echoBrand, echoDocument } from './lib/arcblock.js';
|
|
@@ -61,6 +61,11 @@ const TYPES = [
|
|
|
61
61
|
display: 'vue2 + @vue/cli',
|
|
62
62
|
color: green,
|
|
63
63
|
},
|
|
64
|
+
{
|
|
65
|
+
name: 'blocklet-page',
|
|
66
|
+
display: 'blocklet page',
|
|
67
|
+
color: blue,
|
|
68
|
+
},
|
|
64
69
|
],
|
|
65
70
|
},
|
|
66
71
|
];
|
|
@@ -76,6 +81,7 @@ const SERVICES = [
|
|
|
76
81
|
const renameFiles = {
|
|
77
82
|
_gitignore: '.gitignore',
|
|
78
83
|
'_eslintrc.js': '.eslintrc.js',
|
|
84
|
+
_npmrc: '.npmrc',
|
|
79
85
|
};
|
|
80
86
|
|
|
81
87
|
async function init() {
|
|
@@ -364,9 +370,13 @@ async function init() {
|
|
|
364
370
|
write('blocklet.md', modifyMd);
|
|
365
371
|
}
|
|
366
372
|
function modifyEnv(modifyFn = (...args) => ({ ...args })) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
373
|
+
try {
|
|
374
|
+
const env = envfile.parse(read('.env'));
|
|
375
|
+
modifyFn(env);
|
|
376
|
+
write('.env', envfile.stringify(env));
|
|
377
|
+
} catch {
|
|
378
|
+
console.warn(`\n${lightYellow('No .env file found, please add one.')}`);
|
|
379
|
+
}
|
|
370
380
|
}
|
|
371
381
|
}
|
|
372
382
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Getting Started with Create Blocklet
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
|
|
4
|
+
|
|
5
|
+
This blocklet is a static project, which means this is a frontend application. It's contained `client` code.
|
|
6
|
+
|
|
7
|
+
## File Structure
|
|
8
|
+
|
|
9
|
+
- public/ - static files
|
|
10
|
+
- favicon.ico - favicon
|
|
11
|
+
- favicon.svg - favicon
|
|
12
|
+
- screenshots/ - Screenshots
|
|
13
|
+
- site/ - Client side code (A standard Blocklet Page project)
|
|
14
|
+
- .gitignore - Git ignore file
|
|
15
|
+
- .prettierrc - Prettier configuration
|
|
16
|
+
- blocklet.md - Blocklet README
|
|
17
|
+
- blocklet.yml - Blocklet configuration
|
|
18
|
+
- LICENSE - License file
|
|
19
|
+
- logo.png - Blocklet logo file
|
|
20
|
+
- Makefile - Makefile
|
|
21
|
+
- package.json - Npm package file
|
|
22
|
+
- README.md - A guide for this blocklet
|
|
23
|
+
- version - Version file
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
28
|
+
|
|
29
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
30
|
+
`npm install -g @blocklet/cli`
|
|
31
|
+
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
32
|
+
|
|
33
|
+
2. Init blocklet server & start blocklet server
|
|
34
|
+
|
|
35
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
36
|
+
`blocklet server init --mode=debug`
|
|
37
|
+
`blocklet server start`
|
|
38
|
+
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
39
|
+
|
|
40
|
+
3. Go to the project directory `cd [name]`
|
|
41
|
+
4. Install dependencies: `npm install` or `yarn` or `pnpm`
|
|
42
|
+
5. Start development server: `blocklet dev`
|
|
43
|
+
|
|
44
|
+
## Bundle
|
|
45
|
+
|
|
46
|
+
After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
|
|
47
|
+
|
|
48
|
+
## Deploy
|
|
49
|
+
|
|
50
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
|
|
51
|
+
> Or you can simply use `npm run deploy` command.
|
|
52
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
53
|
+
|
|
54
|
+
```shell
|
|
55
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> Make sure the blocklet is bundled before deployment.
|
|
59
|
+
|
|
60
|
+
## Upload to blocklet store
|
|
61
|
+
|
|
62
|
+
- If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
|
|
63
|
+
|
|
64
|
+
Bump version at first.
|
|
65
|
+
|
|
66
|
+
```shell
|
|
67
|
+
make bump-version
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then config blocklet store url.
|
|
71
|
+
You can use those store url in below.
|
|
72
|
+
|
|
73
|
+
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
74
|
+
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
75
|
+
3. A blocklet store started by yourself.
|
|
76
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
blocklet config set store {store url}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Get a `accessToken` from blocklet store.
|
|
83
|
+
|
|
84
|
+
> Why we need a `accessToken`?
|
|
85
|
+
> A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
|
|
86
|
+
|
|
87
|
+
Set `accessToken` to blocklet config
|
|
88
|
+
|
|
89
|
+
```shell
|
|
90
|
+
blocklet config set accessToken {accessToken}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Upload a new version to a store.
|
|
94
|
+
|
|
95
|
+
> Make sure the blocklet is bundled before upload.
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
blocklet upload
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Or you can simply use `npm run upload` command.
|
|
102
|
+
|
|
103
|
+
- You also can upload a new version to blocklet store by Github CI.
|
|
104
|
+
Bump version at first.
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
make bump-version
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Push your code to Github main/master branch, or make a pull request to the main/master branch.
|
|
111
|
+
The CI workflow will automatically upload a new version to a store.
|
|
112
|
+
|
|
113
|
+
## Q & A
|
|
114
|
+
|
|
115
|
+
1. Q: How to change a blocklet's name?
|
|
116
|
+
|
|
117
|
+
A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
|
|
118
|
+
|
|
119
|
+
You can also change the `title` field and `description` field in the `blocklet.yml` file.
|
|
120
|
+
|
|
121
|
+
Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
|
|
122
|
+
|
|
123
|
+
Replace this command `"bundle": "PUBLIC_URL='/.blocklet/proxy/{did}' npm run build",` in `package.json`
|
|
124
|
+
|
|
125
|
+
Replace `did` field in the `blocklet.yml`
|
|
126
|
+
|
|
127
|
+
2. Q: How to change a blocklet's logo?
|
|
128
|
+
|
|
129
|
+
Change the `logo.png` file root folder.
|
|
130
|
+
|
|
131
|
+
Or you can change the `logo` field in the `blocklet.yml` file.
|
|
132
|
+
|
|
133
|
+
> Make sure you have added the logo path to the `blocklet.yml` file `files` field.
|
|
134
|
+
|
|
135
|
+
## Learn More
|
|
136
|
+
|
|
137
|
+
- 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)
|
|
138
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
The code is licensed under the Apache 2.0 license found in the
|
|
143
|
+
[LICENSE](LICENSE) file.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: template-blocklet-page
|
|
2
|
+
title: Blocklet Page Template
|
|
3
|
+
description: A Blocklet Server blocklet
|
|
4
|
+
keywords:
|
|
5
|
+
- blocklet
|
|
6
|
+
- blocklet-page
|
|
7
|
+
- xmark
|
|
8
|
+
group: static
|
|
9
|
+
did: ''
|
|
10
|
+
main: dist
|
|
11
|
+
author:
|
|
12
|
+
name: Arcblock
|
|
13
|
+
email: blocklet@arcblock.io
|
|
14
|
+
repository:
|
|
15
|
+
type: git
|
|
16
|
+
url: 'git+https://github.com/blocklet/create-blocklet.git'
|
|
17
|
+
specVersion: 1.1.1
|
|
18
|
+
version: 0.1.0
|
|
19
|
+
logo: logo.png
|
|
20
|
+
files:
|
|
21
|
+
- logo.png
|
|
22
|
+
- README.md
|
|
23
|
+
- blocklet.md
|
|
24
|
+
- screenshots
|
|
25
|
+
interfaces:
|
|
26
|
+
- type: web
|
|
27
|
+
name: publicUrl
|
|
28
|
+
path: /
|
|
29
|
+
prefix: '*'
|
|
30
|
+
port: BLOCKLET_PORT
|
|
31
|
+
protocol: http
|
|
32
|
+
community: ''
|
|
33
|
+
documentation: ''
|
|
34
|
+
homepage: ''
|
|
35
|
+
license: ''
|
|
36
|
+
payment:
|
|
37
|
+
tokens: []
|
|
38
|
+
shares: []
|
|
39
|
+
timeout:
|
|
40
|
+
start: 60
|
|
41
|
+
requirements:
|
|
42
|
+
abtnode: '>=1.6.22'
|
|
43
|
+
os: '*'
|
|
44
|
+
cpu: '*'
|
|
45
|
+
scripts:
|
|
46
|
+
dev: npm run start
|
|
47
|
+
environments: []
|
|
48
|
+
capabilities: {}
|
|
49
|
+
screenshots: []
|
|
50
|
+
children: []
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"scripts": {
|
|
4
|
+
"start": "xmark start",
|
|
5
|
+
"dev": "xmark start --open",
|
|
6
|
+
"build": "xmark build",
|
|
7
|
+
"clean": "rm -rf .blocklet",
|
|
8
|
+
"bundle": "npm run clean && npm run build && blocklet bundle --create-release",
|
|
9
|
+
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
10
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@xmark/cli": "^2.0.11"
|
|
14
|
+
},
|
|
15
|
+
"name": "blocklet-page"
|
|
16
|
+
}
|