Skip to content

Commit

Permalink
initail commit
Browse files Browse the repository at this point in the history
  • Loading branch information
knight.chen committed Jun 27, 2022
1 parent a5f7f96 commit 5962bac
Show file tree
Hide file tree
Showing 23 changed files with 876 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space

[*.md]
trim_trailing_whitespace = false

[*.{ts,tsx,vue,less}]
indent_size = 2

trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example
12 changes: 12 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
browser: true,
},
parserOptions: {
ecmaVersion: 2020,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
};
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
pnpm-lock.yaml

.ice
.tmp
build
node_modules
.DS_Store
es
lib
dist
temp
dist-ssr
coverage

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"singleQuote": true,
"proseWrap": "preserve",
"tabWidth": 2,
"useTabs": false,
"endOfLine": "auto",
"bracketSpacing": true,
"stylelintIntegration": true,
"eslintIntegration": true,
"semi": true,
"vueIndentScriptAndStyle": false,
"printWidth": 90
}
23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
"files.associations": {
"*.svg": "html",
"*.env*": "ini",
"api-*.json": "jsonc"
},
"css.validate": false,
"less.validate": false,
"scss.validate": false,
"prettier.enable": true,
"eslint.validate": ["vue", "ts", "tsx"],
"volar.autoCompleteRefs": false,
"volar.codeLens.scriptSetupTools": false,
"volar.codeLens.references": false,
"volar.completion.autoImportComponent": false,
"volar.completion.preferredTagNameCase": "kebab",
"stylelint.validate": ["css", "less", "postcss", "vue"]
}
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# build plugin lowcode

> 编译 vue 自定义组件的 编译插件,基于 `@alib/build-scripts`
## 运行 example

```bash
pnpm install
cd exmaple
pnpm install
pnpm start
```

## 如何与 lowcode engine 集成

编译会生成两个文件:

- `view.js` 组件库代码
- `meta.js` 组件库 meta 信息

将下面 JSON 内容添加到物料中

```json
{
"packages": [
{
"package": "@knxcloud/example-component", // 组件名,务必修改为自己的组件包名
"version": "1.0.0", // 组件版本号,务必修改为自己的组件版本号
"urls": ["http://localhost:3333/view.js"],
"library": "KnxLcUi" // 为 build.json library 字段值
}
],
"components": [
{
"exportName": "KnxLcUiMeta", // 为 build.json library 字段值 + Meta 后缀
"npm": {
"package": "@knxcloud/example-component", // 组件名,务必修改为自己的组件包名
"version": "1.0.0" // 组件版本号,务必修改为自己的组件版本号
},
"url": "http://localhost:3333/meta.js"
}
],
"sort": {
"groupList": ["精选组件", "原子组件"],
"categoryList": [
"基础元素",
"布局容器类",
"表格类",
"表单详情类",
"帮助类",
"对话框类",
"业务类",
"通用",
"引导",
"信息输入",
"信息展示",
"信息反馈"
]
}
}
```
9 changes: 9 additions & 0 deletions example/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"publicPath": "/",
"library": "KnxLcUi",
"externals": {
"vue": "var window.Vue",
"@knx/kui": "var window.Kui"
},
"plugins": ["../"]
}
27 changes: 27 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@knxcloud/example-component",
"version": "1.0.0",
"description": "A component library based on Naive",
"files": [
"dist/"
],
"main": "dist/view.js",
"scripts": {
"start": "build-scripts start",
"build": "build-scripts build"
},
"dependencies": {
"naive-ui": "^2.30.6"
},
"peerDependencies": {
"vue": ">=3.2"
},
"devDependencies": {
"@alib/build-scripts": "^0.1.32",
"@alilc/lowcode-types": "^1.0.10",
"@babel/core": "^7.18.5",
"@vue/tsconfig": "^0.1.3",
"typescript": "~4.7.4",
"vue": "^3.2.37"
}
}
13 changes: 13 additions & 0 deletions example/src/components/button/Button.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<div className="example">
{{ title }}
<n-button v-bind="$attrs">
<slot></slot>
</n-button>
</div>
</template>

<script lang="ts" setup>
import { NButton } from 'naive-ui';
defineProps<{ title?: string }>();
</script>
1 change: 1 addition & 0 deletions example/src/components/button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Button } from './Button.vue';
52 changes: 52 additions & 0 deletions example/src/components/button/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { ComponentMetadata } from '@alilc/lowcode-types';

const ButtonMeta: ComponentMetadata = {
group: '原子组件',
category: '基础组件',
componentName: 'Button',
title: 'Button',
docUrl: '',
screenshot: '',
devMode: 'proCode',
npm: {
package: '@knxcloud/example-component',
version: '1.0.0',
exportName: 'Button',
destructuring: true,
},
configure: {
props: [
{
title: {
label: {
type: 'i18n',
'en-US': 'title',
'zh-CN': 'title',
},
},
name: 'title',
setter: {
componentName: 'StringSetter',
isRequired: true,
initialValue: '',
},
},
],
supports: {
style: true,
},
component: {},
},
snippets: [
{
title: 'Button',
screenshot: '',
schema: {
componentName: 'Button',
props: {},
},
},
],
};

export default ButtonMeta;
12 changes: 12 additions & 0 deletions example/src/components/input/Input.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<div className="example">
{{ title }}
<n-input v-bind="$attrs" />
</div>
</template>

<script lang="ts" setup>
import { NInput } from 'naive-ui';
defineProps<{ title: string }>();
</script>
1 change: 1 addition & 0 deletions example/src/components/input/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Input } from './Input.vue';
46 changes: 46 additions & 0 deletions example/src/components/input/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { ComponentMetadata } from '@alilc/lowcode-types';

const InputMeta: ComponentMetadata = {
group: '原子组件',
category: '表单组件',
componentName: 'Input',
title: 'Input',
docUrl: '',
screenshot: '',
devMode: 'proCode',
npm: {
package: '@knxcloud/example-component',
version: '1.0.0',
exportName: 'Input',
destructuring: true,
},
configure: {
props: [
{
name: 'title',
title: 'title',
setter: {
componentName: 'StringSetter',
isRequired: true,
initialValue: '',
},
},
],
supports: {
style: true,
},
component: {},
},
snippets: [
{
title: 'Input',
screenshot: '',
schema: {
componentName: 'Input',
props: {},
},
},
],
};

export default InputMeta;
4 changes: 4 additions & 0 deletions example/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Button } from './components/button';
import { Input } from './components/input';

export { Button, Input };
5 changes: 5 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["./src/*.ts", "./src/*.tsx", "./src/*.vue"],
"exclude": ["node_modules", "build", "public"]
}
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@knxcloud/build-plugin-lowcode",
"version": "1.0.0",
"main": "./src/index.js",
"files": [
"src"
],
"dependencies": {
"@vue/babel-preset-app": "^5.0.6",
"build-scripts-config": "^3.0.3",
"chokidar": "^3.5.3",
"fast-glob": "^3.2.11",
"handlebars": "^4.7.7",
"is-wsl": "^2.2.0",
"lodash": "^4.17.21",
"vue-loader": "^17.0.0",
"webpack-virtual-modules": "^0.4.3"
},
"devDependencies": {
"@babel/core": "^7.18.5",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.7.1",
"vue": "^3.2.37",
"webpack": "^4.46.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
Loading

0 comments on commit 5962bac

Please sign in to comment.