Merge remote-tracking branch 'origin/master' into feedback
This commit is contained in:
commit
aa5d3d5af2
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/builder",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"license": "AGPL-3.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -64,7 +64,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^1.44.1",
|
||||
"@budibase/client": "^0.2.5",
|
||||
"@budibase/client": "^0.2.6",
|
||||
"@budibase/colorpicker": "^1.0.1",
|
||||
"@fortawesome/fontawesome-free": "^5.14.0",
|
||||
"@sentry/browser": "5.19.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "budibase",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"description": "Budibase CLI",
|
||||
"repository": "https://github.com/Budibase/Budibase",
|
||||
"homepage": "https://www.budibase.com",
|
||||
|
@ -17,7 +17,7 @@
|
|||
"author": "Budibase",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@budibase/server": "^0.2.5",
|
||||
"@budibase/server": "^0.2.6",
|
||||
"@inquirer/password": "^0.0.6-alpha.0",
|
||||
"chalk": "^2.4.2",
|
||||
"dotenv": "^8.2.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/client",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"license": "MPL-2.0",
|
||||
"main": "dist/budibase-client.js",
|
||||
"module": "dist/budibase-client.esm.mjs",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/server",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"description": "Budibase Web Server",
|
||||
"main": "src/electron.js",
|
||||
"repository": {
|
||||
|
@ -42,7 +42,7 @@
|
|||
"author": "Michael Shanks",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@budibase/client": "^0.2.5",
|
||||
"@budibase/client": "^0.2.6",
|
||||
"@koa/router": "^8.0.0",
|
||||
"@sendgrid/mail": "^7.1.1",
|
||||
"@sentry/node": "^5.19.2",
|
||||
|
@ -57,6 +57,7 @@
|
|||
"electron-updater": "^4.3.1",
|
||||
"fix-path": "^3.0.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"jimp": "^0.16.1",
|
||||
"joi": "^17.2.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"koa": "^2.7.0",
|
||||
|
@ -74,7 +75,6 @@
|
|||
"pouchdb-all-dbs": "^1.0.2",
|
||||
"pouchdb-replication-stream": "^1.2.9",
|
||||
"sanitize-s3-objectkey": "^0.0.1",
|
||||
"sharp": "^0.26.0",
|
||||
"squirrelly": "^7.5.0",
|
||||
"tar-fs": "^2.1.0",
|
||||
"uuid": "^3.3.2",
|
||||
|
|
|
@ -12,6 +12,7 @@ const { join, resolve } = require("../../utilities/centralPath")
|
|||
const { promisify } = require("util")
|
||||
const chmodr = require("chmodr")
|
||||
const { generateAppID, getAppParams } = require("../../db/utils")
|
||||
const packageJson = require("../../../package.json")
|
||||
const {
|
||||
downloadExtractComponentLibraries,
|
||||
} = require("../../utilities/createAppPackage")
|
||||
|
@ -38,7 +39,12 @@ exports.fetchAppPackage = async function(ctx) {
|
|||
const devInstance = application.instances.find(
|
||||
i => i.name === `dev-${clientId}`
|
||||
)
|
||||
setBuilderToken(ctx, ctx.params.applicationId, devInstance._id)
|
||||
setBuilderToken(
|
||||
ctx,
|
||||
ctx.params.applicationId,
|
||||
devInstance._id,
|
||||
application.version
|
||||
)
|
||||
}
|
||||
|
||||
exports.create = async function(ctx) {
|
||||
|
@ -64,6 +70,7 @@ exports.create = async function(ctx) {
|
|||
type: "app",
|
||||
instances: [],
|
||||
userInstanceMap: {},
|
||||
version: packageJson.version,
|
||||
componentLibraries: ["@budibase/standard-components"],
|
||||
name: ctx.request.body.name,
|
||||
template: ctx.request.body.template,
|
||||
|
|
|
@ -51,6 +51,7 @@ exports.authenticate = async ctx => {
|
|||
userId: dbUser._id,
|
||||
accessLevelId: dbUser.accessLevelId,
|
||||
appId: ctx.user.appId,
|
||||
version: app.version,
|
||||
instanceId,
|
||||
}
|
||||
// if in cloud add the user api key
|
||||
|
|
|
@ -5,7 +5,6 @@ const fs = require("fs-extra")
|
|||
const uuid = require("uuid")
|
||||
const AWS = require("aws-sdk")
|
||||
const { prepareUploadForS3 } = require("./deploy/aws")
|
||||
|
||||
const {
|
||||
budibaseAppsDir,
|
||||
budibaseTempDir,
|
||||
|
@ -15,6 +14,9 @@ const setBuilderToken = require("../../utilities/builder/setBuilderToken")
|
|||
const fileProcessor = require("../../utilities/fileProcessor")
|
||||
const { AuthTypes } = require("../../constants")
|
||||
|
||||
// this was the version before we started versioning the component library
|
||||
const COMP_LIB_BASE_APP_VERSION = "0.2.5"
|
||||
|
||||
exports.serveBuilder = async function(ctx) {
|
||||
let builderPath = resolve(__dirname, "../../../builder")
|
||||
if (ctx.file === "index.html") {
|
||||
|
@ -163,15 +165,14 @@ exports.serveApp = async function(ctx) {
|
|||
|
||||
exports.serveAttachment = async function(ctx) {
|
||||
const appId = ctx.user.appId
|
||||
|
||||
const attachmentsPath = resolve(budibaseAppsDir(), appId, "attachments")
|
||||
|
||||
// Serve from CloudFront
|
||||
if (process.env.CLOUD) {
|
||||
const S3_URL = `https://cdn.app.budi.live/assets/${appId}/attachments/${ctx.file}`
|
||||
|
||||
const response = await fetch(S3_URL)
|
||||
const body = await response.text()
|
||||
ctx.set("Content-Type", response.headers.get("Content-Type"))
|
||||
ctx.body = body
|
||||
return
|
||||
}
|
||||
|
@ -213,11 +214,16 @@ exports.serveComponentLibrary = async function(ctx) {
|
|||
)
|
||||
}
|
||||
|
||||
// TODO: component libs should be versioned based on app version
|
||||
if (process.env.CLOUD) {
|
||||
let componentLib = "componentlibrary"
|
||||
if (ctx.user.version) {
|
||||
componentLib += `-${ctx.user.version}`
|
||||
} else {
|
||||
componentLib += `-${COMP_LIB_BASE_APP_VERSION}`
|
||||
}
|
||||
const appId = ctx.query.appId
|
||||
const S3_URL = encodeURI(
|
||||
`https://${appId}.app.budi.live/assets/componentlibrary/${ctx.query.library}/dist/index.js`
|
||||
`https://${appId}.app.budi.live/assets/${componentLib}/${ctx.query.library}/dist/index.js`
|
||||
)
|
||||
const response = await fetch(S3_URL)
|
||||
const body = await response.text()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
const Router = require("@koa/router")
|
||||
const StatusCodes = require("../../utilities/statusCodes")
|
||||
const joiValidator = require("../../middleware/joi-validator")
|
||||
const Joi = require("joi")
|
||||
const {
|
||||
listScreens,
|
||||
saveScreen,
|
||||
|
@ -12,6 +14,33 @@ const { BUILDER } = require("../../utilities/accessLevels")
|
|||
|
||||
const router = Router()
|
||||
|
||||
function generateSaveValidation() {
|
||||
// prettier-ignore
|
||||
return joiValidator.body(Joi.object({
|
||||
_css: Joi.string().allow(""),
|
||||
name: Joi.string().required(),
|
||||
route: Joi.string().required(),
|
||||
props: Joi.object({
|
||||
_id: Joi.string().required(),
|
||||
_component: Joi.string().required(),
|
||||
_children: Joi.array().required(),
|
||||
_instanceName: Joi.string().required(),
|
||||
_styles: Joi.object().required(),
|
||||
type: Joi.string().optional(),
|
||||
table: Joi.string().optional(),
|
||||
}).required().unknown(true),
|
||||
}).unknown(true))
|
||||
}
|
||||
|
||||
function generatePatchValidation() {
|
||||
return joiValidator.body(
|
||||
Joi.object({
|
||||
oldname: Joi.string().required(),
|
||||
newname: Joi.string().required(),
|
||||
}).unknown(true)
|
||||
)
|
||||
}
|
||||
|
||||
router.post(
|
||||
"/_builder/api/:appId/pages/:pageName",
|
||||
authorized(BUILDER),
|
||||
|
@ -42,6 +71,7 @@ router.get(
|
|||
router.post(
|
||||
"/_builder/api/:appId/pages/:pagename/screen",
|
||||
authorized(BUILDER),
|
||||
generateSaveValidation(),
|
||||
async ctx => {
|
||||
ctx.body = await saveScreen(
|
||||
ctx.config,
|
||||
|
@ -56,6 +86,7 @@ router.post(
|
|||
router.patch(
|
||||
"/_builder/api/:appname/pages/:pagename/screen",
|
||||
authorized(BUILDER),
|
||||
generatePatchValidation(),
|
||||
async ctx => {
|
||||
await renameScreen(
|
||||
ctx.config,
|
||||
|
|
|
@ -7,6 +7,7 @@ const {
|
|||
BUILDER_LEVEL_ID,
|
||||
generateAdminPermissions,
|
||||
} = require("../../../utilities/accessLevels")
|
||||
const packageJson = require("../../../../package")
|
||||
const jwt = require("jsonwebtoken")
|
||||
const env = require("../../../environment")
|
||||
|
||||
|
@ -214,6 +215,7 @@ const createUserWithPermissions = async (
|
|||
userId: "ANON",
|
||||
accessLevelId: ANON_LEVEL_ID,
|
||||
appId: appId,
|
||||
version: packageJson.version,
|
||||
}
|
||||
|
||||
const anonToken = jwt.sign(anonUser, env.JWT_SECRET)
|
||||
|
|
|
@ -15,4 +15,5 @@ module.exports = {
|
|||
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
||||
AWS_REGION: process.env.AWS_REGION,
|
||||
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
|
||||
BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY,
|
||||
}
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
const { BUILDER_LEVEL_ID } = require("../accessLevels")
|
||||
const environment = require("../../environment")
|
||||
const jwt = require("jsonwebtoken")
|
||||
|
||||
module.exports = (ctx, appId, instanceId) => {
|
||||
module.exports = (ctx, appId, instanceId, version) => {
|
||||
const builderUser = {
|
||||
userId: "BUILDER",
|
||||
accessLevelId: BUILDER_LEVEL_ID,
|
||||
instanceId,
|
||||
appId,
|
||||
version,
|
||||
}
|
||||
if (process.env.BUDIBASE_API_KEY) {
|
||||
builderUser.apiKey = process.env.BUDIBASE_API_KEY
|
||||
if (environment.BUDIBASE_API_KEY) {
|
||||
builderUser.apiKey = environment.BUDIBASE_API_KEY
|
||||
}
|
||||
const token = jwt.sign(builderUser, ctx.config.jwtSecret, {
|
||||
expiresIn: "30 days",
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
const fs = require("fs")
|
||||
const sharp = require("sharp")
|
||||
const jimp = require("jimp")
|
||||
const fsPromises = fs.promises
|
||||
|
||||
const FORMATS = {
|
||||
IMAGES: ["png", "jpg", "jpeg", "gif", "svg", "tiff", "raw"],
|
||||
IMAGES: ["png", "jpg", "jpeg", "gif", "bmp", "tiff"],
|
||||
}
|
||||
|
||||
async function processImage(file) {
|
||||
const imgMeta = await sharp(file.path)
|
||||
.resize(300)
|
||||
.toFile(file.outputPath)
|
||||
return {
|
||||
...file,
|
||||
...imgMeta,
|
||||
}
|
||||
function processImage(file) {
|
||||
return jimp.read(file.path).then(img => {
|
||||
return img.resize(300, jimp.AUTO).write(file.outputPath)
|
||||
})
|
||||
}
|
||||
|
||||
async function process(file) {
|
||||
if (FORMATS.IMAGES.includes(file.extension.toLowerCase())) {
|
||||
return await processImage(file)
|
||||
await processImage(file)
|
||||
return file
|
||||
}
|
||||
|
||||
// No processing required
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,14 +6,14 @@
|
|||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"prepublishOnly": "npm run build",
|
||||
"postpublish": "scripts/deploy.sh",
|
||||
"postpublish": "node scripts/deploy.js",
|
||||
"testbuild": "rollup -w -c rollup.testconfig.js",
|
||||
"dev": "run-p start:dev testbuild",
|
||||
"start:dev": "sirv public --single --dev",
|
||||
"dev:builder": "rollup -cw"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@budibase/client": "^0.2.5",
|
||||
"@budibase/client": "^0.2.6",
|
||||
"@rollup/plugin-commonjs": "^11.1.0",
|
||||
"lodash": "^4.17.15",
|
||||
"rollup": "^2.11.2",
|
||||
|
@ -31,7 +31,7 @@
|
|||
"keywords": [
|
||||
"svelte"
|
||||
],
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"license": "MIT",
|
||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691",
|
||||
"dependencies": {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
const packageJson = require("../package.json")
|
||||
const { execSync } = require("child_process")
|
||||
const fs = require("fs")
|
||||
|
||||
const TO_SYNC = "dist/"
|
||||
const BUCKET_LOCATION = "s3://prod-budi-app-assets/assets"
|
||||
const BASE_PROFILE = "budibase"
|
||||
const S3_COMP_DIR = "@budibase/standard-components/dist"
|
||||
const MANIFEST = "componentlibrary-latest.json"
|
||||
|
||||
function buildS3Path() {
|
||||
return `${BUCKET_LOCATION}/componentlibrary-${packageJson.version}/${S3_COMP_DIR}`
|
||||
}
|
||||
|
||||
async function run() {
|
||||
let profile = process.env.AWS_PROFILE
|
||||
if (profile == null) {
|
||||
profile = BASE_PROFILE
|
||||
}
|
||||
// basic manifest file describing the latest
|
||||
fs.writeFileSync(
|
||||
MANIFEST,
|
||||
JSON.stringify({
|
||||
version: packageJson.version,
|
||||
dir: S3_COMP_DIR,
|
||||
})
|
||||
)
|
||||
execSync(`aws s3 sync ${TO_SYNC} ${buildS3Path()} --profile ${profile}`)
|
||||
execSync(
|
||||
`aws s3 cp ${MANIFEST} ${BUCKET_LOCATION}/${MANIFEST} --profile ${profile}`
|
||||
)
|
||||
fs.unlinkSync(MANIFEST)
|
||||
}
|
||||
|
||||
run()
|
||||
.then(() => {
|
||||
console.log(`Deployment complete, version ${packageJson.version}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
})
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
aws s3 sync dist s3://prod-budi-app-assets/assets/componentlibrary/@budibase/standard-components/dist --profile budibase
|
Loading…
Reference in New Issue