From 211afeffa121401964d1dc36814d0e5581ae7e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Tue, 5 Jun 2018 13:04:28 +0200 Subject: [PATCH] Create InstantSearch App v3 (#10) * feat: Support InstantSearch templates (a870767af9a409275f2a749923cc2d2e9f5fc37b) Closes #9 * feat: Support custom templates (#30) * test(e2e): Test template installations (#14) * test(e2e): Test template snapshots (9b938cca54b5e583284ec4778c22a333bbf570e7) * ci(travis): Add Travis configuration (#22) * docs(readme): Update documentation (#26) * feat(release): Create templates release script (#27) * feat(release): Create release scripts (#28) --- .editorconfig | 10 + .eslintignore | 2 + .eslintrc.js | 8 + .gitignore | 15 + .travis.yml | 16 + LICENSE | 21 + README.md | 215 +- bin/create-instantsearch-app.js | 85 - boilerplates/instantsearch.js/app.js.hbs | 29 - boilerplates/instantsearch.js/index.html.hbs | 49 - boilerplates/instantsearch.js/main.css | 79 - .../instantsearch.js/package.json.hbs | 10 - boilerplates/instantsearch.js/readme.md.hbs | 21 - index.js | 3 + lib/createProject.js | 20 - lib/fetchVersions.js | 35 - package.json | 64 +- packages/cli/cli.js | 223 + packages/cli/index.js | 3 + packages/cli/utils.js | 45 + packages/cli/utils.test.js | 139 + .../createInstantSearchApp.test.js.snap | 15 + .../createInstantSearchApp.js | 114 + .../createInstantSearchApp.test.js | 248 + packages/create-instantsearch-app/index.js | 3 + .../shared/__snapshots__/utils.test.js.snap | 16 + packages/shared/utils.js | 125 + packages/shared/utils.test.js | 95 + packages/tasks/common/build.js | 40 + packages/tasks/common/clean.js | 13 + packages/tasks/node/install.js | 45 + packages/tasks/node/teardown.js | 41 + ...angular-instantsearch-favicon.png-snap.png | Bin 0 -> 2611 bytes ...alls-instantsearch.js-favicon.png-snap.png | Bin 0 -> 906 bytes ...s-react-instantsearch-favicon.png-snap.png | Bin 0 -> 1922 bytes ...lls-vue-instantsearch-favicon.png-snap.png | Bin 0 -> 1635 bytes .../__snapshots__/e2e-templates.test.js.snap | 1877 +++++++ scripts/e2e-installs.test.js | 98 + scripts/e2e-templates.test.js | 104 + scripts/release-templates.js | 154 + templates/Angular InstantSearch/.gitignore | 5 + templates/Angular InstantSearch/.template.js | 13 + templates/Angular InstantSearch/README.md | 19 + templates/Angular InstantSearch/angular.json | 129 + .../e2e/protractor.conf.js | 28 + .../e2e/src/app.e2e-spec.ts | 14 + .../Angular InstantSearch/e2e/src/app.po.ts | 11 + .../e2e/tsconfig.e2e.json | 13 + templates/Angular InstantSearch/package.json | 49 + .../src/app/app.component.css | 49 + .../src/app/app.component.html.hbs | 36 + .../src/app/app.component.spec.ts | 16 + .../src/app/app.component.ts | 14 + .../src/app/app.module.ts | 18 + .../Angular InstantSearch/src/assets/.gitkeep | 0 .../Angular InstantSearch/src/browserslist | 9 + .../src/environments/environment.prod.ts | 3 + .../src/environments/environment.ts | 15 + .../Angular InstantSearch/src/favicon.png | Bin 0 -> 2611 bytes .../Angular InstantSearch/src/index.html | 19 + .../Angular InstantSearch/src/karma.conf.js | 31 + templates/Angular InstantSearch/src/main.ts | 12 + .../Angular InstantSearch/src/manifest.json | 15 + .../Angular InstantSearch/src/polyfills.ts | 85 + .../Angular InstantSearch/src/styles.css | 11 + templates/Angular InstantSearch/src/test.ts | 20 + .../src/tsconfig.app.json | 12 + .../src/tsconfig.spec.json | 19 + .../Angular InstantSearch/src/tslint.json | 17 + templates/Angular InstantSearch/tsconfig.json | 20 + templates/Angular InstantSearch/tslint.json | 130 + templates/InstantSearch.js/.gitignore | 22 + templates/InstantSearch.js/.template.js | 13 + templates/InstantSearch.js/README.md | 19 + templates/InstantSearch.js/favicon.png | Bin 0 -> 906 bytes templates/InstantSearch.js/index.html.hbs | 54 + .../InstantSearch.js/manifest.webmanifest | 15 + templates/InstantSearch.js/package.json | 12 + templates/InstantSearch.js/src/app.css | 69 + templates/InstantSearch.js/src/app.js.hbs | 49 + templates/InstantSearch.js/src/index.css | 10 + templates/React InstantSearch/.gitignore | 21 + templates/React InstantSearch/.template.js | 13 + templates/React InstantSearch/README.md | 19 + templates/React InstantSearch/package.json | 18 + .../React InstantSearch/public/favicon.png | Bin 0 -> 1922 bytes .../React InstantSearch/public/index.html | 29 + .../React InstantSearch/public/manifest.json | 15 + templates/React InstantSearch/src/App.css | 54 + templates/React InstantSearch/src/App.js.hbs | 78 + templates/React InstantSearch/src/index.css | 10 + templates/React InstantSearch/src/index.js | 6 + templates/Vue InstantSearch/.babelrc.template | 6 + templates/Vue InstantSearch/.gitignore | 5 + templates/Vue InstantSearch/.template.js | 13 + templates/Vue InstantSearch/README.md | 19 + templates/Vue InstantSearch/favicon.png | Bin 0 -> 1635 bytes templates/Vue InstantSearch/index.html | 31 + templates/Vue InstantSearch/manifest.json | 15 + templates/Vue InstantSearch/package.json | 26 + templates/Vue InstantSearch/src/App.vue | 139 + templates/Vue InstantSearch/src/main.js | 10 + templates/Vue InstantSearch/webpack.config.js | 76 + yarn.lock | 4960 +++++++++++++++-- 104 files changed, 10015 insertions(+), 723 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc.js create mode 100644 .travis.yml create mode 100644 LICENSE delete mode 100755 bin/create-instantsearch-app.js delete mode 100644 boilerplates/instantsearch.js/app.js.hbs delete mode 100644 boilerplates/instantsearch.js/index.html.hbs delete mode 100644 boilerplates/instantsearch.js/main.css delete mode 100644 boilerplates/instantsearch.js/package.json.hbs delete mode 100644 boilerplates/instantsearch.js/readme.md.hbs create mode 100644 index.js delete mode 100644 lib/createProject.js delete mode 100644 lib/fetchVersions.js create mode 100644 packages/cli/cli.js create mode 100644 packages/cli/index.js create mode 100644 packages/cli/utils.js create mode 100644 packages/cli/utils.test.js create mode 100644 packages/create-instantsearch-app/__snapshots__/createInstantSearchApp.test.js.snap create mode 100755 packages/create-instantsearch-app/createInstantSearchApp.js create mode 100644 packages/create-instantsearch-app/createInstantSearchApp.test.js create mode 100644 packages/create-instantsearch-app/index.js create mode 100644 packages/shared/__snapshots__/utils.test.js.snap create mode 100644 packages/shared/utils.js create mode 100644 packages/shared/utils.test.js create mode 100644 packages/tasks/common/build.js create mode 100644 packages/tasks/common/clean.js create mode 100644 packages/tasks/node/install.js create mode 100644 packages/tasks/node/teardown.js create mode 100644 scripts/__image_snapshots__/e2e-installs-angular-instantsearch-favicon.png-snap.png create mode 100644 scripts/__image_snapshots__/e2e-installs-instantsearch.js-favicon.png-snap.png create mode 100644 scripts/__image_snapshots__/e2e-installs-react-instantsearch-favicon.png-snap.png create mode 100644 scripts/__image_snapshots__/e2e-installs-vue-instantsearch-favicon.png-snap.png create mode 100644 scripts/__snapshots__/e2e-templates.test.js.snap create mode 100644 scripts/e2e-installs.test.js create mode 100644 scripts/e2e-templates.test.js create mode 100644 scripts/release-templates.js create mode 100644 templates/Angular InstantSearch/.gitignore create mode 100644 templates/Angular InstantSearch/.template.js create mode 100644 templates/Angular InstantSearch/README.md create mode 100644 templates/Angular InstantSearch/angular.json create mode 100644 templates/Angular InstantSearch/e2e/protractor.conf.js create mode 100644 templates/Angular InstantSearch/e2e/src/app.e2e-spec.ts create mode 100644 templates/Angular InstantSearch/e2e/src/app.po.ts create mode 100644 templates/Angular InstantSearch/e2e/tsconfig.e2e.json create mode 100644 templates/Angular InstantSearch/package.json create mode 100644 templates/Angular InstantSearch/src/app/app.component.css create mode 100644 templates/Angular InstantSearch/src/app/app.component.html.hbs create mode 100644 templates/Angular InstantSearch/src/app/app.component.spec.ts create mode 100644 templates/Angular InstantSearch/src/app/app.component.ts create mode 100644 templates/Angular InstantSearch/src/app/app.module.ts create mode 100644 templates/Angular InstantSearch/src/assets/.gitkeep create mode 100644 templates/Angular InstantSearch/src/browserslist create mode 100644 templates/Angular InstantSearch/src/environments/environment.prod.ts create mode 100644 templates/Angular InstantSearch/src/environments/environment.ts create mode 100644 templates/Angular InstantSearch/src/favicon.png create mode 100644 templates/Angular InstantSearch/src/index.html create mode 100644 templates/Angular InstantSearch/src/karma.conf.js create mode 100644 templates/Angular InstantSearch/src/main.ts create mode 100644 templates/Angular InstantSearch/src/manifest.json create mode 100644 templates/Angular InstantSearch/src/polyfills.ts create mode 100644 templates/Angular InstantSearch/src/styles.css create mode 100644 templates/Angular InstantSearch/src/test.ts create mode 100644 templates/Angular InstantSearch/src/tsconfig.app.json create mode 100644 templates/Angular InstantSearch/src/tsconfig.spec.json create mode 100644 templates/Angular InstantSearch/src/tslint.json create mode 100644 templates/Angular InstantSearch/tsconfig.json create mode 100644 templates/Angular InstantSearch/tslint.json create mode 100644 templates/InstantSearch.js/.gitignore create mode 100644 templates/InstantSearch.js/.template.js create mode 100644 templates/InstantSearch.js/README.md create mode 100644 templates/InstantSearch.js/favicon.png create mode 100644 templates/InstantSearch.js/index.html.hbs create mode 100644 templates/InstantSearch.js/manifest.webmanifest create mode 100644 templates/InstantSearch.js/package.json create mode 100644 templates/InstantSearch.js/src/app.css create mode 100644 templates/InstantSearch.js/src/app.js.hbs create mode 100644 templates/InstantSearch.js/src/index.css create mode 100644 templates/React InstantSearch/.gitignore create mode 100644 templates/React InstantSearch/.template.js create mode 100644 templates/React InstantSearch/README.md create mode 100644 templates/React InstantSearch/package.json create mode 100644 templates/React InstantSearch/public/favicon.png create mode 100644 templates/React InstantSearch/public/index.html create mode 100644 templates/React InstantSearch/public/manifest.json create mode 100644 templates/React InstantSearch/src/App.css create mode 100644 templates/React InstantSearch/src/App.js.hbs create mode 100644 templates/React InstantSearch/src/index.css create mode 100644 templates/React InstantSearch/src/index.js create mode 100644 templates/Vue InstantSearch/.babelrc.template create mode 100644 templates/Vue InstantSearch/.gitignore create mode 100644 templates/Vue InstantSearch/.template.js create mode 100644 templates/Vue InstantSearch/README.md create mode 100644 templates/Vue InstantSearch/favicon.png create mode 100644 templates/Vue InstantSearch/index.html create mode 100644 templates/Vue InstantSearch/manifest.json create mode 100644 templates/Vue InstantSearch/package.json create mode 100644 templates/Vue InstantSearch/src/App.vue create mode 100644 templates/Vue InstantSearch/src/main.js create mode 100644 templates/Vue InstantSearch/webpack.config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..d1d8a4176 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..100bac21a --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +**/node_modules/** +/templates diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..bfd3a913d --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,8 @@ +module.exports = { + extends: ['algolia', 'algolia/jest'], + rules: { + 'import/no-commonjs': 'off', + 'no-console': 'off', + 'no-process-exit': 'off', + }, +}; diff --git a/.gitignore b/.gitignore index 3c3629e64..dc69cdf75 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,16 @@ +# dependencies node_modules + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# release +/build diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..650b1d286 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: node_js +node_js: + - 8 + - 9 + - 10 +cache: + - yarn: true +before_install: + - curl -o- -L yarnpkg.com/install.sh | bash -s -- --version 1.7.0 + - export PATH=$HOME/.yarn/bin:$PATH +script: + - "${SCRIPT}" +env: + matrix: + - SCRIPT="yarn test && yarn lint" + - SCRIPT="yarn test:e2e" diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..78f811663 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015-present Algolia, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 2641db1d3..3a6f76c3f 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,216 @@ -# create-instantsearch-app +# Create InstantSearch App -Start your next instantsearch app in a ms ⚡️ +> Build InstantSearch apps at the speed of thoughts ⚡️ -`create-instantsearch-app` is a command line utility that helps you quick start your next search app using [Algolia InstantSearch.js](https://community.algolia.com/instantsearch.js/v2). +[![Build Status][travis-svg]][travis-url] [![Version][version-svg]][package-url] [![License][license-image]][license-url] + +`create-instantsearch-app` is a command line utility that helps you quick start your InstantSearch app using any [Algolia][algolia-website] InstantSearch flavor ([InstantSearch.js][instantsearchjs-github], [React InstantSearch][react-instantsearch-github], [Vue InstantSearch][vue-instantsearch-github] and [Angular InstantSearch][angular-instantsearch-github]). + +## Get started + +> The tool requires Node ≥ 8. + +``` +npm init instantsearch-app my-app +cd my-app +npm start +``` + +Open http://localhost:3000 to see you app. + +
+ I use an older npm version + +[`npm-init <@scope>` ](https://docs.npmjs.com/cli/init) is only available on recent `npm` versions. If it's not available, install `create-instantsearch-app` globally and run the binary. + +``` +npm install --global create-instantsearch-app +create-instantsearch-app my-app +cd my-app +npm start +``` + +
+ +--- + +Alternatively, you can use [Yarn](https://http://yarnpkg.com): + +``` +yarn create instantsearch-app my-app +cd my-app +yarn start +``` ## Usage -`create-instantsearch-app` is a node based tool, in order to use you need node and npm installed on your computer. Have a look at their documentation to [get started](https://docs.npmjs.com/getting-started/installing-node) or use [nvm](https://github.com/creationix/nvm) (advanced) +This package comes with the module `createInstantSearchApp(path, options?, tasks?)` and the command-line tool `create-instantsearch-app`. -We recommend to use Yarn as an alternative to NPM for handling dependencies in Node projects because it offers some nice integration with CLI tools like `create-instantsearch-app`. +``` +$ create-instantsearch-app --help -### Using NPM + Usage: create-instantsearch-app [options] -Installation: + Options: -```sh -npm install -g create-instantsearch-app + -v, --version output the version number + --name The name of the application + --app-id The application ID + --api-key The Algolia search API key + --index-name The main index of your search + --main-attribute The main searchable attribute of your index + --attributes-for-faceting The attributes for faceting + -t, --template