소스 검색

Merge pull request #1045 from YevhenZvieriev/feature/setup-pwa-sampledata

Mark Shust 1 년 전
부모
커밋
6e93776c89
2개의 변경된 파일36개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      README.md
  2. 34 0
      compose/bin/setup-pwa-studio-sampledata

+ 2 - 1
README.md

@@ -312,7 +312,8 @@ It is recommended to keep your root docker config files in one repository, and y
 - `bin/setup-composer-auth`: Setup authentication credentials for Composer.
 - `bin/setup-domain`: Setup Magento domain name. Ex: `bin/setup-domain magento.test`
 - `bin/setup-grunt`: Install and configure Grunt JavaScript task runner to compile .less files
-- `bin/setup-pwa-studio`: (BETA) Install PWA Studio (requires NodeJS and Yarn to be installed on the host machine). Pass in your base site domain, otherwise the default `master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud` will be used. Ex: `bin/setup-pwa-studio magento.test`
+- `bin/setup-pwa-studio`: (BETA) Install PWA Studio (requires NodeJS and Yarn to be installed on the host machine). Pass in your base site domain, otherwise the default `master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud` will be used. Ex: `bin/setup-pwa-studio magento.test`.
+- `bin/setup-pwa-studio-sampledata`: This script makes it easier to install Venia sample data. Pass in your base site domain, otherwise the default `master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud` will be used. Ex: `bin/setup-pwa-studio-sampledata magento.test`.
 - `bin/setup-ssl`: Generate an SSL certificate for one or more domains. Ex. `bin/setup-ssl magento.test foo.test`
 - `bin/setup-ssl-ca`: Generate a certificate authority and copy it to the host.
 - `bin/start`: Start all containers, good practice to use this instead of `docker-compose up -d`, as it may contain additional helpers.

+ 34 - 0
compose/bin/setup-pwa-studio-sampledata

@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+set +e
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+NC='\033[0m'
+
+BASE_URL=${1:-master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud}
+
+install_sampledata() {
+    echo -e "${GREEN}Setting up composer repository for Venia sample data.${NC}"
+    bin/composer config --no-interaction --ansi repositories.venia-sample-data composer https://repo.magento.com
+
+    echo -e "${GREEN}Requiring Venia sample data metapackage.${NC}"
+    bin/composer require --no-interaction --ansi magento/venia-sample-data:*
+
+    echo -e "${GREEN}Installing Venia sample data modules.${NC}"
+    bin/magento setup:upgrade
+
+    echo -e "${GREEN}Reindexing the data from the modules.${NC}"
+    bin/magento indexer:reindex
+}
+
+install_sampledata
+
+ENV_DIST_FILE="packages/venia-concept/.env.dist"
+if [ -f "$ENV_DIST_FILE" ]; then
+    cp "$ENV_DIST_FILE" packages/venia-concept/.env
+else
+    echo -e "${RED}.env.dist file not found. Continuing without copying.${NC}"
+fi
+
+echo -e "${GREEN}Script completed successfully.${NC}"
+echo "You may now access your Magento PWA Studio instance at https://${BASE_URL}/"