@adobe/aio-cli-plugin-app 11.0.0 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,7 +70,7 @@ DESCRIPTION
70
70
  Create, run, test, and deploy Adobe I/O Apps
71
71
  ```
72
72
 
73
- _See code: [src/commands/app/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/index.ts)_
73
+ _See code: [src/commands/app/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/index.ts)_
74
74
 
75
75
  ## `aio app add`
76
76
 
@@ -88,7 +88,7 @@ DESCRIPTION
88
88
  Add a new component to an existing Adobe I/O App
89
89
  ```
90
90
 
91
- _See code: [src/commands/app/add/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/add/index.ts)_
91
+ _See code: [src/commands/app/add/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/add/index.ts)_
92
92
 
93
93
  ## `aio app add action`
94
94
 
@@ -113,7 +113,7 @@ ALIASES
113
113
  $ aio app add actions
114
114
  ```
115
115
 
116
- _See code: [src/commands/app/add/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/add/action.ts)_
116
+ _See code: [src/commands/app/add/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/add/action.ts)_
117
117
 
118
118
  ## `aio app add ci`
119
119
 
@@ -131,7 +131,7 @@ DESCRIPTION
131
131
  Add CI files
132
132
  ```
133
133
 
134
- _See code: [src/commands/app/add/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/add/ci.ts)_
134
+ _See code: [src/commands/app/add/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/add/ci.ts)_
135
135
 
136
136
  ## `aio app add event`
137
137
 
@@ -156,7 +156,7 @@ ALIASES
156
156
  $ aio app add events
157
157
  ```
158
158
 
159
- _See code: [src/commands/app/add/event.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/add/event.ts)_
159
+ _See code: [src/commands/app/add/event.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/add/event.ts)_
160
160
 
161
161
  ## `aio app add extension`
162
162
 
@@ -182,7 +182,7 @@ ALIASES
182
182
  $ aio app add extensions
183
183
  ```
184
184
 
185
- _See code: [src/commands/app/add/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/add/extension.ts)_
185
+ _See code: [src/commands/app/add/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/add/extension.ts)_
186
186
 
187
187
  ## `aio app add service`
188
188
 
@@ -206,7 +206,7 @@ ALIASES
206
206
  $ aio app add services
207
207
  ```
208
208
 
209
- _See code: [src/commands/app/add/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/add/service.ts)_
209
+ _See code: [src/commands/app/add/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/add/service.ts)_
210
210
 
211
211
  ## `aio app add web-assets`
212
212
 
@@ -227,7 +227,7 @@ DESCRIPTION
227
227
  Add web assets support
228
228
  ```
229
229
 
230
- _See code: [src/commands/app/add/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/add/web-assets.ts)_
230
+ _See code: [src/commands/app/add/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/add/web-assets.ts)_
231
231
 
232
232
  ## `aio app build`
233
233
 
@@ -256,7 +256,7 @@ DESCRIPTION
256
256
  This will always force a rebuild unless --no-force-build is set.
257
257
  ```
258
258
 
259
- _See code: [src/commands/app/build.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/build.ts)_
259
+ _See code: [src/commands/app/build.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/build.ts)_
260
260
 
261
261
  ## `aio app create [PATH]`
262
262
 
@@ -278,7 +278,7 @@ DESCRIPTION
278
278
  Create a new Adobe I/O App with default parameters
279
279
  ```
280
280
 
281
- _See code: [src/commands/app/create.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/create.ts)_
281
+ _See code: [src/commands/app/create.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/create.ts)_
282
282
 
283
283
  ## `aio app delete`
284
284
 
@@ -296,7 +296,7 @@ DESCRIPTION
296
296
  Delete a component from an existing Adobe I/O App
297
297
  ```
298
298
 
299
- _See code: [src/commands/app/delete/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/delete/index.ts)_
299
+ _See code: [src/commands/app/delete/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/delete/index.ts)_
300
300
 
301
301
  ## `aio app delete action [ACTION-NAME]`
302
302
 
@@ -322,7 +322,7 @@ ALIASES
322
322
  $ aio app delete actions
323
323
  ```
324
324
 
325
- _See code: [src/commands/app/delete/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/delete/action.ts)_
325
+ _See code: [src/commands/app/delete/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/delete/action.ts)_
326
326
 
327
327
  ## `aio app delete ci`
328
328
 
