Repository: nuxt/create-nuxt-app
Pull request #737 (2021-03-06 10:09:23)

feat: Add CircleCI and Travis CI
Adds CircleCI and Travis CI as continuous integration options.


Patch:
diff --git a/README.md b/README.md
index a249109..19770b0 100644
--- a/README.md
+++ b/README.md
@@ -80,6 +80,8 @@ yarn create nuxt-app <my-project>
     - [Dependabot (for GitHub only)](https://dependabot.com/)
 1. Continous Integration
     - [GitHub Actions](https://github.com/features/actions)
+    - [Travis CI](https://travis-ci.com)
+    - [CircleCI](https://circleci.com)
 
 ## CLI Options
 
diff --git a/packages/cna-template/template/frameworks/circleci/.circleci/config.yml b/packages/cna-template/template/frameworks/circleci/.circleci/config.yml
new file mode 100644
index 0000000..cef7c27
--- /dev/null
+++ b/packages/cna-template/template/frameworks/circleci/.circleci/config.yml
@@ -0,0 +1,56 @@
+version: 2
+
+jobs:
+  ci:
+    docker:
+      - image: cimg/node:lts
+    steps:
+      - checkout
+
+      - restore_cache:
+          keys:
+            <%_ if (pm === 'npm') { _%>
+            - node-v1-{{ checksum "package-lock.json" }}
+            <%_ } _%>
+            <%_ if (pm === 'yarn') { _%>
+            - yarn-v1-{{ checksum "yarn.lock" }}
+            <%_ } _%>
+
+      - run:
+          name: Install dependencies
+          command: <%= pm === 'yarn' ? 'yarn --frozen-lockfile --cache-folder ~/.cache/yarn': 'npm ci'  %>
+
+      - save_cache:
+          <%_ if (pm === 'npm') { _%>
+          key: node-v1-{{ checksum "package-lock.json" }}
+          paths:
+            - ~/.npm
+          <%_ } _%>
+          <%_ if (pm === 'yarn') { _%>
+          key: yarn-v1-{{ checksum "yarn.lock" }}
+          paths:
+            - ~/.cache/yarn
+          <%_ } _%>
+
+      <%_ if (linter.length > 0) { _%>
+      - run:
+          name: Run linter
+          command: <%= pmRun  %> lint
+      <%_ } _%>
+
+      <%_ if (test !== 'none') { _%>
+      - run:
+          name: Run tests
+          command: <%= pmRun  %> test
+      <%_ } _%>
+
+workflows:
+  version: 2
+  ci:
+    jobs:
+      - ci:
+          filters:
+            branches:
+              only:
+                - main
+                - master
diff --git a/packages/cna-template/template/frameworks/travis-ci/.travis.yml b/packages/cna-template/template/frameworks/travis-ci/.travis.yml
new file mode 100644
index 0000000..5f56088
--- /dev/null
+++ b/packages/cna-template/template/frameworks/travis-ci/.travis.yml
@@ -0,0 +1,27 @@
+language: node_js
+node_js:
+  - lts/*
+
+os:
+  - linux
+dist: focal
+
+branches:
+  only:
+    - main
+    - master
+
+<%_ if (pm === 'yarn') { _%>
+cache: yarn
+<%_ } _%>
+<%_ if (pm === 'npm') { _%>
+cache: npm
+<%_ } _%>
+
+script:
+  <%_ if (linter.length > 0) { _%>
+  - <%= pmRun  %> lint
+  <%_ } _%>
+  <%_ if (test !== 'none') { _%>
+  - <%= pmRun  %> test
+  <%_ } _%>
diff --git a/packages/create-nuxt-app/lib/prompts.js b/packages/create-nuxt-app/lib/prompts.js
index c63e42f..1a31b0a 100644
--- a/packages/create-nuxt-app/lib/prompts.js
+++ b/packages/create-nuxt-app/lib/prompts.js
@@ -125,7 +125,9 @@ module.exports = [
     type: 'list',
     choices: [
       { name: 'None', value: 'none' },
-      { name: 'GitHub Actions (GitHub only)', value: 'github-actions' }
+      { name: 'GitHub Actions (GitHub only)', value: 'github-actions' },
+      { name: 'Travis CI', value: 'travis-ci' },
+      { name: 'CircleCI', value: 'circleci' }
     ],
     default: 'none'
   },


Test patch:
diff --git a/packages/create-nuxt-app/test/snapshots/index.test.js.md b/packages/create-nuxt-app/test/snapshots/index.test.js.md
index d3ac0c4..cc8fdad 100644
--- a/packages/create-nuxt-app/test/snapshots/index.test.js.md
+++ b/packages/create-nuxt-app/test/snapshots/index.test.js.md
@@ -4024,6 +4024,176 @@ Generated by [AVA](https://avajs.dev).
 
 ## verify ci: GitHub Actions (GitHub only)
 
+> Generated files
+
+    [
+      '.editorconfig',
+      '.gitignore',
+      'README.md',
+      'assets/README.md',
+      'components/Logo.vue',
+      'components/README.md',
+      'layouts/README.md',
+      'layouts/default.vue',
+      'middleware/README.md',
+      'nuxt.config.js',
+      'package.json',
+      'pages/README.md',
+      'pages/index.vue',
+      'plugins/README.md',
+      'static/README.md',
+      'static/favicon.ico',
+      'store/README.md',
+    ]
+
+> package.json
+
+    {
+      dependencies: {
+        'core-js': '^3.9.1',
+        nuxt: '^2.15.2',
+      },
+      devDependencies: {},
+      private: true,
+      scripts: {
+        build: 'nuxt build',
+        dev: 'nuxt',
+        generate: 'nuxt generate',
+        start: 'nuxt start',
+      },
+    }
+
+> Generated nuxt.config.js
+
+    `export default {␊
+      // Global page headers: https://go.nuxtjs.dev/config-head␊
+      head: {␊
+        title: 'output',␊
+        htmlAttrs: {␊
+          lang: 'en'␊
+        },␊
+        meta: [␊
+          { charset: 'utf-8' },␊
+          { name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
+          { hid: 'description', name: 'description', content: '' }␊
+        ],␊
+        link: [␊
+          { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
+        ]␊
+      },␊
+    ␊
+      // Global CSS: https://go.nuxtjs.dev/config-css␊
+      css: [␊
+      ],␊
+    ␊
+      // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins␊
+      plugins: [␊
+      ],␊
+    ␊
+      // Auto import components: https://go.nuxtjs.dev/config-components␊
+      components: true,␊
+    ␊
+      // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules␊
+      buildModules: [␊
+      ],␊
+    ␊
+      // Modules: https://go.nuxtjs.dev/config-modules␊
+      modules: [␊
+      ],␊
+    ␊
+      // Build Configuration: https://go.nuxtjs.dev/config-build␊
+      build: {␊
+      }␊
+    }␊
+    `
+
+## verify ci: Travis CI
+
+> Generated files
+
+    [
+      '.editorconfig',
+      '.gitignore',
+      'README.md',
+      'assets/README.md',
+      'components/Logo.vue',
+      'components/README.md',
+      'layouts/README.md',
+      'layouts/default.vue',
+      'middleware/README.md',
+      'nuxt.config.js',
+      'package.json',
+      'pages/README.md',
+      'pages/index.vue',
+      'plugins/README.md',
+      'static/README.md',
+      'static/favicon.ico',
+      'store/README.md',
+    ]
+
+> package.json
+
+    {
+      dependencies: {
+        'core-js': '^3.9.1',
+        nuxt: '^2.15.2',
+      },
+      devDependencies: {},
+      private: true,
+      scripts: {
+        build: 'nuxt build',
+        dev: 'nuxt',
+        generate: 'nuxt generate',
+        start: 'nuxt start',
+      },
+    }
+
+> Generated nuxt.config.js
+
+    `export default {␊
+      // Global page headers: https://go.nuxtjs.dev/config-head␊
+      head: {␊
+        title: 'output',␊
+        htmlAttrs: {␊
+          lang: 'en'␊
+        },␊
+        meta: [␊
+          { charset: 'utf-8' },␊
+          { name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
+          { hid: 'description', name: 'description', content: '' }␊
+        ],␊
+        link: [␊
+          { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
+        ]␊
+      },␊
+    ␊
+      // Global CSS: https://go.nuxtjs.dev/config-css␊
+      css: [␊
+      ],␊
+    ␊
+      // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins␊
+      plugins: [␊
+      ],␊
+    ␊
+      // Auto import components: https://go.nuxtjs.dev/config-components␊
+      components: true,␊
+    ␊
+      // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules␊
+      buildModules: [␊
+      ],␊
+    ␊
+      // Modules: https://go.nuxtjs.dev/config-modules␊
+      modules: [␊
+      ],␊
+    ␊
+      // Build Configuration: https://go.nuxtjs.dev/config-build␊
+      build: {␊
+      }␊
+    }␊
+    `
+
+## verify ci: CircleCI
+
 > Generated files
 
     [