From 69576610c4ee344870d85bed970840b75c4b5e2b Mon Sep 17 00:00:00 2001 From: Josh Larson Date: Wed, 10 Nov 2021 12:01:53 -0600 Subject: [PATCH] chore: improve Stackblitz publishing flow (#203) * chore: hoist local flag to root project * chore: publish to stackblitz branch with new release * chore: rename gitignore for stackblitz * chore: use correct path * chore: include `.stackblitzrc` file to ensure dev server starts --- .github/workflows/publish_stackblitz.yml | 21 +++++++++++++++++++ package.json | 2 +- .../scripts/tmp-copy-template-from-dev.js | 2 +- packages/dev/.stackblitzrc | 4 ++++ packages/dev/package.json | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish_stackblitz.yml create mode 100644 packages/dev/.stackblitzrc diff --git a/.github/workflows/publish_stackblitz.yml b/.github/workflows/publish_stackblitz.yml new file mode 100644 index 0000000..970509c --- /dev/null +++ b/.github/workflows/publish_stackblitz.yml @@ -0,0 +1,21 @@ +name: Publish to Stackblitz + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + name: Publish latest release to Stackblitz + steps: + - name: Checkout the code + uses: actions/checkout@v2 + - name: Rename gitignore + run: | + mv packages/dev/_gitignore packages/dev/.gitignore + - name: Push to stackblitz branch + uses: EndBug/add-and-commit@v7.4.0 + with: + push: 'origin stackblitz --force' + diff --git a/package.json b/package.json index 517e4c6..0285337 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "scripts": { "dev-lib": "yarn workspace @shopify/hydrogen dev", - "dev-server": "VITE_INSPECT=1 yarn workspace dev dev", + "dev-server": "LOCAL_DEV=true VITE_INSPECT=1 yarn workspace dev dev", "build": "run-s build-lib build-dev build-cli", "build-lib": "yarn workspace @shopify/hydrogen build", "build-cli": "yarn workspace @shopify/hydrogen-cli build", diff --git a/packages/create-hydrogen-app/scripts/tmp-copy-template-from-dev.js b/packages/create-hydrogen-app/scripts/tmp-copy-template-from-dev.js index ef11ce4..cd50c36 100644 --- a/packages/create-hydrogen-app/scripts/tmp-copy-template-from-dev.js +++ b/packages/create-hydrogen-app/scripts/tmp-copy-template-from-dev.js @@ -12,7 +12,7 @@ const {copy} = require('./utils'); const devPath = path.resolve(__dirname, '..', '..', 'dev'); const templatePath = path.resolve(__dirname, '..', './template-hydrogen'); -const skipFiles = ['node_modules', 'dist']; +const skipFiles = ['node_modules', 'dist', '.stackblitzrc']; // Remove the symlink and replace it with a folder fs.unlinkSync(templatePath); diff --git a/packages/dev/.stackblitzrc b/packages/dev/.stackblitzrc new file mode 100644 index 0000000..d98146f --- /dev/null +++ b/packages/dev/.stackblitzrc @@ -0,0 +1,4 @@ +{ + "installDependencies": true, + "startCommand": "npm run dev" +} diff --git a/packages/dev/package.json b/packages/dev/package.json index 25c0fb8..86e7408 100644 --- a/packages/dev/package.json +++ b/packages/dev/package.json @@ -5,7 +5,7 @@ "license": "MIT", "private": true, "scripts": { - "dev": "LOCAL_DEV=true vite", + "dev": "vite", "lint": "npm-run-all lint:*", "lint:js": "eslint --no-error-on-unmatched-pattern --ext .js,.ts,.jsx,.tsx src", "lint:css": "stylelint ./src/**/*.{css,sass,scss}",