@@ -341,7 +341,7 @@ DESCRIPTION
341
341
  Delete existing CI files
342
342
  ```
343
343
 
344
- _See code: [src/commands/app/delete/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/delete/ci.ts)_
344
+ _See code: [src/commands/app/delete/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/delete/ci.ts)_
345
345
 
346
346
  ## `aio app delete extension`
347
347
 
@@ -367,7 +367,7 @@ ALIASES
367
367
  $ aio app delete extensions
368
368
  ```
369
369
 
370
- _See code: [src/commands/app/delete/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/delete/extension.ts)_
370
+ _See code: [src/commands/app/delete/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/delete/extension.ts)_
371
371
 
372
372
  ## `aio app delete service`
373
373
 
@@ -391,7 +391,7 @@ ALIASES
391
391
  $ aio app delete services
392
392
  ```
393
393
 
394
- _See code: [src/commands/app/delete/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/delete/service.ts)_
394
+ _See code: [src/commands/app/delete/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/delete/service.ts)_
395
395
 
396
396
  ## `aio app delete web-assets`
397
397
 
@@ -410,7 +410,7 @@ DESCRIPTION
410
410
  Delete existing web assets
411
411
  ```
412
412
 
413
- _See code: [src/commands/app/delete/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/delete/web-assets.ts)_
413
+ _See code: [src/commands/app/delete/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/delete/web-assets.ts)_
414
414
 
415
415
  ## `aio app deploy`
416
416
 
@@ -451,7 +451,7 @@ DESCRIPTION
451
451
  This will always force a rebuild unless --no-force-build is set.
452
452
  ```
453
453
 
454
- _See code: [src/commands/app/deploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/deploy.ts)_
454
+ _See code: [src/commands/app/deploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/deploy.ts)_
455
455
 
456
456
  ## `aio app get-url [ACTION]`
457
457
 
@@ -474,7 +474,7 @@ DESCRIPTION
474
474
  Get action URLs
475
475
  ```
476
476
 
477
- _See code: [src/commands/app/get-url.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/get-url.ts)_
477
+ _See code: [src/commands/app/get-url.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/get-url.ts)_
478
478
 
479
479
  ## `aio app info`
480
480
 
@@ -496,7 +496,7 @@ DESCRIPTION
496
496
  Display settings/configuration in use by an Adobe I/O App
497
497
  ```
498
498
 
499
- _See code: [src/commands/app/info.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/info.ts)_
499
+ _See code: [src/commands/app/info.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/info.ts)_
500
500
 
501
501
  ## `aio app init [PATH]`
502
502
 
@@ -504,8 +504,8 @@ Create a new Adobe I/O App
504
504
 
505
505
  ```
506
506
  USAGE
507
- $ aio app init [PATH] [-v] [--version] [--install] [-y] [--login] [-e <value> | -t <value>]
508
- [--standalone-app | ] [-w <value> | -i <value>] [--confirm-new-workspace] [--use-jwt]
507
+ $ aio app init [PATH] [-v] [--version] [--install] [-y] [--login] [-e <value> | -t <value> | --repo <value>]
508
+ [--standalone-app | | ] [-w <value> | -i <value>] [--confirm-new-workspace] [--use-jwt]
509
509
 
510
510
  ARGUMENTS
511
511
  PATH [default: .] Path to the app directory
@@ -521,6 +521,7 @@ FLAGS
521
521
  --confirm-new-workspace Skip and confirm prompt for creating a new workspace
522
522
  --[no-]install [default: true] Run npm installation after files are created
523
523
  --[no-]login Login using your Adobe ID for interacting with Adobe I/O Developer Console
524
+ --repo=<value> Init from gh quick-start repo. Expected to be of the form <owner>/<repo>/<path>
524
525
  --standalone-app Create a stand-alone application
525
526
  --use-jwt if the config has both jwt and OAuth Server to Server Credentials (while migrating),
526
527
  prefer the JWT credentials
@@ -530,7 +531,7 @@ DESCRIPTION
530
531
  Create a new Adobe I/O App
531
532
  ```
532
533
 
533
- _See code: [src/commands/app/init.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/init.ts)_
534
+ _See code: [src/commands/app/init.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/init.ts)_
534
535
 
535
536
  ## `aio app list`
536
537
 
@@ -548,7 +549,7 @@ DESCRIPTION
548
549
  List components for Adobe I/O App
549
550
  ```
