From 2b3d6ffd106b6cf3969b075a1451d8ec4ed4b381 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Mon, 9 Nov 2020 11:39:25 +0100 Subject: [PATCH] feat(vue): update vue template for vue-instantsearch 3 (#452) * feat(vue): update vue template for vue-instantsearch 3 not much is different, except the version of the library and the compatibility with algoliasearch@4 * update unit test --- .../public/favicon.png-snap.png | Bin 0 -> 1635 bytes e2e/__snapshots__/templates.test.js.snap | 304 +++++++++++++++++- .../__snapshots__/index.test.js.snap | 6 +- .../Vue InstantSearch 2/.editorconfig | 9 + .../Vue InstantSearch 2/.eslintrc.js | 9 + .../Vue InstantSearch 2/.gitignore.template | 21 ++ src/templates/Vue InstantSearch 2/.prettierrc | 5 + .../Vue InstantSearch 2/.template.js | 15 + src/templates/Vue InstantSearch 2/README.md | 21 ++ .../Vue InstantSearch 2/babel.config.js | 3 + .../Vue InstantSearch 2/package.json | 36 +++ .../Vue InstantSearch 2/public/favicon.png | Bin 0 -> 1635 bytes .../Vue InstantSearch 2/public/index.html | 22 ++ src/templates/Vue InstantSearch 2/src/App.vue | 147 +++++++++ src/templates/Vue InstantSearch 2/src/main.js | 11 + src/templates/Vue InstantSearch/.template.js | 2 +- src/templates/Vue InstantSearch/package.json | 2 +- 17 files changed, 607 insertions(+), 6 deletions(-) create mode 100644 e2e/__image_snapshots__/vue-instantsearch-2.x/public/favicon.png-snap.png create mode 100644 src/templates/Vue InstantSearch 2/.editorconfig create mode 100644 src/templates/Vue InstantSearch 2/.eslintrc.js create mode 100644 src/templates/Vue InstantSearch 2/.gitignore.template create mode 100644 src/templates/Vue InstantSearch 2/.prettierrc create mode 100644 src/templates/Vue InstantSearch 2/.template.js create mode 100644 src/templates/Vue InstantSearch 2/README.md create mode 100644 src/templates/Vue InstantSearch 2/babel.config.js create mode 100644 src/templates/Vue InstantSearch 2/package.json create mode 100644 src/templates/Vue InstantSearch 2/public/favicon.png create mode 100644 src/templates/Vue InstantSearch 2/public/index.html create mode 100644 src/templates/Vue InstantSearch 2/src/App.vue create mode 100644 src/templates/Vue InstantSearch 2/src/main.js diff --git a/e2e/__image_snapshots__/vue-instantsearch-2.x/public/favicon.png-snap.png b/e2e/__image_snapshots__/vue-instantsearch-2.x/public/favicon.png-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..f1db2815cb4b755e97e894f1994e691a3ad3385f GIT binary patch literal 1635 zcmV-p2AuhcP)Rb3H) zGhcplS#oLpRf=3fQ=K5F0t%TkpsJvPde@MB2bxmsJECtPup_Xg@J~_wWM^IHn}DR; z;XJjn{%2L%>_gSakOa;&dI#bMXHJMtnzDIzCVFm@M7{=0##$%Oyir6hqUya9K**dB zK^s8pCyb7IY|mi6fxPKy!jP6=#q+a}=#!aXum@0H`V`X0mq=kJ*2UOC1Aji^p&QO`%N@ zEMObi1%qP4C?$;6pcRfcb@Iunhx4qXgWR)!KQBEq!AB+@N@H=E@$OR~NI(th(*@4p zkZ9yUjG%f^C`;m@_F&;G1HBr7I;Wa))%H9Cx93V zCO}_U#_NfuZi=>T=Vib68n>=20r2NruH^%N`2{;_8q+A0B7)HoB51*2v^a1WKN$DE z4lHtkx}s9nw>G(TbrEr9h#MAX0jMr4HpebP(-{{S!alkg5h@Cn-+s>eFbbE?-NN>G zf}@R{9!e@KqMJ>^$5)>B;WHXiI*+2aP&p0^5 zBlnyJY@^~Em;V(6RCB6mGzYs^jh<_y0YbGK63$6bdh_COo_A!FFZ}QKjDF!QJoK9% z;{IQIA8W}?9<%qfPm8bouon1d6RcINP_Y`8XdW3>2)dfYyGbm?U`fOY3;&*@y7rUw@Hb-gudH zHjRbld~Ep9yy~}KXK{T!gNy>l8oJ1fC%Es|-UFJMivmwSG|0KuK1M$KHVC^cqD23N zLqH)&nX>H#08Fnhf!I5y*Oma%`CrJ{mOduC_A-?oEhUxAtS%XSnG6zPI{mC5v7JQB zdHao@_7FE=q|_?jW%D;@c)ifPga6ImjG~#S&$SEy@Sm9*NvERqh!5RylKb=>&IEGp z!ZezpG0xfa>MxtQg{@Q)RWRZ;N_T=ZG#xO%vBDQF`yErA`+4D^Nya<&^5ngPJZ0Zt zhLV3wUk_f2e)+OLGPAbK+b`Uo2k$t>J$euD?!gDrmd=WI{^^H)#ux&Yh6?5wZ^DQF z{S)5zj~{WD$|jz)XOJ^Z{e1cIKk&-me%0SlEa0d9_*48nogw!hILhPpoeTh45GB h+_P%p?RQHL{tsGYpVm<}Z2 1%\\", + \\"last 2 versions\\", + \\"not ie <= 8\\" + ], + \\"partialDependencies\\": { + \\"vue-instantsearch\\": \\"2.0.0\\" + } +}" +`; + +exports[`Templates Vue InstantSearch 2 File content: public/index.html 1`] = ` +" + + + + + + favicon.png\\"> + + + vue-instantsearch-app + + + +
+ + +" +`; + +exports[`Templates Vue InstantSearch 2 File content: src/App.vue 1`] = ` +" + + + +" +`; + +exports[`Templates Vue InstantSearch 2 File content: src/main.js 1`] = ` +"import Vue from 'vue'; +import InstantSearch from 'vue-instantsearch'; +import App from './App.vue'; + +Vue.config.productionTip = false; + +Vue.use(InstantSearch); + +new Vue({ + render: h => h(App), +}).$mount('#app');" +`; + +exports[`Templates Vue InstantSearch 2 Folder structure: contains the right files 1`] = ` +Array [ + ".editorconfig", + ".eslintrc.js", + ".gitignore", + ".prettierrc", + "README.md", + "babel.config.js", + "package.json", + "public/favicon.png", + "public/index.html", + "src/App.vue", + "src/main.js", +] +`; + exports[`Templates Vue InstantSearch File content: .editorconfig 1`] = ` "root = true @@ -5302,7 +5604,7 @@ exports[`Templates Vue InstantSearch File content: package.json 1`] = ` \\"not ie <= 8\\" ], \\"partialDependencies\\": { - \\"vue-instantsearch\\": \\"2.0.0\\" + \\"vue-instantsearch\\": \\"3.0.0\\" } }" `; diff --git a/src/api/__tests__/__snapshots__/index.test.js.snap b/src/api/__tests__/__snapshots__/index.test.js.snap index 1bcaa5ec7..1c0d0297a 100644 --- a/src/api/__tests__/__snapshots__/index.test.js.snap +++ b/src/api/__tests__/__snapshots__/index.test.js.snap @@ -6,10 +6,10 @@ exports[`Options with invalid name throws 1`] = ` - name can only contain URL-friendly characters" `; -exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1"`; +exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; -exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1"`; +exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; exports[`Options without path throws 1`] = `"The option \`path\` is required."`; -exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1"`; +exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; diff --git a/src/templates/Vue InstantSearch 2/.editorconfig b/src/templates/Vue InstantSearch 2/.editorconfig new file mode 100644 index 000000000..9d08a1a82 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/src/templates/Vue InstantSearch 2/.eslintrc.js b/src/templates/Vue InstantSearch 2/.eslintrc.js new file mode 100644 index 000000000..1b63c5ea4 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/.eslintrc.js @@ -0,0 +1,9 @@ +module.exports = { + // extends from 'prettier/vue' until we update the Algolia configuration + extends: ['algolia/vue', 'prettier/vue'], + rules: { + 'import/no-commonjs': 'off', + // enable the rule until we update the Algolia configuration + 'vue/component-name-in-template-casing': ['error', 'kebab-case'], + }, +}; diff --git a/src/templates/Vue InstantSearch 2/.gitignore.template b/src/templates/Vue InstantSearch 2/.gitignore.template new file mode 100644 index 000000000..a0dddc6fb --- /dev/null +++ b/src/templates/Vue InstantSearch 2/.gitignore.template @@ -0,0 +1,21 @@ +.DS_Store +node_modules +/dist + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/src/templates/Vue InstantSearch 2/.prettierrc b/src/templates/Vue InstantSearch 2/.prettierrc new file mode 100644 index 000000000..833f03b62 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "proseWrap": "never", + "trailingComma": "es5" +} diff --git a/src/templates/Vue InstantSearch 2/.template.js b/src/templates/Vue InstantSearch 2/.template.js new file mode 100644 index 000000000..1f4cfa053 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/.template.js @@ -0,0 +1,15 @@ +const install = require('../../tasks/node/install'); +const teardown = require('../../tasks/node/teardown'); + +module.exports = { + category: 'Web', + libraryName: 'vue-instantsearch', + templateName: 'vue-instantsearch-2.x', + supportedVersion: '>= 2.0.0 < 3.0.0', + appName: 'vue-instantsearch-app', + keywords: ['algolia', 'InstantSearch', 'Vue', 'vue-instantsearch'], + tasks: { + install, + teardown, + }, +}; diff --git a/src/templates/Vue InstantSearch 2/README.md b/src/templates/Vue InstantSearch 2/README.md new file mode 100644 index 000000000..f330c8c3e --- /dev/null +++ b/src/templates/Vue InstantSearch 2/README.md @@ -0,0 +1,21 @@ +# {{name}} + +_This project was generated with [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) by [Algolia](https://algolia.com)._ + +## Get started + +To run this project locally, install the dependencies and run the local server: + +```sh +npm install +npm start +``` + +Alternatively, you may use [Yarn](https://http://yarnpkg.com/): + +```sh +yarn +yarn start +``` + +Open http://localhost:3000 to see your app. diff --git a/src/templates/Vue InstantSearch 2/babel.config.js b/src/templates/Vue InstantSearch 2/babel.config.js new file mode 100644 index 000000000..4f45f32b5 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/babel.config.js @@ -0,0 +1,3 @@ +module.exports = { + presets: ['@vue/app'], +}; diff --git a/src/templates/Vue InstantSearch 2/package.json b/src/templates/Vue InstantSearch 2/package.json new file mode 100644 index 000000000..9a43fb875 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/package.json @@ -0,0 +1,36 @@ +{ + "name": "{{name}}", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "vue-cli-service serve --port 3000", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint", + "lint:fix": "npm run lint -- --fix" + }, + "dependencies": { + "algoliasearch": "3.32.0", + "core-js": "2.6.9", + "vue": "2.6.10", + "vue-instantsearch": "{{libraryVersion}}" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "3.6.0", + "@vue/cli-plugin-eslint": "3.6.0", + "@vue/cli-service": "3.6.0", + "babel-eslint": "10.0.2", + "eslint": "5.16.0", + "eslint-config-algolia": "13.2.3", + "eslint-config-prettier": "4.1.0", + "eslint-plugin-import": "2.19.1", + "eslint-plugin-prettier": "3.1.2", + "eslint-plugin-vue": "5.2.2", + "prettier": "1.19.1", + "vue-template-compiler": "2.6.10" + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 8" + ] +} diff --git a/src/templates/Vue InstantSearch 2/public/favicon.png b/src/templates/Vue InstantSearch 2/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..f1db2815cb4b755e97e894f1994e691a3ad3385f GIT binary patch literal 1635 zcmV-p2AuhcP)Rb3H) zGhcplS#oLpRf=3fQ=K5F0t%TkpsJvPde@MB2bxmsJECtPup_Xg@J~_wWM^IHn}DR; z;XJjn{%2L%>_gSakOa;&dI#bMXHJMtnzDIzCVFm@M7{=0##$%Oyir6hqUya9K**dB zK^s8pCyb7IY|mi6fxPKy!jP6=#q+a}=#!aXum@0H`V`X0mq=kJ*2UOC1Aji^p&QO`%N@ zEMObi1%qP4C?$;6pcRfcb@Iunhx4qXgWR)!KQBEq!AB+@N@H=E@$OR~NI(th(*@4p zkZ9yUjG%f^C`;m@_F&;G1HBr7I;Wa))%H9Cx93V zCO}_U#_NfuZi=>T=Vib68n>=20r2NruH^%N`2{;_8q+A0B7)HoB51*2v^a1WKN$DE z4lHtkx}s9nw>G(TbrEr9h#MAX0jMr4HpebP(-{{S!alkg5h@Cn-+s>eFbbE?-NN>G zf}@R{9!e@KqMJ>^$5)>B;WHXiI*+2aP&p0^5 zBlnyJY@^~Em;V(6RCB6mGzYs^jh<_y0YbGK63$6bdh_COo_A!FFZ}QKjDF!QJoK9% z;{IQIA8W}?9<%qfPm8bouon1d6RcINP_Y`8XdW3>2)dfYyGbm?U`fOY3;&*@y7rUw@Hb-gudH zHjRbld~Ep9yy~}KXK{T!gNy>l8oJ1fC%Es|-UFJMivmwSG|0KuK1M$KHVC^cqD23N zLqH)&nX>H#08Fnhf!I5y*Oma%`CrJ{mOduC_A-?oEhUxAtS%XSnG6zPI{mC5v7JQB zdHao@_7FE=q|_?jW%D;@c)ifPga6ImjG~#S&$SEy@Sm9*NvERqh!5RylKb=>&IEGp z!ZezpG0xfa>MxtQg{@Q)RWRZ;N_T=ZG#xO%vBDQF`yErA`+4D^Nya<&^5ngPJZ0Zt zhLV3wUk_f2e)+OLGPAbK+b`Uo2k$t>J$euD?!gDrmd=WI{^^H)#ux&Yh6?5wZ^DQF z{S)5zj~{WD$|jz)XOJ^Z{e1cIKk&-me%0SlEa0d9_*48nogw!hILhPpoeTh45GB h+_P%p?RQHL{tsGYpVm<}Z2 + + + + + + + + + {{name}} + + + +
+ + + diff --git a/src/templates/Vue InstantSearch 2/src/App.vue b/src/templates/Vue InstantSearch 2/src/App.vue new file mode 100644 index 000000000..51af51100 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/src/App.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/src/templates/Vue InstantSearch 2/src/main.js b/src/templates/Vue InstantSearch 2/src/main.js new file mode 100644 index 000000000..d395c9de9 --- /dev/null +++ b/src/templates/Vue InstantSearch 2/src/main.js @@ -0,0 +1,11 @@ +import Vue from 'vue'; +import InstantSearch from 'vue-instantsearch'; +import App from './App.vue'; + +Vue.config.productionTip = false; + +Vue.use(InstantSearch); + +new Vue({ + render: h => h(App), +}).$mount('#app'); diff --git a/src/templates/Vue InstantSearch/.template.js b/src/templates/Vue InstantSearch/.template.js index 0aa014f3b..3a9bd6ed8 100644 --- a/src/templates/Vue InstantSearch/.template.js +++ b/src/templates/Vue InstantSearch/.template.js @@ -5,7 +5,7 @@ module.exports = { category: 'Web', libraryName: 'vue-instantsearch', templateName: 'vue-instantsearch', - supportedVersion: '>= 2.0.0 < 3.0.0', + supportedVersion: '>= 3.0.0 < 4.0.0', appName: 'vue-instantsearch-app', keywords: ['algolia', 'InstantSearch', 'Vue', 'vue-instantsearch'], tasks: { diff --git a/src/templates/Vue InstantSearch/package.json b/src/templates/Vue InstantSearch/package.json index 9a43fb875..371e4abf0 100644 --- a/src/templates/Vue InstantSearch/package.json +++ b/src/templates/Vue InstantSearch/package.json @@ -9,7 +9,7 @@ "lint:fix": "npm run lint -- --fix" }, "dependencies": { - "algoliasearch": "3.32.0", + "algoliasearch": "4.6.0", "core-js": "2.6.9", "vue": "2.6.10", "vue-instantsearch": "{{libraryVersion}}"