@blocklet/component-studio-cli 0.4.134
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 +84 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +11 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.js +140 -0
- package/dist/commands/component-studio.d.ts +2 -0
- package/dist/commands/component-studio.js +70 -0
- package/dist/commands/dev.d.ts +2 -0
- package/dist/commands/dev.js +87 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +114 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.js +177 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +22 -0
- package/dist/utils/display-logo.d.ts +2 -0
- package/dist/utils/display-logo.js +24 -0
- package/dist/utils/helper.d.ts +97 -0
- package/dist/utils/helper.js +479 -0
- package/package.json +58 -0
- package/templates/add/components/HelloWorld/@metadata.json +433 -0
- package/templates/add/components/HelloWorld/@template.json +4 -0
- package/templates/add/components/HelloWorld/index.tsx +560 -0
- package/templates/add/tools/cursor-rules/.cursor/rules/@metadata-json.mdc +549 -0
- package/templates/add/tools/cursor-rules/.cursor/rules/component-studio.mdc +138 -0
- package/templates/add/tools/cursor-rules/.cursor/rules/index-tsx.mdc +192 -0
- package/templates/add/tools/cursor-rules/@template.json +4 -0
- package/templates/init/0-basic/@template.json +4 -0
- package/templates/init/0-basic/README.md +30 -0
- package/templates/init/0-basic/package.json +26 -0
- package/templates/init/0-basic/src/HelloWorld/@metadata.json +433 -0
- package/templates/init/0-basic/src/HelloWorld/index.tsx +560 -0
- package/templates/init/1-professional/@template.json +4 -0
- package/templates/init/1-professional/README.md +75 -0
- package/templates/init/1-professional/biome.json +36 -0
- package/templates/init/1-professional/global.d.ts +131 -0
- package/templates/init/1-professional/package.json +73 -0
- package/templates/init/1-professional/scripts/bump-version.mjs +35 -0
- package/templates/init/1-professional/src/atoms/AnimationWrapper.tsx +95 -0
- package/templates/init/1-professional/src/atoms/ArrayTable.tsx +114 -0
- package/templates/init/1-professional/src/atoms/Card.tsx +52 -0
- package/templates/init/1-professional/src/atoms/ContentWrapper.tsx +72 -0
- package/templates/init/1-professional/src/atoms/CopyrightFooter.tsx +31 -0
- package/templates/init/1-professional/src/atoms/DataDisplays.tsx +157 -0
- package/templates/init/1-professional/src/atoms/GradientTitle.tsx +64 -0
- package/templates/init/1-professional/src/atoms/Logo.tsx +58 -0
- package/templates/init/1-professional/src/atoms/index.ts +27 -0
- package/templates/init/1-professional/src/components/HelloWorld/@metadata.json +433 -0
- package/templates/init/1-professional/src/components/HelloWorld/index.tsx +224 -0
- package/templates/init/1-professional/src/type.d.ts +42 -0
- package/templates/init/1-professional/src/utils/index.ts +1 -0
- package/templates/init/1-professional/tsconfig.json +102 -0
- package/templates/init/1-professional/version +1 -0
- package/templates/init/2-blank/@template.json +4 -0
- package/templates/init/2-blank/README.md +27 -0
- package/templates/init/2-blank/package.json +26 -0
- package/templates/workspace/.component-studio-runtime/_theme.tsx +4 -0
- package/templates/workspace/.editorconfig +23 -0
- package/templates/workspace/.env +1 -0
- package/templates/workspace/.init-component-studio +0 -0
- package/templates/workspace/LICENSE +13 -0
- package/templates/workspace/README.md +127 -0
- package/templates/workspace/api/dev.ts +21 -0
- package/templates/workspace/api/src/index.ts +50 -0
- package/templates/workspace/api/src/libs/auth.ts +17 -0
- package/templates/workspace/api/src/libs/env.ts +6 -0
- package/templates/workspace/api/src/libs/logger.ts +3 -0
- package/templates/workspace/api/src/routes/index.ts +12 -0
- package/templates/workspace/api/third.d.ts +17 -0
- package/templates/workspace/biome.json +36 -0
- package/templates/workspace/blocklet.md +8 -0
- package/templates/workspace/blocklet.yml +58 -0
- package/templates/workspace/index.html +15 -0
- package/templates/workspace/logo.png +0 -0
- package/templates/workspace/package.json +125 -0
- package/templates/workspace/pnpm-workspace.yaml +3 -0
- package/templates/workspace/scripts/build-clean.mjs +6 -0
- package/templates/workspace/scripts/bump-version.mjs +39 -0
- package/templates/workspace/scripts/init-component-studio.mjs +36 -0
- package/templates/workspace/tsconfig.api.json +12 -0
- package/templates/workspace/tsconfig.json +102 -0
- package/templates/workspace/version +1 -0
- package/templates/workspace/vite-server.config.ts +39 -0
- package/templates/workspace/vite.config.ts +68 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ts-node": {
|
|
3
|
+
"files": true,
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"module": "Node16"
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
"compilerOptions": {
|
|
9
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
10
|
+
/* Projects */
|
|
11
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
12
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
13
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
14
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
15
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
16
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
17
|
+
/* Language and Environment */
|
|
18
|
+
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
19
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
20
|
+
"jsx": "react-jsx" /* Specify what JSX code is generated. */,
|
|
21
|
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
22
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
23
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
24
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
25
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
26
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
27
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
28
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
29
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
30
|
+
/* Modules */
|
|
31
|
+
"module": "commonjs" /* Specify what module code is generated. */,
|
|
32
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
33
|
+
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
34
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
35
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
36
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
37
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
38
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
39
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
40
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
41
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
42
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
43
|
+
/* JavaScript Support */
|
|
44
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
45
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
46
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
47
|
+
/* Emit */
|
|
48
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
49
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
50
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
51
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
52
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
53
|
+
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
54
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
55
|
+
"noEmit": true /* Disable emitting files from a compilation. */,
|
|
56
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
57
|
+
"ignoreDeprecations": "5.0",
|
|
58
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
59
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
60
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
61
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
62
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
63
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
64
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
65
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
66
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
67
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
68
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
69
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
70
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
71
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
72
|
+
/* Interop Constraints */
|
|
73
|
+
"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
|
|
74
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
75
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
76
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
77
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
78
|
+
/* Type Checking */
|
|
79
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
80
|
+
"noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
|
|
81
|
+
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
|
|
82
|
+
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
|
|
83
|
+
"strictBindCallApply": true /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */,
|
|
84
|
+
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
|
|
85
|
+
"noImplicitThis": true /* Enable error reporting when 'this' is given the type 'any'. */,
|
|
86
|
+
"useUnknownInCatchVariables": false /* Default catch clause variables as 'unknown' instead of 'any'. */,
|
|
87
|
+
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
|
|
88
|
+
"noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
|
|
89
|
+
"noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
|
|
90
|
+
// "exactOptionalPropertyTypes": false /* Interpret optional property types as written, rather than adding 'undefined'. */,
|
|
91
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
92
|
+
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
|
|
93
|
+
"noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */,
|
|
94
|
+
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
|
|
95
|
+
// "noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type. */,
|
|
96
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
97
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
98
|
+
/* Completeness */
|
|
99
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
100
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Blank Component Studio Project
|
|
2
|
+
|
|
3
|
+
This is a minimal component studio project created with Component Studio.
|
|
4
|
+
|
|
5
|
+
## Project Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
{your-project-name}/
|
|
9
|
+
├── src/
|
|
10
|
+
│ └── {your-component-name} # Your component name
|
|
11
|
+
| └── index.tsx # Main entry point
|
|
12
|
+
├── package.json # Project dependencies and scripts
|
|
13
|
+
├── .gitignore # Git ignore
|
|
14
|
+
└── README.md # README
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Getting Started
|
|
18
|
+
|
|
19
|
+
Start development server:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm run dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "blank-component-studio-project",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A minimal component studio project",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "component-studio dev",
|
|
9
|
+
"dev": "component-studio dev",
|
|
10
|
+
"update:deps": "npx -y taze -r -n '/arcblock|ocap|abtnode|blocklet|did-connect|did-comment|nedb/' -w -f && pnpm install && pnpm run deduplicate",
|
|
11
|
+
"deduplicate": "pnpm dedupe"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/react": "^18.2.0",
|
|
16
|
+
"@types/react-dom": "^18.2.0",
|
|
17
|
+
"react": "^18.2.0",
|
|
18
|
+
"react-dom": "^18.2.0",
|
|
19
|
+
"typescript": "^5.0.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
23
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT"
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# For more information about the properties used in
|
|
2
|
+
# this file, please see the EditorConfig documentation:
|
|
3
|
+
# http://editorconfig.org/
|
|
4
|
+
#
|
|
5
|
+
# Sensible EditorConfig defaults
|
|
6
|
+
# https://gist.github.com/matijs/662bf45dd4ec37b3a068
|
|
7
|
+
root = true
|
|
8
|
+
|
|
9
|
+
[*]
|
|
10
|
+
charset = utf-8
|
|
11
|
+
end_of_line = lf
|
|
12
|
+
indent_size = 2
|
|
13
|
+
indent_style = space
|
|
14
|
+
insert_final_newline = true
|
|
15
|
+
trim_trailing_whitespace = true
|
|
16
|
+
|
|
17
|
+
# Make sure package.json always uses 2 spaces to indent
|
|
18
|
+
[{package.json}]
|
|
19
|
+
indent_size = 2
|
|
20
|
+
indent_style = space
|
|
21
|
+
|
|
22
|
+
[{makefile, Makefile}]
|
|
23
|
+
indent_style = tab
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BLOCK_ENTRY_FILES_PATTERN="projects/user-project/src/**/index.{ts,tsx,js,jsx}"
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2018-2024 ArcBlock
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Getting Started with Create Blocklet
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
|
|
4
|
+
|
|
5
|
+
Component Studio is a development tool for creating Pages Kit visual blocks. With this tool, developers can:
|
|
6
|
+
|
|
7
|
+
- Create and manage reusable frontend block components
|
|
8
|
+
- Provide a visual editing interface for easy block configuration and preview
|
|
9
|
+
- Support development of various visualization component types (charts, forms, animations, etc.)
|
|
10
|
+
- Seamlessly integrate into the ArcBlock Blocklet ecosystem
|
|
11
|
+
|
|
12
|
+
## File Structure
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
your-component-studio/
|
|
16
|
+
├── api/ # Backend API code
|
|
17
|
+
│ ├── dev.ts # Development server entry
|
|
18
|
+
│ ├── src/ # API source code directory
|
|
19
|
+
│ └── third.d.ts # Third-party library type declarations
|
|
20
|
+
├── scripts/ # Build and version management scripts
|
|
21
|
+
│ ├── build-clean.mjs # Build cleanup script
|
|
22
|
+
│ └── bump-version.mjs # Version upgrade script
|
|
23
|
+
├── src/ # Frontend source code
|
|
24
|
+
│ ├── HelloWorld/ # Example HelloWorld block
|
|
25
|
+
│ │ └── index.tsx # Block entry
|
|
26
|
+
│ │ └── @metadata.json # Block metadata
|
|
27
|
+
│ │ └── @preview-images/ # Block preview images directory
|
|
28
|
+
│ └── <your-component-name>/ # Your block directory
|
|
29
|
+
│ | └── index.tsx # Block entry
|
|
30
|
+
│ | └── @metadata.json # Block metadata
|
|
31
|
+
│ | └── @preview-images/ # Block preview images directory
|
|
32
|
+
│ └── components/ # Components directory
|
|
33
|
+
│ └── utils/ # Utility functions directory
|
|
34
|
+
│ └── types/ # Type declarations directory
|
|
35
|
+
├── package.json # Project configuration and dependencies
|
|
36
|
+
├── vite.config.mts # Vite client configuration
|
|
37
|
+
└── vite-server.config.ts # Vite server configuration
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Development
|
|
41
|
+
|
|
42
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
43
|
+
|
|
44
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
45
|
+
`npm install -g @blocklet/cli`
|
|
46
|
+
See details in [ https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli#start-blocklet-server]( https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli#start-blocklet-server)
|
|
47
|
+
|
|
48
|
+
2. Init blocklet server & start blocklet server
|
|
49
|
+
|
|
50
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
51
|
+
`blocklet server init`
|
|
52
|
+
`blocklet server start`
|
|
53
|
+
See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli#start-blocklet-server](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli#start-blocklet-server)
|
|
54
|
+
|
|
55
|
+
3. Go to the project directory `cd [name]`
|
|
56
|
+
4. Install dependencies: `npm install` or `yarn`
|
|
57
|
+
5. Start development server: `blocklet dev`
|
|
58
|
+
|
|
59
|
+
## Bundle
|
|
60
|
+
|
|
61
|
+
After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
|
|
62
|
+
|
|
63
|
+
## Deploy
|
|
64
|
+
|
|
65
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle --app-id {appId}` command(Make sure the blocklet is bundled before deployment).
|
|
66
|
+
- appId is the id of the container you want to run on your server, you can see it in your server's dashboard
|
|
67
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
68
|
+
|
|
69
|
+
```shell
|
|
70
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Upload to blocklet store
|
|
74
|
+
|
|
75
|
+
- If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
|
|
76
|
+
|
|
77
|
+
Bump version at first.
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
npm run bump-version
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Connect to a store, You may need some testnet tokens to deploy your blocklet, you can get some from https://faucet.abtnetwork.io/
|
|
84
|
+
|
|
85
|
+
```shell
|
|
86
|
+
blocklet connect https://test.store.blocklet.dev/
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Upload a new version to a store.
|
|
90
|
+
|
|
91
|
+
> Make sure the blocklet is bundled before upload.
|
|
92
|
+
|
|
93
|
+
```shell
|
|
94
|
+
blocklet upload
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Or you can simply use `npm run upload` command.
|
|
98
|
+
|
|
99
|
+
- You also can upload a new version to a store by Github CI.
|
|
100
|
+
Bump version at first.
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
npm run bump-version
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Push your code to Github main/master branch, or make a pull request to the main/master branch.
|
|
107
|
+
The CI workflow will automatically upload a new version to a store.
|
|
108
|
+
|
|
109
|
+
## Q & A
|
|
110
|
+
|
|
111
|
+
1. Q: How to change a blocklet's logo?
|
|
112
|
+
|
|
113
|
+
Change the `logo.png` file root folder.
|
|
114
|
+
|
|
115
|
+
Or you can change the `logo` field in the `blocklet.yml` file.
|
|
116
|
+
|
|
117
|
+
> Make sure you have added the logo path to the `blocklet.yml` file `files` field.
|
|
118
|
+
|
|
119
|
+
## Learn More
|
|
120
|
+
|
|
121
|
+
- 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)
|
|
122
|
+
- Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
The code is licensed under the Apache 2.0 license found in the
|
|
127
|
+
[LICENSE](LICENSE) file.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { setupClient } from 'vite-plugin-blocklet';
|
|
4
|
+
|
|
5
|
+
import { app, server } from './src';
|
|
6
|
+
|
|
7
|
+
(async () => {
|
|
8
|
+
const viteDevServer = await setupClient(app, {
|
|
9
|
+
appType: 'custom',
|
|
10
|
+
server,
|
|
11
|
+
importMetaHot: import.meta.hot,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const html = readFileSync(path.join(__dirname, '../index.html'), 'utf-8');
|
|
15
|
+
const transformedHtml = await viteDevServer.transformIndexHtml('/', html);
|
|
16
|
+
|
|
17
|
+
// Add route to serve the transformed HTML
|
|
18
|
+
app.get('*', (req, res) => {
|
|
19
|
+
res.send(transformedHtml);
|
|
20
|
+
});
|
|
21
|
+
})();
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import 'express-async-errors';
|
|
2
|
+
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
import cookieParser from 'cookie-parser';
|
|
6
|
+
import cors from 'cors';
|
|
7
|
+
import dotenv from 'dotenv-flow';
|
|
8
|
+
import express, { ErrorRequestHandler } from 'express';
|
|
9
|
+
import fallback from '@blocklet/sdk/lib/middlewares/fallback';
|
|
10
|
+
|
|
11
|
+
import logger from './libs/logger';
|
|
12
|
+
import routes from './routes';
|
|
13
|
+
|
|
14
|
+
dotenv.config();
|
|
15
|
+
|
|
16
|
+
const { name, version } = require('../../package.json');
|
|
17
|
+
|
|
18
|
+
export const app = express();
|
|
19
|
+
|
|
20
|
+
app.set('trust proxy', true);
|
|
21
|
+
app.use(cookieParser());
|
|
22
|
+
app.use(express.json({ limit: '1 mb' }));
|
|
23
|
+
app.use(express.urlencoded({ extended: true, limit: '1 mb' }));
|
|
24
|
+
app.use(cors());
|
|
25
|
+
|
|
26
|
+
const router = express.Router();
|
|
27
|
+
router.use(routes);
|
|
28
|
+
|
|
29
|
+
app.use(router);
|
|
30
|
+
|
|
31
|
+
const isProduction = process.env.NODE_ENV === 'production' || process.env.ABT_NODE_SERVICE_ENV === 'production';
|
|
32
|
+
|
|
33
|
+
if (isProduction) {
|
|
34
|
+
const staticDir = path.resolve(process.env.BLOCKLET_APP_DIR!, 'dist');
|
|
35
|
+
app.use(express.static(staticDir, { maxAge: '30d', index: false }));
|
|
36
|
+
app.use(fallback('index.html', { root: staticDir }));
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
|
+
app.use(<ErrorRequestHandler>((err, _req, res, _next) => {
|
|
40
|
+
logger.error(err.stack);
|
|
41
|
+
res.status(500).send('Something broke!');
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const port = parseInt(process.env.BLOCKLET_PORT!, 10);
|
|
46
|
+
|
|
47
|
+
export const server = app.listen(port, (err?: any) => {
|
|
48
|
+
if (err) throw err;
|
|
49
|
+
logger.info(`> ${name} v${version} ready on ${port}`);
|
|
50
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
import AuthStorage from '@arcblock/did-auth-storage-nedb';
|
|
4
|
+
import getWallet from '@blocklet/sdk/lib/wallet';
|
|
5
|
+
import WalletAuthenticator from '@blocklet/sdk/lib/wallet-authenticator';
|
|
6
|
+
import WalletHandler from '@blocklet/sdk/lib/wallet-handler';
|
|
7
|
+
|
|
8
|
+
import env from './env';
|
|
9
|
+
|
|
10
|
+
export const wallet = getWallet();
|
|
11
|
+
export const authenticator = new WalletAuthenticator();
|
|
12
|
+
export const handlers = new WalletHandler({
|
|
13
|
+
authenticator,
|
|
14
|
+
tokenStorage: new AuthStorage({
|
|
15
|
+
dbPath: path.join(env.dataDir, 'auth.db'),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { initBlockStudioRouter } from '@blocklet/pages-kit-block-studio/init-block-studio-router';
|
|
2
|
+
import { initResourceRouter } from '@blocklet/pages-kit-block-studio/init-resource-router';
|
|
3
|
+
import { initUploaderRouter } from '@blocklet/pages-kit-block-studio/init-uploader-router';
|
|
4
|
+
import { Router } from 'express';
|
|
5
|
+
|
|
6
|
+
const router = Router();
|
|
7
|
+
|
|
8
|
+
router.use('/api/resources', initResourceRouter);
|
|
9
|
+
router.use('/api/blocks', initBlockStudioRouter);
|
|
10
|
+
router.use(initUploaderRouter);
|
|
11
|
+
|
|
12
|
+
export default router;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'vite-plugin-blocklet';
|
|
2
|
+
|
|
3
|
+
declare module 'express-history-api-fallback';
|
|
4
|
+
|
|
5
|
+
declare module 'express-async-errors';
|
|
6
|
+
|
|
7
|
+
declare namespace Express {
|
|
8
|
+
interface Request {
|
|
9
|
+
user?: {
|
|
10
|
+
did: string;
|
|
11
|
+
role: string;
|
|
12
|
+
fullName: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
walletOS: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
|
|
3
|
+
"organizeImports": {
|
|
4
|
+
"enabled": true
|
|
5
|
+
},
|
|
6
|
+
"linter": {
|
|
7
|
+
"enabled": true,
|
|
8
|
+
"rules": {
|
|
9
|
+
"recommended": true,
|
|
10
|
+
"correctness": {
|
|
11
|
+
"noUnusedVariables": "error"
|
|
12
|
+
},
|
|
13
|
+
"suspicious": {
|
|
14
|
+
"noExplicitAny": "warn"
|
|
15
|
+
},
|
|
16
|
+
"style": {
|
|
17
|
+
"noNonNullAssertion": "off",
|
|
18
|
+
"useShorthandArrayType": "error"
|
|
19
|
+
},
|
|
20
|
+
"a11y": {
|
|
21
|
+
"noNoninteractiveElementToInteractiveRole": "off",
|
|
22
|
+
"useKeyWithClickEvents": "off",
|
|
23
|
+
"useValidAnchor": "off",
|
|
24
|
+
"noSvgWithoutTitle": "off",
|
|
25
|
+
"useKeyWithMouseEvents": "off"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"ignore": ["**/node_modules/**", "*.md"]
|
|
29
|
+
},
|
|
30
|
+
"formatter": {
|
|
31
|
+
"enabled": true,
|
|
32
|
+
"indentStyle": "space",
|
|
33
|
+
"indentWidth": 2,
|
|
34
|
+
"lineWidth": 100
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Component Studio
|
|
2
|
+
|
|
3
|
+
Component Studio is a development tool for creating Pages Kit visual blocks. With this tool, developers can:
|
|
4
|
+
|
|
5
|
+
- Create and manage reusable frontend block components
|
|
6
|
+
- Provide a visual editing interface for easy block configuration and preview
|
|
7
|
+
- Support development of various visualization component types (charts, forms, animations, etc.)
|
|
8
|
+
- Seamlessly integrate into the ArcBlock Blocklet ecosystem
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
title: component-studio
|
|
2
|
+
description: A Blocklet to help you develop components for Pages Kit
|
|
3
|
+
keywords:
|
|
4
|
+
- blocklet
|
|
5
|
+
- react
|
|
6
|
+
group: dapp
|
|
7
|
+
did: z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM
|
|
8
|
+
main: api/dist/index.js
|
|
9
|
+
author:
|
|
10
|
+
name: Arcblock
|
|
11
|
+
email: blocklet@arcblock.io
|
|
12
|
+
repository:
|
|
13
|
+
type: git
|
|
14
|
+
url: git+https://github.com/blocklet/create-blocklet.git
|
|
15
|
+
specVersion: 1.2.8
|
|
16
|
+
version: 0.1.0
|
|
17
|
+
logo: logo.png
|
|
18
|
+
files:
|
|
19
|
+
- dist
|
|
20
|
+
- logo.png
|
|
21
|
+
- screenshots
|
|
22
|
+
interfaces:
|
|
23
|
+
- type: web
|
|
24
|
+
name: publicUrl
|
|
25
|
+
path: /
|
|
26
|
+
prefix: '*'
|
|
27
|
+
port: BLOCKLET_PORT
|
|
28
|
+
protocol: http
|
|
29
|
+
community: ''
|
|
30
|
+
documentation: ''
|
|
31
|
+
homepage: ''
|
|
32
|
+
license: ''
|
|
33
|
+
payment:
|
|
34
|
+
price: []
|
|
35
|
+
share: []
|
|
36
|
+
timeout:
|
|
37
|
+
start: 60
|
|
38
|
+
requirements:
|
|
39
|
+
server: '>=1.16.28'
|
|
40
|
+
os: '*'
|
|
41
|
+
cpu: '*'
|
|
42
|
+
scripts:
|
|
43
|
+
dev: npm run start
|
|
44
|
+
environments: []
|
|
45
|
+
capabilities: {}
|
|
46
|
+
screenshots: []
|
|
47
|
+
components:
|
|
48
|
+
- name: image-bin
|
|
49
|
+
required: true
|
|
50
|
+
mountPoint: /image-bin
|
|
51
|
+
source:
|
|
52
|
+
name: image-bin
|
|
53
|
+
version: latest
|
|
54
|
+
resource:
|
|
55
|
+
exportApi: /api/resources
|
|
56
|
+
types:
|
|
57
|
+
- type: page
|
|
58
|
+
description: Used by Pages Kit to import one or multiple components
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.ico?imageFilter=convert&f=png&w=32" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<noscript> You need to enable JavaScript to run this app. </noscript>
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
<script type="module" src="/@pages-infra/main.js"></script>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
Binary file
|