diff --git a/CHANGELOG.md b/CHANGELOG.md index feb34f1f85..adfd4b2fe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed / Improved +- use yarn in cli installer - @gibkigonzo (#4292) + ### Fixed diff --git a/core/scripts/all.js b/core/scripts/all.js index 37dba7b24b..a7f6a39306 100644 --- a/core/scripts/all.js +++ b/core/scripts/all.js @@ -23,7 +23,7 @@ class Manager extends installer.Manager { */ initStorefront () { return this.storefront.goToDirectory() - .then(this.storefront.npmBuild.bind(this.storefront)) + .then(this.storefront.depBuild.bind(this.storefront)) .then(this.storefront.runDevEnvironment.bind(this.storefront)) } diff --git a/core/scripts/installer.js b/core/scripts/installer.js index e7a2f72ec8..21e6d35ad3 100644 --- a/core/scripts/installer.js +++ b/core/scripts/installer.js @@ -168,16 +168,16 @@ class Backend extends Abstract { } /** - * Run 'npm install' in backend directory + * Run 'yarn install' in backend directory * * @returns {Promise} */ - npmInstall () { + depInstall () { return new Promise((resolve, reject) => { - Message.info('Installing backend npm...') + Message.info('Installing backend dep...') - if (shell.exec(`npm i >> ${Abstract.infoLogStream} 2>&1`).code !== 0) { - reject(new Error('Can\'t install backend npm.')) + if (shell.exec(`yarn >> ${Abstract.infoLogStream} 2>&1`).code !== 0) { + reject(new Error('Can\'t install backend dep.')) } resolve() @@ -280,7 +280,7 @@ class Backend extends Abstract { } /** - * Run 'npm run restore' + * Run 'yarn restore' * * @returns {Promise} */ @@ -288,7 +288,7 @@ class Backend extends Abstract { return new Promise((resolve, reject) => { Message.info('Restoring data for ElasticSearch...') - if (shell.exec(`npm run restore >> ${Abstract.infoLogStream} 2>&1`).code !== 0) { + if (shell.exec(`yarn restore >> ${Abstract.infoLogStream} 2>&1`).code !== 0) { reject(new Error('Can\'t restore data for ElasticSearch.')) } @@ -297,7 +297,7 @@ class Backend extends Abstract { } /** - * Run 'npm run migrate' + * Run 'yarn migrate' * * @returns {Promise} */ @@ -305,7 +305,7 @@ class Backend extends Abstract { return new Promise((resolve, reject) => { Message.info('Migrating data into ElasticSearch...') - if (shell.exec(`npm run migrate >> ${Abstract.infoLogStream} 2>&1`).code !== 0) { + if (shell.exec(`yarn migrate >> ${Abstract.infoLogStream} 2>&1`).code !== 0) { reject(new Error('Can\'t migrate data into ElasticSearch.')) } @@ -348,7 +348,7 @@ class Backend extends Abstract { } /** - * Start 'npm run dev' in background + * Start 'yarn dev' in background * * @returns {Promise} */ @@ -357,11 +357,11 @@ class Backend extends Abstract { Message.info('Starting backend server...') if (isWindows()) { - if (shell.exec(`start /min npm run dev > ${Abstract.backendLogStream} 2>&1 &`).code !== 0) { + if (shell.exec(`start /min yarn dev > ${Abstract.backendLogStream} 2>&1 &`).code !== 0) { reject(new Error('Can\'t start dev server.', VUE_STOREFRONT_BACKEND_LOG_FILE)) } } else { - if (shell.exec(`nohup npm run dev > ${Abstract.backendLogStream} 2>&1 &`).code !== 0) { + if (shell.exec(`nohup yarn dev > ${Abstract.backendLogStream} 2>&1 &`).code !== 0) { reject(new Error('Can\'t start dev server.', VUE_STOREFRONT_BACKEND_LOG_FILE)) } } @@ -472,16 +472,16 @@ class Storefront extends Abstract { } /** - * Run 'npm run build' on storefront + * Run 'yarn build' on storefront * * @returns {Promise} */ - npmBuild () { + depBuild () { return new Promise((resolve, reject) => { - Message.info('Build storefront npm...') + Message.info('Build storefront dep...') - if (shell.exec(`npm run build > ${Abstract.storefrontLogStream} 2>&1`).code !== 0) { - reject(new Error('Can\'t build storefront npm.', VUE_STOREFRONT_LOG_FILE)) + if (shell.exec(`yarn build > ${Abstract.storefrontLogStream} 2>&1`).code !== 0) { + reject(new Error('Can\'t build storefront dep.', VUE_STOREFRONT_LOG_FILE)) } resolve() @@ -489,7 +489,7 @@ class Storefront extends Abstract { } /** - * Start 'npm run dev' in background + * Start 'yarn dev' in background * * @returns {Promise} */ @@ -498,11 +498,11 @@ class Storefront extends Abstract { Message.info('Starting storefront server...') if (isWindows()) { - if (shell.exec(`start /min npm run dev >> ${Abstract.storefrontLogStream} 2>&1 &`).code !== 0) { + if (shell.exec(`start /min yarn dev >> ${Abstract.storefrontLogStream} 2>&1 &`).code !== 0) { reject(new Error('Can\'t start storefront server.', VUE_STOREFRONT_LOG_FILE)) } } else { - if (shell.exec(`nohup npm run dev >> ${Abstract.storefrontLogStream} 2>&1 &`).code !== 0) { + if (shell.exec(`nohup yarn dev >> ${Abstract.storefrontLogStream} 2>&1 &`).code !== 0) { reject(new Error('Can\'t start storefront server.', VUE_STOREFRONT_LOG_FILE)) } } @@ -574,7 +574,7 @@ class Manager extends Abstract { return this.backend.validateM2Integration() .then(this.backend.cloneRepository.bind(this.backend)) .then(this.backend.goToDirectory.bind(this.backend)) - .then(this.backend.npmInstall.bind(this.backend)) + .then(this.backend.depInstall.bind(this.backend)) .then(this.backend.createConfig.bind(this.backend)) .then(this.backend.dockerComposeUp.bind(this.backend)) .then(this.backend.importElasticSearch.bind(this.backend)) @@ -582,7 +582,7 @@ class Manager extends Abstract { } else { return this.backend.cloneRepository() .then(this.backend.goToDirectory.bind(this.backend)) - .then(this.backend.npmInstall.bind(this.backend)) + .then(this.backend.depInstall.bind(this.backend)) .then(this.backend.createConfig.bind(this.backend)) .then(this.backend.dockerComposeUp.bind(this.backend)) .then(this.backend.restoreElasticSearch.bind(this.backend)) @@ -603,7 +603,7 @@ class Manager extends Abstract { initStorefront () { return this.storefront.goToDirectory() .then(this.storefront.createConfig.bind(this.storefront)) - .then(this.storefront.npmBuild.bind(this.storefront)) + .then(this.storefront.depBuild.bind(this.storefront)) .then(this.storefront.runDevEnvironment.bind(this.storefront)) } diff --git a/docs/guide/basics/recipes.md b/docs/guide/basics/recipes.md index d707b89c8d..1e42d6fa21 100644 --- a/docs/guide/basics/recipes.md +++ b/docs/guide/basics/recipes.md @@ -183,17 +183,6 @@ To make it work, you need have Magento 2 OAuth keys configured in your `vue-stor After this change, you need to restart the `yarn dev` command to take the config changes into consideration by the VS. All the cart actions (add to cart, remove from cart, modify the quantity) are now synchronized directly with Magento 2 for both guest and logged-in clients. -## How to prevent an error "Can’t build storefront npm" - -The error, "Can't build storefront npm", appears because npm can't automatically install required modules. To prevent this error, you should manually install those modules before running the installer. It's easy: - -```bash -git clone https://github.com/DivanteLtd/vue-storefront.git vue-storefront && cd vue-storefront -npm install -npm install vue-carousel vue-no-ssr -npm run build # check if no errors -npm run installer -``` ## How to integrate 3rd party platform? Do you think it could be used with a legacy bespoke PHP eCommerce? @@ -240,7 +229,7 @@ If you would like to have a Category filter working with configurable products, There is an SEO redirects generator for NGINX -> `https://serverfault.com/a/441517` available within the [vue-storefront-api](https://github.com/DivanteLtd/vue-storefront-api/commit/2c7e10b4c4294f222f7a1aae96627d6a0e23f30e). Now you can generate an SEO map redirecting users from the original Magento URLs to Vue Storefront URLs by running: ```bash -npm run seo redirects — —oldFormat=true | false +yarn seo redirects — —oldFormat=true | false ``` Please make sure that `vue-storefront/config/local.json` setting of `useMagentoUrlKeys` is set to `true` and you have ElasticSearch synchronized with the Magento2 instance using the current version of [mage2vuestorefront](https://github.com/DivanteLtd/mage2vuestorefront). diff --git a/docs/guide/basics/ssr-cache.md b/docs/guide/basics/ssr-cache.md index e79df35abb..7da4fbffe5 100644 --- a/docs/guide/basics/ssr-cache.md +++ b/docs/guide/basics/ssr-cache.md @@ -69,10 +69,10 @@ We strongly recommend you DO NOT USE output cache in development mode. By using You can manually clear the Redis cache for specific tags by running the following command: ```bash -npm run cache clear -npm run cache clear -- --tag=product,category -npm run cache clear -- --tag=P198 -npm run cache clear -- --tag=* +yarn cache clear +yarn cache clear -- --tag=product,category +yarn cache clear -- --tag=P198 +yarn cache clear -- --tag=* ``` **Note:** The commands presented above works exactly the same way in the `vue-storefront-api`. diff --git a/docs/guide/cookbook/data-import.md b/docs/guide/cookbook/data-import.md index 60fa01cbdb..f31590ab4a 100644 --- a/docs/guide/cookbook/data-import.md +++ b/docs/guide/cookbook/data-import.md @@ -22,7 +22,7 @@ Vue Storefront uses a data-migration mechanism based on [node-migrate](https://g ### 2. Recipe 1. Run a node script from **Vue Storefront API root path** which is configured out of the box. ```bash -npm run migrate +yarn migrate ``` which runs the migrations in `migrations` folder. @@ -370,7 +370,7 @@ We worked in the red rectangle part of the architecture as a preparation for dat What we did in a simple term, we taught Elasticsearch types and sorts of data(mapping, also known as schema) we will use for Vue Storefront API later on. -Upon running `npm run migrate`, it runs the pre-configured [migration scripts](https://github.com/DivanteLtd/vue-storefront-api/tree/master/migrations) using [node-migrate](https://github.com/tj/node-migrate). If you take a closer look into the migration scripts, you will notice the ultimate js file which is located at [`./src/lib/elastic.js`](https://github.com/DivanteLtd/vue-storefront-api/blob/master/src/lib/elastic.js) that does the actual labor for migration. +Upon running `yarn migrate`, it runs the pre-configured [migration scripts](https://github.com/DivanteLtd/vue-storefront-api/tree/master/migrations) using [node-migrate](https://github.com/tj/node-migrate). If you take a closer look into the migration scripts, you will notice the ultimate js file which is located at [`./src/lib/elastic.js`](https://github.com/DivanteLtd/vue-storefront-api/blob/master/src/lib/elastic.js) that does the actual labor for migration. If you take one more closer look in the `elastic.js` file, you will also find all the schema files are located under [`./config`](https://github.com/DivanteLtd/vue-storefront-api/tree/master/config) folder. What those scripts do can be divided into steps as per the file name. It first creates index from index schema, then import schema from `elastic.schema.[types].json` files. It will then reindex them, and delete temporary index. Finally it will work a few workarounds to deal with deprecated process. @@ -386,14 +386,14 @@ If you encountered with the exception as follows during the migration script : It means you don't have the temporary index `vue_storefront_catalog_temp` which is required. Solution is : ```bash -npm run restore +yarn restore ``` This will create the necessary temporary index, then the necessary temp index will be deleted by the steps mentioned [above](#_3-peep-into-the-kitchen-what-happens-internally) when the migration is finished #### Secret 2. Add a new migration script You might need to write your own migration script. In that case, you can do so by adding a file under the `./migrations` directory though this is not a recommended way. `node-migrate` provides you with the cli command for the purpose as follows : ```bash -npm run migrate create name-of-migration +yarn migrate create name-of-migration ``` This wil create a migration script template under `./migration` folder with the standard naming convention. [more info](https://github.com/tj/node-migrate#creating-migrations) @@ -438,7 +438,7 @@ module.exports.down = function(next) { ``` #### Secret 3. Execute migration multiple times -If you run a migration multiple times using `npm run migrate`, it will only run the migration once and subsequent execution will be ignored and only repeat the result as follows : +If you run a migration multiple times using `yarn migrate`, it will only run the migration once and subsequent execution will be ignored and only repeat the result as follows : ![migration complete](../images/npm-run-migrate-result.png) @@ -725,7 +725,7 @@ node --harmony cli.js pages 7. Finally, reindex the Elasticsearch making sure up-to-date with data source in **Vue Storefront API** root path. ```bash -npm run db rebuild +yarn db rebuild ``` ### 3. Peep into the kitchen (what happens internally) diff --git a/docs/guide/cookbook/internals.md b/docs/guide/cookbook/internals.md index 966ca78c5e..da8efdae3d 100644 --- a/docs/guide/cookbook/internals.md +++ b/docs/guide/cookbook/internals.md @@ -22,7 +22,7 @@ Ever wonder what happens when you enter into **Vue Storefront** shop? From gatew 1. Go to **Vue Storefront** root path and run the following : ```bash -npm run dev +yarn dev ``` 2. Open your browser and go to your development **Vue Storefront** store, for example, [_http://localhost:3000_](http://localhost:3000) if you run it by default. diff --git a/docs/guide/cookbook/setup.md b/docs/guide/cookbook/setup.md index 24c2e4fdf4..12b0eba888 100644 --- a/docs/guide/cookbook/setup.md +++ b/docs/guide/cookbook/setup.md @@ -1362,7 +1362,7 @@ Upon the release of 1.10, we also present a new way of setup and all its sorts f We will continuously add new features to [`CLI`](https://www.npmjs.com/package/@vue-storefront/cli) as the version goes up. ### 1. Preparation -- You need to have installed [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) on your machine. (or [`yarn`](https://yarnpkg.com/lang/en/docs/install/#debian-stable) if you chose it) +- You need to have installed [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) on your machine and [`yarn`](https://yarnpkg.com/lang/en/docs/install/#debian-stable). ### 2. Recipe 1. Install _Vue Storefront CLI_ package on your machine with `-g` flag as follows : diff --git a/docs/guide/data/data-migrations.md b/docs/guide/data/data-migrations.md index fa2080a43e..14019fefd2 100644 --- a/docs/guide/data/data-migrations.md +++ b/docs/guide/data/data-migrations.md @@ -11,7 +11,7 @@ Vue Storefront uses a data-migration mechanism based on [node-migrate](https://g We use node-migrate, which is pre-configured with npm, so we're using the following alias: ```bash -npm run migrate +yarn migrate ``` which runs the migrations against `migrations` folder. @@ -21,7 +21,7 @@ which runs the migrations against `migrations` folder. You can add a new migration by simply adding a file to the `migrations` directory (not recommended) or using the command line tool: ```bash -npm run migrate create name-of-my-migration +yarn migrate create name-of-my-migration ``` The tool automatically generates the file under the `migrations` folder. diff --git a/docs/guide/installation/production-setup.md b/docs/guide/installation/production-setup.md index 69ba382147..75a6ddcb7e 100644 --- a/docs/guide/installation/production-setup.md +++ b/docs/guide/installation/production-setup.md @@ -1,6 +1,6 @@ # Production setup -If you’d like to start developing sites using Vue Storefront, you should start with the [Installation guide](linux-mac.md). For development purposes, you'll likely use the `yarn install` / `npm run installer` sequence, which will set up Vue Storefront locally using the automated installer and prepared Docker images for having Elasticsearch and Redis support. +If you’d like to start developing sites using Vue Storefront, you should start with the [Installation guide](linux-mac.md). For development purposes, you'll likely use the `yarn install` sequence, which will set up Vue Storefront locally using the automated installer and prepared Docker images for having Elasticsearch and Redis support. Development mode means you're using a node.js-based server as HTTP service and running the app on the `3000` TCP port. As it's great for local testing, it's not recommended to use the installer and direct-user access to node.js in production configurations. @@ -412,7 +412,7 @@ You can easily dump your current VS index using the following command (your loca ```bash cd vue-storefront-api rm var/catalog.json -npm run dump +yarn dump ``` Now in the `var/catalog.json` you have your current database dump. Please transfer this file to the server—for example, using the following ssh command: @@ -426,9 +426,9 @@ Then, after logging in to your `prod.vuestorefront.io` server as a `vuestorefron ```bash cd vue-storefront-api -npm run db new -npm run restore2main -npm run db rebuild +yarn db new +yarn restore2main +yarn db rebuild ``` #### Running the Vue Storefront and Vue Storefront API diff --git a/docs/guide/integrations/direct-prices-sync.md b/docs/guide/integrations/direct-prices-sync.md index 176bbdf929..1db1b88f8d 100644 --- a/docs/guide/integrations/direct-prices-sync.md +++ b/docs/guide/integrations/direct-prices-sync.md @@ -28,4 +28,4 @@ To use this feature, you should also modify `config/local.json` within your `vue }, ``` -_Important note_: To use the dynamic Magento 2 prices sync, you should restore the database using `npm run restore` within the `vue-storefront-api` or re-run the `mage2vuestorefront` product sync, because an "ID" field has been added to the `configurable_children` products and it's required for the prices sync. +_Important note_: To use the dynamic Magento 2 prices sync, you should restore the database using `yarn restore` within the `vue-storefront-api` or re-run the `mage2vuestorefront` product sync, because an "ID" field has been added to the `configurable_children` products and it's required for the prices sync. diff --git a/docs/guide/integrations/multistore.md b/docs/guide/integrations/multistore.md index 09a3b58417..d7839c7796 100644 --- a/docs/guide/integrations/multistore.md +++ b/docs/guide/integrations/multistore.md @@ -57,9 +57,9 @@ In the result, you should get: Then, to use these indexes in Vue Storefront, you should index the database schema using the `vue-storefront-api` db tool: ```bash -npm run db rebuild -- --indexName=vue_storefront_catalog_it -npm run db rebuild -- --indexName=vue_storefront_catalog_de -npm run db rebuild -- --indexName=vue_storefront_catalog +yarn db rebuild -- --indexName=vue_storefront_catalog_it +yarn db rebuild -- --indexName=vue_storefront_catalog_de +yarn db rebuild -- --indexName=vue_storefront_catalog ``` ## Vue Storefront and Vue Storefront API configuration @@ -154,9 +154,9 @@ By default, the language / store is switched by the URL prefix: General URL format is: `http://localhost:3000/{storeCode}` -The storeCode may be switched by ENV variable set before running `npm run dev` / `npm start`: +The storeCode may be switched by ENV variable set before running `yarn dev` / `yarn start`: -- `export STORE_CODE=de && npm run dev` will run the shop with the `de` shop loaded +- `export STORE_CODE=de && yarn dev` will run the shop with the `de` shop loaded Another option, useful when using multistore mode with the NGINX/varnish mode, is to set the shop code by the `x-vs-store-code` http reqeuest header. diff --git a/docs/guide/integrations/totals-sync.md b/docs/guide/integrations/totals-sync.md index 330d6d055c..de95988d52 100644 --- a/docs/guide/integrations/totals-sync.md +++ b/docs/guide/integrations/totals-sync.md @@ -87,6 +87,6 @@ This process doesn't require much additional configuration: 1. You must have the Magento2 API access configures in the `config/local.json` file of `vue-storefront-api` 2. You must have the "Orders" section marked On within the "Permissions" section of Magento Integration ([see the previous tutorial for the reference on how to set it up](../installation/magento.md)). -3. After the configuration step You just run `npm run o2m` inside your `vue-storefront-api` directory. +3. After the configuration step You just run `yarn o2m` inside your `vue-storefront-api` directory. ![This is the output of o2m after successfull setup](../images/o2m-output.png) diff --git a/docs/guide/upgrade-notes/README.md b/docs/guide/upgrade-notes/README.md index c91a09a4ba..5034414a49 100644 --- a/docs/guide/upgrade-notes/README.md +++ b/docs/guide/upgrade-notes/README.md @@ -432,7 +432,7 @@ Now it mirrors `core/` folder structure, which is desired behaviour. We added the possibility to run the `vue-storefront-api` fully in Docker (previously, just the Elastic and Redis images were present in the `docker-compose.yml`. Please read the [README.md](https://github.com/DivanteLtd/vue-storefront-api) for more details. -**PLEASE NOTE:** We changed the structure of the `elasticsearch` section of the config files, moving `esIndexes` to `elasticsearch.indices` etc. There is an automatic migration that will update your config files automatically by running: `npm run migrate` in the `vue-storefront-api` folder. +**PLEASE NOTE:** We changed the structure of the `elasticsearch` section of the config files, moving `esIndexes` to `elasticsearch.indices` etc. There is an automatic migration that will update your config files automatically by running: `yarn migrate` in the `vue-storefront-api` folder. ### Default storage of the shopping carts and user data moved to localStorage