From b753be78386f7f9aa308ea649bdc3c37f6e4f5bc Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 21 Jun 2020 17:38:07 +0300 Subject: [PATCH 01/19] wip --- Dockerfile | 1 + .../cli/commands/components/update.cmd.js | 25 +++++++++ lib/interface/cli/commands/hybrid/helper.js | 52 +++++++++++++++---- lib/interface/cli/commands/hybrid/init.cmd.js | 7 +-- .../cli/commands/root/components.cmd.js | 17 ++++++ 5 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 lib/interface/cli/commands/components/update.cmd.js create mode 100644 lib/interface/cli/commands/root/components.cmd.js diff --git a/Dockerfile b/Dockerfile index 95daad58e..a99eb1c46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,4 +39,5 @@ RUN apk del yarn RUN ln -s $(pwd)/lib/interface/cli/codefresh /usr/local/bin/codefresh +RUN codefresh components update ENTRYPOINT ["codefresh"] diff --git a/lib/interface/cli/commands/components/update.cmd.js b/lib/interface/cli/commands/components/update.cmd.js new file mode 100644 index 000000000..199ec7bdb --- /dev/null +++ b/lib/interface/cli/commands/components/update.cmd.js @@ -0,0 +1,25 @@ +const Command = require('../../Command'); +const componentsRoot = require('../root/components.cmd'); +const helper = require('../hybrid/helper'); + +const command = new Command({ + command: 'update', + parent: componentsRoot, + description: 'Update Codefresh CLI components', + webDocs: { + category: 'Componenets', + title: 'Update', + }, + builder: yargs => yargs + .env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv + .option('path', { + describe: 'Path to place components', + }), + handler: async (argv) => { + const downloadPath = argv.path || process.cwd(); + console.log(`Updating components to ${downloadPath}`); + await helper.downloadRelatedComponents(downloadPath); + }, +}); + +module.exports = command; diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index 44338ddfc..32d74d714 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -10,9 +10,11 @@ const { followLogs } = require('../../helpers/logs'); const ProgressEvents = require('../../helpers/progressEvents'); const cliProgress = require('cli-progress'); const figlet = require('figlet'); +const path = require('path'); const { components, Runner, Downloader, CommonProgressFormat, } = require('./../../../../binary'); +const { pathExists } = require('../../helpers/general'); const INSTALLATION_DEFAULTS = { NAMESPACE: 'codefresh', @@ -308,7 +310,7 @@ async function getRecommendedKubeNamespace(kubeconfigPath, kubeContextName) { return name; } -async function _downloadVeonona() { +async function _downloadVeonona(location) { const downloader = new Downloader({ progress: new cliProgress.SingleBar( { @@ -317,13 +319,42 @@ async function _downloadVeonona() { }, cliProgress.Presets.shades_classic, ), + location, }); - await downloader.download(components.venona); + const error = await to(downloader.download(components.venona)); + if (error) { + const newLocation = path.join(process.cwd(), components.venona.local.binary); + if (await pathExists(newLocation)) { + console.log('Failed to download insatller, using local version'); + return process.cwd(); + } + console.log('Failed to download installer, aborting'); + throw error; + } + return downloader.location; +} +async function _downloadSteveDore(location) { + const downloader = new Downloader({ + progress: new cliProgress.SingleBar( + { + stopOnComplete: true, + format: CommonProgressFormat, + }, + cliProgress.Presets.shades_classic, + ), + location, + }); + await downloader.download(components.stevedore); +} + +async function downloadHybridComponents(location) { + await _downloadVeonona(location); + await _downloadSteveDore(location); } async function runClusterAcceptanceTests({ kubeNamespace, kubeConfigPath }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const location = await _downloadVeonona(); + const componentRunner = new Runner(location); const cmd = ['test', '--log-formtter', DefaultLogFormatter]; if (kubeNamespace) { cmd.push('--kube-namespace'); @@ -353,8 +384,8 @@ async function installAgent({ verbose, // --verbose logFormatting = DefaultLogFormatter, // --log-formtter }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const location = await _downloadVeonona(); + const componentRunner = new Runner(location); const cmd = [ 'install', 'agent', @@ -422,8 +453,8 @@ async function installRuntime({ storageClassName, // --storage-class logFormatting = DefaultLogFormatter, // --log-formtter }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const location = await _downloadVeonona(); + const componentRunner = new Runner(location); const cmd = [ 'install', 'runtime', @@ -487,8 +518,8 @@ async function attachRuntime({ runtimeName, // --runtimeName logFormatting = DefaultLogFormatter, // --log-formtter }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const location = await _downloadVeonona(); + const componentRunner = new Runner(location); const cmd = [ 'attach', '--kube-context-name', @@ -615,6 +646,7 @@ module.exports = { newRuntimeName, newAgentName, parseNodeSelector, + downloadRelatedComponents: downloadHybridComponents, INSTALLATION_DEFAULTS, DefaultLogFormatter, }; diff --git a/lib/interface/cli/commands/hybrid/init.cmd.js b/lib/interface/cli/commands/hybrid/init.cmd.js index 52d8dded3..7f32a641c 100644 --- a/lib/interface/cli/commands/hybrid/init.cmd.js +++ b/lib/interface/cli/commands/hybrid/init.cmd.js @@ -111,7 +111,7 @@ const initCmd = new Command({ .option('install-monitor', { describe: 'Install a monitoring component that will help provide valueable data about your cluster to Codefresh', type: 'boolean', - default: true, + default: true, }) .option('kube-namespace', { describe: 'Name of the namespace on which venona should be installed [$CF_ARG_KUBE_NAMESPACE]', @@ -329,10 +329,7 @@ const initCmd = new Command({ const agent = await sdk.agents.create({ name: agentName }); installationPlan.addContext('agent', agent); const { token: agentToken } = agent; - console.log(`A Codefresh Runner with the name: ${colors.cyan(agentName)} has been created.` + - `\n${colors.yellow('*IMPORTANT*')} Make sure to copy your access token now and st` + - 'ore it in a safe location. You won’t be able to see it again.'); - console.log(agentToken); + console.log(`A Codefresh Runner with the name: ${colors.cyan(agentName)} has been created.`); installationPlan.addContext('agentToken', agentToken); }, condition: async () => !installationPlan.getContext('agentToken'), diff --git a/lib/interface/cli/commands/root/components.cmd.js b/lib/interface/cli/commands/root/components.cmd.js new file mode 100644 index 000000000..17db9c9d3 --- /dev/null +++ b/lib/interface/cli/commands/root/components.cmd.js @@ -0,0 +1,17 @@ +const Command = require('../../Command'); + + +const install = new Command({ + root: true, + command: 'components', + description: 'Manages Codefresh CLI components', + requiresAuthentication: false, + webDocs: { + description: 'Codefresh CLI components', + category: 'Codefresh CLI components', + title: 'components', + weight: 40, + }, +}); + +module.exports = install; From d67cdc583103293cc3f5a0e5173f38eeb72fee62 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 21 Jun 2020 17:38:30 +0300 Subject: [PATCH 02/19] Revert "SAAS-7564 - fix downloading venona release with no assets (#507)" This reverts commit 398921e4383e53220f10a49428565a6267b8cfa7. --- lib/binary/downloader.js | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/lib/binary/downloader.js b/lib/binary/downloader.js index 5e4b8c3c1..9338c80b8 100644 --- a/lib/binary/downloader.js +++ b/lib/binary/downloader.js @@ -28,28 +28,16 @@ function _ensureDirectory(location) { } async function _getRemoteVersion({ - name, osType, + name, branch, path, file, }) { - // get the 10 latest releases - const releasesUrl = `https://api.github.com/repos/codefresh-io/${name}/releases?per_page=10`; - const res = await rp({ - uri: releasesUrl, + const final = branch ? `${name}/${branch}/${path}` : `${name}/${path}`; + const url = `https://raw.githubusercontent.com/codefresh-io/${final}/${file}`; + const req = await rp({ + url, method: 'GET', headers: { 'User-Agent': 'codefresh' }, }); - - const releases = JSON.parse(res); - for (let i = 0; i < releases.length; i += 1) { - const curRelease = releases[i]; - const neededAsset = (curRelease.assets || []).find(asset => { - const assetName = asset.name || ''; - return assetName.startsWith(`${name}_`) && assetName.endsWith(osType); - }); - if (neededAsset) { - return { remoteVersion: curRelease.name, download_url: neededAsset.browser_download_url }; - } - } - return { remoteVersion: '0', download_url: '' }; + return req; } function _buildDownloadURL({ name, version, binary }) { @@ -118,18 +106,25 @@ class Downloader { let localVersion = _getLocalVersion(join(dir, component.local.versionFile)); const { - repo: name, + repo: name, branch, versionPath: path, versionFile: file, } = component.remote; - let { remoteVersion, download_url } = await _getRemoteVersion({ name, osType }); + let remoteVersion = await _getRemoteVersion({ + name, branch, path, file, + }); remoteVersion = remoteVersion.trim(); localVersion = localVersion.trim(); if (compareVersions(localVersion, remoteVersion) >= 0) { + // logger.debug(`Download is not required latest-version=${remoteVersion} local-version=${localVersion}`); return Promise.resolve(); } - logger.debug(`${component.name} component upgrade is required, downloading latest version [${remoteVersion}]`); + logger.debug(`${component.name} component upgrade is required, downloading.`); + - const resp = await request(download_url); + const binary = `${name}_${remoteVersion}_${osType}`; + const version = component.version.prefix ? `${component.version.prefix}${remoteVersion}` : remoteVersion; + const url = _buildDownloadURL({ name, version, binary }); + const resp = await request(url); if (this.progress) { let size = 0; From edf3aebdb54b326b48b21505f037b34beefd803a Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 21 Jun 2020 18:37:51 +0300 Subject: [PATCH 03/19] wip --- .../cli/commands/components/update.cmd.js | 12 ++---- lib/interface/cli/commands/hybrid/helper.js | 39 ++++++++++--------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/lib/interface/cli/commands/components/update.cmd.js b/lib/interface/cli/commands/components/update.cmd.js index 199ec7bdb..5e6c5bd3a 100644 --- a/lib/interface/cli/commands/components/update.cmd.js +++ b/lib/interface/cli/commands/components/update.cmd.js @@ -10,15 +10,9 @@ const command = new Command({ category: 'Componenets', title: 'Update', }, - builder: yargs => yargs - .env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv - .option('path', { - describe: 'Path to place components', - }), - handler: async (argv) => { - const downloadPath = argv.path || process.cwd(); - console.log(`Updating components to ${downloadPath}`); - await helper.downloadRelatedComponents(downloadPath); + handler: async () => { + console.log('Updating components'); + await helper.downloadRelatedComponents(); }, }); diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index 32d74d714..7d4f559e8 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -310,7 +310,7 @@ async function getRecommendedKubeNamespace(kubeconfigPath, kubeContextName) { return name; } -async function _downloadVeonona(location) { +async function _downloadVeonona() { const downloader = new Downloader({ progress: new cliProgress.SingleBar( { @@ -319,21 +319,21 @@ async function _downloadVeonona(location) { }, cliProgress.Presets.shades_classic, ), - location, }); - const error = await to(downloader.download(components.venona)); - if (error) { + const [error] = await to(downloader.download(components.venona)); + + if (error != null) { const newLocation = path.join(process.cwd(), components.venona.local.binary); if (await pathExists(newLocation)) { console.log('Failed to download insatller, using local version'); - return process.cwd(); + return INSTALLATION_DEFAULTS.COMPONENETS_INSTALLATION_PATH; } - console.log('Failed to download installer, aborting'); + console.log('Failed to download component, aborting'); throw error; } return downloader.location; } -async function _downloadSteveDore(location) { +async function _downloadSteveDore() { const downloader = new Downloader({ progress: new cliProgress.SingleBar( { @@ -342,19 +342,20 @@ async function _downloadSteveDore(location) { }, cliProgress.Presets.shades_classic, ), - location, }); await downloader.download(components.stevedore); } -async function downloadHybridComponents(location) { - await _downloadVeonona(location); - await _downloadSteveDore(location); +async function downloadHybridComponents() { + await _downloadVeonona(); + console.log('Kubernetes components installer downloaded successfully'); + await _downloadSteveDore(); + console.log('Kubernetes registrator installer downloaded successfully'); } async function runClusterAcceptanceTests({ kubeNamespace, kubeConfigPath }) { - const location = await _downloadVeonona(); - const componentRunner = new Runner(location); + await _downloadVeonona(); + const componentRunner = new Runner(); const cmd = ['test', '--log-formtter', DefaultLogFormatter]; if (kubeNamespace) { cmd.push('--kube-namespace'); @@ -384,8 +385,8 @@ async function installAgent({ verbose, // --verbose logFormatting = DefaultLogFormatter, // --log-formtter }) { - const location = await _downloadVeonona(); - const componentRunner = new Runner(location); + await _downloadVeonona(); + const componentRunner = new Runner(); const cmd = [ 'install', 'agent', @@ -453,8 +454,8 @@ async function installRuntime({ storageClassName, // --storage-class logFormatting = DefaultLogFormatter, // --log-formtter }) { - const location = await _downloadVeonona(); - const componentRunner = new Runner(location); + await _downloadVeonona(); + const componentRunner = new Runner(); const cmd = [ 'install', 'runtime', @@ -518,8 +519,8 @@ async function attachRuntime({ runtimeName, // --runtimeName logFormatting = DefaultLogFormatter, // --log-formtter }) { - const location = await _downloadVeonona(); - const componentRunner = new Runner(location); + await _downloadVeonona(); + const componentRunner = new Runner(); const cmd = [ 'attach', '--kube-context-name', From 62cf032c8af7ee2ce56da70275b0189075789bae Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Mon, 22 Jun 2020 18:04:07 +0300 Subject: [PATCH 04/19] wip --- Dockerfile | 2 +- lib/binary/downloader.js | 1 + lib/binary/index.js | 3 +- .../cli/commands/cluster/create.cmd.js | 49 ++++++----- .../cli/commands/components/update.cmd.js | 10 ++- lib/interface/cli/commands/hybrid/helper.js | 60 +++++++++----- .../cli/commands/monitor/install.cmd.js | 81 +++++++++++-------- package.json | 4 +- 8 files changed, 122 insertions(+), 88 deletions(-) diff --git a/Dockerfile b/Dockerfile index a99eb1c46..1e817fd20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,5 +39,5 @@ RUN apk del yarn RUN ln -s $(pwd)/lib/interface/cli/codefresh /usr/local/bin/codefresh -RUN codefresh components update +RUN codefresh components update --location components ENTRYPOINT ["codefresh"] diff --git a/lib/binary/downloader.js b/lib/binary/downloader.js index 9338c80b8..bd488005d 100644 --- a/lib/binary/downloader.js +++ b/lib/binary/downloader.js @@ -163,4 +163,5 @@ class Downloader { module.exports = { CommonProgressFormat: 'downloading [{bar}] {percentage}% | {value}/{total}', Downloader, + CODEFRESH_PATH, }; diff --git a/lib/binary/index.js b/lib/binary/index.js index a1edeefa8..79542f4a0 100644 --- a/lib/binary/index.js +++ b/lib/binary/index.js @@ -1,10 +1,11 @@ const components = require('./components'); const { Runner } = require('./runner'); -const { Downloader, CommonProgressFormat } = require('./downloader'); +const { Downloader, CommonProgressFormat, CODEFRESH_PATH } = require('./downloader'); module.exports = { components, Runner, Downloader, CommonProgressFormat, + CODEFRESH_PATH, }; diff --git a/lib/interface/cli/commands/cluster/create.cmd.js b/lib/interface/cli/commands/cluster/create.cmd.js index 890e44034..06f95e914 100644 --- a/lib/interface/cli/commands/cluster/create.cmd.js +++ b/lib/interface/cli/commands/cluster/create.cmd.js @@ -1,8 +1,8 @@ const Command = require('../../Command'); const createRoot = require('../root/create.cmd'); const { sdk } = require('../../../../logic'); -const ProgressEvents = require('../../helpers/progressEvents'); -const cliProgress = require('cli-progress'); +const { downloadSteveDore } = require('../hybrid/helper'); +const { Runner, components } = require('../../../../binary'); const command = new Command({ command: 'clusters [name]', @@ -53,33 +53,30 @@ const command = new Command({ if (terminateProcess === undefined) { terminateProcess = true; } - const events = new ProgressEvents(); - const format = 'downloading cluster installer [{bar}] {percentage}% | {value}/{total}'; - const progressBar = new cliProgress.SingleBar( - { stopOnComplete: true, format }, - cliProgress.Presets.shades_classic, - ); - let clusterTotalSize; - events.onStart((size) => { - progressBar.start(size, 0); - clusterTotalSize = size; - }); - events.onProgress((progress) => { - progressBar.update(progress); - if (progress >= clusterTotalSize) { - console.log('\n'); - } - }); - return sdk.clusters.create({ + const binLocation = await downloadSteveDore(); + const componentRunner = new Runner(binLocation); + const commands = [ + 'create', + '--c', contextName, - context, + '--token', + context.token, + '--api-host', + `${context.url}/`, + '--namespace', namespace, + '--serviceaccount', serviceaccount, - behindFirewall, - name, - terminateProcess, - events, - }); + ]; + if (name) { + commands.push('--name-overwrite'); + commands.push(name); + } + if (behindFirewall) { + commands.push('--behind-firewall'); + } + + await componentRunner.run(components.stevedore, commands); }, }); diff --git a/lib/interface/cli/commands/components/update.cmd.js b/lib/interface/cli/commands/components/update.cmd.js index 5e6c5bd3a..1539c0145 100644 --- a/lib/interface/cli/commands/components/update.cmd.js +++ b/lib/interface/cli/commands/components/update.cmd.js @@ -10,9 +10,15 @@ const command = new Command({ category: 'Componenets', title: 'Update', }, - handler: async () => { + builder: yargs => yargs + .env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv + .option('location', { + describe: 'Override dowload folder location', + }), + handler: async (argv) => { console.log('Updating components'); - await helper.downloadRelatedComponents(); + const { location } = argv; + await helper.downloadRelatedComponents(location); }, }); diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index 7d4f559e8..9bce5b95a 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -13,6 +13,7 @@ const figlet = require('figlet'); const path = require('path'); const { components, Runner, Downloader, CommonProgressFormat, + CODEFRESH_PATH, } = require('./../../../../binary'); const { pathExists } = require('../../helpers/general'); @@ -25,6 +26,7 @@ const INSTALLATION_DEFAULTS = { CF_CONTEXT_NAME: 'cf-runner', STORAGE_CLASS_PREFIX: 'dind-local-volumes-runner', RESUME_OLD_INSTALLATION: true, + COMPONENTS_FOLDER: 'components', }; const maxRuntimeNameLength = 63; @@ -310,7 +312,7 @@ async function getRecommendedKubeNamespace(kubeconfigPath, kubeContextName) { return name; } -async function _downloadVeonona() { +async function downloadVeonona(location = CODEFRESH_PATH) { const downloader = new Downloader({ progress: new cliProgress.SingleBar( { @@ -319,21 +321,21 @@ async function _downloadVeonona() { }, cliProgress.Presets.shades_classic, ), + location, }); const [error] = await to(downloader.download(components.venona)); - if (error != null) { - const newLocation = path.join(process.cwd(), components.venona.local.binary); + const newLocation = path.join(INSTALLATION_DEFAULTS.COMPONENTS_FOLDER, components.venona.local.dir, components.venona.local.binary); if (await pathExists(newLocation)) { - console.log('Failed to download insatller, using local version'); - return INSTALLATION_DEFAULTS.COMPONENETS_INSTALLATION_PATH; + console.log('Failed to download insatller, using binary from components folder'); + return path.resolve(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER); } console.log('Failed to download component, aborting'); throw error; } - return downloader.location; + return location; } -async function _downloadSteveDore() { +async function downloadSteveDore(location = CODEFRESH_PATH) { const downloader = new Downloader({ progress: new cliProgress.SingleBar( { @@ -342,20 +344,34 @@ async function _downloadSteveDore() { }, cliProgress.Presets.shades_classic, ), + location, }); - await downloader.download(components.stevedore); + const [error] = await to(downloader.download(components.stevedore)); + if (error != null) { + const newLocation = path.join( + INSTALLATION_DEFAULTS.COMPONENTS_FOLDER, + components.stevedore.local.dir, components.stevedore.local.binary, + ); + if (await pathExists(newLocation)) { + console.log('Failed to download insatller, using binary from components folder'); + return path.resolve(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER); + } + console.log('Failed to download component, aborting'); + throw error; + } + return location; } -async function downloadHybridComponents() { - await _downloadVeonona(); - console.log('Kubernetes components installer downloaded successfully'); - await _downloadSteveDore(); - console.log('Kubernetes registrator installer downloaded successfully'); +async function downloadHybridComponents(location) { + await downloadVeonona(location); + console.log(`Kubernetes components installer downloaded successfully to ${location} `); + await downloadSteveDore(location); + console.log(`Kubernetes registrator installer downloaded successfully ${location}`); } async function runClusterAcceptanceTests({ kubeNamespace, kubeConfigPath }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const binLocation = await downloadVeonona(); + const componentRunner = new Runner(binLocation); const cmd = ['test', '--log-formtter', DefaultLogFormatter]; if (kubeNamespace) { cmd.push('--kube-namespace'); @@ -385,8 +401,8 @@ async function installAgent({ verbose, // --verbose logFormatting = DefaultLogFormatter, // --log-formtter }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const binLocation = await downloadVeonona(); + const componentRunner = new Runner(binLocation); const cmd = [ 'install', 'agent', @@ -454,8 +470,8 @@ async function installRuntime({ storageClassName, // --storage-class logFormatting = DefaultLogFormatter, // --log-formtter }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const binLocation = await downloadVeonona(); + const componentRunner = new Runner(binLocation); const cmd = [ 'install', 'runtime', @@ -519,8 +535,8 @@ async function attachRuntime({ runtimeName, // --runtimeName logFormatting = DefaultLogFormatter, // --log-formtter }) { - await _downloadVeonona(); - const componentRunner = new Runner(); + const binLocation = await downloadVeonona(); + const componentRunner = new Runner(binLocation); const cmd = [ 'attach', '--kube-context-name', @@ -648,6 +664,8 @@ module.exports = { newAgentName, parseNodeSelector, downloadRelatedComponents: downloadHybridComponents, + downloadSteveDore, + downloadVeonona, INSTALLATION_DEFAULTS, DefaultLogFormatter, }; diff --git a/lib/interface/cli/commands/monitor/install.cmd.js b/lib/interface/cli/commands/monitor/install.cmd.js index 94269d719..10152be2a 100644 --- a/lib/interface/cli/commands/monitor/install.cmd.js +++ b/lib/interface/cli/commands/monitor/install.cmd.js @@ -2,9 +2,9 @@ const Command = require('../../Command'); const installRoot = require('../root/install.cmd'); const { sdk } = require('../../../../logic'); -const ProgressEvents = require('../../helpers/progressEvents'); -const cliProgress = require('cli-progress'); const { DefaultLogFormatter } = require('./../hybrid/helper'); +const { downloadVeonona } = require('../hybrid/helper'); +const { Runner, components } = require('../../../../binary'); const installMonitorCmd = new Command({ root: false, @@ -39,49 +39,60 @@ const installMonitorCmd = new Command({ handler: async (argv) => { const { url, - 'kube-config-path': kubeConfigPath, + // 'kube-config-path': kubeConfigPath, 'cluster-id': clusterId, token, 'kube-context-name': kubeContextName, 'kube-namespace': kubeNamespace, verbose, - noExit, + // noExit, } = argv; const apiHost = sdk.config.context.url; - const events = new ProgressEvents(); - const format = 'downloading [{bar}] {percentage}% | {value}/{total}'; - const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic); - let totalSize; - events.onStart((size) => { - console.log('Downloading agent\'s installer \n'); - progressBar.start(size, 0); - totalSize = size; - }); - events.onProgress((progress) => { - progressBar.update(progress); - if (progress >= totalSize) { - console.log('\n'); - } - }); - const monitorInstallStatusCode = await sdk.monitor.install({ - apiHost, - kubeContextName, - kubeNamespace, - token, - clusterId, - kubeConfigPath, - verbose, - events, - codefreshHost: url, - logFormatting: DefaultLogFormatter, - }); - if (monitorInstallStatusCode !== 0) { - throw new Error(`\nCodefresh Monitoring installation failed with code ${monitorInstallStatusCode}`); + + const binLocation = await downloadVeonona(); + const componentRunner = new Runner(binLocation); + + const commands = [ + 'install', + 'monitor', + ]; + + if (clusterId) { + commands.push('--clusterId'); + commands.push(clusterId); + } + + if (token) { + commands.push('--codefreshToken'); + commands.push(token); } - if (!noExit) { - process.exit(0); + if (kubeContextName) { + commands.push('--kube-context-name'); + commands.push(kubeContextName); } + + // if (helm3) { + // commands.push('--helm3'); + // } + + if (kubeNamespace) { + commands.push('--kube-namespace'); + commands.push(kubeNamespace); + } + + if (url) { + commands.push('--codefreshHost'); + commands.push(url); + } + if (verbose) { + commands.push('--verbose'); + } + if (DefaultLogFormatter) { + commands.push(`--log-formtter=${DefaultLogFormatter}`); + } + + await componentRunner.run(components.venona, commands); }, }); diff --git a/package.json b/package.json index dd087f92c..3a20c4c4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.68.14", + "version": "0.69.0", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true, @@ -91,7 +91,7 @@ "author": "Codefresh", "license": "ISC", "engines": { - "node": ">=8.0.0" + "node": "10.x" }, "jest": { "testEnvironment": "node", From ba8214b5b4f02fc8487bce09ee04d3ebdbcff208 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Mon, 22 Jun 2020 19:36:27 +0300 Subject: [PATCH 05/19] fix ut --- lib/interface/cli/commands/cluster/cluster.sdk.spec.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/interface/cli/commands/cluster/cluster.sdk.spec.js b/lib/interface/cli/commands/cluster/cluster.sdk.spec.js index 1639ed2bf..777ac44bd 100644 --- a/lib/interface/cli/commands/cluster/cluster.sdk.spec.js +++ b/lib/interface/cli/commands/cluster/cluster.sdk.spec.js @@ -1,12 +1,12 @@ const getCmd = require('./get.cmd').toCommand(); const deleteCmd = require('./delete.cmd').toCommand(); const createCmd = require('./create.cmd').toCommand(); -const { sdk } = require('../../../../logic'); - +const { Runner } = require('./../../../../binary'); const request = require('requestretry'); jest.mock('../../../../logic/entities/Cluster'); - +jest.mock('../hybrid/helper'); +jest.mock('./../../../../binary'); const DEFAULT_RESPONSE = request.__defaultResponse(); @@ -29,10 +29,9 @@ describe('cluster commands', () => { describe('create', () => { it('should skip', async () => { - jest.spyOn(sdk.clusters, 'create').mockImplementation(); const argv = {}; await createCmd.handler(argv); - expect(sdk.clusters.create).toBeCalled(); + expect(Runner.mock.instances[0].run).toBeCalled(); }); }); From c3aaa1bc89771e959f5437e4204a344cd1d713d8 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Tue, 23 Jun 2020 15:52:31 +0300 Subject: [PATCH 06/19] wip --- lib/binary/downloader.js | 5 ++++- lib/interface/cli/commands/hybrid/helper.js | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/binary/downloader.js b/lib/binary/downloader.js index bd488005d..46cbbc2db 100644 --- a/lib/binary/downloader.js +++ b/lib/binary/downloader.js @@ -125,7 +125,7 @@ class Downloader { const version = component.version.prefix ? `${component.version.prefix}${remoteVersion}` : remoteVersion; const url = _buildDownloadURL({ name, version, binary }); const resp = await request(url); - + if (this.progress) { let size = 0; resp.on('response', (res) => { @@ -156,6 +156,9 @@ class Downloader { } resolveFn(); }); + resp.on('error', (err) => { + rejectFn(err); + }); }); } } diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index cfd3bcd15..a6c34e999 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -324,7 +324,7 @@ async function downloadVeonona(location = CODEFRESH_PATH) { location, }); const [error] = await to(downloader.download(components.venona)); - if (error != null) { + if (error) { const newLocation = path.join(INSTALLATION_DEFAULTS.COMPONENTS_FOLDER, components.venona.local.dir, components.venona.local.binary); if (await pathExists(newLocation)) { console.log('Failed to download insatller, using binary from components folder'); @@ -347,7 +347,7 @@ async function downloadSteveDore(location = CODEFRESH_PATH) { location, }); const [error] = await to(downloader.download(components.stevedore)); - if (error != null) { + if (error) { const newLocation = path.join( INSTALLATION_DEFAULTS.COMPONENTS_FOLDER, components.stevedore.local.dir, components.stevedore.local.binary, diff --git a/package.json b/package.json index 2b341509f..020af4e34 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "author": "Codefresh", "license": "ISC", "engines": { - "node": "10.x" + "node": ">=8.0.0" }, "jest": { "testEnvironment": "node", From be22cc654de49c218e8d4c5511f3a0fa3c83cb99 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Tue, 23 Jun 2020 17:51:47 +0300 Subject: [PATCH 07/19] typo fix --- lib/interface/cli/commands/hybrid/helper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index a6c34e999..b70699631 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -327,7 +327,7 @@ async function downloadVeonona(location = CODEFRESH_PATH) { if (error) { const newLocation = path.join(INSTALLATION_DEFAULTS.COMPONENTS_FOLDER, components.venona.local.dir, components.venona.local.binary); if (await pathExists(newLocation)) { - console.log('Failed to download insatller, using binary from components folder'); + console.log('Failed to download installer, using binary from components folder'); return path.resolve(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER); } console.log('Failed to download component, aborting'); @@ -353,7 +353,7 @@ async function downloadSteveDore(location = CODEFRESH_PATH) { components.stevedore.local.dir, components.stevedore.local.binary, ); if (await pathExists(newLocation)) { - console.log('Failed to download insatller, using binary from components folder'); + console.log('Failed to download installer, using binary from components folder'); return path.resolve(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER); } console.log('Failed to download component, aborting'); From 64223acbf8bc5ba264b2e7d64a18773ba6f412e1 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Thu, 25 Jun 2020 18:13:59 +0300 Subject: [PATCH 08/19] don't show logs on node version mismatch --- lib/interface/cli/commands/hybrid/init.cmd.js | 4 +++- lib/interface/cli/helpers/logs.js | 11 +++++++++++ lib/logic/entities/Agent.js | 18 +++++++++--------- package.json | 4 ++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/interface/cli/commands/hybrid/init.cmd.js b/lib/interface/cli/commands/hybrid/init.cmd.js index 43f8dd76e..0eb4ecd5b 100644 --- a/lib/interface/cli/commands/hybrid/init.cmd.js +++ b/lib/interface/cli/commands/hybrid/init.cmd.js @@ -368,11 +368,12 @@ const initCmd = new Command({ installationPlan.addStep({ name: 'create new runtime', func: async () => { + const reName = installationPlan.getContext('runtimeName'); const runtimeCreateOpt = { namespace: kubeNamespace, storageClassName: storageClassName || `${INSTALLATION_DEFAULTS.STORAGE_CLASS_PREFIX}-${kubeNamespace}`, clusterName: kubeContextName, - runtimeEnvironmentName: installationPlan.getContext('runtimeName'), + runtimeEnvironmentName: reName, agent: true, }; @@ -381,6 +382,7 @@ const initCmd = new Command({ } await sdk.cluster.create(runtimeCreateOpt); + console.log(`Runtime environment "${colors.cyan(reName)}" has been created`); }, }); diff --git a/lib/interface/cli/helpers/logs.js b/lib/interface/cli/helpers/logs.js index 2863ffdfa..73c626bb9 100644 --- a/lib/interface/cli/helpers/logs.js +++ b/lib/interface/cli/helpers/logs.js @@ -6,6 +6,9 @@ const CFError = require('cf-errors'); const { sdk } = require('../../../logic'); const Workflow = require('../../../logic/entities/Workflow'); const Output = require('../../../output/Output'); +const checkVersion = require('./../../../../check-version'); + +const nodeVersionToValidate = '<=10.x >=8.x'; const END_STATUSES = ['error', 'success', 'terminated']; @@ -53,6 +56,14 @@ async function _fallbackLogs(workflowId, interval, retriesLeft) { } const followLogs = async (workflowId) => { + try { + checkVersion(nodeVersionToValidate); + } catch (error) { + // eslint-disable-next-line max-len + console.log(`As your node version (${process.version}) is not compatible with supported node version (${nodeVersionToValidate}) for this command, you won't be able to see logs`); + return; + } + try { await sdk.logs.showWorkflowLogs(workflowId, true); } catch (e) { diff --git a/lib/logic/entities/Agent.js b/lib/logic/entities/Agent.js index 707146014..aa6240b21 100644 --- a/lib/logic/entities/Agent.js +++ b/lib/logic/entities/Agent.js @@ -10,14 +10,13 @@ class Agent extends Entity { this.name = data.name; this.runtimes = data.runtimes; const status = _.get(data, 'status.healthStatus', 'N/A'); - this.status = this._pickStatusColor(status)(status); + this.status = Agent._pickStatusColor(status)(status); const lastReported = _.get(data, 'status.reportedAt', 'N/A'); - this.reported = this._pickLastReportedColor(status)(lastReported); + this.reported = Agent._pickLastReportedColor(status)(lastReported); this.defaultColumns = ['name', 'runtimes', 'status', 'reported']; } - // eslint-disable-next-line class-methods-use-this - _pickLastReportedColor(healthStatus) { + static _pickLastReportedColor(healthStatus) { switch (healthStatus) { case 'N/A': return chalk.gray; @@ -30,19 +29,20 @@ class Agent extends Entity { } } - _pickStatusColor(healthStatus) { + static _pickStatusColor(healthStatus) { switch (healthStatus) { case 'N/A': - return chalk.white.bgGray; + return chalk.white.bgGray || _.identity; case 'unhealthy': - return chalk.white.bgRed; + return chalk.white.bgRed || _.identity; case 'healthy': - return chalk.black.bgGreen; + return chalk.black.bgGreen || _.identity; default: - return chalk.black.bgRed; + return chalk.black.bgRed || _.identity; } } + static fromResponse(response) { return new Agent(_.pick(response, 'id', 'name', 'runtimes', 'status', 'lastReported')); } diff --git a/package.json b/package.json index 020af4e34..6d02273f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.69.0", + "version": "0.69.1", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true, @@ -91,7 +91,7 @@ "author": "Codefresh", "license": "ISC", "engines": { - "node": ">=8.0.0" + "node": ">=8.x" }, "jest": { "testEnvironment": "node", From be6bfbc3be1fedad4ffcb1d7adde7b530d9043cf Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sat, 27 Jun 2020 21:52:55 +0300 Subject: [PATCH 09/19] fix ut --- lib/interface/cli/helpers/helpers.sdk.spec.js | 21 +++++++++++++------ lib/interface/cli/helpers/logs.js | 1 - 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/interface/cli/helpers/helpers.sdk.spec.js b/lib/interface/cli/helpers/helpers.sdk.spec.js index 3b2ee89f8..4f709ecc9 100644 --- a/lib/interface/cli/helpers/helpers.sdk.spec.js +++ b/lib/interface/cli/helpers/helpers.sdk.spec.js @@ -15,6 +15,7 @@ jest.mock('../../../logic/entities/Context', () => ({ getType: () => 'yaml', }), })); +jest.mock('./../../../../check-version'); jest.mock('../../../logic/entities/Workflow', () => ({ fromResponse: () => ({ @@ -65,6 +66,16 @@ describe('helpers using sdk', () => { expect(sdk.logs.showWorkflowLogs).toBeCalled(); await verifyResponsesReturned([DEFAULT_RESPONSE]); // eslint-disable-line }); + it('should not show logs if check version throw an exception', async () => { + const workflowId = 'id'; + jest.spyOn(sdk.logs, 'showWorkflowLogs').mockImplementation(); + const checkVersion = require('./../../../../check-version'); + checkVersion.mockClear().mockImplementation(() => { + throw new Error(); + }); + await followLogs(workflowId); + expect(sdk.logs.showWorkflowLogs).not.toBeCalled(); + }); }); describe('auth', () => { @@ -151,12 +162,10 @@ describe('helpers using sdk', () => { it('should log all contexts when filter is "all"', async () => { sdk.config.context = Config.manager().getCurrentContext(); - const verifyContexts = _.map(_.values(Config.MOCK_CONTEXTS), (context) => { - return _.mapValues(_.pick(context, context.defaultColumns), (val, key) => { - if (key === 'current') return chalk.green('*'); - return val; - }); - }); + const verifyContexts = _.map(_.values(Config.MOCK_CONTEXTS), context => _.mapValues(_.pick(context, context.defaultColumns), (val, key) => { + if (key === 'current') return chalk.green('*'); + return val; + })); await printTableForAuthContexts(); diff --git a/lib/interface/cli/helpers/logs.js b/lib/interface/cli/helpers/logs.js index 73c626bb9..6856c9916 100644 --- a/lib/interface/cli/helpers/logs.js +++ b/lib/interface/cli/helpers/logs.js @@ -63,7 +63,6 @@ const followLogs = async (workflowId) => { console.log(`As your node version (${process.version}) is not compatible with supported node version (${nodeVersionToValidate}) for this command, you won't be able to see logs`); return; } - try { await sdk.logs.showWorkflowLogs(workflowId, true); } catch (e) { From 25315c3f45a55904000f60f2136a52da7dd46100 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sat, 27 Jun 2020 22:03:50 +0300 Subject: [PATCH 10/19] add message --- lib/interface/cli/helpers/logs.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/interface/cli/helpers/logs.js b/lib/interface/cli/helpers/logs.js index 6856c9916..41d7414ea 100644 --- a/lib/interface/cli/helpers/logs.js +++ b/lib/interface/cli/helpers/logs.js @@ -59,8 +59,10 @@ const followLogs = async (workflowId) => { try { checkVersion(nodeVersionToValidate); } catch (error) { + const url = _.get(sdk, 'config.context.url', 'https://g.codefresh.io'); + const buildLink = `${url}/build/${workflowId}`; // eslint-disable-next-line max-len - console.log(`As your node version (${process.version}) is not compatible with supported node version (${nodeVersionToValidate}) for this command, you won't be able to see logs`); + console.log(`Your node version (${process.version}) is not compatible with supported node version (${nodeVersionToValidate}) for this command, click the link to see it in codefresh UI : ${buildLink}`); return; } try { From b69232ae8df4e6207b0cabc753f9bfd5450f6f28 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sat, 27 Jun 2020 22:13:41 +0300 Subject: [PATCH 11/19] fix ut --- lib/interface/cli/commands/pipeline/pipeline.sdk.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/interface/cli/commands/pipeline/pipeline.sdk.spec.js b/lib/interface/cli/commands/pipeline/pipeline.sdk.spec.js index 1b99a2ffe..883d72618 100644 --- a/lib/interface/cli/commands/pipeline/pipeline.sdk.spec.js +++ b/lib/interface/cli/commands/pipeline/pipeline.sdk.spec.js @@ -7,7 +7,7 @@ const { positionalHandler } = require('./get.completion'); const { sdk } = require('../../../../logic'); jest.mock('../../helpers/validation'); // eslint-disable-line - +jest.mock('../../../../../check-version'); jest.mock('../../completion/helpers', () => { // eslint-disable-line return { authContextWrapper: func => func, From 8cba155af11eee83c46536921916353604ddecef Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sat, 27 Jun 2020 22:35:39 +0300 Subject: [PATCH 12/19] fix ut --- lib/interface/cli/helpers/helpers.sdk.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/interface/cli/helpers/helpers.sdk.spec.js b/lib/interface/cli/helpers/helpers.sdk.spec.js index 4f709ecc9..9e4caa365 100644 --- a/lib/interface/cli/helpers/helpers.sdk.spec.js +++ b/lib/interface/cli/helpers/helpers.sdk.spec.js @@ -70,7 +70,7 @@ describe('helpers using sdk', () => { const workflowId = 'id'; jest.spyOn(sdk.logs, 'showWorkflowLogs').mockImplementation(); const checkVersion = require('./../../../../check-version'); - checkVersion.mockClear().mockImplementation(() => { + checkVersion.mockImplementationOnce(() => { throw new Error(); }); await followLogs(workflowId); From 80e393b799a4614448442929ea111d08f5169db3 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sat, 27 Jun 2020 22:45:17 +0300 Subject: [PATCH 13/19] wip --- lib/interface/cli/helpers/helpers.sdk.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/interface/cli/helpers/helpers.sdk.spec.js b/lib/interface/cli/helpers/helpers.sdk.spec.js index 9e4caa365..671c877eb 100644 --- a/lib/interface/cli/helpers/helpers.sdk.spec.js +++ b/lib/interface/cli/helpers/helpers.sdk.spec.js @@ -16,6 +16,7 @@ jest.mock('../../../logic/entities/Context', () => ({ }), })); jest.mock('./../../../../check-version'); +const checkVersion = require('./../../../../check-version'); jest.mock('../../../logic/entities/Workflow', () => ({ fromResponse: () => ({ @@ -69,7 +70,6 @@ describe('helpers using sdk', () => { it('should not show logs if check version throw an exception', async () => { const workflowId = 'id'; jest.spyOn(sdk.logs, 'showWorkflowLogs').mockImplementation(); - const checkVersion = require('./../../../../check-version'); checkVersion.mockImplementationOnce(() => { throw new Error(); }); From 1419ffa4418d925ea94e6de0a37518ef87ec5dac Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 28 Jun 2020 09:26:33 +0300 Subject: [PATCH 14/19] wip --- lib/interface/cli/helpers/helpers.sdk.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/interface/cli/helpers/helpers.sdk.spec.js b/lib/interface/cli/helpers/helpers.sdk.spec.js index 671c877eb..b47513811 100644 --- a/lib/interface/cli/helpers/helpers.sdk.spec.js +++ b/lib/interface/cli/helpers/helpers.sdk.spec.js @@ -16,7 +16,7 @@ jest.mock('../../../logic/entities/Context', () => ({ }), })); jest.mock('./../../../../check-version'); -const checkVersion = require('./../../../../check-version'); +const versionChecker = require('./../../../../check-version'); jest.mock('../../../logic/entities/Workflow', () => ({ fromResponse: () => ({ @@ -70,7 +70,7 @@ describe('helpers using sdk', () => { it('should not show logs if check version throw an exception', async () => { const workflowId = 'id'; jest.spyOn(sdk.logs, 'showWorkflowLogs').mockImplementation(); - checkVersion.mockImplementationOnce(() => { + versionChecker.checkVersion.mockImplementationOnce(() => { throw new Error(); }); await followLogs(workflowId); From 0a2d501f2747cf632b0b9b1e8851d077791d6a4d Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 28 Jun 2020 09:33:04 +0300 Subject: [PATCH 15/19] wip --- check-version.js | 11 ++++++++--- lib/interface/cli/helpers/logs.js | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/check-version.js b/check-version.js index 2442c9279..7ed0761c4 100644 --- a/check-version.js +++ b/check-version.js @@ -1,8 +1,13 @@ const semver = require('semver'); const { engines } = require('./package'); -const version = engines.node; -if (!semver.satisfies(process.version, version)) { - throw new Error(`Required node version ${version} not satisfied with current version ${process.version}.`); +function checkVersion(version = engines.node) { + if (!semver.satisfies(process.version, version)) { + throw new Error(`Required node version ${version} not satisfied with current version ${process.version}.`); + } } +// checkVersion(); +module.exports = { + checkVersion, +}; diff --git a/lib/interface/cli/helpers/logs.js b/lib/interface/cli/helpers/logs.js index 41d7414ea..bafab5780 100644 --- a/lib/interface/cli/helpers/logs.js +++ b/lib/interface/cli/helpers/logs.js @@ -6,7 +6,7 @@ const CFError = require('cf-errors'); const { sdk } = require('../../../logic'); const Workflow = require('../../../logic/entities/Workflow'); const Output = require('../../../output/Output'); -const checkVersion = require('./../../../../check-version'); +const { checkVersion } = require('./../../../../check-version'); const nodeVersionToValidate = '<=10.x >=8.x'; From 20eabec805d738a5d2628982d79abbcfd3190131 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 28 Jun 2020 09:37:15 +0300 Subject: [PATCH 16/19] wip --- run-check-version.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 run-check-version.js diff --git a/run-check-version.js b/run-check-version.js new file mode 100644 index 000000000..bf74b3d4d --- /dev/null +++ b/run-check-version.js @@ -0,0 +1,3 @@ +const { checkVersion } = require('./check-version'); + +checkVersion(); From 3a3051e3dc566b5e23f4b13d0ade8c0db023e7ca Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 28 Jun 2020 09:45:14 +0300 Subject: [PATCH 17/19] wip --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f77728f32..df3112eb4 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "serve-docs-beta": "ALLOW_BETA_COMMANDS=true yarn build-local-docs && cd temp && hugo server -D", "build-local-docs": "node ./docs/index.js", "build-public-docs": "node ./docs/index.js && cd temp && hugo", - "postinstall": "node check-version.js" + "postinstall": "node run-check-version.js" }, "bin": { "codefresh": "./lib/interface/cli/codefresh" From 42de4bd979b441fe1e28afc8cdf16e2409bab7c3 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 28 Jun 2020 09:48:12 +0300 Subject: [PATCH 18/19] wip --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1e817fd20..532a8eaf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ WORKDIR /cf-cli COPY package.json /cf-cli COPY yarn.lock /cf-cli -COPY check-version.js /cf-cli +COPY run-check-version.js /cf-cli RUN yarn install --prod --frozen-lockfile && \ yarn cache clean From 4c5f8ae025cb69b7f9e23505ad19a5640ecf4db8 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 28 Jun 2020 09:53:11 +0300 Subject: [PATCH 19/19] wip --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 532a8eaf6..08ef29341 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ WORKDIR /cf-cli COPY package.json /cf-cli COPY yarn.lock /cf-cli +COPY check-version.js /cf-cli COPY run-check-version.js /cf-cli RUN yarn install --prod --frozen-lockfile && \