UNPKG

733 BJavaScriptView Raw
1var _ = require('lodash');
2var api = require('../lib/api');
3var log = require('../lib/log');
4var debug = require('debug')('4front:cli:create-org');
5
6require("simple-errors");
7
8module.exports = function(program, done) {
9 log.messageBox("Create a new 4front organization");
10
11 if (_.isEmpty(program.orgName))
12 return done("Please provide a organization name with the --org-name option");
13
14 var requestOptions = {
15 path: '/orgs',
16 method: 'POST',
17 json: {
18 name: program.orgName
19 }
20 };
21
22 debug("invoking api to create organization %s", program.orgName);
23 api(program, requestOptions, function(err, org) {
24 if (err) return done(err);
25
26 log.success("Organization %s created", org.name);
27 done();
28 });
29};