Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Migrate task #108

Merged
merged 10 commits into from
Feb 14, 2017
Merged

Migrate task #108

merged 10 commits into from
Feb 14, 2017

Conversation

cshold
Copy link
Contributor

@cshold cshold commented Feb 1, 2017

This PR introduces slate migrate — a task to be used on an existing Shopify theme to get it ready for use with Slate tools.

Steps to test:

  1. Download theme from Theme Store (or use slate build on existing theme and work from the dist directory)
  2. Run slate migrate from root of theme
  • If not in the root migration will purposefully fail. We check for layout/theme.liquid before going too far
  1. Run slate start
  • Note you will get an error because you don't have config.yml. Opened a bug to fix that here. The task works as it should otherwise.

@Shopify/themes-fed
cc @m-ux @macdonaldr93

@macdonaldr93
Copy link
Contributor

Tested on Windows 10, node 7.5 👍

Copy link
Collaborator

@NathanPJF NathanPJF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review is just from reading the code. Haven't tried it out yet because I don't know how to make my globally installed slate use this branch. Could @cshold or @macdonaldr93 give me some instructions or point me to some docs?


if (!isShopifyTheme(workingDirectory)) {
console.log('');
console.error(yellow(' Your theme doesn\'t have /layout/theme.liquid. We have to assume your theme isn\'t a Shopify theme'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change, but I prefer the message focus on the root directory instead of a "your theme isn't a theme" message.

Suggestion: ' The directory doesn't have /layout/theme.liquid. We have to assume this isn't a Shopify theme.'

const answers = await prompt({
type: 'confirm',
name: 'confirmation',
message: 'Warning! This will move files in your theme. Are you sure you want to proceed?',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving files in the theme sounds like it's going to be random. All this is doing is moving everything into a new src directory and creating two empty directories, correct?

Suggestion: 'Warning! This will change your theme's folder structure. Are you sure you want to proceed?'

@macdonaldr93
Copy link
Contributor

@NathanPJF sounds good 👍 I've updated the messages accordingly. To get this up and running, all need is slate to be symlinked (npm link) and then checkout this branch. Once you've checked out the branch, run npm start to build the dist folder.

return;
}

if (!existsSync(configYml)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While testing with no config.yml I realized this helpful message is really easy to miss as it's outputted at the top of a long list of console messages. Video: http://take.ms/fgZ3B

Let's put it as one of the last messages after a successful migration.

README.md Outdated
slate migrate
```

Converts an existing theme to work with Slate. Run this command from your project root to install dependencies and your theme files moved to to a `src/` directory. Use [theme commands](#theme-commands) to start developing. An empty `styles/` and `scripts/` folder will also be created.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Missing icons/ directory.
  • Updated instructions from other docs PR.
Converts an existing theme to work with Slate. Run this command from your project root to install dependencies and restructure your theme files into a `src/` directory.  Empty `icons/`, `styles/` and `scripts/` folders will also be created.

Create `config.yml` in your root using [this sample file](https://github.com/Shopify/slate/blob/master/config-sample.yml), then use [theme commands](#theme-commands) to start developing.


if (!isShopifyTheme(workingDirectory)) {
console.log('');
console.error(yellow(' The directory doesn\'t have /layout/theme.liquid. We have to assume this isn\'t a Shopify theme'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor edit: "The current directory"

console.log('');

if (existsSync(srcDir)) {
console.error(yellow(' Your theme already has a src directory'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this isn't enough information to the user to quit the process.

Suggestion:

console.error(yellow('  Migrate task could not create a new src directory since your theme already has one.'));
console.error(yellow('  Please remove or rename your current src directory.'));

src/utils.js Outdated
*/
export function isShopifyThemeWhitelistedDir(directory) {
const whitelist = ['assets', 'layout', 'config', 'locales', 'sections', 'snippets', 'templates'];
return whitelist.indexOf(directory) > 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return whitelist.indexOf(directory) > -1;

This function is ignoring the assets/ directory since it is element 0. Video: http://take.ms/umfXJ

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally had -1 and I don't know why I convinced myself 0 was right in a later commit lol Thanks for catching this.

@macdonaldr93
Copy link
Contributor

@NathanPJF ready for another round or approval

@NathanPJF
Copy link
Collaborator

@cshold @macdonaldr93 did another run through and it's good. I added an alias for migrate because it was the only one that didn't have one.

@macdonaldr93
Copy link
Contributor

Carson and I were chatting about the alias and Carson was thinking it would best not to have one. You wouldn't accidentally want to run this command. I'm indifferent. What do you think @NathanPJF ?

@NathanPJF
Copy link
Collaborator

@macdonaldr93 I'm indifferent. I can remove it.

Remove alias for `migrate`
@macdonaldr93 macdonaldr93 merged commit f36b239 into master Feb 14, 2017
@macdonaldr93 macdonaldr93 deleted the migrate branch February 14, 2017 22:34
@macdonaldr93
Copy link
Contributor

macdonaldr93 commented Feb 14, 2017

Made a new release (v0.9.0) and published 🎉 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants