Skip to content

Commit 0bc105c

Browse files
author
FalkWolsky
committed
fixing plugin creator
1 parent e5f36ab commit 0bc105c

File tree

10 files changed

+935
-20152
lines changed

10 files changed

+935
-20152
lines changed

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/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default {
2-
projects: ["<rootDir>/packages/lowcoder", "<rootDir>/packages/lowcoder-core"],
2+
projects: ["<rootDir>/packages/lowcoder", "<rootDir>/packages/lowcoder-core", "<rootDir>/packages/lowcoder-dev-utils"],
33
};

client/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"jest": "^29.5.0",
5151
"jest-environment-jsdom": "^29.5.0",
5252
"lint-staged": "^13.0.1",
53-
"lowcoder-dev-utils": "workspace:^",
5453
"mq-polyfill": "^1.1.8",
5554
"prettier": "^2.7.0",
5655
"rimraf": "^3.0.2",
@@ -65,7 +64,7 @@
6564
"**/*.{mjs,ts,tsx,json,md,html}": "prettier --write --ignore-unknown",
6665
"**/*.svg": "svgo"
6766
},
68-
"packageManager": "yarn@3.2.4",
67+
"packageManager": "yarn@3.6.4",
6968
"resolutions": {
7069
"@types/react": "^17",
7170
"moment": "2.29.2",
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
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
8+
```bash
9+
cd /client
10+
```
11+
2) execute the Plugin Builder Script. PLease name your plugin with the prefix lowcoder-comp-
912

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

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

Lines changed: 24 additions & 3 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,25 @@ async function isDirEmpty(dir) {
4652

4753
async function install(dependencies) {
4854
return new Promise((resolve, reject) => {
55+
56+
console.log("install dependencies:", dependencies);
57+
4958
let cmd = "npm";
5059
let args = ["install", "--no-audit", "--save", "--save-exact", "--loglevel", "error"];
5160
if (isUsingYarn) {
5261
cmd = "yarn";
5362
args = ["add"];
5463
}
64+
5565
if (registry) {
5666
args.push("--registry", registry);
5767
}
5868
args.push(...dependencies);
69+
5970
const child = spawn(cmd, args, { stdio: "inherit" });
71+
72+
console.log("spawn child process: ", child);
73+
6074
child.on("close", (code) => {
6175
if (code !== 0) {
6276
reject({
@@ -123,19 +137,26 @@ async function createProject(projectName, options) {
123137
type: "module",
124138
license: "MIT",
125139
};
140+
141+
// now we prepare the files
126142
writePackageJson(packageJsonFile, initialPackageJson);
127-
console.log("initial package.json generated");
143+
// without empty yarn file the setup will fail
144+
writeYarnFile();
128145

129146
await install([
130-
cliPackageName,
147+
// cliPackageName,
131148
sdkPackageName,
149+
devPackageName,
132150
"react@17",
133151
"react-dom@17",
134152
"@types/react@17",
135153
"@types/react-dom@17",
136154
"vite",
137155
]);
138156

157+
console.log("install packages done");
158+
console.log("Now executeNodeScript");
159+
139160
await executeNodeScript(
140161
{
141162
cwd: process.cwd(),

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: 2 additions & 2 deletions
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,7 +39,8 @@
4039
},
4140
"devDependencies": {
4241
"@types/axios": "^0.14.0",
43-
"typescript": "^4.8.4"
42+
"typescript": "^4.8.4",
43+
"lowcoder-dev-utils": "workspace:^"
4444
},
4545
"peerDependencies": {
4646
"lowcoder-sdk": "*"

0 commit comments

Comments
 (0)