From 6fd1e42f9f305c9c458a1532f80f245d27f73b82 Mon Sep 17 00:00:00 2001
From: Marquise Rosier <mrosier@adobe.com>
Date: Mon, 16 Sep 2019 18:31:25 -0700
Subject: [PATCH] feat(pub): fix tests and remove yargs-debug.js

---
 src/publish.js         |  7 +++++--
 src/yargs-debug.js     | 20 --------------------
 test/testPublishCli.js | 15 +++++++++++++++
 3 files changed, 20 insertions(+), 22 deletions(-)
 delete mode 100644 src/yargs-debug.js

diff --git a/src/publish.js b/src/publish.js
index a6fc13687..68d280840 100644
--- a/src/publish.js
+++ b/src/publish.js
@@ -14,7 +14,6 @@
 
 const yargsOpenwhisk = require('./yargs-openwhisk.js');
 const yargsFastly = require('./yargs-fastly.js');
-const yargsDebug = require('./yargs-debug.js');
 const yargsGithub = require('./yargs-github.js');
 const { makeLogger } = require('./log-common.js');
 
@@ -30,7 +29,6 @@ module.exports = function strain() {
     builder: (yargs) => {
       yargsOpenwhisk(yargs);
       yargsFastly(yargs);
-      yargsDebug(yargs);
       yargsGithub(yargs);
       yargs
         .option('dry-run', {
@@ -81,6 +79,11 @@ module.exports = function strain() {
           choices: ['soft', 'hard', 'skip'],
           default: 'soft',
         })
+        .option('debug-key', {
+          alias: 'debugKey',
+          describe: 'The key to enable the X-Debug header (default is the fastly service id)',
+          type: 'string',
+        })
         .conflicts('only', 'exclude')
         .demandOption(
           'fastly-auth',
diff --git a/src/yargs-debug.js b/src/yargs-debug.js
deleted file mode 100644
index 051a31043..000000000
--- a/src/yargs-debug.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2019 Adobe. All rights reserved.
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License. You may obtain a copy
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
- * OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-
-module.exports = function commonArgs(yargs) {
-  return yargs
-    .option('debug-key', {
-      alias: 'debugKey',
-      describe: 'The key to enable the X-Debug header (default is the fastly service id)',
-      type: 'string',
-    });
-};
diff --git a/test/testPublishCli.js b/test/testPublishCli.js
index e2d6812b0..89584e2af 100644
--- a/test/testPublishCli.js
+++ b/test/testPublishCli.js
@@ -292,4 +292,19 @@ describe('hlx publish', () => {
 
     sinon.assert.fail('hlx publish should fail with empty wsk-auth');
   });
+
+  it('hlx publish handles debug-key', () => {
+    new CLI()
+      .withCommandExecutor('publish', mockPublish)
+      .run(['publish',
+        '--wsk-auth', 'secret-key',
+        '--wsk-namespace', 'hlx',
+        '--fastly-auth', 'secret-key',
+        '--fastly-namespace', 'hlx',
+        '--dispatch-version', 'ci1',
+        '--debug-key', 'something',
+      ]);
+
+    sinon.assert.calledWith(mockPublish.withDebugKey, 'something');
+  });
 });