Skip to content

Commit 812097a

Browse files
committed
NocoDB datasource for Budibase
0 parents  commit 812097a

File tree

16 files changed

+6910
-0
lines changed

16 files changed

+6910
-0
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v1
17+
with:
18+
node-version: 18
19+
- name: Make the production plugin bundle
20+
run: |
21+
release_version=$(cat package.json | jq -r '.version')
22+
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
23+
yarn
24+
yarn build
25+
- name: Perform Github Release
26+
uses: softprops/action-gh-release@v1
27+
with:
28+
name: v${{ env.RELEASE_VERSION }}
29+
tag_name: v${{ env.RELEASE_VERSION }}
30+
generate_release_notes: true
31+
files: |
32+
dist/*.tar.gz

.gitignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port
105+
106+
.idea/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.github
3+
rollup.config.js

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# NocoDB
2+
This is a readme for your new Budibase plugin.
3+
4+
# Description
5+
Minimized no-code database
6+
7+
Find out more about [Budibase](https://github.com/Budibase/budibase).
8+
9+
## Instructions
10+
11+
To build your new plugin run the following in your Budibase CLI:
12+
```
13+
budi plugins --build
14+
```
15+
16+
You can also re-build everytime you make a change to your plugin with the command:
17+
```
18+
budi plugins --watch
19+
```

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
3+
}

icon.svg

Lines changed: 44 additions & 0 deletions
Loading

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
transform: {
5+
"^.+\\.ts?$": "ts-jest",
6+
},
7+
transformIgnorePatterns: ["<rootDir>/node_modules/"]
8+
}

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "NocoDB",
3+
"version": "1.0.0",
4+
"description": "Minimized no-code database",
5+
"main": "src/index.ts",
6+
"license": "MIT",
7+
"scripts": {
8+
"build": "rollup -c",
9+
"watch": "rollup -cw"
10+
},
11+
"dependencies": {
12+
"@budibase/types": "^2.0.13",
13+
"node-fetch": "^2"
14+
},
15+
"devDependencies": {
16+
"@budibase/backend-core": "^2.0.13",
17+
"@babel/core": "^7.19.0",
18+
"@babel/preset-env": "^7.19.0",
19+
"@jest/globals": "^29.0.3",
20+
"@rollup/plugin-commonjs": "^22.0.2",
21+
"@rollup/plugin-node-resolve": "^13.3.0",
22+
"@rollup/plugin-typescript": "^8.3.4",
23+
"@types/node-fetch": "^2.6.2",
24+
"babel-jest": "^29.0.3",
25+
"jest": "^29.0.3",
26+
"npm-run-all": "^4.1.5",
27+
"rollup": "^2.44.0",
28+
"rollup-plugin-copy2": "^0.3.1",
29+
"rollup-plugin-json": "^4.0.0",
30+
"rollup-plugin-terser": "^7.0.2",
31+
"tar": "^6.1.11",
32+
"ts-jest": "^29.0.0",
33+
"ts-node": "^10.9.1",
34+
"tslib": "^2.4.0",
35+
"typescript": "^4.8.2"
36+
}
37+
}

rollup.config.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import resolve from "@rollup/plugin-node-resolve"
2+
import commonjs from "@rollup/plugin-commonjs"
3+
import { terser } from "rollup-plugin-terser"
4+
import json from "rollup-plugin-json"
5+
import copy from "rollup-plugin-copy2"
6+
import typescript from "@rollup/plugin-typescript"
7+
import tar from "tar"
8+
import fs from "fs"
9+
import pkg from "./package.json"
10+
import crypto from "crypto"
11+
import { validate } from "@budibase/backend-core/plugins"
12+
13+
const iconFile = "icon.svg"
14+
const iconExists = fs.existsSync(iconFile)
15+
const assets = ["schema.json", "package.json"]
16+
if (iconExists) {
17+
assets.push(iconFile)
18+
}
19+
20+
// Custom plugin to clean the dist folder before building
21+
const clean = () => ({
22+
buildStart() {
23+
const dist = "./dist/"
24+
if (fs.existsSync(dist)) {
25+
fs.readdirSync(dist).forEach(path => {
26+
if (path.endsWith(".tar.gz")) {
27+
fs.unlinkSync(dist + path)
28+
}
29+
})
30+
}
31+
},
32+
})
33+
34+
// Custom plugin to hash the JS bundle and write it in the schema
35+
const hash = () => ({
36+
writeBundle() {
37+
// Generate JS hash
38+
const fileBuffer = fs.readFileSync("dist/plugin.min.js")
39+
const hashSum = crypto.createHash("sha1")
40+
hashSum.update(fileBuffer)
41+
const hex = hashSum.digest("hex")
42+
43+
// Read and parse existing schema from dist folder
44+
const schema = JSON.parse(fs.readFileSync("./dist/schema.json", "utf8"))
45+
46+
// Write updated schema to dist folder, pretty printed as JSON again
47+
const newSchema = {
48+
...schema,
49+
hash: hex,
50+
version: pkg.version,
51+
}
52+
fs.writeFileSync("./dist/schema.json", JSON.stringify(newSchema, null, 2))
53+
},
54+
})
55+
56+
// Custom plugin to bundle up our files after building
57+
const bundle = () => ({
58+
async writeBundle() {
59+
const bundleName = `${pkg.name}-${pkg.version}.tar.gz`
60+
return tar
61+
.c({ gzip: true, cwd: "dist" }, [...assets, "plugin.min.js"])
62+
.pipe(fs.createWriteStream(`dist/${bundleName}`))
63+
},
64+
})
65+
66+
const validateSchema = () => ({
67+
buildStart() {
68+
const schema = fs.readFileSync("schema.json", "utf8")
69+
validate(JSON.parse(schema))
70+
}
71+
})
72+
73+
export default {
74+
input: "src/index.ts",
75+
output: {
76+
sourcemap: false,
77+
format: "cjs",
78+
file: "dist/plugin.min.js",
79+
inlineDynamicImports: true,
80+
exports: "default",
81+
},
82+
plugins: [
83+
validateSchema(),
84+
clean(),
85+
resolve({
86+
preferBuiltins: true,
87+
browser: false,
88+
exportConditions: ["node"]
89+
}),
90+
typescript({
91+
compilerOptions: {
92+
target: "es6",
93+
module: "esnext",
94+
lib: ["es2020"],
95+
allowJs: true,
96+
strict: true,
97+
noImplicitAny: true,
98+
esModuleInterop: true,
99+
resolveJsonModule: true,
100+
types: ["node"],
101+
skipLibCheck: true,
102+
moduleResolution: "node",
103+
},
104+
include: ["./src/**/*"],
105+
exclude: ["node_modules", "dist", "**/*.spec.ts", "**/*.spec.js"],
106+
}),
107+
commonjs(),
108+
json(),
109+
terser(),
110+
copy({
111+
assets,
112+
}),
113+
hash(),
114+
bundle(),
115+
],
116+
}

0 commit comments

Comments
 (0)