From a945b52f9a4cacf43540474c239ebbe1dee6f3cb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 7 Nov 2023 19:15:40 +0100 Subject: [PATCH] Rename dev:builder to dev (unifying account-portal) --- package.json | 8 +-- packages/builder/package.json | 4 +- packages/client/package.json | 4 +- packages/server/package.json | 4 +- packages/shared-core/package.json | 4 +- packages/string-templates/README.md | 92 +++++++++++++++----------- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 4 +- 9 files changed, 68 insertions(+), 56 deletions(-) diff --git a/package.json b/package.json index 40b38fbd53..56030a0883 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,10 @@ "kill-builder": "kill-port 3000", "kill-server": "kill-port 4001 4002", "kill-accountportal": "kill-port 3001 4003", - "kill-all": "yarn run kill-builder && yarn run kill-server", - "dev": "yarn run kill-all && lerna run --parallel prebuild && lerna run --stream dev:builder", - "dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream dev:builder --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker", - "dev:server": "yarn run kill-server && lerna run --stream dev:builder --scope @budibase/worker --scope @budibase/server", + "kill-all": "yarn run kill-builder && yarn run kill-server && yarn kill-accountportal", + "dev": "yarn run kill-all && lerna run --parallel prebuild && lerna run --stream dev --ignore=@budibase/account-portal-ui --ignore @budibase/account-portal-server", + "dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream dev --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker", + "dev:server": "yarn run kill-server && lerna run --stream dev --scope @budibase/worker --scope @budibase/server", "dev:accountportal": "yarn kill-accountportal && lerna run dev --stream --scope @budibase/account-portal-ui --scope @budibase/account-portal-server", "dev:built": "yarn run kill-all && cd packages/server && yarn dev:stack:up && cd ../../ && lerna run --stream dev:built", "dev:docker": "yarn build --scope @budibase/server --scope @budibase/worker && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0", diff --git a/packages/builder/package.json b/packages/builder/package.json index dd89518dce..9472c51965 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "routify -b && vite build --emptyOutDir", "start": "routify -c rollup", - "dev:builder": "routify -c dev:vite", + "dev": "routify -c dev:vite", "dev:vite": "vite --host 0.0.0.0", "rollup": "rollup -c -w", "test": "vitest run", @@ -114,7 +114,7 @@ } ] }, - "dev:builder": { + "dev": { "dependsOn": [ { "projects": [ diff --git a/packages/client/package.json b/packages/client/package.json index 698c7bd929..39ddb4bd49 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -16,7 +16,7 @@ }, "scripts": { "build": "rollup -c", - "dev:builder": "rollup -cw" + "dev": "rollup -cw" }, "dependencies": { "@budibase/bbui": "0.0.0", @@ -78,7 +78,7 @@ } ] }, - "dev:builder": { + "dev": { "dependsOn": [ { "projects": [ diff --git a/packages/server/package.json b/packages/server/package.json index fe1230d30e..8f5b526a62 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -23,7 +23,7 @@ "dev:stack:up": "node scripts/dev/manage.js up", "dev:stack:down": "node scripts/dev/manage.js down", "dev:stack:nuke": "node scripts/dev/manage.js nuke", - "dev:builder": "yarn run dev:stack:up && nodemon", + "dev": "yarn run dev:stack:up && nodemon", "dev:built": "yarn run dev:stack:up && yarn run run:docker", "specs": "ts-node specs/generate.ts && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts", "initialise": "node scripts/initialise.js", @@ -154,7 +154,7 @@ }, "nx": { "targets": { - "dev:builder": { + "dev": { "dependsOn": [ { "comment": "Required for pro usage when submodule not loaded", diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 1aee9c73f6..edbbd1dc56 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -10,7 +10,7 @@ "prebuild": "rimraf dist/", "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", - "dev:builder": "tsc -p tsconfig.json --watch --preserveWatchOutput", + "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput", "check:types": "tsc -p tsconfig.json --noEmit --paths null" }, "dependencies": { @@ -32,7 +32,7 @@ } ] }, - "dev:builder": { + "dev": { "dependsOn": [ { "projects": [ diff --git a/packages/string-templates/README.md b/packages/string-templates/README.md index b2a1ce476e..54cdcf477a 100644 --- a/packages/string-templates/README.md +++ b/packages/string-templates/README.md @@ -1,39 +1,42 @@ # String templating + This package provides a common system for string templating across the Budibase Builder, client and server. The templating is provided through the use of [Handlebars](https://handlebarsjs.com/) an extension of Mustache -which is capable of carrying out logic. We have also extended the base Handlebars functionality through the use +which is capable of carrying out logic. We have also extended the base Handlebars functionality through the use of a set of helpers provided through the [handlebars-helpers](https://github.com/budibase/handlebars-helpers) package. We have not implemented all the helpers provided by the helpers package as some of them provide functionality we felt would not be beneficial. The following collections of helpers have been implemented: -1. [Math](https://github.com/budibase/handlebars-helpers/tree/master#math) - a set of useful helpers for -carrying out logic pertaining to numbers e.g. `avg`, `add`, `abs` and so on. + +1. [Math](https://github.com/budibase/handlebars-helpers/tree/master#math) - a set of useful helpers for + carrying out logic pertaining to numbers e.g. `avg`, `add`, `abs` and so on. 2. [Array](https://github.com/budibase/handlebars-helpers/tree/master#array) - some very specific helpers -for use with arrays, useful for example in automations. Helpers like `first`, `last`, `after` and `join` -can be useful for getting particular portions of arrays or turning them into strings. + for use with arrays, useful for example in automations. Helpers like `first`, `last`, `after` and `join` + can be useful for getting particular portions of arrays or turning them into strings. 3. [Number](https://github.com/budibase/handlebars-helpers/tree/master#number) - unlike the math helpers these -are useful for converting numbers into useful formats for display, e.g. `bytes`, `addCommas` and `toPrecision`. + are useful for converting numbers into useful formats for display, e.g. `bytes`, `addCommas` and `toPrecision`. 4. [URL](https://github.com/budibase/handlebars-helpers/tree/master#url) - very specific helpers for dealing with URLs, -such as `encodeURI`, `escape`, `stripQueryString` and `stripProtocol`. These are primarily useful -for building up particular URLs to hit as say part of an automation. -5. [String](https://github.com/budibase/handlebars-helpers/tree/master#string) - these helpers are useful for building -strings and preparing them for display, e.g. `append`, `camelcase`, `capitalize` and `ellipsis`. -6. [Comparison](https://github.com/budibase/handlebars-helpers/tree/master#comparison) - these helpers are mainly for -building strings when particular conditions are met, for example `and`, `or`, `gt`, `lt`, `not` and so on. This is a very -extensive set of helpers but is mostly as would be expected from a set of logical operators. + such as `encodeURI`, `escape`, `stripQueryString` and `stripProtocol`. These are primarily useful + for building up particular URLs to hit as say part of an automation. +5. [String](https://github.com/budibase/handlebars-helpers/tree/master#string) - these helpers are useful for building + strings and preparing them for display, e.g. `append`, `camelcase`, `capitalize` and `ellipsis`. +6. [Comparison](https://github.com/budibase/handlebars-helpers/tree/master#comparison) - these helpers are mainly for + building strings when particular conditions are met, for example `and`, `or`, `gt`, `lt`, `not` and so on. This is a very + extensive set of helpers but is mostly as would be expected from a set of logical operators. 7. [Object](https://github.com/budibase/handlebars-helpers/tree/master#object) - useful operator for parsing objects, as well -as converting them to JSON strings. -8. [Regex](https://github.com/budibase/handlebars-helpers/tree/master#regex) - allows performing regex tests on strings that -can be used in conditional statements. + as converting them to JSON strings. +8. [Regex](https://github.com/budibase/handlebars-helpers/tree/master#regex) - allows performing regex tests on strings that + can be used in conditional statements. 9. [Date](https://github.com/helpers/helper-date) - last but certainly not least is a moment based date helper, which can -format ISO/timestamp based dates into something human-readable. An example of this would be `{{date dateProperty "DD-MM-YYYY"}}`. + format ISO/timestamp based dates into something human-readable. An example of this would be `{{date dateProperty "DD-MM-YYYY"}}`. ## Date formatting + This package uses the standard method for formatting date times, using the following syntax: | Input | Example | Description | | ----- | ------- | ----------- | | YYYY | 2014 | 4 or 2 digit year. Note: Only 4 digit can be parsed on strict mode | -| YY | 14 | 2 digit year | +| YY | 14 | 2 digit year | | Y | -25 | Year with any number of digits and sign | | Q | 1..4 | Quarter of year. Sets month to first month in quarter. | | M MM | 1..12 | Month number | @@ -42,55 +45,64 @@ This package uses the standard method for formatting date times, using the follo | Do | 1st..31st | Day of month with ordinal | | DDD DDDD | 1..365 | Day of year | | X | 1410715640.579 | Unix timestamp | -| x | 1410715640579 | Unix ms timestamp | +| x | 1410715640579 | Unix ms timestamp | ## Template format + There are two main ways that the templating system can be used, the first is very similar to that which would be produced by Mustache - a single statement: + ``` Hello I'm building a {{uppercase adjective}} string with Handlebars! ``` + In the statement above provided a context of `{adjective: "cool"}` will produce a string of `Hello I'm building a COOL string with Handlebars!`. Here we can see an example of how string helpers can be used to make a string exactly as we need it. These statements are relatively simple; we can also stack helpers as such: `{{ uppercase (remove string "bad") }}` with the use of parenthesis. The other type of statement that can be made with the templating system is conditional ones, that appear as such: + ``` Hello I'm building a {{ #gte score "50" }}Great{{ else }}Bad{{ /gte }} string with Handlebars! -``` -In this string we can see that the string `Great` or `Bad` will be inserted depending on the state of the +``` + +In this string we can see that the string `Great` or `Bad` will be inserted depending on the state of the `score` context variable. The comparison, string and array helpers all provide some conditional operators which can be used -in this way. There will also be some operators which will be built with a very similar syntax but will produce an +in this way. There will also be some operators which will be built with a very similar syntax but will produce an iterative operation, like a for each - an example of this would be the `forEach` array helper. ## Usage -Usage of this templating package is through one of the primary functions provided by the package - these functions are + +Usage of this templating package is through one of the primary functions provided by the package - these functions are as follows: -1. `processString` - `async (string, object)` - given a template string and a context object this will build a string -using our pre-processors, post-processors and handlebars. -2. `processObject` - `async (object, object)` - carries out the functionality provided by `processString` for any string -inside the given object. This will recurse deeply into the provided object so for very large objects this could be slow. -3. `processStringSync` - `(string, object)` - a reduced functionality processing of strings which is synchronous, like -functions provided by Node (e.g. `readdirSync`) + +1. `processString` - `async (string, object)` - given a template string and a context object this will build a string + using our pre-processors, post-processors and handlebars. +2. `processObject` - `async (object, object)` - carries out the functionality provided by `processString` for any string + inside the given object. This will recurse deeply into the provided object so for very large objects this could be slow. +3. `processStringSync` - `(string, object)` - a reduced functionality processing of strings which is synchronous, like + functions provided by Node (e.g. `readdirSync`) 4. `processObjectSync` - `(object, object)` - as with the sync'd string, recurses an object to process it synchronously. -5. `makePropSafe` - `(string)` - some properties cannot be handled by Handlebars, for example `Table 1` is not valid due -to spaces found in the property name. This will update the property name to `[Table 1]` wrapping it in literal -specifiers so that it is safe for use in Handlebars. Ideally this function should be called for every level of an object -being accessed, for example `[Table 1].[property name]` is the syntax that is required for Handlebars. +5. `makePropSafe` - `(string)` - some properties cannot be handled by Handlebars, for example `Table 1` is not valid due + to spaces found in the property name. This will update the property name to `[Table 1]` wrapping it in literal + specifiers so that it is safe for use in Handlebars. Ideally this function should be called for every level of an object + being accessed, for example `[Table 1].[property name]` is the syntax that is required for Handlebars. 6. `isValid` - `(string)` - checks the given string for any templates and provides a boolean stating whether it is a valid -template. + template. 7. `getManifest` - returns the manifest JSON which has been generated for the helpers, describing them and their params. ## Development + This library is built with [Rollup](https://rollupjs.org/guide/en/) as many of the packages built by Budibase are. We have -built the string templating package as a UMD so that it can be used by Node and Browser based applications. This package also -builds Typescript stubs which when making use of the library will be used by your IDE to provide code completion. The following +built the string templating package as a UMD so that it can be used by Node and Browser based applications. This package also +builds Typescript stubs which when making use of the library will be used by your IDE to provide code completion. The following commands are provided for development purposes: + 1. `yarn build` - will build the Typescript stubs and the bundle into the `dist` directory. 2. `yarn test` - runs the test suite which will check various helpers are still functioning as -expected and a few expected use cases. -3. `yarn dev:builder` - an internal command which is used by lerna to watch and build any changes -to the package as part of the main `yarn dev` of the repo. + expected and a few expected use cases. +3. `yarn dev` - an internal command which is used by lerna to watch and build any changes + to the package as part of the main `yarn dev` of the repo. It is also important to note this package is managed in the same manner as all other in the mono-repo, -through lerna. \ No newline at end of file +through lerna. diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index ff43fa5da8..52c77f5c4a 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -20,7 +20,7 @@ ], "scripts": { "build": "tsc && rollup -c", - "dev:builder": "tsc && rollup -cw", + "dev": "tsc && rollup -cw", "test": "jest", "manifest": "node ./scripts/gen-collection-info.js" }, diff --git a/packages/types/package.json b/packages/types/package.json index 97ac286568..c180882d44 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -10,7 +10,7 @@ "prebuild": "rimraf dist/", "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", - "dev:builder": "tsc -p tsconfig.json --watch --preserveWatchOutput", + "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput", "check:types": "tsc -p tsconfig.json --noEmit --paths null" }, "jest": {}, diff --git a/packages/worker/package.json b/packages/worker/package.json index a46f485cb8..e7e63680ea 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -21,7 +21,7 @@ "debug": "yarn build && node --expose-gc --inspect=9223 dist/index.js", "run:docker:cluster": "pm2-runtime start pm2.config.js", "dev:stack:init": "node ./scripts/dev/manage.js init", - "dev:builder": "npm run dev:stack:init && nodemon", + "dev": "npm run dev:stack:init && nodemon", "dev:built": "yarn run dev:stack:init && yarn run run:docker", "test": "bash scripts/test.sh", "test:watch": "jest --watch", @@ -94,7 +94,7 @@ }, "nx": { "targets": { - "dev:builder": { + "dev": { "dependsOn": [ { "comment": "Required for pro usage when submodule not loaded",