550
551
 
551
- _See code: [src/commands/app/list/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/list/index.ts)_
552
+ _See code: [src/commands/app/list/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/list/index.ts)_
552
553
 
553
554
  ## `aio app list extension`
554
555
 
@@ -573,7 +574,7 @@ ALIASES
573
574
  $ aio app list extensions
574
575
  ```
575
576
 
576
- _See code: [src/commands/app/list/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/list/extension.ts)_
577
+ _See code: [src/commands/app/list/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/list/extension.ts)_
577
578
 
578
579
  ## `aio app logs`
579
580
 
@@ -597,7 +598,7 @@ DESCRIPTION
597
598
  Fetch logs for an Adobe I/O App
598
599
  ```
599
600
 
600
- _See code: [src/commands/app/logs.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/logs.ts)_
601
+ _See code: [src/commands/app/logs.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/logs.ts)_
601
602
 
602
603
  ## `aio app run`
603
604
 
@@ -620,7 +621,7 @@ DESCRIPTION
620
621
  Run an Adobe I/O App
621
622
  ```
622
623
 
623
- _See code: [src/commands/app/run.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/run.ts)_
624
+ _See code: [src/commands/app/run.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/run.ts)_
624
625
 
625
626
  ## `aio app test`
626
627
 
@@ -648,7 +649,7 @@ DESCRIPTION
648
649
  If the extension has a hook called 'test' in its 'ext.config.yaml', the script specified will be run instead.
649
650
  ```
650
651
 
651
- _See code: [src/commands/app/test.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/test.ts)_
652
+ _See code: [src/commands/app/test.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/test.ts)_
652
653
 
653
654
  ## `aio app undeploy`
654
655
 
@@ -673,7 +674,7 @@ DESCRIPTION
673
674
  Undeploys an Adobe I/O App
674
675
  ```
675
676
 
676
- _See code: [src/commands/app/undeploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/undeploy.ts)_
677
+ _See code: [src/commands/app/undeploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/undeploy.ts)_
677
678
 
678
679
  ## `aio app use [CONFIG_FILE_PATH]`
679
680
 
@@ -721,5 +722,5 @@ DESCRIPTION
721
722
  page in https://developer.adobe.com/console/
722
723
  ```
723
724
 
