diff --git a/package.json b/package.json index 31c9a5b..c443925 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "node": "^8.11.0 || >=10.13.0" }, "dependencies": { + "@tunnckocore/circleci": "^0.2.1", "@tunnckocore/execa": "^2.1.1", "axios": "^0.18.0", "charlike": "^3.1.8", diff --git a/src/enable-circleci.js b/src/enable-circleci.js deleted file mode 100644 index 10fd123..0000000 --- a/src/enable-circleci.js +++ /dev/null @@ -1,17 +0,0 @@ -// https://circleci.com/api/v1.1/project/ -// github/tunnckoCoreLabs/foobar/build?circle-token=XXXX -import proc from 'process'; -import axios from 'axios'; - -export default async function enableCircleCI(answers, type = 'follow') { - const api = 'https://circleci.com/api/v1.1/project'; - const token = - proc.env.CIRCLECI_TOKEN || - answers.circleci_token || - (answers.author && answers.author.circleci_token) || - answers.token; - - return axios.post( - `${api}/github/${answers.repository}/${type}?circle-token=${token}`, - ); -} diff --git a/src/index.js b/src/index.js index 0674ea4..aa286ff 100644 --- a/src/index.js +++ b/src/index.js @@ -7,8 +7,8 @@ import signale from 'signale'; import charlike from 'charlike'; import setValue from 'set-value'; import { exec } from '@tunnckocore/execa'; +import enableCircleCI from '@tunnckocore/circleci'; import createGithubRelease from './create-release'; -import enableCircleCI from './enable-circleci'; import runQuestions from './questions'; /* eslint-disable no-param-reassign, promise/always-return */ @@ -66,7 +66,9 @@ export default async function createProject(initialVersion = '0.0.0') { }), ) .then(() => signale.info('Enabling CircleCI integration ...')) - .then(() => enableCircleCI(ctx.answers)) + .then( + () => ctx.answers.author.circleci_token && enableCircleCI(ctx.answers), + ) .then(() => signale.info(`Publishing version v${initialVersion} to NPM ...`), ) diff --git a/yarn.lock b/yarn.lock index 02317c1..e08f7e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -108,6 +108,14 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd" integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow== +"@tunnckocore/circleci@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@tunnckocore/circleci/-/circleci-0.2.1.tgz#9c8a26ff69f60a188c1bacaa8794ea3007aa8258" + integrity sha512-EXbP/AaIBGrGGVK8+dupr8i/v6dXN+N1nu5nx9TjK62q/gFIeFTAa4Cd6yAONvcRUy6pQm1b3tZb1FMCIPPo7w== + dependencies: + axios "^0.18.0" + esm "^3.0.84" + "@tunnckocore/config@^0.5.1": version "0.5.1" resolved "https://registry.yarnpkg.com/@tunnckocore/config/-/config-0.5.1.tgz#f2ca7cf4442614ead3e5660522c3c02e3312116b"