diff --git a/lib/interface/cli/commands/root/create.cmd.js b/lib/interface/cli/commands/root/create.cmd.js index 2e385dc08..55b9e8c56 100644 --- a/lib/interface/cli/commands/root/create.cmd.js +++ b/lib/interface/cli/commands/root/create.cmd.js @@ -1,8 +1,9 @@ +const _ = require('lodash'); const CFError = require('cf-errors'); const Command = require('../../Command'); const { crudFilenameOption } = require('../../helpers/general'); const yargs = require('yargs'); -const { validatePipelineSpec } = require('../../helpers/validation'); +const { validatePipelineSpec, checkOrProjectExists } = require('../../helpers/validation'); const { sdk } = require('../../../../logic'); const get = new Command({ @@ -31,7 +32,7 @@ const get = new Command({ const name = data.metadata.name; if (!name) { - throw new CFError("Name is missing"); + throw new CFError('Name is missing'); } switch (entity) { @@ -52,6 +53,11 @@ const get = new Command({ await sdk.steps.create(data); console.log(`Step-type '${name}' created`); break; + case 'project': + await checkOrProjectExists(name); + await sdk.projects.create({ projectName: name, ..._.pick(data.metadata, ['tags', 'variables']) }); + console.log(`Project: ${name} created`); + break; default: throw new CFError(`Entity: ${entity} not supported`); } diff --git a/lib/logic/index.js b/lib/logic/index.js index 14e69d780..b39fa8f7a 100644 --- a/lib/logic/index.js +++ b/lib/logic/index.js @@ -3,4 +3,3 @@ const sdk = require('./sdk'); module.exports = { sdk, }; - diff --git a/package.json b/package.json index ad34c3c3e..270147c3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.39.1", + "version": "0.39.2", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,