MCPcopy Index your code
hub / github.com/acode/cli / run

Method run

cli/commands/create.js:60–246  ·  view source on GitHub ↗
(params, callback)

Source from the content-addressed store, hash-verified

58 }
59
60 run(params, callback) {
61
62 let name = params.args[0];
63
64 let host = params.flags.h ? params.flags.h[0] : 'https://api.autocode.com';
65 let port = params.flags.p && params.flags.p[0];
66
67 let nologin = params.flags.hasOwnProperty('n') || params.vflags.hasOwnProperty('no-login');
68
69 let write = params.flags.hasOwnProperty('w') || params.vflags.hasOwnProperty('write-over');
70
71 let build = DEFAULT_BUILD;
72
73 if (!config.location(0)) {
74 console.log();
75 console.log(chalk.bold.red('Oops!'));
76 console.log();
77 console.log(`You're trying to create a new service in development,`);
78 console.log(`But you're not in your root Autocode project directory.`);
79 console.log();
80 if (!config.workspace()) {
81 console.log(`Initialize a workspace first with:`);
82 console.log(`\t${chalk.bold('lib init')}`);
83 } else {
84 console.log('Visit your workspace directory with:');
85 console.log(`\t${chalk.bold('cd ' + config.workspace())}`);
86 }
87 console.log();
88 return callback(null);
89 }
90
91 console.log();
92 console.log(`Awesome! Let's create an ${chalk.bold.green('Autocode')} service!`);
93 console.log();
94
95 let questions = [];
96
97 name || questions.push({
98 name: 'name',
99 type: 'input',
100 default: '',
101 message: 'Service Name'
102 });
103
104 let login = [];
105 !nologin && login.push((cb) => {
106
107 let resource = new APIResource(host, port);
108 resource.authorize(config.get('ACCESS_TOKEN'));
109
110 resource.request('v1/users').index({me: true}, (err, response) => {
111
112 if (err) {
113 return cb(err);
114 }
115 return cb(null, response.data[0]);
116
117 });

Callers

nothing calls this directly

Calls 4

locationMethod · 0.80
workspaceMethod · 0.80
getMethod · 0.80
requestMethod · 0.80

Tested by

no test coverage detected