@@ -3,7 +3,7 @@ const path = require("path");
3
3
const childProcess = require('child_process');
4
4
const { Command } = require("commander");
5
5
const inquirer = require("inquirer");
6
- const { projectsCreate } = require("./projects");
6
+ const { projectsCreate, projectsGet } = require("./projects");
7
7
const { storageCreateBucket } = require("./storage");
8
8
const { messagingCreateTopic } = require("./messaging");
9
9
const { functionsCreate } = require("./functions");
@@ -23,7 +23,7 @@ const { accountGet } = require("./account");
23
23
const { loginCommand } = require("./generic");
24
24
const { sdkForConsole } = require("../sdks");
25
25
26
- const initProject = async () => {
26
+ const initProject = async ({ organizationId, projectId, projectName } = {} ) => {
27
27
let response = {};
28
28
29
29
try {
@@ -40,12 +40,22 @@ const initProject = async () => {
40
40
log('You must login first')
41
41
await loginCommand();
42
42
}
43
+ let answers = {};
43
44
44
- const answers = await inquirer.prompt(questionsInitProject)
45
- if (answers.override === false) {
46
- process.exit(1)
45
+ if (organizationId && projectId) {
46
+ answers = {
47
+ project: { id: projectId, name: projectName },
48
+ organization: { id: organizationId },
49
+ start: 'existing'
50
+ }
51
+ } else {
52
+ answers = await inquirer.prompt(questionsInitProject)
53
+ if (answers.override === false) {
54
+ process.exit(1)
55
+ }
47
56
}
48
57
58
+
49
59
if (answers.start === 'new') {
50
60
response = await projectsCreate({
51
61
projectId: answers.id,
@@ -201,7 +211,6 @@ const initFunction = async () => {
201
211
}
202
212
203
213
204
-
205
214
const copyRecursiveSync = (src, dest) => {
206
215
let exists = fs.existsSync(src);
207
216
let stats = exists && fs.statSync(src);
@@ -254,6 +263,9 @@ const init = new Command("init")
254
263
.configureHelp({
255
264
helpWidth: process.stdout.columns || 80
256
265
})
266
+ .option("--organizationId <organizationId >", "{{ spec .title | caseUcfirst }} organization ID")
267
+ .option("--projectId <projectId >", "{{ spec .title | caseUcfirst }} project ID")
268
+ .option("--projectName <projectnName >", "{{ spec .title | caseUcfirst }} project name")
257
269
.action(actionRunner(initProject));
258
270
259
271
init
0 commit comments