Skip to content

Commit 756b294

Browse files
authored
Merge pull request #567 from lowcoder-org/fix-plugin-creator
Fix plugin creator
2 parents dcd674c + 7440e1a commit 756b294

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+4935
-10271
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ client/.yarn/cache/*.zip
55
server/node-service/.yarn/cache/*.zip
66
.metadata/
77
.DS_Store
8+
client/node_modules/

client/.yarn/releases/yarn-3.2.4.cjs

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

client/.yarn/releases/yarn-3.6.4.cjs

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.

client/.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ plugins:
66
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
77
spec: "@yarnpkg/plugin-workspace-tools"
88

9-
yarnPath: .yarn/releases/yarn-3.2.4.cjs
9+
yarnPath: .yarn/releases/yarn-3.6.4.cjs

client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"lint-staged": "^13.0.1",
5353
"lowcoder-dev-utils": "workspace:^",
5454
"mq-polyfill": "^1.1.8",
55-
"prettier": "^2.7.0",
55+
"prettier": "3.1.0",
5656
"rimraf": "^3.0.2",
5757
"rollup": "^2.79.0",
5858
"shelljs": "^0.8.5",
@@ -65,7 +65,7 @@
6565
"**/*.{mjs,ts,tsx,json,md,html}": "prettier --write --ignore-unknown",
6666
"**/*.svg": "svgo"
6767
},
68-
"packageManager": "yarn@3.2.4",
68+
"packageManager": "yarn@3.6.4",
6969
"resolutions": {
7070
"@types/react": "^17",
7171
"moment": "2.29.2",
Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
11
# create-lowcoder-plugin
22

3-
## Usage
3+
## How to build a Component Plugin
44

5-
```bash
6-
yarn create lowcoder-plugin my-lowcoder-plugin
5+
This script helps you to create a skeleton Lowcoder Component, which you can then publish on npm and use it as imported Plugin in any app.
76

8-
# or
7+
1) Navigate your terminal or bash to /client and install general dependencies
8+
```bash
9+
cd client
10+
yarn install
11+
```
12+
1) execute the Plugin Builder Script. PLease name your plugin with the prefix lowcoder-comp-
913

10-
npm create lowcoder-plugin my-lowcoder-plugin
14+
```bash
15+
npm create lowcoder-plugin lowcoder-comp-my-plugin
1116
```
17+
3) Navigate your terminal or bash to the newly created Plugin folder
18+
```bash
19+
cd lowcoder-comp-my-plugin
20+
```
21+
4) install all dependencies:
22+
```bash
23+
yarn install
24+
```
25+
Now you can start your Plugin in the playground, so during development you have a realtime preview.
26+
4) install all dependencies:
27+
```bash
28+
yarn start
29+
```
30+
This will start the local development server and open a browser on http://localhost:9000
31+
32+
## How to publish a Component Plugin
33+
34+
With the following command you can publish the script to the NPM repository:
35+
```bash
36+
yarn build --publish
37+
```

client/packages/create-lowcoder-plugin/index.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import { readJson, currentDirName } from "../lowcoder-dev-utils/util.js";
1010
const currentDir = currentDirName(import.meta.url);
1111
const pkg = readJson(path.resolve(currentDir, "./package.json"));
1212

13-
const isUsingYarn = (process.env.npm_config_user_agent || "").indexOf("yarn") === 0;
13+
const isUsingYarn = true;
14+
// const isUsingYarn = (process.env.npm_config_user_agent || "").indexOf("yarn") === 0;
1415
const cliPackageName = "lowcoder-cli";
1516
const sdkPackageName = "lowcoder-sdk";
17+
const devPackageName = "lowcoder-dev-utils";
1618

1719
let verbose = false;
1820
let registry;
@@ -36,6 +38,10 @@ function writePackageJson(file, content) {
3638
writeFileSync(file, JSON.stringify(content, null, 2));
3739
}
3840

41+
function writeYarnFile() {
42+
writeFileSync("yarn.lock", "");
43+
}
44+
3945
async function isDirEmpty(dir) {
4046
if (!existsSync(dir)) {
4147
return true;
@@ -46,17 +52,21 @@ async function isDirEmpty(dir) {
4652

4753
async function install(dependencies) {
4854
return new Promise((resolve, reject) => {
55+
4956
let cmd = "npm";
5057
let args = ["install", "--no-audit", "--save", "--save-exact", "--loglevel", "error"];
5158
if (isUsingYarn) {
5259
cmd = "yarn";
5360
args = ["add"];
5461
}
62+
5563
if (registry) {
5664
args.push("--registry", registry);
5765
}
5866
args.push(...dependencies);
67+
5968
const child = spawn(cmd, args, { stdio: "inherit" });
69+
6070
child.on("close", (code) => {
6171
if (code !== 0) {
6272
reject({
@@ -111,8 +121,6 @@ async function createProject(projectName, options) {
111121
}
112122
}
113123

114-
console.log("is using yarn:", isUsingYarn);
115-
116124
const packageJsonFile = path.resolve(root, "package.json");
117125
fs.ensureDirSync(root);
118126
process.chdir(root);
@@ -123,12 +131,16 @@ async function createProject(projectName, options) {
123131
type: "module",
124132
license: "MIT",
125133
};
134+
135+
// now we prepare the files
126136
writePackageJson(packageJsonFile, initialPackageJson);
127-
console.log("initial package.json generated");
137+
// without empty yarn file the setup will fail
138+
writeYarnFile();
128139

129140
await install([
130-
cliPackageName,
141+
// cliPackageName,
131142
sdkPackageName,
143+
devPackageName,
132144
"react@17",
133145
"react-dom@17",
134146
"@types/react@17",

client/packages/create-lowcoder-plugin/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"fs-extra": "^10.1.0",
1111
"lowcoder-dev-utils": "workspace:^"
1212
},
13+
"devDependencies": {
14+
"lowcoder-dev-utils": "workspace:^"
15+
},
1316
"license": "MIT",
1417
"keywords": [
1518
"lowcoder"

client/packages/lowcoder-cli-template-typescript/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
},
1818
"devDependencies": {
1919
"lowcoder-cli": "workspace:^",
20+
"lowcoder-dev-utils": "workspace:^",
2021
"lowcoder-sdk": "workspace:^",
2122
"typescript": "^4.8.4",
2223
"vite": "^4.3.9"
2324
},
2425
"keywords": [
25-
"lowcoder"
26+
"Lowcoder, Component, Template, Plugin"
2627
],
2728
"license": "MIT"
2829
}

client/packages/lowcoder-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"commander": "^9.4.1",
3030
"cross-spawn": "^7.0.3",
3131
"fs-extra": "^10.1.0",
32-
"lowcoder-dev-utils": "workspace:^",
3332
"react": "^17",
3433
"react-dom": "^17",
3534
"react-json-view": "^1.21.3",
@@ -40,6 +39,7 @@
4039
},
4140
"devDependencies": {
4241
"@types/axios": "^0.14.0",
42+
"lowcoder-dev-utils": "workspace:^",
4343
"typescript": "^4.8.4"
4444
},
4545
"peerDependencies": {

client/packages/lowcoder-sdk/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
"vite-plugin-svgr": "^2.2.2",
4949
"vite-tsconfig-paths": "^3.6.0"
5050
},
51+
"dependencies": {
52+
"typedoc": "^0.25.4"
53+
},
5154
"peerDependencies": {
5255
"react": ">=17",
5356
"react-dom": ">=17"

client/packages/lowcoder/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"moment": "^2.29.4",
6565
"numbro": "^2.3.6",
6666
"papaparse": "^5.3.2",
67+
"prettier": "3.1.0",
6768
"qrcode.react": "^3.1.0",
6869
"rc-trigger": "^5.3.1",
6970
"react": "^17.0.2",

client/yarn-output.log

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
➤ YN0000: ┌ Resolution step
2+
➤ YN0001: │ Error: lowcoder-dev-utils@workspace:^: Workspace not found (lowcoder-dev-utils@workspace:^)
3+
at je.getWorkspaceByDescriptor (/Users/falkwolskyadmin/Development/Lowcoder/Development/lowcoder/client/.yarn/releases/yarn-3.6.4.cjs:439:3260)
4+
at cC.getCandidates (/Users/falkwolskyadmin/Development/Lowcoder/Development/lowcoder/client/.yarn/releases/yarn-3.6.4.cjs:390:29582)
5+
at kf.getCandidates (/Users/falkwolskyadmin/Development/Lowcoder/Development/lowcoder/client/.yarn/releases/yarn-3.6.4.cjs:391:1264)
6+
at kf.getCandidates (/Users/falkwolskyadmin/Development/Lowcoder/Development/lowcoder/client/.yarn/releases/yarn-3.6.4.cjs:391:1264)
7+
at /Users/falkwolskyadmin/Development/Lowcoder/Development/lowcoder/client/.yarn/releases/yarn-3.6.4.cjs:439:8033
8+
at df (/Users/falkwolskyadmin/Development/Lowcoder/Development/lowcoder/client/.yarn/releases/yarn-3.6.4.cjs:390:11070)
9+
at ge (/Users/falkwolskyadmin/Development/Lowcoder/Development/lowcoder/client/.yarn/releases/yarn-3.6.4.cjs:439:8013)
10+
➤ YN0000: └ Completed in 0s 878ms
11+
➤ YN0000: Failed with errors in 0s 882ms

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy