Skip to content

Commit

Permalink
Merge branch 'release/1.11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Igloczek committed Nov 16, 2020
2 parents dc447fe + 49abb9c commit 9f1a08d
Show file tree
Hide file tree
Showing 9 changed files with 1,359 additions and 818 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rules:
- 2
- 2
-
SwitchCase: 1
VariableDeclarator:
var: 2
let: 2
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ Please use `yarn [taskName]` or `npm run [taskName]` to avoid necessity of insta
* `--theme name` - Process single theme.
* `--ci` - Enable throwing errors. Useful in CI/CD pipelines.
* `inheritance` - Create necessary symlinks to resolve theme styles inheritance and make the base for styles processing. You have to run in before styles compilation and after adding new files.
* `magepackBundle` - Run [magepack](https://github.com/magesuite/magepack) `bundle` command.
* `-c` or `--config` - (required) Path to previously generated Magepack config file.
* `--theme name` - Process single theme.
* `magepackGenerate` - Run [magepack](https://github.com/magesuite/magepack) `generate` command.
* `--cms-url` - (required) URL to one of CMS pages (e.g. homepage).
* `--category-url` - (required) URL to one of category pages.
* `--product-url` - (required) URL to one of product pages.
* `-u` or `--auth-username` - Username for Basic Auth.
* `-p` or `--auth-password` - Passoword for Basic Auth.
* `-d` or `--debug` - Turn on debugging mode.
* `sasslint` - Run [sass-lint](https://github.com/sasstools/sass-lint) based tests.
* `--theme name` - Process single theme.
* `--ci` - Enable throwing errors. Useful in CI/CD pipelines.
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { setup as setupTask } from './tasks/setup'
import { styles as stylesTask } from './tasks/styles'
import { svg as svgTask } from './tasks/svg'
import { watch as watchTask } from './tasks/watch'
import magepackBundleTask from './tasks/magepack-bundle'
import magepackGenerateTask from './tasks/magepack-generate'

export const babel = series(inheritanceTask, babelTask)
export const clean = cleanTask
Expand All @@ -27,5 +29,7 @@ export const setup = setupTask
export const styles = series(inheritanceTask, stylesTask)
export const svg = series(inheritanceTask, svgTask)
export const watch = watchTask
export const magepackBundle = magepackBundleTask
export const magepackGenerate = magepackGenerateTask

export { default as default } from './tasks/default'
28 changes: 16 additions & 12 deletions helpers/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@ import yaml from 'js-yaml'
import errorMessage from './error-message'
import { projectPath } from './config'

function getContent(filePath) {
if (filePath.endsWith('.yml')) {
return yaml.safeLoad(fs.readFileSync(filePath))
}

if (filePath.endsWith('.json')) {
return JSON.parse(fs.readFileSync(filePath))
}

if (filePath.endsWith('.js')) {
return require(filePath)
}
}

export default (file, failOnError = true) => {
const externalPath = path.join(projectPath, 'dev/tools/frontools/config/', file)

// Check if file exists inside the config directory
if (globby.sync(externalPath).length) {
if (file.includes('yml')) {
return yaml.safeLoad(fs.readFileSync(externalPath))
}
else {
return JSON.parse(fs.readFileSync(externalPath))
}
return getContent(externalPath)
}

if (globby.sync('config/' + file).length) {
if (file.includes('yml')) {
return yaml.safeLoad(fs.readFileSync('config/' + file))
}
else {
return JSON.parse(fs.readFileSync('config/' + file))
}
return getContent('config/' + file)
}

if (failOnError) {
Expand Down
1,071 changes: 640 additions & 431 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magento2-frontools",
"version": "1.10.0",
"version": "1.11.0",
"author": {
"name": "Bartek Igielski",
"email": "[email protected]"
Expand All @@ -12,12 +12,12 @@
},
"license": "MIT",
"dependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"ansi-colors": "^4.1.1",
"autoprefixer": "^9.7.3",
"browser-sync": "^2.26.12",
"chokidar": "^3.4.2",
"browser-sync": "^2.26.13",
"chokidar": "^3.4.3",
"cssnano": "^4.1.10",
"esm": "^3.2.25",
"fancy-log": "^1.3.3",
Expand All @@ -42,14 +42,15 @@
"gulp-svg-sprite": "^1.5.0",
"gulp-uglify": "^3.0.2",
"js-yaml": "^3.14.0",
"marked": "^1.1.1",
"magepack": "^2.4.0",
"marked": "^1.2.2",
"marked-terminal": "^4.1.0",
"merge-stream": "^2.0.0",
"minimist": "^1.2.5",
"node-sass": "^5.0.0",
"postcss-reporter": "^6.0.1",
"run-sequence": "^2.2.1",
"sass": "^1.27.0",
"sass": "^1.28.0",
"stylelint": "^11.1.1",
"stylelint-config-standard": "^19.0.0"
},
Expand All @@ -66,6 +67,8 @@
"emailfix": "gulp emailfix",
"eslint": "gulp eslint",
"inheritance": "gulp inheritance",
"magepackBundle": "gulp magepackBundle",
"magepackGenerate": "gulp magepackGenerate",
"sasslint": "gulp sasslint",
"setup": "gulp setup",
"styles": "gulp styles",
Expand Down
20 changes: 20 additions & 0 deletions tasks/magepack-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import bundle from 'magepack/lib/bundle'

import getThemes from '../helpers/get-themes'
import { env, projectPath, themes } from '../helpers/config'

function getThemesGlobPattern() {
const themesNames = getThemes()

if (themesNames.length === 1) {
return `${projectPath}${themes[themesNames[0]].dest}/*`
}

return `${projectPath}{${themesNames.map(name => themes[name].dest).join(',')}}/*`
}

export default async function() {
const configPath = env.c || env.config
const themesGlobPattern = getThemesGlobPattern()
await bundle(configPath, themesGlobPattern)
}
16 changes: 16 additions & 0 deletions tasks/magepack-generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import generate from 'magepack/lib/generate'

import { env } from '../helpers/config'

export default async function() {
const config = {
cmsUrl: env['cms-url'],
categoryUrl: env['category-url'],
productUrl: env['product-url'],
authUsername: env.u || env['auth-username'],
authPassword: env.p || env['auth-password'],
debug: env.d || env.debug || false
}

await generate(config)
}
Loading

0 comments on commit 9f1a08d

Please sign in to comment.