From c013b0407548592368f0b3bbf2822f1ca189d4ca Mon Sep 17 00:00:00 2001 From: quesurifn Date: Fri, 18 Nov 2022 18:23:56 -0500 Subject: [PATCH 01/12] maybe fix custom path --- src/domain/use-cases/invoke-port.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 87a39020..cb3f05a1 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -1,6 +1,7 @@ 'use strict' import { isMainThread } from 'worker_threads' +import { match } from 'path-to-regexp' import { AppError } from '../util/app-error' /** @@ -51,7 +52,7 @@ export default function makeInvokePort ({ if(!port) { const specPorts = service.getPorts(); const path = context['requestContext'].getStore().get('path'); - const [ [ portName ] ] = Object.entries(specPorts).filter((port) => port[1].path === path); + const [ [ portName ] ] = Object.entries(specPorts).filter((port) => match(port[1].path, { encode: encodeURI })(path) !== false); if(!portName) { throw new Error('no port specified'); } From 301e274a69526dc4c12164ad6d7421daa5afa446 Mon Sep 17 00:00:00 2001 From: quesurifn Date: Fri, 18 Nov 2022 18:40:21 -0500 Subject: [PATCH 02/12] maybe fix custom path --- src/domain/use-cases/invoke-port.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index cb3f05a1..26e06687 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -52,7 +52,7 @@ export default function makeInvokePort ({ if(!port) { const specPorts = service.getPorts(); const path = context['requestContext'].getStore().get('path'); - const [ [ portName ] ] = Object.entries(specPorts).filter((port) => match(port[1].path, { encode: encodeURI })(path) !== false); + const [ [ portName ] ] = Object.entries(specPorts).filter((port) => match(port[1].path || "", { encode: encodeURI })(path) !== false); if(!portName) { throw new Error('no port specified'); } From 910062df605ba2058eb39294f7f0910e96e49389 Mon Sep 17 00:00:00 2001 From: quesurifn Date: Mon, 21 Nov 2022 10:50:07 -0500 Subject: [PATCH 03/12] performant fix for custom path --- src/domain/use-cases/invoke-port.js | 54 ++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 26e06687..9ea2bf7f 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -52,15 +52,20 @@ export default function makeInvokePort ({ if(!port) { const specPorts = service.getPorts(); const path = context['requestContext'].getStore().get('path'); - const [ [ portName ] ] = Object.entries(specPorts).filter((port) => match(port[1].path || "", { encode: encodeURI })(path) !== false); - if(!portName) { - throw new Error('no port specified'); + for(const p of Object.entries(specPorts)) { + if(!p[1].path) { + continue; + } + if (pathsMatch(p[1].path, path)) { + if(!p[0]) { + throw new Error('no port specified'); + } + if(!service[p[0]]) { + throw new Error('no port found'); + } + return await service[p[0]](input); + } } - if(!service[portName]) { - throw new Error('no port found'); - } - - return await service[portName](input); } return await service[port](input) @@ -69,4 +74,37 @@ export default function makeInvokePort ({ } } } +} + +// Performant way of checking if paths are the same +// given one path with params and one with the param pattern +function pathsMatch(pathWithParamRegex, pathWithParams) { + const splitPathWithParams = pathWithParams.split('/'); + const splitPathWithParamRegex = pathWithParamRegex.split('/'); + + // We know if the length is different, the paths are different + if(splitPathWithParams.length !== splitPathWithParamRegex.length) { + return false; + } + + // we loop through the path with params and check if the path with param regex and the called path match + // if they do not match, we return false + // if we get to a segment with a route param we continue + // if we get to the end of the loop and all segments match, we return true + for (let index = 0; index < splitPathWithParams.length; index++) { + const param = splitPathWithParams[index]; + const paramRegex = splitPathWithParamRegex[index]; + + // regex path includes colon meaning route param so we continue + if(paramRegex.includes(':')) { + continue; + } + + // if not equal, we return false the paths don't match + if(param !== paramRegex) { + return false; + } + } + + return true; } \ No newline at end of file From 474e1e30a61fcb618d02bc412c6c3708054663ad Mon Sep 17 00:00:00 2001 From: quesurifn Date: Mon, 21 Nov 2022 10:54:07 -0500 Subject: [PATCH 04/12] more docs --- src/domain/use-cases/invoke-port.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 9ea2bf7f..d986f8ee 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -78,6 +78,9 @@ export default function makeInvokePort ({ // Performant way of checking if paths are the same // given one path with params and one with the param pattern +// this accounts for route params +// since a route param can be anything, we can just compare +/// each path segment skipping over the param field function pathsMatch(pathWithParamRegex, pathWithParams) { const splitPathWithParams = pathWithParams.split('/'); const splitPathWithParamRegex = pathWithParamRegex.split('/'); From 38a6b6e001d3f1bc84e18cc33a99d6814e4e0e43 Mon Sep 17 00:00:00 2001 From: quesurifn Date: Mon, 21 Nov 2022 11:43:31 -0500 Subject: [PATCH 05/12] remove unused library --- src/domain/use-cases/invoke-port.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index d986f8ee..0e7871f6 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -1,7 +1,6 @@ 'use strict' import { isMainThread } from 'worker_threads' -import { match } from 'path-to-regexp' import { AppError } from '../util/app-error' /** From fc90e1c80e874f92c24635d4531891cdfb60d635 Mon Sep 17 00:00:00 2001 From: quesurifn Date: Mon, 21 Nov 2022 16:47:08 -0500 Subject: [PATCH 06/12] cleanup --- src/domain/use-cases/invoke-port.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 0e7871f6..5bdc98e4 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -41,13 +41,13 @@ export default function makeInvokePort ({ return threadpool.runJob(invokePort.name, input, modelName) } else { try { - const { id = null, port = null} = input; + let { id = null, port = null} = input; const service = await findModelService(id) if (!service) { throw new Error('could not find service') } - + if(!port) { const specPorts = service.getPorts(); const path = context['requestContext'].getStore().get('path'); @@ -56,17 +56,19 @@ export default function makeInvokePort ({ continue; } if (pathsMatch(p[1].path, path)) { - if(!p[0]) { - throw new Error('no port specified'); - } - if(!service[p[0]]) { - throw new Error('no port found'); - } - return await service[p[0]](input); + port = p[0]; + break; } } } + if(!port) { + throw new Error('the port is undefined') + } + if(!service[port]) { + throw new Error('the port or record ID is invalid') + } + return await service[port](input) } catch (error) { return AppError(error) From fc04fe14b45ac3140571423ef27d019f6cd72af4 Mon Sep 17 00:00:00 2001 From: quesurifn Date: Mon, 21 Nov 2022 16:57:45 -0500 Subject: [PATCH 07/12] update error message --- src/domain/use-cases/invoke-port.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 5bdc98e4..84fd817f 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -43,9 +43,8 @@ export default function makeInvokePort ({ try { let { id = null, port = null} = input; const service = await findModelService(id) - if (!service) { - throw new Error('could not find service') + throw new Error('could not find a service associated with given id') } if(!port) { From 4b2c47eee2973965c53e9f5f9a25921e5483354d Mon Sep 17 00:00:00 2001 From: vi-ssc <105008018+vi-ssc@users.noreply.github.com> Date: Tue, 29 Nov 2022 21:57:58 +0530 Subject: [PATCH 08/12] Mongo DB null fix (#7) * mongodb null fix * remove commented qpm() configuration --- .../datasources/datasource-mongodb.js | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/adapters/datasources/datasource-mongodb.js b/src/adapters/datasources/datasource-mongodb.js index 71b0f62f..6632900f 100644 --- a/src/adapters/datasources/datasource-mongodb.js +++ b/src/adapters/datasources/datasource-mongodb.js @@ -6,16 +6,20 @@ const HIGHWATERMARK = 50 const mongodb = require('mongodb') const { MongoClient } = mongodb -const { Transform, Writable } = require('stream') -const qpm = require('query-params-mongo') -const processQuery = qpm() -// const processQuery = qpm({ -// autoDetect: [{ fieldPattern: /_id$/, dataType: 'objectId' }], -// converters: { objectId: mongodb.ObjectId } -// }) - -const url = process.env.MONGODB_URL || 'mongodb://localhost:27017' -const configRoot = require('../../config').hostConfig +const { DataSourceMemory } = require("./datasource-memory") +const { Transform, Writable } = require("stream") +const qpm = require("query-params-mongo") +const processQuery = qpm({ + autoDetect: [ + { valuePattern: /^null$/i, dataType: 'nullstring' } + ], + converters: { + nullstring: val=>{ return { $type: 10 } } // reference BSON datatypes https://www.mongodb.com/docs/manual/reference/bson-types/ + } +}) + +const url = process.env.MONGODB_URL || "mongodb://localhost:27017" +const configRoot = require("../../config").hostConfig const dsOptions = configRoot.adapters.datasources.DataSourceMongoDb.options || { runOffline: true, numConns: 2 @@ -266,7 +270,7 @@ export class DataSourceMongoDb extends DataSource { processOptions (param) { const { options = {}, query = {} } = param - return { ...options, ...processQuery(query) } + return { ...processQuery(query), ...options } // options must overwite the query not otherwise } /** From 9a73dc95fda84ad5ac6f21c2a800523f27da7a5d Mon Sep 17 00:00:00 2001 From: vi-ssc <105008018+vi-ssc@users.noreply.github.com> Date: Tue, 29 Nov 2022 22:09:19 +0530 Subject: [PATCH 09/12] Port method and path fixes - can overwrite autogenerated routes - sticks to its http methods (#6) * added method & headers to apply/improve port spec * limit service ports to their portSpec http methods * make a port path validation * replace the port path only if methods match * execute port only if path is provided and matches * fix priorities, custom over autogenerated * execution speed fix - includes over new Regexp --- src/adapters/controllers/post-invoke-port.js | 3 +++ src/aegis.js | 8 +++++--- src/domain/use-cases/invoke-port.js | 15 +++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/adapters/controllers/post-invoke-port.js b/src/adapters/controllers/post-invoke-port.js index 7897a61b..5d5f2242 100644 --- a/src/adapters/controllers/post-invoke-port.js +++ b/src/adapters/controllers/post-invoke-port.js @@ -13,6 +13,9 @@ export default function anyInvokePortFactory (invokePort) { const result = await invokePort({ port: httpRequest.params.port, args: httpRequest.body, + method: httpRequest.method, + headers: httpRequest.headers, + path: httpRequest.path, id: httpRequest.params.id || null }) diff --git a/src/aegis.js b/src/aegis.js index 324d56f3..270c14e5 100644 --- a/src/aegis.js +++ b/src/aegis.js @@ -96,11 +96,13 @@ const router = { if (ctrl.ports) { for (const portName in ctrl.ports) { const port = ctrl.ports[portName] + const specPortMethods = (port?.methods || "").join('|') + if (port.path) { routeOverrides.set(port.path, portName) } - if (checkAllowedMethods(ctrl, method)) { + if (checkAllowedMethods(ctrl, method) && (!port.methods || (specPortMethods.includes(method.toLowerCase()))) ) { routes.set(port.path || path(ctrl.endpoint), { [method]: adapter(ctrl.fn) }) @@ -131,6 +133,8 @@ const router = { } function makeRoutes () { + router.adminRoute(getConfig, http) + router.userRoutes(getRoutes) router.autoRoutes(endpoint, 'get', liveUpdate, http) router.autoRoutes(endpoint, 'get', getModels, http) router.autoRoutes(endpoint, 'post', postModels, http) @@ -146,8 +150,6 @@ function makeRoutes () { router.autoRoutes(endpointPortId, 'patch', anyInvokePorts, http, true) router.autoRoutes(endpointPortId, 'delete', anyInvokePorts, http, true) router.autoRoutes(endpointPortId, 'get', anyInvokePorts, http, true) - router.adminRoute(getConfig, http) - router.userRoutes(getRoutes) console.log(routes) } diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 84fd817f..97fdd395 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -33,7 +33,7 @@ export default function makeInvokePort ({ } /** * - * @param {{id:string,model:import('..').Model,args:string[],port:string}} input + * @param {{id:String,model:import('..').Model,args:String[],port:String,method:String,headers:Array}} input * @returns */ return async function invokePort (input) { @@ -41,15 +41,14 @@ export default function makeInvokePort ({ return threadpool.runJob(invokePort.name, input, modelName) } else { try { - let { id = null, port = null} = input; + let { id = null, port = null, method, path } = input; const service = await findModelService(id) if (!service) { throw new Error('could not find a service associated with given id') } + const specPorts = service.getPorts(); if(!port) { - const specPorts = service.getPorts(); - const path = context['requestContext'].getStore().get('path'); for(const p of Object.entries(specPorts)) { if(!p[1].path) { continue; @@ -68,6 +67,14 @@ export default function makeInvokePort ({ throw new Error('the port or record ID is invalid') } + const specPortMethods = specPorts[port]?.methods.join('|').toLowerCase(); + if (specPortMethods && !(specPortMethods.includes(method.toLowerCase()))) { + throw new Error('invalid method for given port'); + } + if (specPorts[port]?.path && !pathsMatch(specPorts[port].path, path)) { + throw new Error('invalid path for given port'); + } + return await service[port](input) } catch (error) { return AppError(error) From 1f1a7ce61a11041ccdc7abbe30be63dbb37a39e6 Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 29 Nov 2022 13:38:42 -0500 Subject: [PATCH 10/12] Revert "Port method and path fixes - can overwrite autogenerated routes - sticks to its http methods (#6)" (#9) This reverts commit 9a73dc95fda84ad5ac6f21c2a800523f27da7a5d. --- src/adapters/controllers/post-invoke-port.js | 3 --- src/aegis.js | 8 +++----- src/domain/use-cases/invoke-port.js | 15 ++++----------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/adapters/controllers/post-invoke-port.js b/src/adapters/controllers/post-invoke-port.js index 5d5f2242..7897a61b 100644 --- a/src/adapters/controllers/post-invoke-port.js +++ b/src/adapters/controllers/post-invoke-port.js @@ -13,9 +13,6 @@ export default function anyInvokePortFactory (invokePort) { const result = await invokePort({ port: httpRequest.params.port, args: httpRequest.body, - method: httpRequest.method, - headers: httpRequest.headers, - path: httpRequest.path, id: httpRequest.params.id || null }) diff --git a/src/aegis.js b/src/aegis.js index 270c14e5..324d56f3 100644 --- a/src/aegis.js +++ b/src/aegis.js @@ -96,13 +96,11 @@ const router = { if (ctrl.ports) { for (const portName in ctrl.ports) { const port = ctrl.ports[portName] - const specPortMethods = (port?.methods || "").join('|') - if (port.path) { routeOverrides.set(port.path, portName) } - if (checkAllowedMethods(ctrl, method) && (!port.methods || (specPortMethods.includes(method.toLowerCase()))) ) { + if (checkAllowedMethods(ctrl, method)) { routes.set(port.path || path(ctrl.endpoint), { [method]: adapter(ctrl.fn) }) @@ -133,8 +131,6 @@ const router = { } function makeRoutes () { - router.adminRoute(getConfig, http) - router.userRoutes(getRoutes) router.autoRoutes(endpoint, 'get', liveUpdate, http) router.autoRoutes(endpoint, 'get', getModels, http) router.autoRoutes(endpoint, 'post', postModels, http) @@ -150,6 +146,8 @@ function makeRoutes () { router.autoRoutes(endpointPortId, 'patch', anyInvokePorts, http, true) router.autoRoutes(endpointPortId, 'delete', anyInvokePorts, http, true) router.autoRoutes(endpointPortId, 'get', anyInvokePorts, http, true) + router.adminRoute(getConfig, http) + router.userRoutes(getRoutes) console.log(routes) } diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 97fdd395..84fd817f 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -33,7 +33,7 @@ export default function makeInvokePort ({ } /** * - * @param {{id:String,model:import('..').Model,args:String[],port:String,method:String,headers:Array}} input + * @param {{id:string,model:import('..').Model,args:string[],port:string}} input * @returns */ return async function invokePort (input) { @@ -41,14 +41,15 @@ export default function makeInvokePort ({ return threadpool.runJob(invokePort.name, input, modelName) } else { try { - let { id = null, port = null, method, path } = input; + let { id = null, port = null} = input; const service = await findModelService(id) if (!service) { throw new Error('could not find a service associated with given id') } - const specPorts = service.getPorts(); if(!port) { + const specPorts = service.getPorts(); + const path = context['requestContext'].getStore().get('path'); for(const p of Object.entries(specPorts)) { if(!p[1].path) { continue; @@ -67,14 +68,6 @@ export default function makeInvokePort ({ throw new Error('the port or record ID is invalid') } - const specPortMethods = specPorts[port]?.methods.join('|').toLowerCase(); - if (specPortMethods && !(specPortMethods.includes(method.toLowerCase()))) { - throw new Error('invalid method for given port'); - } - if (specPorts[port]?.path && !pathsMatch(specPorts[port].path, path)) { - throw new Error('invalid path for given port'); - } - return await service[port](input) } catch (error) { return AppError(error) From b941391ff9a2bcac358b5dbb0b25d90f480d25eb Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 30 Nov 2022 00:39:16 -0500 Subject: [PATCH 11/12] Port method and path fixes - can overwrite autogenerated routes - sticks to its http methods (#10) * added method & headers to apply/improve port spec * limit service ports to their portSpec http methods * make a port path validation * replace the port path only if methods match * execute port only if path is provided and matches * fix priorities, custom over autogenerated * execution speed fix - includes over new Regexp * specPortMethods is null - "".includes error Co-authored-by: vi-ssc --- src/adapters/controllers/post-invoke-port.js | 3 +++ src/aegis.js | 8 +++++--- src/domain/use-cases/invoke-port.js | 15 +++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/adapters/controllers/post-invoke-port.js b/src/adapters/controllers/post-invoke-port.js index 7897a61b..5d5f2242 100644 --- a/src/adapters/controllers/post-invoke-port.js +++ b/src/adapters/controllers/post-invoke-port.js @@ -13,6 +13,9 @@ export default function anyInvokePortFactory (invokePort) { const result = await invokePort({ port: httpRequest.params.port, args: httpRequest.body, + method: httpRequest.method, + headers: httpRequest.headers, + path: httpRequest.path, id: httpRequest.params.id || null }) diff --git a/src/aegis.js b/src/aegis.js index 324d56f3..4b882a8b 100644 --- a/src/aegis.js +++ b/src/aegis.js @@ -96,11 +96,13 @@ const router = { if (ctrl.ports) { for (const portName in ctrl.ports) { const port = ctrl.ports[portName] + const specPortMethods = port?.methods?.join('|') || "" + if (port.path) { routeOverrides.set(port.path, portName) } - if (checkAllowedMethods(ctrl, method)) { + if (checkAllowedMethods(ctrl, method) && (!port.methods || (specPortMethods.includes(method.toLowerCase()))) ) { routes.set(port.path || path(ctrl.endpoint), { [method]: adapter(ctrl.fn) }) @@ -131,6 +133,8 @@ const router = { } function makeRoutes () { + router.adminRoute(getConfig, http) + router.userRoutes(getRoutes) router.autoRoutes(endpoint, 'get', liveUpdate, http) router.autoRoutes(endpoint, 'get', getModels, http) router.autoRoutes(endpoint, 'post', postModels, http) @@ -146,8 +150,6 @@ function makeRoutes () { router.autoRoutes(endpointPortId, 'patch', anyInvokePorts, http, true) router.autoRoutes(endpointPortId, 'delete', anyInvokePorts, http, true) router.autoRoutes(endpointPortId, 'get', anyInvokePorts, http, true) - router.adminRoute(getConfig, http) - router.userRoutes(getRoutes) console.log(routes) } diff --git a/src/domain/use-cases/invoke-port.js b/src/domain/use-cases/invoke-port.js index 84fd817f..97fdd395 100644 --- a/src/domain/use-cases/invoke-port.js +++ b/src/domain/use-cases/invoke-port.js @@ -33,7 +33,7 @@ export default function makeInvokePort ({ } /** * - * @param {{id:string,model:import('..').Model,args:string[],port:string}} input + * @param {{id:String,model:import('..').Model,args:String[],port:String,method:String,headers:Array}} input * @returns */ return async function invokePort (input) { @@ -41,15 +41,14 @@ export default function makeInvokePort ({ return threadpool.runJob(invokePort.name, input, modelName) } else { try { - let { id = null, port = null} = input; + let { id = null, port = null, method, path } = input; const service = await findModelService(id) if (!service) { throw new Error('could not find a service associated with given id') } + const specPorts = service.getPorts(); if(!port) { - const specPorts = service.getPorts(); - const path = context['requestContext'].getStore().get('path'); for(const p of Object.entries(specPorts)) { if(!p[1].path) { continue; @@ -68,6 +67,14 @@ export default function makeInvokePort ({ throw new Error('the port or record ID is invalid') } + const specPortMethods = specPorts[port]?.methods.join('|').toLowerCase(); + if (specPortMethods && !(specPortMethods.includes(method.toLowerCase()))) { + throw new Error('invalid method for given port'); + } + if (specPorts[port]?.path && !pathsMatch(specPorts[port].path, path)) { + throw new Error('invalid path for given port'); + } + return await service[port](input) } catch (error) { return AppError(error) From 1bb4ce872e6d6f66ece94558b9e9fe133a65c4d7 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 30 Nov 2022 14:39:32 -0500 Subject: [PATCH 12/12] add workflows (#13) --- .github/workflows/bump-version.yml | 23 ++++++ .github/workflows/codesee-arch-diagram.yml | 90 ---------------------- .github/workflows/npm-publish.yml | 51 ------------ 3 files changed, 23 insertions(+), 141 deletions(-) create mode 100644 .github/workflows/bump-version.yml delete mode 100644 .github/workflows/codesee-arch-diagram.yml delete mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 00000000..97a7e455 --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,23 @@ +name: Bump version +on: + push: + branches: + - develop +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Create a GitHub release + uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.tag_version.outputs.new_tag }} + name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} + +#### https://github.com/marketplace/actions/github-tag \ No newline at end of file diff --git a/.github/workflows/codesee-arch-diagram.yml b/.github/workflows/codesee-arch-diagram.yml deleted file mode 100644 index 78909632..00000000 --- a/.github/workflows/codesee-arch-diagram.yml +++ /dev/null @@ -1,90 +0,0 @@ -# This workflow was added by CodeSee. Learn more at https://codesee.io/ -on: - push: - branches: - - main - pull_request_target: - types: [opened, synchronize, reopened] - -name: CodeSee Map - -permissions: read-all - -jobs: - test_map_action: - runs-on: ubuntu-latest - continue-on-error: true - name: Run CodeSee Map Analysis - steps: - - name: checkout - id: checkout - uses: actions/checkout@v2 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - fetch-depth: 0 - - # codesee-detect-languages has an output with id languages. - - name: Detect Languages - id: detect-languages - uses: Codesee-io/codesee-detect-languages-action@latest - - - name: Configure JDK 16 - uses: actions/setup-java@v3 - if: ${{ fromJSON(steps.detect-languages.outputs.languages).java }} - with: - java-version: '16' - distribution: 'zulu' - - # CodeSee Maps Go support uses a static binary so there's no setup step required. - - - name: Configure Node.js 14 - uses: actions/setup-node@v3 - if: ${{ fromJSON(steps.detect-languages.outputs.languages).javascript }} - with: - node-version: '14' - - - name: Configure Python 3.x - uses: actions/setup-python@v2 - if: ${{ fromJSON(steps.detect-languages.outputs.languages).python }} - with: - python-version: '3.10' - architecture: 'x64' - - - name: Configure Ruby '3.x' - uses: ruby/setup-ruby@v1 - if: ${{ fromJSON(steps.detect-languages.outputs.languages).ruby }} - with: - ruby-version: '3.0' - - # We need the rust toolchain because it uses rustc and cargo to inspect the package - - name: Configure Rust 1.x stable - uses: actions-rs/toolchain@v1 - if: ${{ fromJSON(steps.detect-languages.outputs.languages).rust }} - with: - toolchain: stable - - - name: Generate Map - id: generate-map - uses: Codesee-io/codesee-map-action@latest - with: - step: map - api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} - github_ref: ${{ github.ref }} - languages: ${{ steps.detect-languages.outputs.languages }} - - - name: Upload Map - id: upload-map - uses: Codesee-io/codesee-map-action@latest - with: - step: mapUpload - api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} - github_ref: ${{ github.ref }} - - - name: Insights - id: insights - uses: Codesee-io/codesee-map-action@latest - with: - step: insights - api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} - github_ref: ${{ github.ref }} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index 0167ac2e..00000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,51 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: Node.js Package - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: yarn - - run: yarn build - - run: yarn test - - publish-npm: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - publish-gpr: - needs: build - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://npm.pkg.github.com/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}