Skip to content

Commit

Permalink
refactor(default-theme): structure moved to src for multitheme (#1175)
Browse files Browse the repository at this point in the history
  • Loading branch information
patzick authored Oct 14, 2020
1 parent e6922ff commit 36da77e
Show file tree
Hide file tree
Showing 253 changed files with 259 additions and 269 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy-preview-storefrontcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,49 @@ jobs:
run: |
yarn build shopware-6-client --ci
build-default-theme:
name: Build default-theme package
needs: init
runs-on: ubuntu-latest
outputs:
package-hash: ${{ steps.folder-hash-step-default-theme.outputs.hash }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Check hash for directory packages/default-theme
id: folder-hash-step-default-theme
run: |
HASH=$(git rev-parse HEAD:packages/default-theme)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache default-theme build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-default-theme-build
with:
path: |
packages/default-theme/dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-${{ steps.folder-hash-step-default-theme.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
- name: Build default-theme
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
yarn build default-theme --ci
create-test-project:
name: Create test project
needs:
Expand All @@ -258,6 +301,7 @@ jobs:
build-helpers,
build-nuxt-module,
build-shopware-6-client,
build-default-theme,
]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -307,6 +351,14 @@ jobs:
path: |
packages/shopware-6-client/dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-${{ needs.build-shopware-6-client.outputs.package-hash }}
- name: Cache default-theme build
uses: actions/cache@v2
env:
cache-name: test-cache-default-theme-build
with:
path: |
packages/default-theme/dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-${{ needs.build-default-theme.outputs.package-hash }}
# Step to speed up project init
- name: Cache node_modules
uses: actions/cache@v2
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/publish-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,49 @@ jobs:
run: |
yarn build shopware-6-client --release
build-default-theme:
name: Build default-theme package
needs: init
runs-on: ubuntu-latest
outputs:
package-hash: ${{ steps.folder-hash-step-default-theme.outputs.hash }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Check hash for directory packages/default-theme
id: folder-hash-step-default-theme
run: |
HASH=$(git rev-parse HEAD:packages/default-theme)
echo "::set-output name=hash::$HASH"
echo "Hash is: $HASH"
- name: Cache default-theme build
id: step-cache-build
uses: actions/cache@v2
env:
cache-name: test-cache-default-theme-build
with:
path: |
packages/default-theme/dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-${{ steps.folder-hash-step-default-theme.outputs.hash }}
- name: Cache node_modules
if: steps.step-cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v2
env:
cache-name: cache-node-modules-test
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
- name: Build default-theme
if: steps.step-cache-build.outputs.cache-hit != 'true'
run: |
yarn build default-theme --release
publish:
name: Publish version
runs-on: ubuntu-latest
Expand All @@ -260,6 +303,7 @@ jobs:
build-helpers,
build-nuxt-module,
build-shopware-6-client,
build-default-theme,
]
steps:
- name: Checkout code
Expand Down Expand Up @@ -311,6 +355,14 @@ jobs:
path: |
packages/shopware-6-client/dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-${{ needs.build-shopware-6-client.outputs.package-hash }}
- name: Cache defaut-theme build
uses: actions/cache@v2
env:
cache-name: test-cache-defaut-theme-build
with:
path: |
packages/defaut-theme/dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-${{ needs.build-defaut-theme.outputs.package-hash }}
- name: Cache node_modules
uses: actions/cache@v2
id: step-cache-node-modules
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"axios": "^0.20.0",
"brotli": "^1.3.2",
"chalk": "^4.1.0",
"chokidar": "^3.4.2",
"chokidar": "^3.4.3",
"conventional-changelog-cli": "^2.1.0",
"coveralls": "^3.1.0",
"cypress": "^4.12.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"license": "MIT",
"dependencies": {
"@shopware-pwa/shopware-6-client": "0.4.2",
"chokidar": "^3.4.2",
"chokidar": "^3.4.3",
"gluegun": "^4.4.0",
"lodash": "^4.17.20",
"md5-hex": "^3.0.1",
Expand Down
16 changes: 3 additions & 13 deletions packages/cli/src/commands/build-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const command: GluegunCommand = {
name: "build-theme",
description: "Build your theme for Shopware PWA projects.",
run: async (toolbox) => {
const path = require("path");
const fse = require("fs-extra");
const buildingSpinner = toolbox.print.spin("Building theme...");

Expand Down Expand Up @@ -38,18 +37,9 @@ const command: GluegunCommand = {
}
}

await fse.copy("src", destinationDirectoryName);
await fse.copy(
"package.json",
path.join(destinationDirectoryName, "package.json")
);
await toolbox.patching.update(
path.join("dist", "package.json"),
(config) => {
delete config.private;
return config;
}
);
await toolbox.filesystem.copyAsync("src", destinationDirectoryName, {
overwrite: true,
});
buildingSpinner.succeed("Theme built!");
},
};
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/src/commands/create-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,11 @@ const command: GluegunCommand = {
(config) => {
config.baseTheme = baseThemePackageName;

config.private = true;
config.scripts = config.scripts || {};
config.scripts.build = "shopware-pwa build-theme";
config.scripts.dev = "shopware-pwa dev-theme";
config.scripts.postinstall = "yarn build && cd ./dist && yarn link";
config.scripts.release = "yarn build && cd ./dist && yarn publish";

config.files = ["dist"];
delete config.main;
return config;
}
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module.exports = {
"@shopware-pwa/shopware-6-client",
"@shopware-pwa/default-theme",
"@shopware-pwa/nuxt-module",
"@shopware-pwa/theme-base",
];

try {
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/extensions/shopware-pwa-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,20 @@ module.exports = (toolbox: GluegunToolbox) => {
toolbox.getThemePath = (themeName = toolbox.config.theme) => {
const path = require("path");

const directDistPath = path.join(themeName, "dist");
const directDistPathExist = require("fs").existsSync(directDistPath);
if (directDistPathExist) return directDistPath;

const directPath = themeName;
const directPathExist = require("fs").existsSync(directPath);
if (directPathExist) return directPath;

const nodePackageDistPath = path.join("node_modules", themeName, "dist");
const nodePackageDistPathExist = require("fs").existsSync(
nodePackageDistPath
);
if (nodePackageDistPathExist) return nodePackageDistPath;

const nodePackagePath = path.join("node_modules", themeName);
const nodePackagePathExist = require("fs").existsSync(nodePackagePath);
if (nodePackagePathExist) return nodePackagePath;
Expand Down
96 changes: 5 additions & 91 deletions packages/default-theme/.gitignore
Original file line number Diff line number Diff line change
@@ -1,93 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# Nuxt generate
node_modules
node_modules_dev
lerna-debug.log
dist

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# IDE / Editor
.idea

# Service worker
sw.*

# Mac OSX
.DS_Store

# Vim swap files
*.swp

cypress/screenshots
cypress/videos
.yalc
yalc.lock
3 changes: 0 additions & 3 deletions packages/default-theme/.npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion packages/default-theme/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @shopware-pwa/default-theme

> Shopware PWA theme
> Shopware PWA default theme
## Build Setup

Expand Down
7 changes: 0 additions & 7 deletions packages/default-theme/app/router.scrollBehavior.js

This file was deleted.

20 changes: 0 additions & 20 deletions packages/default-theme/helpers/formatPrice.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/default-theme/logic/index.js

This file was deleted.

Loading

0 comments on commit 36da77e

Please sign in to comment.