Skip to content
This repository has been archived by the owner on Jun 26, 2018. It is now read-only.

Issue with local build and editing pattern files. #363

Open
powpow12 opened this issue Mar 8, 2017 · 13 comments
Open

Issue with local build and editing pattern files. #363

powpow12 opened this issue Mar 8, 2017 · 13 comments
Assignees
Labels

Comments

@powpow12
Copy link
Contributor

powpow12 commented Mar 8, 2017

yesterday, I was trying to troubleshoot a pr but was having a problem updating the pattern locally. Here are my steps:

  1. git pull dev
  2. git checkout feature-branch
  3. cd styleguide
  4. gulp
  5. edit source/_patterns/03-organisms/by-template/emergency-alerts.twig
  6. Add random html to test editing the right file, <h2>Hello</h2> - save
  7. Go to http://localhost:3000/?p=organisms-emergency-alerts and confirm Hello is there.

This failed for me several times. At first I was concerned that gulp wasn't listening to file changes but we confirmed that it was. Also, there was a possibility I was editing the wrong file but I grep'd the _patterns directory and there were no results suggesting that. Finally, I got @isaacchansky to test locally, and when he did the above steps, PL worked as expected.

@jesconstantine
Copy link
Contributor

@powpow12 when you say "it worked for him" (@isaacchansky) does that mean he was able to successfully edit the file and gulp rebuilt or he was able to reproduce your problem?

@isaacchansky
Copy link
Contributor

I was able to use PL as normal and edit files/rebuild just fine.

@jesconstantine
Copy link
Contributor

I'm having the same result as @isaacchansky - If I edit and save source/_patterns/03-organisms/by-template/emergency-alerts.twig while gulp task is running, I can see patternlab task run and regenerate the site and my browser automatically refreshes.

I think the best next step is troubleshoot on your machine @powpow12 -- want to do a hangout at some point with me and / or @isaacchansky ??

@legostud
Copy link
Contributor

legostud commented Mar 8, 2017

@powpow12 - did you wait 30 seconds before refreshing the page? Gulp triggers a php generate command when html is changed. Gulp will notify you that the new patterns have been built and how long it took to generate them, which is about 30 seconds now.

I have seen this before though and have not been able to figure out why it was happening. Sarena's macBook (just hers) fails to generate patterns as well. she has to manually run the php command without the --patternsonly flag "php c:\sandboxes\mayflower\styleguide/core/console --generate --patternsonly"

I should note that running that command without the patternsonly flag resets the public folder and removes all of the gulp generated files so you have to run gulp afterwards.

@powpow12
Copy link
Contributor Author

powpow12 commented Mar 8, 2017

@jesconstantine @isaacchansky @legostud thanks for the quick follow up. @jesconstantine I think this can wait till I am back in the office tomorrow. I just wanted to get an issue out incase this is a problem people have solved in the past.

@legostud I left PL on last night and the test string was still not loaded to the page when I reviewed it this morning. When I run php core/console --generate --patternsonly from the patternlabs directory on the dev branch I get several error multiple times:

configuring pattern lab...
unable to parse documentation: Multiple documents are not supported at line 2 (near "---")...
PHP Notice: Undefined variable: yaml in /Users/rppowell/Sites/mayflower/styleguide/vendor/pattern-lab/core/src/PatternLab/Parsers/Documentation.php on line 50

PHP Notice: Array to string conversion in /Users/rppowell/Sites/mayflower/styleguide/vendor/twig/twig/lib/Twig/Environment.php(403) : eval()'d code on line 28
PHP Stack trace:

@legostud
Copy link
Contributor

legostud commented Mar 9, 2017

@powpow12 - It seems that some machines have an issue with the --patternsonly flag. Can you try it without that flag 'php core/console --generate'? Make sure to run gulp after it's done.

@powpow12
Copy link
Contributor Author

powpow12 commented Mar 10, 2017

@legostud that did not make a difference for me. I went ahead and deleted the repo and re-cloned it. Following the steps in the readme, I still get the above php errors but I went ahead and ran gulp anyways. The only way it seems that I can update mayflower and review the changes is to stop gulp. Run, php core/console --generate --patternsonly (even though I get several errors), and then run gulp again. I am running php version 5.5.31.

At least now I have some kind of a workaround. The last time this worked as expected was early last week. I haven't installed or upgraded anything in that time.

@legostud
Copy link
Contributor

Could it be the version of PHP?

I'm running the following.
PHP 5.6.9 (cli) (built: May 13 2015 19:29:00)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

@powpow12
Copy link
Contributor Author

@legostud hey just getting time to circle back now. I upgraded to 5.6.30 via this homebrew tutorial. Confirmed that my php version had in fact updated by running which php and confirmed CLI php updated as well php -v. However, still getting errors:

configuring pattern lab...
unable to parse documentation: Multiple documents are not supported at line 2 (near "---")...

Notice: Undefined variable: yaml in /Users/rppowell/Sites/mayflower/styleguide/vendor/pattern-lab/core/src/PatternLab/Parsers/Documentation.php on line 50

I have the workaround for now but want to keep this opened incase someone else stumbles into the same issue.

@legostud
Copy link
Contributor

Based on that statement it appears the try catch statement is failing.

	public static function convertYAML($text) {
		
		try {
			$yaml = YAML::parse($text);
		} catch (ParseException $e) {
			printf("unable to parse documentation: %s..\n", $e->getMessage());
		}
		
		// single line of text won't throw a YAML error. returns as string
		if (gettype($yaml) == "string") {
			$yaml = array();
		}
		
		return $yaml;
		
	}

@legostud legostud reopened this Mar 15, 2017
@mrnosal
Copy link

mrnosal commented May 10, 2017

@legostud I'm getting the same errors. It seems that something is trying to pass .md files to the convertYAML() function, which of course will fail.

@sumitkumarSrijan
Copy link

sumitkumarSrijan commented Aug 24, 2017

Same issue i faced

configuring pattern lab...
PHP Notice: Array to string conversion in /var/www/web/crain/themes/shila_theme/pattern-lab/vendor/aleksip/plugin-data-transform/src/aleksip/DataTransformPlugin/DataTransformer.php on line 124
PHP Notice: Array to string conversion in /var/www/web/crain/themes/shila_theme/pattern-lab/vendor/aleksip/plugin-data-transform/src/aleksip/DataTransformPlugin/DataTransformer.php on line 124
PHP Notice: Array to string conversion in /var/www/web/crain/themes/shila_theme/pattern-lab/vendor/aleksip/plugin-data-transform/src/aleksip/DataTransformPlugin/DataTransformer.php on line 124

Can Anyone Help how i can resolve it

@legostud
Copy link
Contributor

Does it work if you sync to the Master branch? There is a Pattern Lab upgrade that was just released in that branch.

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

No branches or pull requests

6 participants