UNPKG

1.62 kBJavaScriptView Raw
1/*
2 * Copyright 2019 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12
13'use strict';
14
15/* eslint global-require: off */
16
17const { getOrCreateLogger } = require('./log-common.js');
18
19module.exports = function auth() {
20 let executor;
21 return {
22 set executor(value) {
23 executor = value;
24 },
25 command: 'auth',
26 desc: 'Authenticate against 3rd party systems for development and deployment',
27 builder: (yargs) => {
28 yargs
29 .env('NO_HLX_ENV_SUPPORT_FOR_NOW')
30 .option('github', {
31 boolean: true,
32 default: true,
33 describe: 'Run authentication wizard for GitHub.',
34 })
35 .group(['github'/* , 'fastly', 'wsk' */], 'Services')
36 .strict()
37 .help();
38 },
39 handler: async (argv) => {
40 if (!executor) {
41 // eslint-disable-next-line global-require
42 const BuildCommand = require('./auth.cmd'); // lazy load the handler to speed up execution time
43 executor = new BuildCommand(getOrCreateLogger(argv));
44 }
45
46 await executor
47 .run();
48 },
49 };
50};