|
1 | 1 | const { localConfig } = require('./config');
|
2 | 2 | const { projectsList } = require('./commands/projects');
|
| 3 | +const { teamsList } = require('./commands/teams'); |
3 | 4 | const { functionsListRuntimes } = require('./commands/functions');
|
4 | 5 | const { accountListMfaFactors } = require("./commands/account");
|
5 | 6 | const { sdkForConsole } = require("./sdks");
|
@@ -117,6 +118,35 @@ const questionsInitProject = [
|
117 | 118 | return Object.keys(localConfig.getProject()).length !== 0;
|
118 | 119 | }
|
119 | 120 | },
|
| 121 | + { |
| 122 | + type: "list", |
| 123 | + name: "organization", |
| 124 | + message: "Choose the project Organization", |
| 125 | + choices: async () => { |
| 126 | + let client = await sdkForConsole(true); |
| 127 | + |
| 128 | + let response = await teamsList({ |
| 129 | + parseOutput: false, |
| 130 | + sdk: client |
| 131 | + }) |
| 132 | + let teams = response["teams"] |
| 133 | + let choices = teams.map((team, idx) => { |
| 134 | + return { |
| 135 | + name: `${team.name} (${team['$id']})`, |
| 136 | + value: { |
| 137 | + name: team.name, |
| 138 | + id: team['$id'] |
| 139 | + } |
| 140 | + } |
| 141 | + }) |
| 142 | + |
| 143 | + if (choices.length == 0) { |
| 144 | + throw new Error("No organizations found. Please create a new organization.") |
| 145 | + } |
| 146 | + |
| 147 | + return choices; |
| 148 | + } |
| 149 | + }, |
120 | 150 | {
|
121 | 151 | type: "list",
|
122 | 152 | name: "start",
|
@@ -163,9 +193,10 @@ const questionsInitProject = [
|
163 | 193 | when(answers) {
|
164 | 194 | return answers.start == "existing";
|
165 | 195 | },
|
166 |
| - choices: async () => { |
| 196 | + choices: async (answers) => { |
167 | 197 | let response = await projectsList({
|
168 |
| - parseOutput: false |
| 198 | + parseOutput: false, |
| 199 | + queries: [JSON.stringify({ method: 'equal', attribute:'teamId', values: [answers.organization.id] })], |
169 | 200 | })
|
170 | 201 | let projects = response["projects"]
|
171 | 202 | let choices = projects.map((project, idx) => {
|
@@ -209,12 +240,12 @@ const questionsInitFunction = [
|
209 | 240 | parseOutput: false
|
210 | 241 | })
|
211 | 242 | let runtimes = response["runtimes"]
|
212 |
| - let choices = runtimes.map((runtime, idx) => { |
| 243 | + let choices = runtimes.map((runtime, idx) => { |
213 | 244 | return {
|
214 | 245 | name: `${runtime.name} (${runtime['$id']})`,
|
215 |
| - value: { |
216 |
| - id: runtime['$id'], |
217 |
| - entrypoint: getEntrypoint(runtime['$id']), |
| 246 | + value: { |
| 247 | + id: runtime['$id'], |
| 248 | + entrypoint: getEntrypoint(runtime['$id']), |
218 | 249 | ignore: getIgnores(runtime['$id']),
|
219 | 250 | commands : getInstallCommand(runtime['$id'])
|
220 | 251 | },
|
@@ -403,7 +434,7 @@ const questionsListFactors = [
|
403 | 434 | sdk: client,
|
404 | 435 | parseOutput: false
|
405 | 436 | });
|
406 |
| - |
| 437 | + |
407 | 438 | const choices = [
|
408 | 439 | {
|
409 | 440 | name: `TOTP (Time-based One-time Password)`,
|
|
0 commit comments