From 3efb2d01d115ae2da29d9a8f40628226de9b036a Mon Sep 17 00:00:00 2001 From: digitalkaoz Date: Mon, 23 Jan 2012 12:10:49 +0100 Subject: [PATCH 1/5] added installer note in README --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e3b20a3af..69f5860cd 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,12 @@ See the [about page](http://packagist.org/about) on [packagist.org](http://packa Installation / Usage -------------------- -1. Download the [`composer.phar`](http://getcomposer.org/composer.phar) executable +1. Download the [`composer.phar`](http://getcomposer.org/composer.phar) executable or use the installer. + + + $ curl http://getcomposer.org/installer | php + + 2. Create a composer.json defining your dependencies. Note that this example is a short version for applications that are not meant to be published as packages themselves. To create libraries/packages please read the [guidelines](http://packagist.org/about). @@ -43,7 +48,7 @@ Since composer works with the current working directory it is possible to instal in a system wide way. 1. Change into a directory in your path like `cd /usr/local/bin` -2. Get composer `wget http://getcomposer.org/composer.phar` +2. Get composer `curl http://getcomposer.org/installer | php` 3. Make the phar executeable `chmod a+x composer.phar` 3. Change into a project directory `cd /path/to/my/project` 4. Use composer as you normally would `composer.phar install` From 6227b5ec4eb004536257de3b2b9c55361ffb7ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 24 Jan 2012 13:18:54 +0100 Subject: [PATCH 2/5] Fixed copy-paste bug --- src/Composer/Downloader/VcsDownloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index a4c8239b4..8af2ce48e 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -61,8 +61,8 @@ abstract class VcsDownloader implements DownloaderInterface throw new \InvalidArgumentException('The given package is missing reference information'); } + $this->io->write(" - Package " . $target->getName() . " (" . $target->getPrettyVersion() . ")"); $this->enforceCleanDirectory($path); - $this->io->write(" - Package " . $package->getName() . " (" . $package->getPrettyVersion() . ")"); $this->doUpdate($initial, $target, $path); $this->io->write(''); } From 76a2be5ae07d49b64b3c4d62eb6e478344fb2a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 24 Jan 2012 15:10:55 +0100 Subject: [PATCH 3/5] Fixed detection of missing comma and added detection of missing colon in json --- src/Composer/Json/JsonFile.php | 4 +++- tests/Composer/Test/Json/JsonFileTest.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index fd43c9148..7594b85cc 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -206,7 +206,7 @@ class JsonFile $msg .= ', extra comma'; } elseif (preg_match('#((?<=[^\\\\])\\\\(?!["\\\\/bfnrt]|u[a-f0-9]{4}))#i', $json, $match, PREG_OFFSET_CAPTURE)) { $msg .= ', unescaped backslash (\\)'; - } elseif (preg_match('#(["}\]]) *\r?\n *"#', $json, $match, PREG_OFFSET_CAPTURE)) { + } elseif (preg_match('#(["}\]])(?: *\r?\n *)+"#', $json, $match, PREG_OFFSET_CAPTURE)) { $msg .= ', missing comma'; $charOffset = 1; } elseif (preg_match('#^ *([a-z0-9_-]+) *:#mi', $json, $match, PREG_OFFSET_CAPTURE)) { @@ -215,6 +215,8 @@ class JsonFile $msg .= ', use double quotes (") instead of single quotes (\')'; } elseif (preg_match('#(\[".*?":.*?\])#', $json, $match, PREG_OFFSET_CAPTURE)) { $msg .= ', you must use the hash syntax (e.g. {"foo": "bar"}) instead of array syntax (e.g. ["foo", "bar"])'; + } elseif (preg_match('#".*?"( *["{\[])#', $json, $match, PREG_OFFSET_CAPTURE)) { + $msg .= ', missing colon'; } if (isset($match[1][1])) { $preError = substr($json, 0, $match[1][1]); diff --git a/tests/Composer/Test/Json/JsonFileTest.php b/tests/Composer/Test/Json/JsonFileTest.php index 231839416..4ebf7b0c5 100644 --- a/tests/Composer/Test/Json/JsonFileTest.php +++ b/tests/Composer/Test/Json/JsonFileTest.php @@ -84,6 +84,25 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase $this->expectParseException('missing comma on line 2, char 21', $json); } + public function testParseErrorDetectMissingCommaMultiline() + { + $json = '{ + "foo": "barbar" + + "bar": "foo" +}'; + $this->expectParseException('missing comma on line 2, char 24', $json); + } + + public function testParseErrorDetectMissingColon() + { + $json = '{ + "foo": "bar", + "bar" "foo" +}'; + $this->expectParseException('missing colon on line 3, char 14', $json); + } + public function testSimpleJsonString() { $data = array('name' => 'composer/composer'); From e46e1fb981f8e240e49f22b6c73c2e2041190996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 24 Jan 2012 15:14:46 +0100 Subject: [PATCH 4/5] Changed method to static - JsonFile::encode --- src/Composer/Json/JsonFile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 7594b85cc..67a60c1ea 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -92,7 +92,7 @@ class JsonFile ); } } - file_put_contents($this->path, $this->encode($hash, $prettyPrint)); + file_put_contents($this->path, static::encode($hash, $prettyPrint)); } /** @@ -105,7 +105,7 @@ class JsonFile * @param Boolean $prettyPrint If true, output is pretty-printed * @return string Indented version of the original JSON string */ - public function encode(array $hash, $prettyPrint = true) + static public function encode(array $hash, $prettyPrint = true) { if ($prettyPrint && defined('JSON_PRETTY_PRINT')) { return json_encode($hash, JSON_PRETTY_PRINT); @@ -181,7 +181,7 @@ class JsonFile * * @return array */ - public static function parseJson($json) + static public function parseJson($json) { $data = json_decode($json, true); From 54dece1dc75ff070eff04275fdd4bbdb2622b460 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 24 Jan 2012 22:49:57 +0100 Subject: [PATCH 5/5] Update README --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 69f5860cd..50788a490 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Installation / Usage 1. Download the [`composer.phar`](http://getcomposer.org/composer.phar) executable or use the installer. - $ curl http://getcomposer.org/installer | php + $ curl -s http://getcomposer.org/installer | php 2. Create a composer.json defining your dependencies. Note that this example is @@ -48,10 +48,11 @@ Since composer works with the current working directory it is possible to instal in a system wide way. 1. Change into a directory in your path like `cd /usr/local/bin` -2. Get composer `curl http://getcomposer.org/installer | php` +2. Get composer `curl -s http://getcomposer.org/installer | php` 3. Make the phar executeable `chmod a+x composer.phar` -3. Change into a project directory `cd /path/to/my/project` -4. Use composer as you normally would `composer.phar install` +4. Change into a project directory `cd /path/to/my/project` +5. Use composer as you normally would `composer.phar install` +6. Optionally you can rename the composer.phar to composer to make it easier Global installation of composer (via homebrew) ---------------------------------------------- @@ -101,7 +102,7 @@ Community --------- The developer mailing list is on [google groups](http://groups.google.com/group/composer-dev) -IRC channels are available for discussion as well, on irc.freenode.org [#composer](irc://irc.freenode.org/composer) +IRC channels are available for discussion as well, on irc.freenode.org [#composer](irc://irc.freenode.org/composer) for users and [#composer-dev](irc://irc.freenode.org/composer-dev) for development. Requirements