Skip to content
10 changes: 8 additions & 2 deletions lib/interface/cli/commands/root/create.cmd.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -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) {
Expand All @@ -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`);
}
Expand Down
1 change: 0 additions & 1 deletion lib/logic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ const sdk = require('./sdk');
module.exports = {
sdk,
};

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.39.1",
"version": "0.39.2",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down