Repository: intuit/auto
Pull request #678 (2019-11-12 19:44:36)

warn when canary not implemented
# What Changed

See title

# Why

`canary` would make it seem like something happened when nothing actually did.

Todo:

- [x] Add tests

<!-- GITHUB_RELEASE PR BODY: canary-version -->
Published PR with canary version: `7.13.3-canary.678.8898.0`
<!-- GITHUB_RELEASE PR BODY: canary-version -->



Patch:
diff --git a/docs/pages/autorc.md b/docs/pages/autorc.md
index 1d70f251..ae02e156 100644
--- a/docs/pages/autorc.md
+++ b/docs/pages/autorc.md
@@ -2,7 +2,7 @@
 
 All options for the CLI tools can also be configured via the `.autorc`. As CLI options you supply them in snake-case (`--foo-bar`), but as `.autorc` options you supply them in camelCase (`fooBar`),
 
-We use [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) to find your config, so that means you can define this file a variety of ways. Our Cosmiconfig setup is a little custom and will start at the root of your project and start to search up the directory tree for the following:
+We use [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) to find your config. This means you can define this file a variety of ways. Our `cosmiconfig` setup is a little custom and will start at the root of your project and start to search up the directory tree for the following:
 
 - a JSON or YAML, extension-less "rc file"
 - an "rc file" with the extensions `.json`, `.yaml`, or `.yml`
diff --git a/package.json b/package.json
index 87bda8f5..a9ae5eef 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,7 @@
     "eslint-plugin-prettier": "^3.1.1",
     "graphql": "^14.2.1",
     "husky": "^3.0.3",
-    "ignite": "^1.10.5",
+    "ignite": "^1.10.6",
     "jest": "~24.9.0",
     "jest-serializer-path": "^0.1.15",
     "lerna": "^3.13.4",
diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts
index 86277a99..4d511242 100644
--- a/packages/core/src/auto.ts
+++ b/packages/core/src/auto.ts
@@ -11,6 +11,7 @@ import {
   SyncWaterfallHook,
   AsyncSeriesHook
 } from 'tapable';
+import dedent from 'dedent';
 
 import HttpsProxyAgent from 'https-proxy-agent';
 import {
@@ -103,7 +104,7 @@ export interface IAutoHooks {
     string
   >;
   /** Get owner and repository. Typically from a package distribution description file. */
-  getRepository: AsyncSeriesBailHook<[], IRepoOptions & TestingToken | void>;
+  getRepository: AsyncSeriesBailHook<[], (IRepoOptions & TestingToken) | void>;
   /** Tap into the things the Release class makes. This isn't the same as `auto release`, but the main class that does most of the work. */
   onCreateRelease: SyncHook<[Release]>;
   /** This is where you hook into the LogParse's hooks. This hook is exposed for convenience on during `this.hooks.onCreateRelease` and at the root `this.hooks` */
@@ -584,6 +585,17 @@ export default class Auto {
       throw this.createErrorMessage();
     }
 
+    if (!this.hooks.canary.isUsed()) {
+      this.logger.log.error(dedent`
+        None of the plugins that you are using implement the \`canary\` command!
+
+        "canary" releases are versions that are used solely to test changes. They make sense on some platforms (ex: npm) but not all!
+        
+        If you think your package manager has the ability to support canaries please file an issue or submit a pull request,
+      `);
+      process.exit(1);
+    }
+
     // SailEnv falls back to commit SHA
     let pr: string | undefined;
     let build: string | undefined;
diff --git a/yarn.lock b/yarn.lock
index ae1db9f1..ca9ce486 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7880,10 +7880,10 @@ iferr@^0.1.5:
   resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501"
   integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE=
 
-ignite@^1.10.5:
-  version "1.10.5"
-  resolved "https://registry.yarnpkg.com/ignite/-/ignite-1.10.5.tgz#08f63b2ed0153f1784a1f11c716e793595410eab"
-  integrity sha512-g2qsPS6asvtN9hLus1lPWdipcB6cz3ZA3q5QaJgqyVBIf0BhGlClQp/YoVnhHM68z4bsqsXDYl3EtMJ4cd6g3w==
+ignite@^1.10.6:
+  version "1.10.6"
+  resolved "https://registry.yarnpkg.com/ignite/-/ignite-1.10.6.tgz#7437adb122add8eb87ad5371ff31407e7b3a11c4"
+  integrity sha512-kfn+Ayc2YdgsmKBWjPEAyqP50rdo7K51gy2Fs6QMKuCnRHbMPM8VQmf8OLndNMXriH9i3JGjUn2KOuhRUlsIgg==
   dependencies:
     "@babel/cli" "7.2.0"
     "@babel/core" "7.2.0"


Test patch:
diff --git a/packages/core/src/__tests__/auto-canary-in-pr-ci.test.ts b/packages/core/src/__tests__/auto-canary-in-pr-ci.test.ts
index 86d08791..05b1c9c5 100644
--- a/packages/core/src/__tests__/auto-canary-in-pr-ci.test.ts
+++ b/packages/core/src/__tests__/auto-canary-in-pr-ci.test.ts
@@ -51,6 +51,24 @@ describe('canary in ci', () => {
     expect(version!.newVersion).toBe('1.2.4-canary.123.1');
   });
 
+  test('should fail when canaries not implemented', async () => {
+    const auto = new Auto({ ...defaults, plugins: [] });
+
+    // @ts-ignore
+    jest.spyOn(process, 'exit').mockImplementationOnce(() => {});
+    auto.logger = dummyLog();
+    await auto.loadConfig();
+    auto.git!.getLatestRelease = () => Promise.resolve('1.2.3');
+    auto.release!.getCommitsInRelease = () =>
+      Promise.resolve([makeCommitFromMsg('Test Commit')]);
+    const addToPrBody = jest.fn();
+    auto.git!.addToPrBody = addToPrBody;
+    jest.spyOn(auto.release!, 'getCommits').mockImplementation();
+
+    await auto.canary({ pr: 123, build: 1, message: 'false' });
+    expect(process.exit).toHaveBeenCalled();
+  });
+
   test('should not comment when passed "false"', async () => {
     const auto = new Auto({ ...defaults, plugins: [] });
     auto.logger = dummyLog();
@@ -61,6 +79,7 @@ describe('canary in ci', () => {
     const addToPrBody = jest.fn();
     auto.git!.addToPrBody = addToPrBody;
     jest.spyOn(auto.release!, 'getCommits').mockImplementation();
+    auto.hooks.canary.tap('test', (bump, post) => `1.2.4-canary${post}`);
 
     await auto.canary({ pr: 123, build: 1, message: 'false' });
     expect(addToPrBody).not.toHaveBeenCalled();