diff --git a/.eslintrc.js b/.eslintrc.js index 0a7b0bbfa3..3c6634e03b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -52,6 +52,7 @@ module.exports = { "no-process-exit": [0], "node/no-unsupported-features/es-syntax": [0], "node/shebang": [0], + "no-ex-assign": [0], "import/no-commonjs": [0], "import/no-dynamic-require": [0], "import/no-extraneous-dependencies": noExtraneousRule, diff --git a/packages/kontinuous/src/build/builder.js b/packages/kontinuous/src/build/builder.js index beb15f4d68..ddfa49bb51 100644 --- a/packages/kontinuous/src/build/builder.js +++ b/packages/kontinuous/src/build/builder.js @@ -17,10 +17,12 @@ const loadDependencies = require("./load-dependencies") module.exports = async (_options = {}) => { const config = ctx.require("config") + const logger = ctx.require("logger") - const { buildPath, buildProjectPath, workspaceKsPath } = config + logger.info("🌀 [LIFECYCLE]: pre-build") + // TODO: - const logger = ctx.require("logger") + const { buildPath, buildProjectPath, workspaceKsPath } = config if (await fs.pathExists(workspaceKsPath)) { await fs.copy(workspaceKsPath, buildProjectPath, { @@ -77,6 +79,9 @@ module.exports = async (_options = {}) => { await debugManifests(manifests, values) + logger.info("🌀 [LIFECYCLE]: post-build") + // TODO: + return { manifestsFile, manifests: manifestsDump, diff --git a/packages/kontinuous/src/build/validate-manifests.js b/packages/kontinuous/src/build/validate-manifests.js index e71e6b3c54..7ab021c299 100644 --- a/packages/kontinuous/src/build/validate-manifests.js +++ b/packages/kontinuous/src/build/validate-manifests.js @@ -17,5 +17,16 @@ module.exports = async (manifests) => { logger.info("🌀 [LIFECYCLE]: validators") const context = createContext({ type: "validators", ValidationError }) const { buildProjectPath } = config - await pluginFunction(`${buildProjectPath}/validators`)(manifests, {}, context) + try { + await pluginFunction(`${buildProjectPath}/validators`)( + manifests, + {}, + context + ) + } catch (err) { + if (!(err instanceof ValidationError)) { + err = new ValidationError(err.message) + } + throw err + } } diff --git a/plugins/contrib/deploy-sidecars/kontinuous-ui.js b/plugins/contrib/deploy-sidecars/kontinuous-ui.js new file mode 100644 index 0000000000..758b4e8232 --- /dev/null +++ b/plugins/contrib/deploy-sidecars/kontinuous-ui.js @@ -0,0 +1,38 @@ +module.exports = async (options, { logger, utils, dryRun, ctx }) => { + if (dryRun) { + return + } + + const eventsBucket = ctx.require("eventsBucket") + const abortController = ctx.require("abortController") + + const waitingFor = [] + eventsBucket.on("resource:created", ({ manifests }) => { + waitingFor.push( + new Promise(async (resolve, reject) => { + try { + // TODO push events + resolve(e) + } catch (e) { + reject(e) + } + // await + }) + ) + }) + + return new Promise(async (res, rej) => { + while (true) { + if (abortController.signal.aborted) { + try { + await Promise.all(...waitingFor) + res() + } catch (err) { + rej(err) + } + return + } + await sleep(1) + } + }) +}