Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykbura committed May 26, 2022
2 parents cc39c62 + 8a37531 commit dfc0e6a
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 89 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## [Unreleased]

## [Released]
## [1.0.0] - 26.05.2022
- Add custom vendor name functionality (#2)
- Add mising styles imports, rework addFilesFromDir method (#10)
- Import child theme variables before default ones (#13)
- Add Alpaca Docs info (#1)
## [1.0.0-rc.2] - 25.03.2022
- Improvements and initial fixes

Expand Down
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Quickly create Magento 2 Child Theme based on [Snowdog Alpaca Theme](https://git

After installation is completed:
- Go to `Admin Panel -> Content -> Design -> Configuration` and choose your theme.
- Run `yarn dev` in `app/design/frontend/Snowdog/CHILD_THEME_NAME/Snowdog_Components` directory to see components in Fractal environment.
- Run `yarn dev` in `app/design/frontend/VENDOR_NAME/CHILD_THEME_NAME/Snowdog_Components` directory to see components in Fractal environment.

## What it does?
- Installs following packages:
Expand All @@ -35,7 +35,7 @@ After installation is completed:
- [snowdog/module-shipping-latency](https://github.com/SnowdogApps/magento2-shipping-latency)
- [snowdog/module-wishlist-unlocker](https://github.com/SnowdogApps/magento2-wishlist-unlocker)
- [webshopapps/module-matrixrate](https://github.com/webshopapps/module-matrixrate)</br></br>
- Creates Alpaca Child Theme in `app/design/frontend/Snowdog/CHILD_THEME_NAME` including everything you need to start working with Alpaca:
- Creates Alpaca Child Theme in `app/design/frontend/VENDOR_NAME/CHILD_THEME_NAME` including everything you need to start working with Alpaca:
- Essential configuration files
- Styles inheritance setup
- Custom variables file in `Snowdog_Components/components/Atoms/variables/` directory
Expand All @@ -47,28 +47,26 @@ After installation is completed:
- Upgrades Magento instance, compiles styles, JS files and SVGs.

## User guide
- [Working with Alpaca Theme]() - Learn how to utilize Alpaca Theme.
- [Alpaca Theme step by step setup]() - How to set up Alpaca from scratch, without **create-alpaca-theme**.
- [Alpaca Theme Docs](https://magento2-alpaca-docs.vercel.app/) - Learn how to utilize Alpaca Theme.

## Useful Links
* [Alpaca Theme](https://github.com/SnowdogApps/magento2-alpaca-theme)
* [Snowdog Frontools](https://github.com/SnowdogApps/magento2-frontools)
* [Valet Plus](https://github.com/weprovide/valet-plus/wiki/Database)
* [Fractal guide](https://fractal.build/guide/)
* [Alpaca Packages](https://github.com/SnowdogApps/magento2-alpaca-packages)
* [Alpaca Components guide](https://github.com/SnowdogApps/magento2-alpaca-theme/blob/master/Snowdog_Components/README.md)
* [Alpaca Components preview](https://magento2-alpaca-theme-git-master-snowdog1.vercel.app/)
* [Theme inheritance magento docs](https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/themes/theme-inherit.html)
* [Layout instructions magento docs](https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-instructions.html)

## Test package locally
* clone repository
* change name of package in `package.json` to `create-alpaca-theme`
* install package globally: `npm install -g`
* link command running `npm link`
* run `npx create-alpaca-theme`
## Testing and local development
* Clone this repository
* Change name of package in `package.json` to `create-alpaca-theme`
* Install package globally: `npm install -g`
* Link command running `npm link`
* Run `npx create-alpaca-theme` from Magento project root directory

If you have problems with global npm persmission, check npm docs: [Resolving eaccess permissions error when installing package globally](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)<br/>
## Troubleshooting

* If you have problems with global npm persmission, check npm docs: [Resolving eaccess permissions error when installing package globally](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)
* When running Warden or other dockerized Magento instance, make sure you run `npx @snowdog/create-alpaca-theme` from proper container.

****
2022 **[Snowdog](https://www.snow.dog)**
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snowdog/create-alpaca-theme",
"version": "1.0.0-rc.2",
"version": "1.0.0",
"description": "Create Magento 2 child theme based on Snowdog Alpaca Theme",
"type": "module",
"main": "index.js",
Expand Down
6 changes: 3 additions & 3 deletions src/components-actions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { validateYarn } from './validators.js'
import promiseExec from './utils/promiseExec.js'
import { BASE_PATH } from './constants/constants.js'
import { BASE_THEME_PATH } from './constants/constants.js'

const COMPONENTS_INSTALL_ERROR_MSG = 'There was an error installing Snowdog_Components:'

export async function installComponents(themeName) {
export async function installComponents(themeName, vendor) {
const packageManager = await validateYarn() ? 'yarn' : 'npm'

return promiseExec(`cd ${BASE_PATH}${themeName}/Snowdog_Components && ${packageManager} install`, (msg) => {
return promiseExec(`cd ${BASE_THEME_PATH}${vendor}/${themeName}/Snowdog_Components && ${packageManager} install`, (msg) => {
return `${COMPONENTS_INSTALL_ERROR_MSG} ${msg}`
})
}
2 changes: 1 addition & 1 deletion src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const PACKAGE_PATH = {
}

// BASE PATHS
export const BASE_PATH = 'app/design/frontend/Snowdog/'
export const BASE_THEME_PATH = 'app/design/frontend/'
export const FRONTOOLS_PATH = 'vendor/snowdog/frontools'
export const SNOWDOG_COMPONENTS = '/Snowdog_Components'
export const MAGENTO_CHECKOUT_STYLES = '/Magento_Checkout/styles'
Expand Down
48 changes: 33 additions & 15 deletions src/create-alpaca-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
validateName,
validateConfigFiles,
validateComposer,
validateVendorName,
validateMagentoInstance,
validateRegistrationName
} from './validators.js'
Expand All @@ -37,7 +38,7 @@ import {
addExemplaryStyles
} from './local-env-actions.js'
import {
BASE_PATH,
BASE_THEME_PATH,
LOADING_BAR,
PACKAGE_PATH,
CHECK_MARK_CHARACTER,
Expand Down Expand Up @@ -67,6 +68,13 @@ const promptQuestions = [
name: 'name',
validate: validateRegistrationName
},
{
type: 'input',
message: `Enter vendor name, or leave it as default (${colors.yellow('Snowdog')}):`,
name: 'vendor',
default: 'Snowdog',
validate: validateVendorName
},
{
type: 'confirm',
message: `Extend exemplary Alpaca Component? (${colors.yellow('Recommended')})`,
Expand All @@ -91,8 +99,18 @@ function init() {
log(colors.blue('Snowdog Alpaca Theme CLI v1.0.0\n'))

Inquirer.prompt(promptQuestions).then(async (answers) => {
const {
fullName,
name,
vendor,
exemplaryComponent,
database
} = answers
const timerMsg = 'Finished in'
const vendorPath = `${BASE_THEME_PATH}${vendor}/`

try {
console.time(colors.blue('Finished in')) // Start time counter
console.time(colors.blue(timerMsg))
spinner.start()
bar.start(100, 0, { info: infoColor('Validating Magento config files...') })
validateConfigFiles()
Expand All @@ -112,35 +130,35 @@ function init() {

bar.update(35, { info: infoColor('Creating directories...') })
await Promise.all(directoriesList.map(async (dir) => {
await createDirectory(`${BASE_PATH}${answers.name}${dir}`)
await createDirectory(`${vendorPath}${name}${dir}`)
}))

bar.update(36, { info: infoColor('Setting up component config files...') })
await setupComponentsConfigFiles(answers.name, answers.fullName)
await setupComponentsConfigFiles(name, fullName, vendor)

bar.update(37, { info: infoColor('Setting up theme config files...') })
await setupThemeConfigFiles(answers.name, answers.fullName)
await setupThemeConfigFiles(name, fullName, vendor)

bar.update(38, { info: infoColor('Setting up frontools config files...') })
await setupFrontoolsConfigFiles(answers.name)
await setupFrontoolsConfigFiles(name, vendor)

bar.update(39, { info: infoColor('Setting up base styles structure...') })
await addBaseStyles(answers.name)
await addBaseStyles(name, vendor)

if (answers.exemplaryComponent) {
if (exemplaryComponent) {
bar.update(40, { info: infoColor('Creating exemplary component directories...') })
await Promise.all(exemplaryComponentDirectories.map(async (dir) => {
await createDirectory(`${BASE_PATH}${answers.name}${dir}`)
await createDirectory(`${vendorPath}${name}${dir}`)
}))

bar.update(41, { info: infoColor('Adding exemplary styles...') })
await addExemplaryStyles(answers.name)
await addExemplaryStyles(name, vendor)
}

bar.update(42, { info: infoColor('Installing Snowdog Components...') })
await installComponents(answers.name)
await installComponents(name, vendor)

if (answers.database) {
if (database) {
bar.update(55, { info: infoColor('Creating media directories...') })
await Promise.all(mediaDirList.map(async (dir) => {
await createDirectory(dir)
Expand All @@ -155,7 +173,7 @@ function init() {
bar.update(60, { info: infoColor('Upgrading Magneto instance...') })
await magentoUpgrade()

if (answers.database) {
if (database) {
bar.update(85, { info: infoColor('Running database queries...') })
dbErrors = await runQueries()
}
Expand All @@ -167,8 +185,8 @@ function init() {
process.stdout.write(`\r${CHECK_MARK_CHARACTER}`)
spinner.stop()
bar.stop()
console.timeEnd(colors.blue('Finished in')) // Stop time counter
CLISuccesMessage(answers.fullName, answers.exemplaryComponent, answers.name)
console.timeEnd(colors.blue(timerMsg))
CLISuccesMessage(fullName, exemplaryComponent, name, vendor)

if (dbErrors.length !== 0) {
databaseErrorMessage()
Expand Down
Loading

0 comments on commit dfc0e6a

Please sign in to comment.