Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/theme management #46

Merged
merged 1 commit into from
Jul 22, 2016
Merged

Feature/theme management #46

merged 1 commit into from
Jul 22, 2016

Conversation

mallorydxw
Copy link
Contributor

@mallorydxw mallorydxw commented Apr 1, 2016

This will fix #41. In progress.

Install:

  • Add a new module called dependencies or deps
  • whippet deps install reads from whippet.lock and installs the themes in the appropriate places
  • WhippetLock class should have a ::FromFile() static method and allow instantiating with a string of JSON
  • Produce the same useful output that whippet plugins install does
  • Do not install if there's a hash mismatch

Update:

  • whippet deps update reads from whippet.json, updates whippet.lock appropriately, and installs the themes
  • whippet deps update should modify the gitignore file too

Plugins:

  • Add plugins to whippet.lock
  • Add plugins to whippet.json
  • Make whippet deps migrate command

Loose ends:

  • Move WhippetLock to Files/WhippetLock
  • Use WhippetLock class for generating new whippet.lock file
  • Rename Dependencies(.*).php to Dependencies/$1.php (?)
  • Make sure each ->unwrap() call has a ->isErr() check
    • Dependencies/Installer->install
    • Dependencies/Updater->update (2)
    • Dependencies/Migration->migrate (2)
  • s/FileLocator/DirectoryLocator/
  • Pretty-print whippet.lock (see JSON_PRETTY_PRINT)
  • Pretty-print whippet.json when migrating
  • dependencies install/update should ignore plugins file entirely
  • dependencies update prints error
  • dependencies install doesn't produce any output, mysteriously
  • $git->clone_repo() fails
  • $git->checkout() fails
  • Run whippet dependencies migrate/update in all the projects, and see if anything breaks
  • Test missing file scenarios
  • Test broken JSON scenarios
  • Check gitignore behaviour
  • Test git command failure
  • Test invalid JSON scenarios
  • PHP Warning: file(/workbench/src/github.com/dxw/.gitignore): failed to open stream: No such file or directory in /workbench/src/github.com/dxw/whippet/src/Git/Gitignore.php on line 27
  • Add Files/WhippetJson for parsing/generating whippet.json file
  • Test: a whippet.json file gets updated to remove a plugin, the plugin should be removed from .gitignore, but non-managed plugins should not
  • migrate should refuse to overwrite an existing whippet.json file
  • updater: return "whippet.json: file not found" instead of just "file not found"
  • Break up some of these very large functions into smaller ones
  • Make deps an alias for dependencies
  • Test for running update on {"plugins":[{"name":"foo"}]} - it'll produce a warning
  • Add deprecation notices to whippet plugins commands
  • Update WhippetHelpers->whippet_init to find the whippet directory when there's no plugins file
  • Update deploy (Modules\Release): if whippet.json exists then use Dependencies\Install, otherwise fallback to using Modules\Plugin
  • Make sure the other commands still work without plugins and plugins.lock files
  • Better tests: replace getFactory() with $this->addFactoryCallStatic(), $this->addFactoryInstantiate()
  • Replace DirectoryLocator with ProjectDirectory, which has a class method that returns a Result which contains a ProjectDirectory. It should just have one instance method: ->__toString()
  • Update README

Make tickets (after this has been merged, or shortly before):

@mallorydxw mallorydxw self-assigned this Apr 1, 2016
@mallorydxw mallorydxw force-pushed the feature/theme-management branch 2 times, most recently from c60fda6 to 36ebaeb Compare April 5, 2016 13:23
@mallorydxw mallorydxw added this to the Sprint - April 2016 milestone Apr 5, 2016
@mallorydxw mallorydxw force-pushed the feature/theme-management branch 2 times, most recently from 757302c to 1d49987 Compare April 6, 2016 17:31
@mallorydxw
Copy link
Contributor Author

@harry-m Would you like to make sure it works?

Should be pretty self-explanatory, if you run whippet plugins install/upgrade it will tell you how to migrate and which commands you should be using instead.