724
- _See code: [src/commands/app/use.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.0.0/src/commands/app/use.ts)_
725
+ _See code: [src/commands/app/use.ts](https://github.com/adobe/aio-cli-plugin-app/blob/11.1.0/src/commands/app/use.ts)_
725
726
  <!-- commandsstop -->
@@ -17,37 +17,39 @@ const DOCKER_REPOS = { // repo-name:kind
17
17
  'adobe-action-nodejs-v12': 'nodejs:12',
18
18
  'adobe-action-nodejs-v14': 'nodejs:14',
19
19
  'adobe-action-nodejs-v16': 'nodejs:16',
20
- 'adobe-action-nodejs-v18': 'nodejs:18'
20
+ 'adobe-action-nodejs-v18': 'nodejs:18',
21
+ 'adobe-action-nodejs-v20': 'nodejs:20'
21
22
  }
22
23
 
23
24
  const DEFAULT_KIND = 'nodejs:18'
24
25
 
25
- async function main() {
26
- const nodejs = []
27
-
28
- for ([repoName, kind] of Object.entries(DOCKER_REPOS)) {
29
- const data = await fetch(`https://registry.hub.docker.com/v2/repositories/${DOCKER_ORG}/${repoName}/tags`)
30
- const json = await data.json()
31
- const defaultKind = (kind === DEFAULT_KIND)? true : undefined
32
-
33
- nodejs.push({
34
- kind,
35
- default: defaultKind,
36
- image: {
37
- prefix: DOCKER_ORG,
38
- name: repoName,
39
- tag: json.results[0].name
40
- }
41
- })
42
- }
43
-
44
- const output = {
45
- runtimes: {
46
- nodejs
26
+ /** @private */
27
+ async function main () {
28
+ const nodejs = []
29
+
30
+ for (const [repoName, kind] of Object.entries(DOCKER_REPOS)) {
31
+ const data = await fetch(`https://registry.hub.docker.com/v2/repositories/${DOCKER_ORG}/${repoName}/tags`)
32
+ const json = await data.json()
33
+ const defaultKind = (kind === DEFAULT_KIND) ? true : undefined
34
+
35
+ nodejs.push({
36
+ kind,
37
+ default: defaultKind,
38
+ image: {
39
+ prefix: DOCKER_ORG,
40
+ name: repoName,
41
+ tag: json.results[0].name
47
42
  }
43
+ })
44
+ }
45
+
46
+ const output = {
47
+ runtimes: {
48
+ nodejs
48
49
  }
49
- console.log(JSON.stringify(output, null, 2))
50
50
  }
51
+ console.log(JSON.stringify(output, null, 2))
52
+ }
51
53
 
52
- main()
53
-
54
+ main()
55
+ .catch(console.error)
@@ -6,7 +6,7 @@
6
6
  "image": {
7
7
  "prefix": "adobeapiplatform",
8
8
  "name": "adobe-action-nodejs-v10",
9
- "tag": "3.0.37"
9
+ "tag": "3.0.39"
10
10
  }
11
11
  },
12
12
  {
@@ -14,7 +14,7 @@
14
14
  "image": {
15
15
  "prefix": "adobeapiplatform",
16
16
  "name": "adobe-action-nodejs-v12",
17
- "tag": "3.0.37"
17
+ "tag": "3.0.39"
18
18
  }
19
19
  },
20
20
  {
@@ -22,7 +22,7 @@
22
22
  "image": {
23
23
  "prefix": "adobeapiplatform",
24
24
  "name": "adobe-action-nodejs-v14",
25
- "tag": "3.0.37"
25
+ "tag": "3.0.39"
26
26
  }
27
27
  },
28
28
  {
@@ -30,7 +30,7 @@
30
30
  "image": {
31
31
  "prefix": "adobeapiplatform",
32
32
  "name": "adobe-action-nodejs-v16",
33
- "tag": "3.0.37"
33
+ "tag": "3.0.39"
34
34
  }
35
35
  },
36
36
  {
@@ -39,7 +39,15 @@
39
39
  "image": {
40
40
  "prefix": "adobeapiplatform",
41
41
  "name": "adobe-action-nodejs-v18",
42
- "tag": "3.0.37"
42
+ "tag": "3.0.39"
43
+ }
44
+ },
45
+ {
46
+ "kind": "nodejs:20",
47
+ "image": {
48
+ "prefix": "adobeapiplatform",
49
+ "name": "adobe-action-nodejs-v20",
50
+ "tag": "3.0.39"
43
51
  }
44
52
  }
45
53
  ]
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "11.0.0",
2
+ "version": "11.1.0",
3
3
  "commands": {
4
4
  "app:build": {
5
5
  "id": "app:build",
@@ -457,7 +457,8 @@
457
457
  "description": "Extension point(s) to implement",
458
458
  "multiple": true,
459
459
  "exclusive": [
460
- "template"
460
+ "template",
461
+ "repo"
461
462
  ]
462
463
  },
463
464
  "standalone-app": {
@@ -466,7 +467,8 @@
466
467
  "description": "Create a stand-alone application",
467
468
  "allowNo": false,
468
469
  "exclusive": [
469
- "template"
470
+ "template",
471
+ "repo"
470
472
  ]
471
473
  },
472
474
  "template": {
@@ -476,6 +478,26 @@
476
478
  "description": "Specify a link to a template that will be installed",
477
479
  "multiple": true
478
480
  },
481
+ "org": {
482
+ "name": "org",
483
+ "type": "option",
484
+ "description": "Specify the Adobe Developer Console Org to init from",
485
+ "hidden": true,
486
+ "multiple": false,
487
+ "exclusive": [
488
+ "import"
489
+ ]
490
+ },
491
+ "project": {
492
+ "name": "project",
493
+ "type": "option",
494
+ "description": "Specify the Adobe Developer Console Project to init from",
495
+ "hidden": true,
496
+ "multiple": false,
497
+ "exclusive": [
498
+ "import"
499
+ ]
500
+ },
479
501
  "workspace": {
480
502
  "name": "workspace",
481
503
  "type": "option",
@@ -493,6 +515,17 @@
493
515
  "description": "Skip and confirm prompt for creating a new workspace",
494
516
  "allowNo": false
495
517
  },
518
+ "repo": {
519
+ "name": "repo",
520
+ "type": "option",
521
+ "description": "Init from gh quick-start repo. Expected to be of the form <owner>/<repo>/<path>",
522
+ "multiple": false,
523
+ "exclusive": [
524
+ "template",
525
+ "extension",
526
+ "standalone-app"
527
+ ]
528
+ },
496
529
  "use-jwt": {
497
530
  "name": "use-jwt",
498
531
  "type": "boolean",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adobe/aio-cli-plugin-app",
3
3
  "description": "Create, Build and Deploy Adobe I/O Applications",
4
- "version": "11.0.0",
4
+ "version": "11.1.0",
5
5
  "author": "Adobe Inc.",
6
6
  "bugs": "https://github.com/adobe/aio-cli-plugin-app/issues",
7
7
  "dependencies": {
@@ -19,6 +19,7 @@
19
19
  "@adobe/generator-aio-app": "^6.0.0",
20
20
  "@adobe/generator-app-common-lib": "^1.0.0",
21
21
  "@adobe/inquirer-table-checkbox": "^1.2.0",
22
+ "@octokit/rest": "^19.0.11",
22
23
  "@oclif/core": "^2.11.6",
23
24
  "@parcel/core": "^2.7.0",
24
25
  "@parcel/reporter-cli": "^2.7.0",
@@ -20,9 +20,10 @@ const generators = require('@adobe/generator-aio-app')
20
20
  const TemplateRegistryAPI = require('@adobe/aio-lib-templates')
21
21
  const inquirer = require('inquirer')
22
22
  const hyperlinker = require('hyperlinker')
23
-
24
23
  const { importConsoleConfig } = require('../../lib/import')
25
24
  const { loadAndValidateConfigFile } = require('../../lib/import-helper')
25
+ const { Octokit } = require('@octokit/rest')
26
+ const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:init', { provider: 'debug' })
26
27
 
27
28
  const DEFAULT_WORKSPACE = 'Stage'
28
29
 
@@ -102,24 +103,28 @@ class InitCommand extends TemplatesCommand {
102
103
  this.log(chalk.green(`Loaded Adobe Developer Console configuration file for the Project '${consoleConfig.project.title}' in the Organization '${consoleConfig.project.org.name}'`))
103
104
  }
104
105
 
105
- // 2. prompt for templates to be installed
106
- const templates = await this.getTemplatesForFlags(flags)
107
- // If no templates selected, init a standalone app
108
- if (templates.length <= 0) {
109
- flags['standalone-app'] = true
110
- }
106
+ if (flags.repo) {
107
+ await this.withQuickstart(flags.repo)
108
+ } else {
109
+ // 2. prompt for templates to be installed
110
+ const templates = await this.getTemplatesForFlags(flags)
111
+ // If no templates selected, init a standalone app
112
+ if (templates.length <= 0) {
113
+ flags['standalone-app'] = true
114
+ }
111
115
 
112
- // 3. run base code generators
113
- const projectName = (consoleConfig && consoleConfig.project.name) || path.basename(process.cwd())
114
- await this.runCodeGenerators(this.getInitialGenerators(flags), flags.yes, projectName)
116
+ // 3. run base code generators
117
+ const projectName = (consoleConfig && consoleConfig.project.name) || path.basename(process.cwd())
118
+ await this.runCodeGenerators(this.getInitialGenerators(flags), flags.yes, projectName)
115
119
 
116
- // 4. install templates
117
- await this.installTemplates({
118
- useDefaultValues: flags.yes,
119
- installNpm: flags.install,
120
- installConfig: flags.login,
121
- templates
122
- })
120
+ // 4. install templates
121
+ await this.installTemplates({
122
+ useDefaultValues: flags.yes,
123
+ installNpm: flags.install,
124
+ installConfig: flags.login,
125
+ templates
126
+ })
127
+ }
123
128
 
124
129
  // 5. import config - if any
125
130
  if (flags.import) {
@@ -128,40 +133,50 @@ class InitCommand extends TemplatesCommand {
128
133
  }
129
134
 
130
135
  async initWithLogin (flags) {
136
+ if (flags.repo) {
137
+ await this.withQuickstart(flags.repo)
138
+ }
131
139
  // this will trigger a login
132
140
  const consoleCLI = await this.getLibConsoleCLI()
133
141
 
134
142
  // 1. select org
135
- const org = await this.selectConsoleOrg(consoleCLI)
143
+ const org = await this.selectConsoleOrg(consoleCLI, flags)
136
144
  // 2. get supported services
137
145
  const orgSupportedServices = await consoleCLI.getEnabledServicesForOrg(org.id)
138
146
  // 3. select or create project
139
- const project = await this.selectOrCreateConsoleProject(consoleCLI, org)
147
+ const project = await this.selectOrCreateConsoleProject(consoleCLI, org, flags)
140
148
  // 4. retrieve workspace details, defaults to Stage
141
149
  const workspace = await this.retrieveWorkspaceFromName(consoleCLI, org, project, flags)
142
150
 
143
- // 5. get list of templates to install
144
- const templates = await this.getTemplatesForFlags(flags, orgSupportedServices)
145
- // If no templates selected, init a standalone app
146
- if (templates.length <= 0) {
147
- flags['standalone-app'] = true
151
+ let templates
152
+ if (!flags.repo) {
153
+ // 5. get list of templates to install
154
+ templates = await this.getTemplatesForFlags(flags, orgSupportedServices)
155
+ // If no templates selected, init a standalone app
156
+ if (templates.length <= 0) {
157
+ flags['standalone-app'] = true
158
+ }
148
159
  }
149
160
 
150
161
  // 6. download workspace config
151
162
  const consoleConfig = await consoleCLI.getWorkspaceConfig(org.id, project.id, workspace.id, orgSupportedServices)
152
163
 
153
164
  // 7. run base code generators
154
- await this.runCodeGenerators(this.getInitialGenerators(flags), flags.yes, consoleConfig.project.name)
165
+ if (!flags.repo) {
166
+ await this.runCodeGenerators(this.getInitialGenerators(flags), flags.yes, consoleConfig.project.name)
167
+ }
155
168
 
156
169
  // 8. import config
157
170
  await this.importConsoleConfig(consoleConfig, flags)
158
171
 
159
172
  // 9. install templates
160
- await this.installTemplates({
161
- useDefaultValues: flags.yes,
162
- installNpm: flags.install,
163
- templates
164
- })
173
+ if (!flags.repo) {
174
+ await this.installTemplates({
175
+ useDefaultValues: flags.yes,
176
+ installNpm: flags.install,
177
+ templates
178
+ })
179
+ }
165
180
 
166
181
  this.log(chalk.blue(chalk.bold(`Project initialized for Workspace ${workspace.name}, you can run 'aio app use -w <workspace>' to switch workspace.`)))
167
182
  }
@@ -275,21 +290,24 @@ class InitCommand extends TemplatesCommand {
275
290
  return [searchCriteria, orderByCriteria, selection, selectionLabel]
276
291
  }
277
292
 
278
- async selectConsoleOrg (consoleCLI) {
293
+ async selectConsoleOrg (consoleCLI, flags) {
279
294
  const organizations = await consoleCLI.getOrganizations()
280
- const selectedOrg = await consoleCLI.promptForSelectOrganization(organizations)
295
+ const selectedOrg = await consoleCLI.promptForSelectOrganization(organizations, { orgId: flags.org, orgCode: flags.org })
281
296
  await this.ensureDevTermAccepted(consoleCLI, selectedOrg.id)
282
297
  return selectedOrg
283
298
  }
284
299
 
285
- async selectOrCreateConsoleProject (consoleCLI, org) {
300
+ async selectOrCreateConsoleProject (consoleCLI, org, flags) {
286
301
  const projects = await consoleCLI.getProjects(org.id)
287
302
  let project = await consoleCLI.promptForSelectProject(
288
303
  projects,
289
- {},
304
+ { projectId: flags.project, projectName: flags.project },
290
305
  { allowCreate: true }
291
306
  )
292
307
  if (!project) {
308
+ if (flags.project) {
309
+ this.error(`--project ${flags.project} not found`)
310
+ }
293
311
  // user has escaped project selection prompt, let's create a new one
294
312
  const projectDetails = await consoleCLI.promptForCreateProjectDetails()
295
313
  project = await consoleCLI.createProject(org.id, projectDetails)
@@ -348,7 +366,56 @@ class InitCommand extends TemplatesCommand {
348
366
  }
349
367
  )
350
368
  }
369
+
370
+ async withQuickstart (fullRepo) {
371
+ const octokit = new Octokit({
372
+ auth: ''
373
+ })
374
+ const spinner = ora('Downloading quickstart repo').start()
375
+ /** @private */
376
+ async function downloadRepoDirRecursive (owner, repo, filePath, basePath) {
377
+ const { data } = await octokit.repos.getContent({ owner, repo, path: filePath })
378
+ for (const fileOrDir of data) {
379
+ if (fileOrDir.type === 'dir') {
380
+ const destDir = path.relative(basePath, fileOrDir.path)
381
+ fs.ensureDirSync(destDir)
382
+ await downloadRepoDirRecursive(owner, repo, fileOrDir.path, basePath)
383
+ } else {
384
+ // todo: use a spinner
385
+ spinner.text = `Downloading ${fileOrDir.path}`
386
+ const response = await fetch(fileOrDir.download_url)
387
+ const jsonResponse = await response.text()
388
+ fs.writeFileSync(path.relative(basePath, fileOrDir.path), jsonResponse)
389
+ }
390
+ }
391
+ }
392
+ // we need to handle n-deep paths, <owner>/<repo>/<path>/<path>
393
+ const [owner, repo, ...restOfPath] = fullRepo.split('/')
394
+ const basePath = restOfPath.join('/')
395
+ try {
396
+ const response = await octokit.repos.getContent({ owner, repo, path: `${basePath}/app.config.yaml` })
397
+ aioLogger.debug(`github headers: ${JSON.stringify(response.headers, 0, 2)}`)
398
+ await downloadRepoDirRecursive(owner, repo, basePath, basePath)
399
+ spinner.succeed('Downloaded quickstart repo')
400
+ } catch (e) {
401
+ if (e.status === 404) {
402
+ spinner.fail('Quickstart repo not found')
403
+ this.error('--repo does not point to a valid Adobe App Builder app')
404
+ }
405
+ if (e.status === 403) {
406
+ // This is helpful for debugging, but by default we don't show it
407
+ // github rate limit is 60 requests per hour for unauthenticated users
408
+ const resetTime = new Date(e.response.headers['x-ratelimit-reset'] * 1000)
409
+ aioLogger.debug(`too many requests, resetTime : ${resetTime.toLocaleTimeString()}`)
410
+ spinner.fail()
411
+ this.error('too many requests, please try again later')
412
+ } else {
413
+ this.error(e)
414
+ }
415
+ }
416
+ }
351
417
  }
418
+
352
419
  InitCommand.description = `Create a new Adobe I/O App
353
420
  `
354
421
 
@@ -372,18 +439,28 @@ InitCommand.flags = {
372
439
  description: 'Extension point(s) to implement',
373
440
  char: 'e',
374
441
  multiple: true,
375
- exclusive: ['template']
442
+ exclusive: ['template', 'repo']
376
443
  }),
377
444
  'standalone-app': Flags.boolean({
378
445
  description: 'Create a stand-alone application',
379
446
  default: false,
380
- exclusive: ['template']
447
+ exclusive: ['template', 'repo']
381
448
  }),
382
449
  template: Flags.string({
383
450
  description: 'Specify a link to a template that will be installed',
384
451
  char: 't',
385
452
  multiple: true
386
453
  }),
454
+ org: Flags.string({
455
+ description: 'Specify the Adobe Developer Console Org to init from',
456
+ hidden: true,
457
+ exclusive: ['import'] // also no-login
458
+ }),
459
+ project: Flags.string({
460
+ description: 'Specify the Adobe Developer Console Project to init from',
461
+ hidden: true,
462
+ exclusive: ['import'] // also no-login
463
+ }),
387
464
  workspace: Flags.string({
388
465
  description: 'Specify the Adobe Developer Console Workspace to init from, defaults to Stage',
389
466
  default: DEFAULT_WORKSPACE,
@@ -394,6 +471,10 @@ InitCommand.flags = {
394
471
  description: 'Skip and confirm prompt for creating a new workspace',
395
472
  default: false
396
473
  }),
474
+ repo: Flags.string({
475
+ description: 'Init from gh quick-start repo. Expected to be of the form <owner>/<repo>/<path>',
476
+ exclusive: ['template', 'extension', 'standalone-app']
477
+ }),
397
478
  'use-jwt': Flags.boolean({
398
479
  description: 'if the config has both jwt and OAuth Server to Server Credentials (while migrating), prefer the JWT credentials',
399
480
  default: false