OSDN Git Service

first pass at creating a Phar archive
authorscribu <mail@scribu.net>
Tue, 12 Feb 2013 22:07:53 +0000 (00:07 +0200)
committerscribu <mail@scribu.net>
Tue, 12 Feb 2013 22:14:24 +0000 (00:14 +0200)
.gitignore
bin/wp
php/boot-fs.php [moved from php/wp-cli-boot.php with 89% similarity]
php/boot-phar.php [new file with mode: 0644]
php/wp-cli.php
utils/make-phar.php [new file with mode: 0644]

index 8e2a674..31c4b78 100644 (file)
@@ -4,3 +4,4 @@
 /vendor
 /composer.lock
 /phpunit.xml
+/wp-cli.phar
diff --git a/bin/wp b/bin/wp
index aeebd4d..d2cfa79 100755 (executable)
--- a/bin/wp
+++ b/bin/wp
@@ -28,7 +28,7 @@ if [ ! -d $SCRIPT_PATH ]; then
        SCRIPT_PATH=$(dirname "$SELF_PATH")/../php
 fi
 
-SCRIPT_PATH=$SCRIPT_PATH/wp-cli-boot.php
+SCRIPT_PATH=$SCRIPT_PATH/boot-fs.php
 
 case $(uname -a) in
        CYGWIN*)
similarity index 89%
rename from php/wp-cli-boot.php
rename to php/boot-fs.php
index b7c8de5..a3311c8 100644 (file)
@@ -12,5 +12,7 @@ if ( version_compare( PHP_VERSION, '5.3.0', '<' ) ) {
        die(-1);
 }
 
+define( 'WP_CLI_ROOT', __DIR__ . '/' );
+
 include dirname(__FILE__) . '/wp-cli.php';
 
diff --git a/php/boot-phar.php b/php/boot-phar.php
new file mode 100644 (file)
index 0000000..be8cfdc
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+define( 'WP_CLI_ROOT', 'phar://wp-cli.phar/php/' );
+
+include WP_CLI_ROOT . 'wp-cli.php';
+
index c1443fd..c0000d1 100644 (file)
@@ -5,8 +5,6 @@ define( 'WP_CLI', true );
 
 define( 'WP_CLI_VERSION', '0.9.0-dev' );
 
-define( 'WP_CLI_ROOT', __DIR__ . '/' );
-
 include WP_CLI_ROOT . 'utils.php';
 include WP_CLI_ROOT . 'dispatcher.php';
 include WP_CLI_ROOT . 'class-wp-cli.php';
diff --git a/utils/make-phar.php b/utils/make-phar.php
new file mode 100644 (file)
index 0000000..e6cd3f6
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+// php -dphar.readonly=0 utils/make-phar.php
+
+$iterator = new \RecursiveIteratorIterator(
+       new \RecursiveDirectoryIterator( './php', FilesystemIterator::SKIP_DOTS )
+);
+
+$phar = new Phar( 'wp-cli.phar', 0, 'wp-cli.phar' );
+
+$phar->startBuffering();
+
+foreach ( $iterator as $path ) {
+       if ( !preg_match( '/\.php$/', $path ) )
+               continue;
+
+       $key = str_replace( './', '', $path );
+
+       echo "$key - $path\n";
+
+       $phar[ $key ] = file_get_contents( $path );
+}
+
+$phar->setStub( <<<EOB
+<?php
+Phar::mapPhar();
+include 'phar://wp-cli.phar/php/boot-phar.php';
+__HALT_COMPILER();
+?>
+EOB
+);
+
+$phar->stopBuffering();
+
+echo "Generated wp-cli.phar.\n";
+