(Oh yes... I just remembered I need to update the README. I'll add that to the list.)

@mallorydxw mallorydxw mentioned this pull request Apr 7, 2016
9 tasks
@mallorydxw mallorydxw force-pushed the feature/theme-management branch from d7f40d0 to d1282c1 Compare April 8, 2016 13:19
@mallorydxw
Copy link
Contributor Author

@harry-m
Copy link
Contributor

harry-m commented Apr 15, 2016

@Stretch96 Please can you review/test this?

@harry-m
Copy link
Contributor

harry-m commented Apr 15, 2016

NB see Tom's list of post-merge tasks in his main update above.

@Stretch96
Copy link
Member

Stretch96 commented May 2, 2016

I've gone through the whippet deps update and whippet deps install commands so far, just need to go through the whippet migrate command. Found a few uncaught errors, but it did work when I used it correctly 👍

  • phpunit fails with:
Fatal error: Class 'org\bovigo\vfs\vfsStream' not found in /Users/chris/github-repos/whippet/tests/Helpers.php on line 116

Adding require 'vendor/autoload.php'; into project_directory_test.php passes the tests (Though it may be better to just include the one file needed for that class)

  • With empty whippet.lock file, whippet deps install produces error:
Catchable fatal error: Argument 1 passed to Dxw\Whippet\Files\Base::__construct() must be of the type array, null given, called in /Users/chris/github-repos/whippet/src/Files/Base.php on line 14 and defined in /Users/chris/github-repos/whippet/src/Files/Base.php on line 26

Changing the check in Base.php to:

if (json_last_error() !== JSON_ERROR_NONE || !is_array($data))

Catches this error (I think it's because json_decode('') doesn't cause an error, it just returns NULL instead of an empty array)

  • With {} in whippet.lock file (Or not including the hash in the array) whippet deps install produces notice:
Notice: Undefined index: hash in /Users/chris/github-repos/whippet/src/Files/WhippetLock.php on line 18

changing line 18 in WhippetLock.php to:

return $this->data['hash'] ?? NULL;

catches this

@mallorydxw
Copy link
Contributor Author

phpunit fails with:

Did you run phpunit or vendor/bin/phpunit? If you run vendor/bin/phpunit then it already has the composer dependencies loaded.

(It's also useful for the Travis tests because we need to test 5.5 but the latest version of PHPUnit only supports 5.6 and 7.0).

return $this->data['hash'] ?? NULL;

That's PHP 7 syntax. We can't use that quite yet.

Things to fix:

  • Base.php: Ensure parsing the empty string (or non-arrays) as JSON causes an error
  • Notice: Undefined index: hash in /Users/chris/github-repos/whippet/src/Files/WhippetLock.php on line 18

@mallorydxw mallorydxw force-pushed the feature/theme-management branch from 50bcbe0 to ca19382 Compare July 22, 2016 12:50
- Add Modules/Helpers/FileLocator
- Look for plugins or whippet.json files
- Add Modules/Helpers/Dependencies
- Add Modules/Helpers/WhippetLock
- Add Modules/Dependencies
- Pre-DRY tests
- Handle already-cloned repos
- Add fromString/fromFile static methods to WhippetLock
- Show useful output
- s/Dependencies/DependenciesInstaller/
- Move new classes out of Modules\Helpers
- Check the hash before installing
- Move some test helpers into a separate trait
- Output errors
- Add DependenciesUpdater
- Add update command
- Add paths to gitignore
- Add plugins to DependenciesInstall
- Add plugins to DependenciesUpdater
- Add dependencies migrate command
- mv WhippetLock Files/WhippetLock
- Move some functionality from DependenciesUpdate into WhippetLock
- Rename dependencies, and update FileLocator usage
    - Rename Dependencies* classes
    - Pass directory instead of FileLocator
- Add isErr check to Migration
- Update: test for failed git command
- FileLocator: update message
- s/FileLocator/DirectoryLocator/
- DirectoryLocator: Prevent bug with plugins directory
- migrate: Pretty-print whippet.json
- Pretty-print whippet.lock
- Do not bork on missing whippet.lock
- Dependencies: Ignore plugins file entirely
- Print sensible error if plugins file not found
- Add getNullFactory() to tests
- Move JSON parsing/file writing out of WhippetLock into abstract class
- Support explicit src
- Allow themes/plugins without refs
- Catch failing clones
- Catch failing checkouts
- fromString and fromFile return result objects
- Blank lockfile: show a message
- Blank json file: show message
- Tests: don't override that method
- Don't output warning on missing .gitignore
- Add Files/WhippetJson
- Handle removing previously-installed dependencies from gitignore
- Migration: do not overwrite existing whippet.json
- Fix a couple of bugs in Updater
    - Bubble errors properly
    - Don't bork if whippet.lock is missing
- Dependencies/Updater: refactor for readability
- Dependencies/Installer: refactor for readability
- Dependencies/Migration: refactor for readability
- Make deps an alias for dependencies
- Catch a broken JSON issue
- Add deprecation notice to plugins install/upgrade
- Update whippet_init to find whippet.json
- deploy: use Dependencies/Installer if possible
- Modify the deprecation notice for internal use of Module/Plugin
- Replace DirectoryLocator with ProjectDirectory
- Improve getFactory() test helper
- Do not directly instantiate other classes in tests
- Instantiate Installer correctly
- DRY
- Update README
- Lock sebastian/environment at a version that supports PHP 5.5

Fixes: #41
@mallorydxw mallorydxw force-pushed the feature/theme-management branch from 31d42bd to 1059e5c Compare July 22, 2016 13:02
@mallorydxw mallorydxw merged commit 4a6513d into master Jul 22, 2016
@mallorydxw mallorydxw deleted the feature/theme-management branch July 22, 2016 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Theme management in Whippet
3 participants